Merge branch 'feature/add-try-catch-error-handling' into 'master'

Add try/catch error handling

See merge request pleroma/admin-fe!59
This commit is contained in:
Angelina Filippova 2019-10-28 17:06:39 +00:00
commit 9b9f7369e9
32 changed files with 218 additions and 338 deletions

View file

@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- remove fetching initial data for configuring server settings - remove fetching initial data for configuring server settings
- Actions in users module (ActivateUsers, AddRight, DeactivateUsers, DeleteRight, DeleteUsers) now accept an array of users instead of one user - Actions in users module (ActivateUsers, AddRight, DeactivateUsers, DeleteRight, DeleteUsers) now accept an array of users instead of one user
- Leave dropdown menu open after clicking an action - Leave dropdown menu open after clicking an action
- Move current try/catch error handling from view files to module, add it where necessary
### Added ### Added

View file

@ -365,7 +365,13 @@ export default {
deletePack: 'Delete pack', deletePack: 'Delete pack',
downloadSharedPack: 'Download shared pack to current instance', downloadSharedPack: 'Download shared pack to current instance',
downloadAsOptional: 'Download as (optional)', downloadAsOptional: 'Download as (optional)',
downloadPackArchive: 'Download pack archive' downloadPackArchive: 'Download pack archive',
successfullyDownloaded: 'Successfully downloaded',
successfullyImported: 'Successfully imported',
nowNewPacksToImport: 'No new packs to import',
successfullyUpdated: 'Successfully updated',
metadatLowerCase: 'metadata',
files: 'files'
}, },
invites: { invites: {
inviteTokens: 'Invite tokens', inviteTokens: 'Invite tokens',

View file

@ -8,7 +8,7 @@ import {
savePackMetadata, savePackMetadata,
importFromFS, importFromFS,
updatePackFile } from '@/api/emojiPacks' updatePackFile } from '@/api/emojiPacks'
import i18n from '@/lang'
import { Message } from 'element-ui' import { Message } from 'element-ui'
import Vue from 'vue' import Vue from 'vue'
@ -44,34 +44,30 @@ const packs = {
} }
}, },
actions: { actions: {
async SetLocalEmojiPacks({ commit, getters, state }) { async CreatePack({ getters }, { name }) {
const { data } = await listPacks(getters.authHost) await createPack(getters.authHost, getters.token, name)
commit('SET_LOCAL_PACKS', data)
}, },
async SetRemoteEmojiPacks({ commit, getters, state }, { remoteInstance }) { async DeletePack({ getters }, { name }) {
const { data } = await listRemotePacks(getters.authHost, getters.token, remoteInstance) await deletePack(getters.authHost, getters.token, name)
commit('SET_REMOTE_PACKS', data)
}, },
async DownloadFrom({ commit, getters, state }, { instanceAddress, packName, as }) { async DownloadFrom({ getters }, { instanceAddress, packName, as }) {
const result = await downloadFrom(getters.authHost, instanceAddress, packName, as, getters.token) const result = await downloadFrom(getters.authHost, instanceAddress, packName, as, getters.token)
if (result.data === 'ok') { if (result.data === 'ok') {
Message({ Message({
message: `Successfully downloaded ${packName}`, message: `${i18n.t('settings.successfullyDownloaded')} ${packName}`,
type: 'success', type: 'success',
duration: 5 * 1000 duration: 5 * 1000
}) })
} }
}, },
async ReloadEmoji({ commit, getters, state }) { async ImportFromFS({ getters }) {
await reloadEmoji(getters.authHost, getters.token)
},
async ImportFromFS({ commit, getters, state }) {
const result = await importFromFS(getters.authHost, getters.token) const result = await importFromFS(getters.authHost, getters.token)
if (result.status === 200) { if (result.status === 200) {
const message = result.data.length > 0 ? `Successfully imported ${result.data}` : 'No new packs to import' const message = result.data.length > 0
? `${i18n.t('settings.successfullyImported')} ${result.data}`
: i18n.t('settings.nowNewPacksToImport')
Message({ Message({
message, message,
@ -80,17 +76,9 @@ const packs = {
}) })
} }
}, },
async DeletePack({ commit, getters, state }, { name }) { async ReloadEmoji({ getters }) {
await deletePack(getters.authHost, getters.token, name) await reloadEmoji(getters.authHost, getters.token)
}, },
async CreatePack({ commit, getters, state }, { name }) {
await createPack(getters.authHost, getters.token, name)
},
async UpdateLocalPackVal({ commit, getters, state }, args) {
commit('UPDATE_LOCAL_PACK_VAL', args)
},
async SavePackMetadata({ commit, getters, state }, { packName }) { async SavePackMetadata({ commit, getters, state }, { packName }) {
const result = const result =
await savePackMetadata( await savePackMetadata(
@ -102,7 +90,7 @@ const packs = {
if (result.status === 200) { if (result.status === 200) {
Message({ Message({
message: `Successfully updated ${packName} metadata`, message: `${i18n.t('settings.successfullyUpdated')} ${packName} ${i18n.t('settings.metadatLowerCase')}`,
type: 'success', type: 'success',
duration: 5 * 1000 duration: 5 * 1000
}) })
@ -110,21 +98,32 @@ const packs = {
commit('UPDATE_LOCAL_PACK_PACK', { name: packName, pack: result.data }) commit('UPDATE_LOCAL_PACK_PACK', { name: packName, pack: result.data })
} }
}, },
async SetLocalEmojiPacks({ commit, getters }) {
const { data } = await listPacks(getters.authHost)
commit('SET_LOCAL_PACKS', data)
},
async SetRemoteEmojiPacks({ commit, getters }, { remoteInstance }) {
const { data } = await listRemotePacks(getters.authHost, getters.token, remoteInstance)
async UpdateAndSavePackFile({ commit, getters, state }, args) { commit('SET_REMOTE_PACKS', data)
},
async UpdateAndSavePackFile({ commit, getters }, args) {
const result = await updatePackFile(getters.authHost, getters.token, args) const result = await updatePackFile(getters.authHost, getters.token, args)
if (result.status === 200) { if (result.status === 200) {
const { packName } = args const { packName } = args
Message({ Message({
message: `Successfully updated ${packName} files`, message: `${i18n.t('settings.successfullyUpdated')} ${packName} ${i18n.t('settings.metadatLowerCase')}`,
type: 'success', type: 'success',
duration: 5 * 1000 duration: 5 * 1000
}) })
commit('UPDATE_LOCAL_PACK_FILES', { name: packName, files: result.data }) commit('UPDATE_LOCAL_PACK_FILES', { name: packName, files: result.data })
} }
},
async UpdateLocalPackVal({ commit }, args) {
commit('UPDATE_LOCAL_PACK_VAL', args)
} }
} }
} }

View file

@ -1,4 +1,6 @@
import { generateInviteToken, inviteViaEmail, listInviteTokens, revokeToken } from '@/api/invites' import { generateInviteToken, inviteViaEmail, listInviteTokens, revokeToken } from '@/api/invites'
import { Message } from 'element-ui'
import i18n from '@/lang'
const invites = { const invites = {
state: { state: {
@ -25,18 +27,35 @@ const invites = {
commit('SET_LOADING', false) commit('SET_LOADING', false)
}, },
async GenerateInviteToken({ commit, dispatch, getters }, { maxUse, expiresAt }) { async GenerateInviteToken({ commit, dispatch, getters }, { maxUse, expiresAt }) {
try {
const { data } = await generateInviteToken(maxUse, expiresAt, getters.authHost, getters.token) const { data } = await generateInviteToken(maxUse, expiresAt, getters.authHost, getters.token)
commit('SET_NEW_TOKEN', { token: data.token, maxUse: data.max_use, expiresAt: data.expires_at }) commit('SET_NEW_TOKEN', { token: data.token, maxUse: data.max_use, expiresAt: data.expires_at })
} catch (_e) {
return
}
dispatch('FetchInviteTokens') dispatch('FetchInviteTokens')
}, },
async InviteUserViaEmail({ commit, dispatch, getters }, { email, name }) { async InviteUserViaEmail({ commit, dispatch, getters }, { email, name }) {
try {
await inviteViaEmail(email, name, getters.authHost, getters.token) await inviteViaEmail(email, name, getters.authHost, getters.token)
} catch (_e) {
return
}
Message({
message: i18n.t('invites.emailSent'),
type: 'success',
duration: 5 * 1000
})
}, },
RemoveNewToken({ commit }) { RemoveNewToken({ commit }) {
commit('SET_NEW_TOKEN', {}) commit('SET_NEW_TOKEN', {})
}, },
async RevokeToken({ commit, dispatch, getters }, token) { async RevokeToken({ commit, dispatch, getters }, token) {
try {
await revokeToken(token, getters.authHost, getters.token) await revokeToken(token, getters.authHost, getters.token)
} catch (_e) {
return
}
dispatch('FetchInviteTokens') dispatch('FetchInviteTokens')
} }
} }

View file

@ -28,15 +28,27 @@ const relays = {
commit('SET_RELAYS', response.data.relays) commit('SET_RELAYS', response.data.relays)
commit('SET_LOADING', false) commit('SET_LOADING', false)
}, },
async AddRelay({ commit, getters }, relay) { async AddRelay({ commit, dispatch, getters }, relay) {
commit('ADD_RELAY', relay) commit('ADD_RELAY', relay)
try {
await addRelay(relay, getters.authHost, getters.token) await addRelay(relay, getters.authHost, getters.token)
} catch (_e) {
return
} finally {
dispatch('FetchRelays')
}
}, },
async DeleteRelay({ commit, getters }, relay) { async DeleteRelay({ commit, dispatch, getters }, relay) {
commit('DELETE_RELAY', relay) commit('DELETE_RELAY', relay)
try {
await deleteRelay(relay, getters.authHost, getters.token) await deleteRelay(relay, getters.authHost, getters.token)
} catch (_e) {
return
} finally {
dispatch('FetchRelays')
}
} }
} }
} }

View file

@ -1,5 +1,7 @@
import i18n from '@/lang'
import { fetchSettings, updateSettings, uploadMedia } from '@/api/settings' import { fetchSettings, updateSettings, uploadMedia } from '@/api/settings'
import { filterIgnored, parseTuples, valueHasTuples, wrapConfig } from './normalizers' import { filterIgnored, parseTuples, valueHasTuples, wrapConfig } from './normalizers'
import { Message } from 'element-ui'
const settings = { const settings = {
state: { state: {
@ -124,10 +126,17 @@ const settings = {
async SubmitChanges({ getters, commit, state }, data) { async SubmitChanges({ getters, commit, state }, data) {
const filteredSettings = filterIgnored(state.settings, state.ignoredIfNotEnabled) const filteredSettings = filterIgnored(state.settings, state.ignoredIfNotEnabled)
const configs = data || wrapConfig(filteredSettings) const configs = data || wrapConfig(filteredSettings)
try {
const response = await updateSettings(configs, getters.authHost, getters.token) const response = await updateSettings(configs, getters.authHost, getters.token)
if (data) {
commit('SET_SETTINGS', response.data.configs) commit('SET_SETTINGS', response.data.configs)
} catch (_e) {
return
} }
Message({
message: i18n.t('settings.success'),
type: 'success',
duration: 5 * 1000
})
}, },
UpdateSettings({ commit }, { tab, data }) { UpdateSettings({ commit }, { tab, data }) {
commit('UPDATE_SETTINGS', { tab, data }) commit('UPDATE_SETTINGS', { tab, data })

View file

@ -1,3 +1,5 @@
import { Message } from 'element-ui'
import i18n from '@/lang'
import { import {
activateUsers, activateUsers,
addRight, addRight,
@ -78,8 +80,14 @@ const users = {
commit('SWAP_USERS', updatedUsers) commit('SWAP_USERS', updatedUsers)
const usersNicknames = users.map(user => user.nickname) const usersNicknames = users.map(user => user.nickname)
try {
await activateUsers(usersNicknames, getters.authHost, getters.token) await activateUsers(usersNicknames, getters.authHost, getters.token)
} catch (_e) {
return
} finally {
dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage }) dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage })
}
dispatch('SuccessMessage')
}, },
async AddRight({ commit, dispatch, getters, state }, { users, right }) { async AddRight({ commit, dispatch, getters, state }, { users, right }) {
const updatedUsers = users.map(user => { const updatedUsers = users.map(user => {
@ -88,8 +96,14 @@ const users = {
commit('SWAP_USERS', updatedUsers) commit('SWAP_USERS', updatedUsers)
const usersNicknames = users.map(user => user.nickname) const usersNicknames = users.map(user => user.nickname)
try {
await addRight(usersNicknames, right, getters.authHost, getters.token) await addRight(usersNicknames, right, getters.authHost, getters.token)
} catch (_e) {
return
} finally {
dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage }) dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage })
}
dispatch('SuccessMessage')
}, },
async AddTag({ commit, dispatch, getters, state }, { users, tag }) { async AddTag({ commit, dispatch, getters, state }, { users, tag }) {
const updatedUsers = users.map(user => { const updatedUsers = users.map(user => {
@ -98,16 +112,28 @@ const users = {
commit('SWAP_USERS', updatedUsers) commit('SWAP_USERS', updatedUsers)
const nicknames = users.map(user => user.nickname) const nicknames = users.map(user => user.nickname)
try {
await tagUser(nicknames, [tag], getters.authHost, getters.token) await tagUser(nicknames, [tag], getters.authHost, getters.token)
} catch (_e) {
return
} finally {
dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage }) dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage })
}
dispatch('SuccessMessage')
}, },
async ClearFilters({ commit, dispatch, state }) { async ClearFilters({ commit, dispatch, state }) {
commit('CLEAR_USERS_FILTERS') commit('CLEAR_USERS_FILTERS')
dispatch('SearchUsers', { query: state.searchQuery, page: 1 }) dispatch('SearchUsers', { query: state.searchQuery, page: 1 })
}, },
async CreateNewAccount({ dispatch, getters, state }, { nickname, email, password }) { async CreateNewAccount({ dispatch, getters, state }, { nickname, email, password }) {
try {
await createNewAccount(nickname, email, password, getters.authHost, getters.token) await createNewAccount(nickname, email, password, getters.authHost, getters.token)
} catch (_e) {
return
} finally {
dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage }) dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage })
}
dispatch('SuccessMessage')
}, },
async DeactivateUsers({ commit, dispatch, getters, state }, users) { async DeactivateUsers({ commit, dispatch, getters, state }, users) {
const updatedUsers = users.map(user => { const updatedUsers = users.map(user => {
@ -116,8 +142,14 @@ const users = {
commit('SWAP_USERS', updatedUsers) commit('SWAP_USERS', updatedUsers)
const usersNicknames = users.map(user => user.nickname) const usersNicknames = users.map(user => user.nickname)
try {
await deactivateUsers(usersNicknames, getters.authHost, getters.token) await deactivateUsers(usersNicknames, getters.authHost, getters.token)
} catch (_e) {
return
} finally {
dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage }) dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage })
}
dispatch('SuccessMessage')
}, },
async DeleteRight({ commit, dispatch, getters, state }, { users, right }) { async DeleteRight({ commit, dispatch, getters, state }, { users, right }) {
const updatedUsers = users.map(user => { const updatedUsers = users.map(user => {
@ -126,19 +158,26 @@ const users = {
commit('SWAP_USERS', updatedUsers) commit('SWAP_USERS', updatedUsers)
const usersNicknames = users.map(user => user.nickname) const usersNicknames = users.map(user => user.nickname)
try {
await deleteRight(usersNicknames, right, getters.authHost, getters.token) await deleteRight(usersNicknames, right, getters.authHost, getters.token)
} catch (_e) {
return
} finally {
dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage }) dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage })
}
dispatch('SuccessMessage')
}, },
async DeleteUsers({ commit, getters, state }, users) { async DeleteUsers({ commit, dispatch, getters, state }, users) {
const usersNicknames = users.map(user => user.nickname)
try {
await deleteUsers(usersNicknames, getters.authHost, getters.token)
} catch (_e) {
return
}
const deletedUsersIds = users.map(deletedUser => deletedUser.id) const deletedUsersIds = users.map(deletedUser => deletedUser.id)
const updatedUsers = state.fetchedUsers.filter(user => !deletedUsersIds.includes(user.id)) const updatedUsers = state.fetchedUsers.filter(user => !deletedUsersIds.includes(user.id))
commit('SET_USERS', updatedUsers) commit('SET_USERS', updatedUsers)
dispatch('SuccessMessage')
const usersNicknames = users.map(user => user.nickname)
await deleteUsers(usersNicknames, getters.authHost, getters.token)
},
async RequirePasswordReset({ getters }, user) {
await requirePasswordReset(user.nickname, getters.authHost, getters.token)
}, },
async FetchUsers({ commit, dispatch, getters, state }, { page }) { async FetchUsers({ commit, dispatch, getters, state }, { page }) {
commit('SET_LOADING', true) commit('SET_LOADING', true)
@ -161,8 +200,22 @@ const users = {
commit('SWAP_USERS', updatedUsers) commit('SWAP_USERS', updatedUsers)
const nicknames = users.map(user => user.nickname) const nicknames = users.map(user => user.nickname)
try {
await untagUser(nicknames, [tag], getters.authHost, getters.token) await untagUser(nicknames, [tag], getters.authHost, getters.token)
} catch (_e) {
return
} finally {
dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage }) dispatch('SearchUsers', { query: state.searchQuery, page: state.currentPage })
}
dispatch('SuccessMessage')
},
async RequirePasswordReset({ dispatch, getters }, user) {
try {
await requirePasswordReset(user.nickname, getters.authHost, getters.token)
} catch (_e) {
return
}
dispatch('SuccessMessage')
}, },
async SearchUsers({ commit, dispatch, state, getters }, { query, page }) { async SearchUsers({ commit, dispatch, state, getters }, { query, page }) {
if (query.length === 0) { if (query.length === 0) {
@ -178,6 +231,13 @@ const users = {
loadUsers(commit, page, response.data) loadUsers(commit, page, response.data)
} }
}, },
SuccessMessage() {
return Message({
message: i18n.t('users.completed'),
type: 'success',
duration: 5 * 1000
})
},
async ToggleUsersFilter({ commit, dispatch, state }, filters) { async ToggleUsersFilter({ commit, dispatch, state }, filters) {
const defaultFilters = { const defaultFilters = {
local: false, local: false,

View file

@ -192,17 +192,8 @@ export default {
async inviteUserViaEmail() { async inviteUserViaEmail() {
this.$refs['inviteUserForm'].validate(async(valid) => { this.$refs['inviteUserForm'].validate(async(valid) => {
if (valid) { if (valid) {
try {
await this.$store.dispatch('InviteUserViaEmail', this.$data.inviteUserForm) await this.$store.dispatch('InviteUserViaEmail', this.$data.inviteUserForm)
} catch (_e) {
return
} finally {
this.closeDialogWindow() this.closeDialogWindow()
}
this.$message({
type: 'success',
message: this.$t('invites.emailSent')
})
} else { } else {
this.$message({ this.$message({
type: 'error', type: 'error',

View file

@ -37,7 +37,6 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import i18n from '@/lang'
export default { export default {
name: 'ActivityPub', name: 'ActivityPub',
@ -57,16 +56,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -232,7 +232,6 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import i18n from '@/lang'
export default { export default {
name: 'Authentication', name: 'Authentication',
@ -259,16 +258,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -52,7 +52,6 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import i18n from '@/lang'
export default { export default {
name: 'AutoLinker', name: 'AutoLinker',
@ -107,16 +106,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -33,7 +33,6 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import i18n from '@/lang'
export default { export default {
name: 'Captcha', name: 'Captcha',
@ -53,16 +52,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -135,7 +135,6 @@
</template> </template>
<script> <script>
import i18n from '@/lang'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
export default { export default {
@ -157,16 +156,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -172,7 +172,6 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import i18n from '@/lang'
import { options } from './options' import { options } from './options'
import AceEditor from 'vue2-ace-editor' import AceEditor from 'vue2-ace-editor'
import 'brace/mode/elixir' import 'brace/mode/elixir'
@ -246,16 +245,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -55,7 +55,6 @@
</template> </template>
<script> <script>
import i18n from '@/lang'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
export default { export default {
@ -82,16 +81,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -318,7 +318,6 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import i18n from '@/lang'
import { options } from './options' import { options } from './options'
export default { export default {
@ -419,16 +418,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -23,7 +23,6 @@
</template> </template>
<script> <script>
import i18n from '@/lang'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
export default { export default {
@ -43,16 +42,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -129,7 +129,6 @@
</template> </template>
<script> <script>
import i18n from '@/lang'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
export default { export default {
@ -161,16 +160,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -337,7 +337,6 @@
</template> </template>
<script> <script>
import i18n from '@/lang'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { options } from './options' import { options } from './options'
@ -396,16 +395,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -51,7 +51,6 @@
</template> </template>
<script> <script>
import i18n from '@/lang'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
export default { export default {
@ -72,16 +71,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -173,7 +173,6 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import i18n from '@/lang'
import { options } from './options' import { options } from './options'
export default { export default {
@ -212,16 +211,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -145,7 +145,6 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import i18n from '@/lang'
import { options } from './options' import { options } from './options'
export default { export default {
@ -257,16 +256,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -202,7 +202,6 @@
</template> </template>
<script> <script>
import i18n from '@/lang'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { options } from './options' import { options } from './options'
import AceEditor from 'vue2-ace-editor' import AceEditor from 'vue2-ace-editor'
@ -249,16 +248,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -75,7 +75,6 @@
</template> </template>
<script> <script>
import i18n from '@/lang'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { options } from './options' import { options } from './options'
@ -126,16 +125,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -52,7 +52,6 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import i18n from '@/lang'
export default { export default {
name: 'Metadata', name: 'Metadata',
@ -72,16 +71,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -30,7 +30,6 @@
</template> </template>
<script> <script>
import i18n from '@/lang'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
export default { export default {
@ -65,16 +64,8 @@ export default {
}, {}) }, {})
this.updateSetting(updatedValue, 'types', 'value') this.updateSetting(updatedValue, 'types', 'value')
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
}, },
parseMimeTypes(value, inputType, index) { parseMimeTypes(value, inputType, index) {
const updatedValue = this.mimeTypes.reduce((acc, el, i) => { const updatedValue = this.mimeTypes.reduce((acc, el, i) => {

View file

@ -223,7 +223,6 @@
</template> </template>
<script> <script>
import i18n from '@/lang'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
export default { export default {
@ -379,16 +378,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -52,22 +52,10 @@ export default {
}, },
methods: { methods: {
followRelay() { followRelay() {
try {
this.$store.dispatch('AddRelay', this.newRelay) this.$store.dispatch('AddRelay', this.newRelay)
} catch (_e) {
return
} finally {
this.$store.dispatch('FetchRelays')
}
}, },
deleteRelay(relay) { deleteRelay(relay) {
try {
this.$store.dispatch('DeleteRelay', relay) this.$store.dispatch('DeleteRelay', relay)
} catch (_e) {
return
} finally {
this.$store.dispatch('FetchRelays')
}
} }
} }
} }

View file

@ -144,7 +144,6 @@
</template> </template>
<script> <script>
import i18n from '@/lang'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { options } from './options' import { options } from './options'
@ -207,16 +206,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -21,7 +21,6 @@
</template> </template>
<script> <script>
import i18n from '@/lang'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
export default { export default {
@ -41,16 +40,8 @@ export default {
updateSetting(value, tab, input) { updateSetting(value, tab, input) {
this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }}) this.$store.dispatch('UpdateSettings', { tab, data: { [input]: value }})
}, },
async onSubmit() { onSubmit() {
try { this.$store.dispatch('SubmitChanges')
await this.$store.dispatch('SubmitChanges')
} catch (e) {
return
}
this.$message({
type: 'success',
message: i18n.t('settings.success')
})
} }
} }
} }

View file

@ -151,16 +151,7 @@ export default {
methods: { methods: {
mappers() { mappers() {
const applyAction = async(users, dispatchAction) => { const applyAction = async(users, dispatchAction) => {
try {
await dispatchAction(users) await dispatchAction(users)
} catch (err) {
console.log(err)
return
}
this.$message({
type: 'success',
message: this.$t('users.completed')
})
this.$emit('apply-action') this.$emit('apply-action')
} }
return { return {
@ -215,7 +206,9 @@ export default {
applyAction(filtered, removeTagFn) applyAction(filtered, removeTagFn)
}, },
requirePasswordReset: () => { requirePasswordReset: () => {
this.selectedUsers.map(user => this.$store.dispatch('RequirePasswordReset', user)) const filtered = this.selectedUsers.filter(user => user.local)
filtered.map(user => this.$store.dispatch('RequirePasswordReset', user))
this.$emit('apply-action')
} }
} }
}, },

View file

@ -245,17 +245,8 @@ export default {
this.$refs.usersTable.clearSelection() this.$refs.usersTable.clearSelection()
}, },
async createNewAccount(accountData) { async createNewAccount(accountData) {
try {
await this.$store.dispatch('CreateNewAccount', accountData) await this.$store.dispatch('CreateNewAccount', accountData)
} catch (_e) {
return
} finally {
this.createAccountDialogOpen = false this.createAccountDialogOpen = false
}
this.$message({
type: 'success',
message: this.$t('users.accountCreated')
})
}, },
getFirstLetter(str) { getFirstLetter(str) {
return str.charAt(0).toUpperCase() return str.charAt(0).toUpperCase()