From 399c6e792ba374e0b89de107af8a98167a63d70b Mon Sep 17 00:00:00 2001 From: Jiiks Date: Wed, 6 Mar 2019 09:29:23 +0200 Subject: [PATCH] Updater ui --- client/src/modules/updater.js | 16 +++++++++++ client/src/ui/components/bd/UpdaterStatus.vue | 28 +++++++++++++++++++ client/src/ui/components/bd/UpdaterToggle.vue | 28 +++++++++++++++++++ client/src/ui/components/bd/UpdaterView.vue | 17 +++++++---- client/src/ui/components/bd/index.js | 2 ++ 5 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 client/src/ui/components/bd/UpdaterStatus.vue create mode 100644 client/src/ui/components/bd/UpdaterToggle.vue diff --git a/client/src/modules/updater.js b/client/src/modules/updater.js index 0726cdc3..403e3002 100644 --- a/client/src/modules/updater.js +++ b/client/src/modules/updater.js @@ -43,6 +43,18 @@ export default new class extends Module { ipc.on('updater-updatesAvailable', (_, updates) => { if (this.state.updating) return; // If for some reason we get more updates when we're already updating + updates.bd = updates.bd.map(update => { + update.text = `${update.id.charAt(0).toUpperCase()}${update.id.slice(1)}`; + update.hint = `Current: ${update.currentVersion} | Latest: ${update.version}`; + update.status = { + update: true, + updating: false, + updated: false, + error: null + }; + + return update; + }); this.setState({ updates, updatesAvailable: true @@ -55,4 +67,8 @@ export default new class extends Module { if (!oldState.updatesAvailable && newState.updatesAvailable) return Events.emit('updates-available'); } + toggleUpdate(update) { + update.status.update = !update.status.update; + } + } diff --git a/client/src/ui/components/bd/UpdaterStatus.vue b/client/src/ui/components/bd/UpdaterStatus.vue new file mode 100644 index 00000000..c266a89f --- /dev/null +++ b/client/src/ui/components/bd/UpdaterStatus.vue @@ -0,0 +1,28 @@ +/** + * BetterDiscord Updater Status Component + * Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks + * All rights reserved. + * https://betterdiscord.net + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. +*/ + + + + diff --git a/client/src/ui/components/bd/UpdaterToggle.vue b/client/src/ui/components/bd/UpdaterToggle.vue new file mode 100644 index 00000000..43f016fd --- /dev/null +++ b/client/src/ui/components/bd/UpdaterToggle.vue @@ -0,0 +1,28 @@ +/** + * BetterDiscord Updater Switch Component + * Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks + * All rights reserved. + * https://betterdiscord.net + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. +*/ + + + + diff --git a/client/src/ui/components/bd/UpdaterView.vue b/client/src/ui/components/bd/UpdaterView.vue index b091be20..e1fce5fc 100644 --- a/client/src/ui/components/bd/UpdaterView.vue +++ b/client/src/ui/components/bd/UpdaterView.vue @@ -18,11 +18,15 @@
- {{update.id}} - {{update.currentVersion}} - {{update.version}} + +
+
+ Update +
@@ -31,7 +35,8 @@ import { Globals, Updater } from 'modules'; import { ClientLogger as Logger } from 'common'; import SettingsWrapper from './SettingsWrapper.vue'; - import { FormButton } from '../common'; + import UpdaterToggle from './UpdaterToggle.vue'; + import UpdaterStatus from './UpdaterStatus.vue'; export default { data() { @@ -43,7 +48,8 @@ }, components: { SettingsWrapper, - FormButton + UpdaterToggle, + UpdaterStatus }, computed: { updatesAvailable() { @@ -63,8 +69,9 @@ } }, methods: { - async install() { - + async update() { + // TODO + console.log('update'); } } } diff --git a/client/src/ui/components/bd/index.js b/client/src/ui/components/bd/index.js index 5744e2ad..4ef07ae3 100644 --- a/client/src/ui/components/bd/index.js +++ b/client/src/ui/components/bd/index.js @@ -4,5 +4,7 @@ export { default as CssEditorView } from './CssEditor.vue'; export { default as PluginsView } from './PluginsView.vue'; export { default as ThemesView } from './ThemesView.vue'; export { default as UpdaterView } from './UpdaterView.vue'; +export { default as UpdaterStatus } from './UpdaterStatus.vue'; +export { default as UpdaterToggle } from './UpdaterToggle.vue'; export { default as BdBadge } from './BdBadge.vue'; export { default as ConnectivityView } from './ConnectivityView.vue';