From 541fe9854c04632e420be41f617bc53e5672085c Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 2 Dec 2018 15:28:52 +0900 Subject: [PATCH] Refactor: rename alert to dialog --- src/client/app/admin/views/announcements.vue | 8 +++---- src/client/app/admin/views/emoji.vue | 14 ++++++------ src/client/app/admin/views/instance.vue | 6 ++--- src/client/app/admin/views/moderators.vue | 4 ++-- src/client/app/admin/views/users.vue | 22 +++++++++---------- .../app/common/scripts/check-for-update.ts | 2 +- .../app/common/scripts/fuck-ad-block.ts | 2 +- src/client/app/common/scripts/note-mixin.ts | 2 +- .../components/{alert.vue => dialog.vue} | 0 .../app/common/views/components/note-menu.vue | 8 +++---- .../views/components/password-settings.vue | 2 +- .../views/components/profile-editor.vue | 2 +- .../app/common/views/components/theme.vue | 14 ++++++------ src/client/app/desktop/api/update-avatar.ts | 4 ++-- src/client/app/desktop/api/update-banner.ts | 2 +- .../desktop/views/components/drive.file.vue | 2 +- .../desktop/views/components/drive.folder.vue | 2 +- .../app/desktop/views/components/drive.vue | 4 ++-- .../app/desktop/views/components/home.vue | 2 +- .../app/desktop/views/components/settings.vue | 6 ++--- .../views/pages/deck/deck.user-column.vue | 2 +- .../desktop/views/pages/user/user.profile.vue | 4 ++-- src/client/app/init.ts | 6 ++--- .../app/mobile/views/pages/notifications.vue | 2 +- .../app/mobile/views/pages/settings.vue | 4 ++-- src/client/app/mobile/views/pages/user.vue | 4 ++-- src/client/app/test/views/index.vue | 2 +- 27 files changed, 66 insertions(+), 66 deletions(-) rename src/client/app/common/views/components/{alert.vue => dialog.vue} (100%) diff --git a/src/client/app/admin/views/announcements.vue b/src/client/app/admin/views/announcements.vue index 42e926af4..8fc8ad4ce 100644 --- a/src/client/app/admin/views/announcements.vue +++ b/src/client/app/admin/views/announcements.vue @@ -48,7 +48,7 @@ export default Vue.extend({ }, remove(i) { - this.$root.alert({ + this.$root.dialog({ type: 'warning', text: this.$t('_remove.are-you-sure').replace('$1', this.announcements.find((_, j) => j == i).title), showCancelButton: true @@ -56,7 +56,7 @@ export default Vue.extend({ if (!res) return; this.announcements = this.announcements.filter((_, j) => j !== i); this.save(true); - this.$root.alert({ + this.$root.dialog({ type: 'success', text: this.$t('_remove.removed') }); @@ -68,13 +68,13 @@ export default Vue.extend({ broadcasts: this.announcements }).then(() => { if (!silent) { - this.$root.alert({ + this.$root.dialog({ type: 'success', text: this.$t('saved') }); } }).catch(e => { - this.$root.alert({ + this.$root.dialog({ type: 'error', text: e }); diff --git a/src/client/app/admin/views/emoji.vue b/src/client/app/admin/views/emoji.vue index 31c6b0ebf..0dcc42161 100644 --- a/src/client/app/admin/views/emoji.vue +++ b/src/client/app/admin/views/emoji.vue @@ -75,13 +75,13 @@ export default Vue.extend({ url: this.url, aliases: this.aliases.split(' ').filter(x => x.length > 0) }).then(() => { - this.$root.alert({ + this.$root.dialog({ type: 'success', text: this.$t('add-emoji.added') }); this.fetchEmojis(); }).catch(e => { - this.$root.alert({ + this.$root.dialog({ type: 'error', text: e }); @@ -103,12 +103,12 @@ export default Vue.extend({ url: emoji.url, aliases: emoji.aliases.split(' ').filter(x => x.length > 0) }).then(() => { - this.$root.alert({ + this.$root.dialog({ type: 'success', text: this.$t('updated') }); }).catch(e => { - this.$root.alert({ + this.$root.dialog({ type: 'error', text: e }); @@ -116,7 +116,7 @@ export default Vue.extend({ }, removeEmoji(emoji) { - this.$root.alert({ + this.$root.dialog({ type: 'warning', text: this.$t('remove-emoji.are-you-sure').replace('$1', emoji.name), showCancelButton: true @@ -126,13 +126,13 @@ export default Vue.extend({ this.$root.api('admin/emoji/remove', { id: emoji.id }).then(() => { - this.$root.alert({ + this.$root.dialog({ type: 'success', text: this.$t('remove-emoji.removed') }); this.fetchEmojis(); }).catch(e => { - this.$root.alert({ + this.$root.dialog({ type: 'error', text: e }); diff --git a/src/client/app/admin/views/instance.vue b/src/client/app/admin/views/instance.vue index 05de9b1c0..cf9b01820 100644 --- a/src/client/app/admin/views/instance.vue +++ b/src/client/app/admin/views/instance.vue @@ -212,7 +212,7 @@ export default Vue.extend({ this.$root.api('admin/invite').then(x => { this.inviteCode = x.code; }).catch(e => { - this.$root.alert({ + this.$root.dialog({ type: 'error', text: e }); @@ -258,12 +258,12 @@ export default Vue.extend({ smtpUser: this.smtpUser, smtpPass: this.smtpPass }).then(() => { - this.$root.alert({ + this.$root.dialog({ type: 'success', text: this.$t('saved') }); }).catch(e => { - this.$root.alert({ + this.$root.dialog({ type: 'error', text: e }); diff --git a/src/client/app/admin/views/moderators.vue b/src/client/app/admin/views/moderators.vue index ba9417d96..296c553bb 100644 --- a/src/client/app/admin/views/moderators.vue +++ b/src/client/app/admin/views/moderators.vue @@ -34,14 +34,14 @@ export default Vue.extend({ const process = async () => { const user = await this.$root.api('users/show', parseAcct(this.username)); await this.$root.api('admin/moderators/add', { userId: user.id }); - this.$root.alert({ + this.$root.dialog({ type: 'success', text: this.$t('add-moderator.added') }); }; await process().catch(e => { - this.$root.alert({ + this.$root.dialog({ type: 'error', text: e.toString() }); diff --git a/src/client/app/admin/views/users.vue b/src/client/app/admin/views/users.vue index 40daed7b0..ac2991c51 100644 --- a/src/client/app/admin/views/users.vue +++ b/src/client/app/admin/views/users.vue @@ -115,12 +115,12 @@ export default Vue.extend({ return await this.$root.api('users/show', this.target.startsWith('@') ? parseAcct(this.target) : { userId: this.target }); } catch (e) { if (e == 'user not found') { - this.$root.alert({ + this.$root.dialog({ type: 'error', text: this.$t('user-not-found') }); } else { - this.$root.alert({ + this.$root.dialog({ type: 'error', text: e.toString() }); @@ -138,7 +138,7 @@ export default Vue.extend({ async resetPassword() { const user = await this.fetchUser(); this.$root.api('admin/reset-password', { userId: user.id }).then(res => { - this.$root.alert({ + this.$root.dialog({ type: 'success', text: this.$t('password-updated', { password: res.password }) }); @@ -151,14 +151,14 @@ export default Vue.extend({ const process = async () => { const user = await this.fetchUser(); await this.$root.api('admin/verify-user', { userId: user.id }); - this.$root.alert({ + this.$root.dialog({ type: 'success', text: this.$t('verified') }); }; await process().catch(e => { - this.$root.alert({ + this.$root.dialog({ type: 'error', text: e.toString() }); @@ -173,14 +173,14 @@ export default Vue.extend({ const process = async () => { const user = await this.fetchUser(); await this.$root.api('admin/unverify-user', { userId: user.id }); - this.$root.alert({ + this.$root.dialog({ type: 'success', text: this.$t('unverified') }); }; await process().catch(e => { - this.$root.alert({ + this.$root.dialog({ type: 'error', text: e.toString() }); @@ -195,14 +195,14 @@ export default Vue.extend({ const process = async () => { const user = await this.fetchUser(); await this.$root.api('admin/suspend-user', { userId: user.id }); - this.$root.alert({ + this.$root.dialog({ type: 'success', text: this.$t('suspended') }); }; await process().catch(e => { - this.$root.alert({ + this.$root.dialog({ type: 'error', text: e.toString() }); @@ -217,14 +217,14 @@ export default Vue.extend({ const process = async () => { const user = await this.fetchUser(); await this.$root.api('admin/unsuspend-user', { userId: user.id }); - this.$root.alert({ + this.$root.dialog({ type: 'success', text: this.$t('unsuspended') }); }; await process().catch(e => { - this.$root.alert({ + this.$root.dialog({ type: 'error', text: e.toString() }); diff --git a/src/client/app/common/scripts/check-for-update.ts b/src/client/app/common/scripts/check-for-update.ts index d0e22ca32..e8a5d18f0 100644 --- a/src/client/app/common/scripts/check-for-update.ts +++ b/src/client/app/common/scripts/check-for-update.ts @@ -22,7 +22,7 @@ export default async function($root: any, force = false, silent = false) { } /*if (!silent) { - $root.alert({ + $root.dialog({ title: $root.$t('@.update-available-title'), text: $root.$t('@.update-available', { newer, current }) }); diff --git a/src/client/app/common/scripts/fuck-ad-block.ts b/src/client/app/common/scripts/fuck-ad-block.ts index f5cc1b71f..ba7e5a9f8 100644 --- a/src/client/app/common/scripts/fuck-ad-block.ts +++ b/src/client/app/common/scripts/fuck-ad-block.ts @@ -4,7 +4,7 @@ export default ($root: any) => { require('fuckadblock'); function adBlockDetected() { - $root.alert({ + $root.dialog({ title: $root.$t('@.adblock.detected'), text: $root.$t('@.adblock.warning') }); diff --git a/src/client/app/common/scripts/note-mixin.ts b/src/client/app/common/scripts/note-mixin.ts index ae824260c..36b8ca32c 100644 --- a/src/client/app/common/scripts/note-mixin.ts +++ b/src/client/app/common/scripts/note-mixin.ts @@ -142,7 +142,7 @@ export default (opts: Opts = {}) => ({ this.$root.api('notes/favorites/create', { noteId: this.appearNote.id }).then(() => { - this.$root.alert({ + this.$root.dialog({ type: 'success', splash: true }); diff --git a/src/client/app/common/views/components/alert.vue b/src/client/app/common/views/components/dialog.vue similarity index 100% rename from src/client/app/common/views/components/alert.vue rename to src/client/app/common/views/components/dialog.vue diff --git a/src/client/app/common/views/components/note-menu.vue b/src/client/app/common/views/components/note-menu.vue index 7d15b4ed7..c4b1a02fe 100644 --- a/src/client/app/common/views/components/note-menu.vue +++ b/src/client/app/common/views/components/note-menu.vue @@ -78,7 +78,7 @@ export default Vue.extend({ this.$root.api('i/pin', { noteId: this.note.id }).then(() => { - this.$root.alert({ + this.$root.dialog({ type: 'success', splash: true }); @@ -95,7 +95,7 @@ export default Vue.extend({ }, del() { - this.$root.alert({ + this.$root.dialog({ type: 'warning', text: this.$t('delete-confirm'), showCancelButton: true @@ -114,7 +114,7 @@ export default Vue.extend({ this.$root.api('notes/favorites/create', { noteId: this.note.id }).then(() => { - this.$root.alert({ + this.$root.dialog({ type: 'success', splash: true }); @@ -126,7 +126,7 @@ export default Vue.extend({ this.$root.api('notes/favorites/delete', { noteId: this.note.id }).then(() => { - this.$root.alert({ + this.$root.dialog({ type: 'success', splash: true }); diff --git a/src/client/app/common/views/components/password-settings.vue b/src/client/app/common/views/components/password-settings.vue index 356f8b2fa..d41b5a5bd 100644 --- a/src/client/app/common/views/components/password-settings.vue +++ b/src/client/app/common/views/components/password-settings.vue @@ -25,7 +25,7 @@ export default Vue.extend({ type: 'password' }).then(newPassword2 => { if (newPassword !== newPassword2) { - this.$root.alert({ + this.$root.dialog({ title: null, text: this.$t('not-match') }); diff --git a/src/client/app/common/views/components/profile-editor.vue b/src/client/app/common/views/components/profile-editor.vue index d5ba58ca7..80c322fa9 100644 --- a/src/client/app/common/views/components/profile-editor.vue +++ b/src/client/app/common/views/components/profile-editor.vue @@ -213,7 +213,7 @@ export default Vue.extend({ this.$store.state.i.bannerUrl = i.bannerUrl; if (notify) { - this.$root.alert({ + this.$root.dialog({ type: 'success', text: this.$t('saved') }); diff --git a/src/client/app/common/views/components/theme.vue b/src/client/app/common/views/components/theme.vue index 8e23d4cfa..6a90c3021 100644 --- a/src/client/app/common/views/components/theme.vue +++ b/src/client/app/common/views/components/theme.vue @@ -223,7 +223,7 @@ export default Vue.extend({ try { theme = JSON5.parse(code); } catch (e) { - this.$root.alert({ + this.$root.dialog({ type: 'error', text: this.$t('invalid-theme') }); @@ -236,7 +236,7 @@ export default Vue.extend({ } if (theme.id == null) { - this.$root.alert({ + this.$root.dialog({ type: 'error', text: this.$t('invalid-theme') }); @@ -244,7 +244,7 @@ export default Vue.extend({ } if (this.$store.state.device.themes.some(t => t.id == theme.id)) { - this.$root.alert({ + this.$root.dialog({ type: 'info', text: this.$t('already-installed') }); @@ -256,7 +256,7 @@ export default Vue.extend({ key: 'themes', value: themes }); - this.$root.alert({ + this.$root.dialog({ type: 'success', text: this.$t('installed').replace('{}', theme.name) }); @@ -269,7 +269,7 @@ export default Vue.extend({ key: 'themes', value: themes }); - this.$root.alert({ + this.$root.dialog({ type: 'info', text: this.$t('uninstalled').replace('{}', theme.name) }); @@ -306,7 +306,7 @@ export default Vue.extend({ const theme = this.myTheme; if (theme.name == null || theme.name.trim() == '') { - this.$root.alert({ + this.$root.dialog({ type: 'warning', text: this.$t('theme-name-required') }); @@ -320,7 +320,7 @@ export default Vue.extend({ key: 'themes', value: themes }); - this.$root.alert({ + this.$root.dialog({ type: 'success', text: this.$t('saved') }); diff --git a/src/client/app/desktop/api/update-avatar.ts b/src/client/app/desktop/api/update-avatar.ts index e0215aa34..07a614fc1 100644 --- a/src/client/app/desktop/api/update-avatar.ts +++ b/src/client/app/desktop/api/update-avatar.ts @@ -8,7 +8,7 @@ export default ($root: any) => { const regex = RegExp('\.(jpg|jpeg|png|gif|webp|bmp|tiff)$'); if (!regex.test(file.name) ) { - $root.alert({ + $root.dialog({ title: '%fa:info-circle% %i18n:desktop.invalid-filetype%', text: null }); @@ -87,7 +87,7 @@ export default ($root: any) => { value: i.avatarUrl }); - $root.alert({ + $root.dialog({ title: '%fa:info-circle% %i18n:desktop.avatar-updated%', text: null }); diff --git a/src/client/app/desktop/api/update-banner.ts b/src/client/app/desktop/api/update-banner.ts index 36582684e..ef84a32c0 100644 --- a/src/client/app/desktop/api/update-banner.ts +++ b/src/client/app/desktop/api/update-banner.ts @@ -87,7 +87,7 @@ export default ($root: any) => { value: i.bannerUrl }); - $root.alert({ + $root.dialog({ title: '%fa:info-circle% %i18n:desktop.banner-updated%', text: null }); diff --git a/src/client/app/desktop/views/components/drive.file.vue b/src/client/app/desktop/views/components/drive.file.vue index a64306407..3a7181bf0 100644 --- a/src/client/app/desktop/views/components/drive.file.vue +++ b/src/client/app/desktop/views/components/drive.file.vue @@ -170,7 +170,7 @@ export default Vue.extend({ copyUrl() { copyToClipboard(this.file.url); - this.$root.alert({ + this.$root.dialog({ title: this.$t('contextmenu.copied'), text: this.$t('contextmenu.copied-url-to-clipboard') }); diff --git a/src/client/app/desktop/views/components/drive.folder.vue b/src/client/app/desktop/views/components/drive.folder.vue index 5558f65c3..783c9f151 100644 --- a/src/client/app/desktop/views/components/drive.folder.vue +++ b/src/client/app/desktop/views/components/drive.folder.vue @@ -155,7 +155,7 @@ export default Vue.extend({ }).catch(err => { switch (err) { case 'detected-circular-definition': - this.$root.alert({ + this.$root.dialog({ title: this.$t('unable-to-process'), text: this.$t('circular-reference-detected') }); diff --git a/src/client/app/desktop/views/components/drive.vue b/src/client/app/desktop/views/components/drive.vue index c4e9e102d..52b84fc0c 100644 --- a/src/client/app/desktop/views/components/drive.vue +++ b/src/client/app/desktop/views/components/drive.vue @@ -313,7 +313,7 @@ export default Vue.extend({ }).catch(err => { switch (err) { case 'detected-circular-definition': - this.$root.alert({ + this.$root.dialog({ title: this.$t('unable-to-process'), text: this.$t('circular-reference-detected') }); @@ -340,7 +340,7 @@ export default Vue.extend({ folderId: this.folder ? this.folder.id : undefined }); - this.$root.alert({ + this.$root.dialog({ title: this.$t('url-upload-requested'), text: this.$t('may-take-time') }); diff --git a/src/client/app/desktop/views/components/home.vue b/src/client/app/desktop/views/components/home.vue index 492edc67d..9ebab08a9 100644 --- a/src/client/app/desktop/views/components/home.vue +++ b/src/client/app/desktop/views/components/home.vue @@ -186,7 +186,7 @@ export default Vue.extend({ methods: { hint() { - this.$root.alert({ + this.$root.dialog({ title: this.$t('@.customization-tips.title'), text: this.$t('@.customization-tips.paragraph') }); diff --git a/src/client/app/desktop/views/components/settings.vue b/src/client/app/desktop/views/components/settings.vue index 6b209641a..39145bdb0 100644 --- a/src/client/app/desktop/views/components/settings.vue +++ b/src/client/app/desktop/views/components/settings.vue @@ -596,12 +596,12 @@ export default Vue.extend({ this.checkingForUpdate = false; this.latestVersion = newer; if (newer == null) { - this.$root.alert({ + this.$root.dialog({ title: this.$t('no-updates'), text: this.$t('no-updates-desc') }); } else { - this.$root.alert({ + this.$root.dialog({ title: this.$t('update-available'), text: this.$t('update-available-desc') }); @@ -610,7 +610,7 @@ export default Vue.extend({ }, clean() { localStorage.clear(); - this.$root.alert({ + this.$root.dialog({ title: this.$t('cache-cleared'), text: this.$t('cache-cleared-desc') }); diff --git a/src/client/app/desktop/views/pages/deck/deck.user-column.vue b/src/client/app/desktop/views/pages/deck/deck.user-column.vue index 937166cec..404e93442 100644 --- a/src/client/app/desktop/views/pages/deck/deck.user-column.vue +++ b/src/client/app/desktop/views/pages/deck/deck.user-column.vue @@ -307,7 +307,7 @@ export default Vue.extend({ listId: list.id, userId: this.user.id }); - this.$root.alert({ + this.$root.dialog({ type: 'success', splash: true }); diff --git a/src/client/app/desktop/views/pages/user/user.profile.vue b/src/client/app/desktop/views/pages/user/user.profile.vue index 4d45b2433..974297cb0 100644 --- a/src/client/app/desktop/views/pages/user/user.profile.vue +++ b/src/client/app/desktop/views/pages/user/user.profile.vue @@ -73,7 +73,7 @@ export default Vue.extend({ }, block() { - this.$root.alert({ + this.$root.dialog({ type: 'warning', text: this.$t('block-confirm'), showCancelButton: true @@ -108,7 +108,7 @@ export default Vue.extend({ listId: list.id, userId: this.user.id }); - this.$root.alert({ + this.$root.dialog({ type: 'success', title: 'Done!', text: this.$t('list-pushed', { diff --git a/src/client/app/init.ts b/src/client/app/init.ts index e0eef935f..ee6848599 100644 --- a/src/client/app/init.ts +++ b/src/client/app/init.ts @@ -15,7 +15,7 @@ import checkForUpdate from './common/scripts/check-for-update'; import MiOS from './mios'; import { clientVersion as version, codename, lang } from './config'; import { builtinThemes, lightTheme, applyTheme } from './theme'; -import Alert from './common/views/components/alert.vue'; +import Dialog from './common/views/components/dialog.vue'; if (localStorage.getItem('theme') == null) { applyTheme(lightTheme); @@ -457,9 +457,9 @@ export default (callback: (launch: (router: VueRouter) => [Vue, MiOS]) => void, document.body.appendChild(x.$el); return x; }, - alert(opts) { + dialog(opts) { return new Promise((res) => { - const vm = this.new(Alert, opts); + const vm = this.new(Dialog, opts); vm.$once('ok', result => res(result)); vm.$once('cancel', () => res(false)); }); diff --git a/src/client/app/mobile/views/pages/notifications.vue b/src/client/app/mobile/views/pages/notifications.vue index b64e86d68..a7271162d 100644 --- a/src/client/app/mobile/views/pages/notifications.vue +++ b/src/client/app/mobile/views/pages/notifications.vue @@ -23,7 +23,7 @@ export default Vue.extend({ }, methods: { fn() { - this.$root.alert({ + this.$root.dialog({ type: 'warning', text: this.$t('read-all'), showCancelButton: true diff --git a/src/client/app/mobile/views/pages/settings.vue b/src/client/app/mobile/views/pages/settings.vue index a48729c70..ff4475242 100644 --- a/src/client/app/mobile/views/pages/settings.vue +++ b/src/client/app/mobile/views/pages/settings.vue @@ -402,12 +402,12 @@ export default Vue.extend({ this.checkingForUpdate = false; this.latestVersion = newer; if (newer == null) { - this.$root.alert({ + this.$root.dialog({ title: this.$t('no-updates'), text: this.$t('no-updates-desc') }); } else { - this.$root.alert({ + this.$root.dialog({ title: this.$t('update-available'), text: this.$t('update-available-desc') }); diff --git a/src/client/app/mobile/views/pages/user.vue b/src/client/app/mobile/views/pages/user.vue index 7e167d83d..a926b1a83 100644 --- a/src/client/app/mobile/views/pages/user.vue +++ b/src/client/app/mobile/views/pages/user.vue @@ -120,7 +120,7 @@ export default Vue.extend({ text: this.$t('push-to-list'), action: async () => { const lists = await this.$root.api('users/lists/list'); - const listId = await this.$root.alert({ + const listId = await this.$root.dialog({ type: null, title: this.$t('select-list'), select: { @@ -135,7 +135,7 @@ export default Vue.extend({ listId: listId, userId: this.user.id }); - this.$root.alert({ + this.$root.dialog({ type: 'success', text: this.$t('list-pushed', { user: this.user.name, diff --git a/src/client/app/test/views/index.vue b/src/client/app/test/views/index.vue index 8e5db93c4..209dc7c40 100644 --- a/src/client/app/test/views/index.vue +++ b/src/client/app/test/views/index.vue @@ -63,7 +63,7 @@ export default Vue.extend({ methods: { showDialog() { - this.$root.alert({ + this.$root.dialog({ type: this.dialogType, title: this.dialogTitle, text: this.dialogText,