Refactor: rename alert to dialog

This commit is contained in:
syuilo 2018-12-02 15:28:52 +09:00
parent bb14895fd8
commit c9ac9923df
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
27 changed files with 66 additions and 66 deletions

View file

@ -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
});

View file

@ -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
});

View file

@ -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
});

View file

@ -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()
});

View file

@ -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()
});

View file

@ -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 })
});

View file

@ -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')
});

View file

@ -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
});

View file

@ -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
});

View file

@ -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')
});

View file

@ -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')
});

View file

@ -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')
});

View file

@ -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
});

View file

@ -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
});

View file

@ -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')
});

View file

@ -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')
});

View file

@ -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')
});

View file

@ -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')
});

View file

@ -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')
});

View file

@ -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
});

View file

@ -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', {

View file

@ -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));
});

View file

@ -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

View file

@ -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')
});

View file

@ -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,

View file

@ -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,