1
0
mirror of https://github.com/hotomoe/hotomoe synced 2024-12-12 13:48:12 +09:00

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) { remove(i) {
this.$root.alert({ this.$root.dialog({
type: 'warning', type: 'warning',
text: this.$t('_remove.are-you-sure').replace('$1', this.announcements.find((_, j) => j == i).title), text: this.$t('_remove.are-you-sure').replace('$1', this.announcements.find((_, j) => j == i).title),
showCancelButton: true showCancelButton: true
@ -56,7 +56,7 @@ export default Vue.extend({
if (!res) return; if (!res) return;
this.announcements = this.announcements.filter((_, j) => j !== i); this.announcements = this.announcements.filter((_, j) => j !== i);
this.save(true); this.save(true);
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
text: this.$t('_remove.removed') text: this.$t('_remove.removed')
}); });
@ -68,13 +68,13 @@ export default Vue.extend({
broadcasts: this.announcements broadcasts: this.announcements
}).then(() => { }).then(() => {
if (!silent) { if (!silent) {
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
text: this.$t('saved') text: this.$t('saved')
}); });
} }
}).catch(e => { }).catch(e => {
this.$root.alert({ this.$root.dialog({
type: 'error', type: 'error',
text: e text: e
}); });

View File

@ -75,13 +75,13 @@ export default Vue.extend({
url: this.url, url: this.url,
aliases: this.aliases.split(' ').filter(x => x.length > 0) aliases: this.aliases.split(' ').filter(x => x.length > 0)
}).then(() => { }).then(() => {
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
text: this.$t('add-emoji.added') text: this.$t('add-emoji.added')
}); });
this.fetchEmojis(); this.fetchEmojis();
}).catch(e => { }).catch(e => {
this.$root.alert({ this.$root.dialog({
type: 'error', type: 'error',
text: e text: e
}); });
@ -103,12 +103,12 @@ export default Vue.extend({
url: emoji.url, url: emoji.url,
aliases: emoji.aliases.split(' ').filter(x => x.length > 0) aliases: emoji.aliases.split(' ').filter(x => x.length > 0)
}).then(() => { }).then(() => {
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
text: this.$t('updated') text: this.$t('updated')
}); });
}).catch(e => { }).catch(e => {
this.$root.alert({ this.$root.dialog({
type: 'error', type: 'error',
text: e text: e
}); });
@ -116,7 +116,7 @@ export default Vue.extend({
}, },
removeEmoji(emoji) { removeEmoji(emoji) {
this.$root.alert({ this.$root.dialog({
type: 'warning', type: 'warning',
text: this.$t('remove-emoji.are-you-sure').replace('$1', emoji.name), text: this.$t('remove-emoji.are-you-sure').replace('$1', emoji.name),
showCancelButton: true showCancelButton: true
@ -126,13 +126,13 @@ export default Vue.extend({
this.$root.api('admin/emoji/remove', { this.$root.api('admin/emoji/remove', {
id: emoji.id id: emoji.id
}).then(() => { }).then(() => {
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
text: this.$t('remove-emoji.removed') text: this.$t('remove-emoji.removed')
}); });
this.fetchEmojis(); this.fetchEmojis();
}).catch(e => { }).catch(e => {
this.$root.alert({ this.$root.dialog({
type: 'error', type: 'error',
text: e text: e
}); });

View File

@ -212,7 +212,7 @@ export default Vue.extend({
this.$root.api('admin/invite').then(x => { this.$root.api('admin/invite').then(x => {
this.inviteCode = x.code; this.inviteCode = x.code;
}).catch(e => { }).catch(e => {
this.$root.alert({ this.$root.dialog({
type: 'error', type: 'error',
text: e text: e
}); });
@ -258,12 +258,12 @@ export default Vue.extend({
smtpUser: this.smtpUser, smtpUser: this.smtpUser,
smtpPass: this.smtpPass smtpPass: this.smtpPass
}).then(() => { }).then(() => {
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
text: this.$t('saved') text: this.$t('saved')
}); });
}).catch(e => { }).catch(e => {
this.$root.alert({ this.$root.dialog({
type: 'error', type: 'error',
text: e text: e
}); });

View File

@ -34,14 +34,14 @@ export default Vue.extend({
const process = async () => { const process = async () => {
const user = await this.$root.api('users/show', parseAcct(this.username)); const user = await this.$root.api('users/show', parseAcct(this.username));
await this.$root.api('admin/moderators/add', { userId: user.id }); await this.$root.api('admin/moderators/add', { userId: user.id });
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
text: this.$t('add-moderator.added') text: this.$t('add-moderator.added')
}); });
}; };
await process().catch(e => { await process().catch(e => {
this.$root.alert({ this.$root.dialog({
type: 'error', type: 'error',
text: e.toString() 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 }); return await this.$root.api('users/show', this.target.startsWith('@') ? parseAcct(this.target) : { userId: this.target });
} catch (e) { } catch (e) {
if (e == 'user not found') { if (e == 'user not found') {
this.$root.alert({ this.$root.dialog({
type: 'error', type: 'error',
text: this.$t('user-not-found') text: this.$t('user-not-found')
}); });
} else { } else {
this.$root.alert({ this.$root.dialog({
type: 'error', type: 'error',
text: e.toString() text: e.toString()
}); });
@ -138,7 +138,7 @@ export default Vue.extend({
async resetPassword() { async resetPassword() {
const user = await this.fetchUser(); const user = await this.fetchUser();
this.$root.api('admin/reset-password', { userId: user.id }).then(res => { this.$root.api('admin/reset-password', { userId: user.id }).then(res => {
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
text: this.$t('password-updated', { password: res.password }) text: this.$t('password-updated', { password: res.password })
}); });
@ -151,14 +151,14 @@ export default Vue.extend({
const process = async () => { const process = async () => {
const user = await this.fetchUser(); const user = await this.fetchUser();
await this.$root.api('admin/verify-user', { userId: user.id }); await this.$root.api('admin/verify-user', { userId: user.id });
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
text: this.$t('verified') text: this.$t('verified')
}); });
}; };
await process().catch(e => { await process().catch(e => {
this.$root.alert({ this.$root.dialog({
type: 'error', type: 'error',
text: e.toString() text: e.toString()
}); });
@ -173,14 +173,14 @@ export default Vue.extend({
const process = async () => { const process = async () => {
const user = await this.fetchUser(); const user = await this.fetchUser();
await this.$root.api('admin/unverify-user', { userId: user.id }); await this.$root.api('admin/unverify-user', { userId: user.id });
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
text: this.$t('unverified') text: this.$t('unverified')
}); });
}; };
await process().catch(e => { await process().catch(e => {
this.$root.alert({ this.$root.dialog({
type: 'error', type: 'error',
text: e.toString() text: e.toString()
}); });
@ -195,14 +195,14 @@ export default Vue.extend({
const process = async () => { const process = async () => {
const user = await this.fetchUser(); const user = await this.fetchUser();
await this.$root.api('admin/suspend-user', { userId: user.id }); await this.$root.api('admin/suspend-user', { userId: user.id });
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
text: this.$t('suspended') text: this.$t('suspended')
}); });
}; };
await process().catch(e => { await process().catch(e => {
this.$root.alert({ this.$root.dialog({
type: 'error', type: 'error',
text: e.toString() text: e.toString()
}); });
@ -217,14 +217,14 @@ export default Vue.extend({
const process = async () => { const process = async () => {
const user = await this.fetchUser(); const user = await this.fetchUser();
await this.$root.api('admin/unsuspend-user', { userId: user.id }); await this.$root.api('admin/unsuspend-user', { userId: user.id });
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
text: this.$t('unsuspended') text: this.$t('unsuspended')
}); });
}; };
await process().catch(e => { await process().catch(e => {
this.$root.alert({ this.$root.dialog({
type: 'error', type: 'error',
text: e.toString() text: e.toString()
}); });

View File

@ -22,7 +22,7 @@ export default async function($root: any, force = false, silent = false) {
} }
/*if (!silent) { /*if (!silent) {
$root.alert({ $root.dialog({
title: $root.$t('@.update-available-title'), title: $root.$t('@.update-available-title'),
text: $root.$t('@.update-available', { newer, current }) text: $root.$t('@.update-available', { newer, current })
}); });

View File

@ -4,7 +4,7 @@ export default ($root: any) => {
require('fuckadblock'); require('fuckadblock');
function adBlockDetected() { function adBlockDetected() {
$root.alert({ $root.dialog({
title: $root.$t('@.adblock.detected'), title: $root.$t('@.adblock.detected'),
text: $root.$t('@.adblock.warning') text: $root.$t('@.adblock.warning')
}); });

View File

@ -142,7 +142,7 @@ export default (opts: Opts = {}) => ({
this.$root.api('notes/favorites/create', { this.$root.api('notes/favorites/create', {
noteId: this.appearNote.id noteId: this.appearNote.id
}).then(() => { }).then(() => {
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
splash: true splash: true
}); });

View File

@ -78,7 +78,7 @@ export default Vue.extend({
this.$root.api('i/pin', { this.$root.api('i/pin', {
noteId: this.note.id noteId: this.note.id
}).then(() => { }).then(() => {
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
splash: true splash: true
}); });
@ -95,7 +95,7 @@ export default Vue.extend({
}, },
del() { del() {
this.$root.alert({ this.$root.dialog({
type: 'warning', type: 'warning',
text: this.$t('delete-confirm'), text: this.$t('delete-confirm'),
showCancelButton: true showCancelButton: true
@ -114,7 +114,7 @@ export default Vue.extend({
this.$root.api('notes/favorites/create', { this.$root.api('notes/favorites/create', {
noteId: this.note.id noteId: this.note.id
}).then(() => { }).then(() => {
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
splash: true splash: true
}); });
@ -126,7 +126,7 @@ export default Vue.extend({
this.$root.api('notes/favorites/delete', { this.$root.api('notes/favorites/delete', {
noteId: this.note.id noteId: this.note.id
}).then(() => { }).then(() => {
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
splash: true splash: true
}); });

View File

@ -25,7 +25,7 @@ export default Vue.extend({
type: 'password' type: 'password'
}).then(newPassword2 => { }).then(newPassword2 => {
if (newPassword !== newPassword2) { if (newPassword !== newPassword2) {
this.$root.alert({ this.$root.dialog({
title: null, title: null,
text: this.$t('not-match') text: this.$t('not-match')
}); });

View File

@ -213,7 +213,7 @@ export default Vue.extend({
this.$store.state.i.bannerUrl = i.bannerUrl; this.$store.state.i.bannerUrl = i.bannerUrl;
if (notify) { if (notify) {
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
text: this.$t('saved') text: this.$t('saved')
}); });

View File

@ -223,7 +223,7 @@ export default Vue.extend({
try { try {
theme = JSON5.parse(code); theme = JSON5.parse(code);
} catch (e) { } catch (e) {
this.$root.alert({ this.$root.dialog({
type: 'error', type: 'error',
text: this.$t('invalid-theme') text: this.$t('invalid-theme')
}); });
@ -236,7 +236,7 @@ export default Vue.extend({
} }
if (theme.id == null) { if (theme.id == null) {
this.$root.alert({ this.$root.dialog({
type: 'error', type: 'error',
text: this.$t('invalid-theme') 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)) { if (this.$store.state.device.themes.some(t => t.id == theme.id)) {
this.$root.alert({ this.$root.dialog({
type: 'info', type: 'info',
text: this.$t('already-installed') text: this.$t('already-installed')
}); });
@ -256,7 +256,7 @@ export default Vue.extend({
key: 'themes', value: themes key: 'themes', value: themes
}); });
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
text: this.$t('installed').replace('{}', theme.name) text: this.$t('installed').replace('{}', theme.name)
}); });
@ -269,7 +269,7 @@ export default Vue.extend({
key: 'themes', value: themes key: 'themes', value: themes
}); });
this.$root.alert({ this.$root.dialog({
type: 'info', type: 'info',
text: this.$t('uninstalled').replace('{}', theme.name) text: this.$t('uninstalled').replace('{}', theme.name)
}); });
@ -306,7 +306,7 @@ export default Vue.extend({
const theme = this.myTheme; const theme = this.myTheme;
if (theme.name == null || theme.name.trim() == '') { if (theme.name == null || theme.name.trim() == '') {
this.$root.alert({ this.$root.dialog({
type: 'warning', type: 'warning',
text: this.$t('theme-name-required') text: this.$t('theme-name-required')
}); });
@ -320,7 +320,7 @@ export default Vue.extend({
key: 'themes', value: themes key: 'themes', value: themes
}); });
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
text: this.$t('saved') text: this.$t('saved')
}); });

View File

@ -8,7 +8,7 @@ export default ($root: any) => {
const regex = RegExp('\.(jpg|jpeg|png|gif|webp|bmp|tiff)$'); const regex = RegExp('\.(jpg|jpeg|png|gif|webp|bmp|tiff)$');
if (!regex.test(file.name) ) { if (!regex.test(file.name) ) {
$root.alert({ $root.dialog({
title: '%fa:info-circle% %i18n:desktop.invalid-filetype%', title: '%fa:info-circle% %i18n:desktop.invalid-filetype%',
text: null text: null
}); });
@ -87,7 +87,7 @@ export default ($root: any) => {
value: i.avatarUrl value: i.avatarUrl
}); });
$root.alert({ $root.dialog({
title: '%fa:info-circle% %i18n:desktop.avatar-updated%', title: '%fa:info-circle% %i18n:desktop.avatar-updated%',
text: null text: null
}); });

View File

@ -87,7 +87,7 @@ export default ($root: any) => {
value: i.bannerUrl value: i.bannerUrl
}); });
$root.alert({ $root.dialog({
title: '%fa:info-circle% %i18n:desktop.banner-updated%', title: '%fa:info-circle% %i18n:desktop.banner-updated%',
text: null text: null
}); });

View File

@ -170,7 +170,7 @@ export default Vue.extend({
copyUrl() { copyUrl() {
copyToClipboard(this.file.url); copyToClipboard(this.file.url);
this.$root.alert({ this.$root.dialog({
title: this.$t('contextmenu.copied'), title: this.$t('contextmenu.copied'),
text: this.$t('contextmenu.copied-url-to-clipboard') text: this.$t('contextmenu.copied-url-to-clipboard')
}); });

View File

@ -155,7 +155,7 @@ export default Vue.extend({
}).catch(err => { }).catch(err => {
switch (err) { switch (err) {
case 'detected-circular-definition': case 'detected-circular-definition':
this.$root.alert({ this.$root.dialog({
title: this.$t('unable-to-process'), title: this.$t('unable-to-process'),
text: this.$t('circular-reference-detected') text: this.$t('circular-reference-detected')
}); });

View File

@ -313,7 +313,7 @@ export default Vue.extend({
}).catch(err => { }).catch(err => {
switch (err) { switch (err) {
case 'detected-circular-definition': case 'detected-circular-definition':
this.$root.alert({ this.$root.dialog({
title: this.$t('unable-to-process'), title: this.$t('unable-to-process'),
text: this.$t('circular-reference-detected') text: this.$t('circular-reference-detected')
}); });
@ -340,7 +340,7 @@ export default Vue.extend({
folderId: this.folder ? this.folder.id : undefined folderId: this.folder ? this.folder.id : undefined
}); });
this.$root.alert({ this.$root.dialog({
title: this.$t('url-upload-requested'), title: this.$t('url-upload-requested'),
text: this.$t('may-take-time') text: this.$t('may-take-time')
}); });

View File

@ -186,7 +186,7 @@ export default Vue.extend({
methods: { methods: {
hint() { hint() {
this.$root.alert({ this.$root.dialog({
title: this.$t('@.customization-tips.title'), title: this.$t('@.customization-tips.title'),
text: this.$t('@.customization-tips.paragraph') text: this.$t('@.customization-tips.paragraph')
}); });

View File

@ -596,12 +596,12 @@ export default Vue.extend({
this.checkingForUpdate = false; this.checkingForUpdate = false;
this.latestVersion = newer; this.latestVersion = newer;
if (newer == null) { if (newer == null) {
this.$root.alert({ this.$root.dialog({
title: this.$t('no-updates'), title: this.$t('no-updates'),
text: this.$t('no-updates-desc') text: this.$t('no-updates-desc')
}); });
} else { } else {
this.$root.alert({ this.$root.dialog({
title: this.$t('update-available'), title: this.$t('update-available'),
text: this.$t('update-available-desc') text: this.$t('update-available-desc')
}); });
@ -610,7 +610,7 @@ export default Vue.extend({
}, },
clean() { clean() {
localStorage.clear(); localStorage.clear();
this.$root.alert({ this.$root.dialog({
title: this.$t('cache-cleared'), title: this.$t('cache-cleared'),
text: this.$t('cache-cleared-desc') text: this.$t('cache-cleared-desc')
}); });

View File

@ -307,7 +307,7 @@ export default Vue.extend({
listId: list.id, listId: list.id,
userId: this.user.id userId: this.user.id
}); });
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
splash: true splash: true
}); });

View File

@ -73,7 +73,7 @@ export default Vue.extend({
}, },
block() { block() {
this.$root.alert({ this.$root.dialog({
type: 'warning', type: 'warning',
text: this.$t('block-confirm'), text: this.$t('block-confirm'),
showCancelButton: true showCancelButton: true
@ -108,7 +108,7 @@ export default Vue.extend({
listId: list.id, listId: list.id,
userId: this.user.id userId: this.user.id
}); });
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
title: 'Done!', title: 'Done!',
text: this.$t('list-pushed', { text: this.$t('list-pushed', {

View File

@ -15,7 +15,7 @@ import checkForUpdate from './common/scripts/check-for-update';
import MiOS from './mios'; import MiOS from './mios';
import { clientVersion as version, codename, lang } from './config'; import { clientVersion as version, codename, lang } from './config';
import { builtinThemes, lightTheme, applyTheme } from './theme'; 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) { if (localStorage.getItem('theme') == null) {
applyTheme(lightTheme); applyTheme(lightTheme);
@ -457,9 +457,9 @@ export default (callback: (launch: (router: VueRouter) => [Vue, MiOS]) => void,
document.body.appendChild(x.$el); document.body.appendChild(x.$el);
return x; return x;
}, },
alert(opts) { dialog(opts) {
return new Promise((res) => { return new Promise((res) => {
const vm = this.new(Alert, opts); const vm = this.new(Dialog, opts);
vm.$once('ok', result => res(result)); vm.$once('ok', result => res(result));
vm.$once('cancel', () => res(false)); vm.$once('cancel', () => res(false));
}); });

View File

@ -23,7 +23,7 @@ export default Vue.extend({
}, },
methods: { methods: {
fn() { fn() {
this.$root.alert({ this.$root.dialog({
type: 'warning', type: 'warning',
text: this.$t('read-all'), text: this.$t('read-all'),
showCancelButton: true showCancelButton: true

View File

@ -402,12 +402,12 @@ export default Vue.extend({
this.checkingForUpdate = false; this.checkingForUpdate = false;
this.latestVersion = newer; this.latestVersion = newer;
if (newer == null) { if (newer == null) {
this.$root.alert({ this.$root.dialog({
title: this.$t('no-updates'), title: this.$t('no-updates'),
text: this.$t('no-updates-desc') text: this.$t('no-updates-desc')
}); });
} else { } else {
this.$root.alert({ this.$root.dialog({
title: this.$t('update-available'), title: this.$t('update-available'),
text: this.$t('update-available-desc') text: this.$t('update-available-desc')
}); });

View File

@ -120,7 +120,7 @@ export default Vue.extend({
text: this.$t('push-to-list'), text: this.$t('push-to-list'),
action: async () => { action: async () => {
const lists = await this.$root.api('users/lists/list'); const lists = await this.$root.api('users/lists/list');
const listId = await this.$root.alert({ const listId = await this.$root.dialog({
type: null, type: null,
title: this.$t('select-list'), title: this.$t('select-list'),
select: { select: {
@ -135,7 +135,7 @@ export default Vue.extend({
listId: listId, listId: listId,
userId: this.user.id userId: this.user.id
}); });
this.$root.alert({ this.$root.dialog({
type: 'success', type: 'success',
text: this.$t('list-pushed', { text: this.$t('list-pushed', {
user: this.user.name, user: this.user.name,

View File

@ -63,7 +63,7 @@ export default Vue.extend({
methods: { methods: {
showDialog() { showDialog() {
this.$root.alert({ this.$root.dialog({
type: this.dialogType, type: this.dialogType,
title: this.dialogTitle, title: this.dialogTitle,
text: this.dialogText, text: this.dialogText,