migration: vue3 GLOBAL_DELETE INSTANCE_DELETE GLOBAL_SET INSTANCE_SET

This commit is contained in:
axolotle 2024-03-11 14:47:36 +01:00
parent 2a5bbb594d
commit f6adc87691
8 changed files with 27 additions and 26 deletions

View file

@ -1,5 +1,3 @@
import Vue from 'vue'
import api from '@/api' import api from '@/api'
import { isEmptyValue } from '@/helpers/commons' import { isEmptyValue } from '@/helpers/commons'
import { stratify } from '@/helpers/data/tree' import { stratify } from '@/helpers/data/tree'
@ -34,7 +32,7 @@ export default {
}, },
SET_DOMAINS_DETAILS(state, [name, details]) { SET_DOMAINS_DETAILS(state, [name, details]) {
Vue.set(state.domains_details, name, details) state.domains_details[name] = details
}, },
UPDATE_DOMAINS_DETAILS(state, payload) { UPDATE_DOMAINS_DETAILS(state, payload) {
@ -43,9 +41,9 @@ export default {
}, },
DEL_DOMAINS_DETAILS(state, [name]) { DEL_DOMAINS_DETAILS(state, [name]) {
Vue.delete(state.domains_details, name) delete state.domains_details[name]
if (state.domains) { if (state.domains) {
Vue.delete(state.domains, name) delete state.domains[name]
} }
}, },
@ -72,16 +70,16 @@ export default {
ADD_USERS(state, [user]) { ADD_USERS(state, [user]) {
if (!state.users) state.users = {} if (!state.users) state.users = {}
Vue.set(state.users, user.username, user) state.users[user.username] = user
}, },
SET_USERS_DETAILS(state, [username, userData]) { SET_USERS_DETAILS(state, [username, userData]) {
Vue.set(state.users_details, username, userData) state.users_details[username] = userData
if (!state.users) return if (!state.users) return
const user = state.users[username] const user = state.users[username]
for (const key of ['fullname', 'mail']) { for (const key of ['fullname', 'mail']) {
if (user[key] !== userData[key]) { if (user[key] !== userData[key]) {
Vue.set(user, key, userData[key]) user[key] = userData[key]
} }
} }
}, },
@ -92,9 +90,9 @@ export default {
}, },
DEL_USERS_DETAILS(state, [username]) { DEL_USERS_DETAILS(state, [username]) {
Vue.delete(state.users_details, username) delete state.users_details[username]
if (state.users) { if (state.users) {
Vue.delete(state.users, username) delete state.users[username]
if (Object.keys(state.users).length === 0) { if (Object.keys(state.users).length === 0) {
state.users = null state.users = null
} }
@ -107,16 +105,16 @@ export default {
ADD_GROUPS(state, [{ name }]) { ADD_GROUPS(state, [{ name }]) {
if (state.groups !== undefined) { if (state.groups !== undefined) {
Vue.set(state.groups, name, { members: [], permissions: [] }) state.groups[name] = { members: [], permissions: [] }
} }
}, },
UPDATE_GROUPS(state, [data, { groupName }]) { UPDATE_GROUPS(state, [data, { groupName }]) {
Vue.set(state.groups, groupName, data) state.groups[groupName] = data
}, },
DEL_GROUPS(state, [groupname]) { DEL_GROUPS(state, [groupname]) {
Vue.delete(state.groups, groupname) delete state.groups[groupname]
}, },
SET_PERMISSIONS(state, [permissions]) { SET_PERMISSIONS(state, [permissions]) {

View file

@ -1,4 +1,3 @@
import Vue from 'vue'
import router from '@/router' import router from '@/router'
import i18n from '@/i18n' import i18n from '@/i18n'
import api from '@/api' import api from '@/api'
@ -55,7 +54,7 @@ export default {
UPDATE_REQUEST(state, { request, key, value }) { UPDATE_REQUEST(state, { request, key, value }) {
// This rely on data persistance and reactivity. // This rely on data persistance and reactivity.
Vue.set(request, key, value) request[key] = value
}, },
REMOVE_REQUEST(state, request) { REMOVE_REQUEST(state, request) {
@ -303,7 +302,7 @@ export default {
// the ownership to stay generic. // the ownership to stay generic.
const request = error.request const request = error.request
delete error.request delete error.request
Vue.set(request, 'error', error) request.error = error
// Display the error in a modal on the current view. // Display the error in a modal on the current view.
commit('SET_ERROR', request) commit('SET_ERROR', request)
} }
@ -330,7 +329,7 @@ export default {
DISMISS_WARNING({ commit, state }, request) { DISMISS_WARNING({ commit, state }, request) {
commit('SET_WAITING', false) commit('SET_WAITING', false)
Vue.delete(request, 'showWarningMessage') delete request.showWarningMessage
}, },
UPDATE_ROUTER_KEY({ commit }, { to, from }) { UPDATE_ROUTER_KEY({ commit }, { to, from }) {

View file

@ -629,7 +629,9 @@ export default {
Object.assign(this.externalResults, { Object.assign(this.externalResults, {
forms: { [panel.id]: { [err.data.name]: [err.data.error] } }, forms: { [panel.id]: { [err.data.name]: [err.data.error] } },
}) })
} else this.$set(panel, 'serverError', err.message) } else {
panel.serverError = err.message
}
}) })
}, },

View file

@ -257,7 +257,9 @@ export default {
Object.assign(this.externalResults, { Object.assign(this.externalResults, {
forms: { [panel.id]: { [err.data.name]: [err.data.error] } }, forms: { [panel.id]: { [err.data.name]: [err.data.error] } },
}) })
} else this.$set(panel, 'serverError', err.message) } else {
panel.serverError = err.message
}
}) })
}, },

View file

@ -133,8 +133,6 @@
</template> </template>
<script> <script>
import Vue from 'vue'
import api from '@/api' import api from '@/api'
import { isEmptyValue } from '@/helpers/commons' import { isEmptyValue } from '@/helpers/commons'
import TagsSelectizeItem from '@/components/globals/formItems/TagsSelectizeItem.vue' import TagsSelectizeItem from '@/components/globals/formItems/TagsSelectizeItem.vue'
@ -325,7 +323,7 @@ export default {
{ key: 'groups.delete', name: groupName }, { key: 'groups.delete', name: groupName },
) )
.then(() => { .then(() => {
Vue.delete(this.primaryGroups, groupName) delete this.primaryGroups[groupName]
}) })
}, },
}, },

View file

@ -270,13 +270,13 @@ export default {
}, },
onTablePortToggling(port, protocol, connection, index, value) { onTablePortToggling(port, protocol, connection, index, value) {
this.$set(this.protocols[protocol][index], connection, value) this.protocols[protocol][index][connection] = value
const action = value ? 'allow' : 'disallow' const action = value ? 'allow' : 'disallow'
this.togglePort({ action, port, protocol, connection }).then( this.togglePort({ action, port, protocol, connection }).then(
(toggled) => { (toggled) => {
// Revert change on cancel // Revert change on cancel
if (!toggled) { if (!toggled) {
this.$set(this.protocols[protocol][index], connection, !value) this.protocols[protocol][index][connection] = !value
} }
}, },
) )

View file

@ -112,7 +112,7 @@ export default {
pending.forEach((migration) => { pending.forEach((migration) => {
if (migration.disclaimer) { if (migration.disclaimer) {
migration.disclaimer = migration.disclaimer.replaceAll('\n', '<br>') migration.disclaimer = migration.disclaimer.replaceAll('\n', '<br>')
this.$set(this.checked, migration.id, null) this.checked[migration.id] = null
} }
}) })
// FIXME change to pending // FIXME change to pending

View file

@ -68,7 +68,9 @@ export default {
Object.assign(this.externalResults, { Object.assign(this.externalResults, {
forms: { [panel.id]: { [err.data.name]: [err.data.error] } }, forms: { [panel.id]: { [err.data.name]: [err.data.error] } },
}) })
} else this.$set(panel, 'serverError', err.message) } else {
panel.serverError = err.message
}
}) })
}, },
}, },