mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
migration: vue3 GLOBAL_DELETE INSTANCE_DELETE GLOBAL_SET INSTANCE_SET
This commit is contained in:
parent
2a5bbb594d
commit
f6adc87691
8 changed files with 27 additions and 26 deletions
|
@ -1,5 +1,3 @@
|
|||
import Vue from 'vue'
|
||||
|
||||
import api from '@/api'
|
||||
import { isEmptyValue } from '@/helpers/commons'
|
||||
import { stratify } from '@/helpers/data/tree'
|
||||
|
@ -34,7 +32,7 @@ export default {
|
|||
},
|
||||
|
||||
SET_DOMAINS_DETAILS(state, [name, details]) {
|
||||
Vue.set(state.domains_details, name, details)
|
||||
state.domains_details[name] = details
|
||||
},
|
||||
|
||||
UPDATE_DOMAINS_DETAILS(state, payload) {
|
||||
|
@ -43,9 +41,9 @@ export default {
|
|||
},
|
||||
|
||||
DEL_DOMAINS_DETAILS(state, [name]) {
|
||||
Vue.delete(state.domains_details, name)
|
||||
delete state.domains_details[name]
|
||||
if (state.domains) {
|
||||
Vue.delete(state.domains, name)
|
||||
delete state.domains[name]
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -72,16 +70,16 @@ export default {
|
|||
|
||||
ADD_USERS(state, [user]) {
|
||||
if (!state.users) state.users = {}
|
||||
Vue.set(state.users, user.username, user)
|
||||
state.users[user.username] = user
|
||||
},
|
||||
|
||||
SET_USERS_DETAILS(state, [username, userData]) {
|
||||
Vue.set(state.users_details, username, userData)
|
||||
state.users_details[username] = userData
|
||||
if (!state.users) return
|
||||
const user = state.users[username]
|
||||
for (const key of ['fullname', 'mail']) {
|
||||
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]) {
|
||||
Vue.delete(state.users_details, username)
|
||||
delete state.users_details[username]
|
||||
if (state.users) {
|
||||
Vue.delete(state.users, username)
|
||||
delete state.users[username]
|
||||
if (Object.keys(state.users).length === 0) {
|
||||
state.users = null
|
||||
}
|
||||
|
@ -107,16 +105,16 @@ export default {
|
|||
|
||||
ADD_GROUPS(state, [{ name }]) {
|
||||
if (state.groups !== undefined) {
|
||||
Vue.set(state.groups, name, { members: [], permissions: [] })
|
||||
state.groups[name] = { members: [], permissions: [] }
|
||||
}
|
||||
},
|
||||
|
||||
UPDATE_GROUPS(state, [data, { groupName }]) {
|
||||
Vue.set(state.groups, groupName, data)
|
||||
state.groups[groupName] = data
|
||||
},
|
||||
|
||||
DEL_GROUPS(state, [groupname]) {
|
||||
Vue.delete(state.groups, groupname)
|
||||
delete state.groups[groupname]
|
||||
},
|
||||
|
||||
SET_PERMISSIONS(state, [permissions]) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import Vue from 'vue'
|
||||
import router from '@/router'
|
||||
import i18n from '@/i18n'
|
||||
import api from '@/api'
|
||||
|
@ -55,7 +54,7 @@ export default {
|
|||
|
||||
UPDATE_REQUEST(state, { request, key, value }) {
|
||||
// This rely on data persistance and reactivity.
|
||||
Vue.set(request, key, value)
|
||||
request[key] = value
|
||||
},
|
||||
|
||||
REMOVE_REQUEST(state, request) {
|
||||
|
@ -303,7 +302,7 @@ export default {
|
|||
// the ownership to stay generic.
|
||||
const request = error.request
|
||||
delete error.request
|
||||
Vue.set(request, 'error', error)
|
||||
request.error = error
|
||||
// Display the error in a modal on the current view.
|
||||
commit('SET_ERROR', request)
|
||||
}
|
||||
|
@ -330,7 +329,7 @@ export default {
|
|||
|
||||
DISMISS_WARNING({ commit, state }, request) {
|
||||
commit('SET_WAITING', false)
|
||||
Vue.delete(request, 'showWarningMessage')
|
||||
delete request.showWarningMessage
|
||||
},
|
||||
|
||||
UPDATE_ROUTER_KEY({ commit }, { to, from }) {
|
||||
|
|
|
@ -629,7 +629,9 @@ export default {
|
|||
Object.assign(this.externalResults, {
|
||||
forms: { [panel.id]: { [err.data.name]: [err.data.error] } },
|
||||
})
|
||||
} else this.$set(panel, 'serverError', err.message)
|
||||
} else {
|
||||
panel.serverError = err.message
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
|
|
|
@ -257,7 +257,9 @@ export default {
|
|||
Object.assign(this.externalResults, {
|
||||
forms: { [panel.id]: { [err.data.name]: [err.data.error] } },
|
||||
})
|
||||
} else this.$set(panel, 'serverError', err.message)
|
||||
} else {
|
||||
panel.serverError = err.message
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
|
|
|
@ -133,8 +133,6 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import Vue from 'vue'
|
||||
|
||||
import api from '@/api'
|
||||
import { isEmptyValue } from '@/helpers/commons'
|
||||
import TagsSelectizeItem from '@/components/globals/formItems/TagsSelectizeItem.vue'
|
||||
|
@ -325,7 +323,7 @@ export default {
|
|||
{ key: 'groups.delete', name: groupName },
|
||||
)
|
||||
.then(() => {
|
||||
Vue.delete(this.primaryGroups, groupName)
|
||||
delete this.primaryGroups[groupName]
|
||||
})
|
||||
},
|
||||
},
|
||||
|
|
|
@ -270,13 +270,13 @@ export default {
|
|||
},
|
||||
|
||||
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'
|
||||
this.togglePort({ action, port, protocol, connection }).then(
|
||||
(toggled) => {
|
||||
// Revert change on cancel
|
||||
if (!toggled) {
|
||||
this.$set(this.protocols[protocol][index], connection, !value)
|
||||
this.protocols[protocol][index][connection] = !value
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
|
@ -112,7 +112,7 @@ export default {
|
|||
pending.forEach((migration) => {
|
||||
if (migration.disclaimer) {
|
||||
migration.disclaimer = migration.disclaimer.replaceAll('\n', '<br>')
|
||||
this.$set(this.checked, migration.id, null)
|
||||
this.checked[migration.id] = null
|
||||
}
|
||||
})
|
||||
// FIXME change to pending
|
||||
|
|
|
@ -68,7 +68,9 @@ export default {
|
|||
Object.assign(this.externalResults, {
|
||||
forms: { [panel.id]: { [err.data.name]: [err.data.error] } },
|
||||
})
|
||||
} else this.$set(panel, 'serverError', err.message)
|
||||
} else {
|
||||
panel.serverError = err.message
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue