fix: vuex store mutation violation when archiving a namespace
This commit is contained in:
parent
9e4ea9e597
commit
fdd2e7e538
2 changed files with 10 additions and 9 deletions
|
@ -23,8 +23,6 @@ export default {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: direct manipulation of the prop
|
|
||||||
// might not be a problem since this is happening in the mutation
|
|
||||||
if (!namespace.lists || namespace.lists.length === 0) {
|
if (!namespace.lists || namespace.lists.length === 0) {
|
||||||
namespace.lists = state.namespaces[namespaceIndex].lists
|
namespace.lists = state.namespaces[namespaceIndex].lists
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
@submit="archiveNamespace()"
|
@submit="archiveNamespace()"
|
||||||
>
|
>
|
||||||
<template #header><span>{{ title }}</span></template>
|
<template #header><span>{{ title }}</span></template>
|
||||||
|
|
||||||
<template #text>
|
<template #text>
|
||||||
<p>{{ list.isArchived ? $t('namespace.archive.unarchiveText') : $t('namespace.archive.archiveText') }}</p>
|
<p>
|
||||||
|
{{ namespace.isArchived ? $t('namespace.archive.unarchiveText') : $t('namespace.archive.archiveText')}}
|
||||||
|
</p>
|
||||||
</template>
|
</template>
|
||||||
</modal>
|
</modal>
|
||||||
</template>
|
</template>
|
||||||
|
@ -27,17 +29,18 @@ export default {
|
||||||
created() {
|
created() {
|
||||||
this.namespace = this.$store.getters['namespaces/getNamespaceById'](this.$route.params.id)
|
this.namespace = this.$store.getters['namespaces/getNamespaceById'](this.$route.params.id)
|
||||||
this.title = this.namespace.isArchived ?
|
this.title = this.namespace.isArchived ?
|
||||||
this.$t('namespace.archive.titleUnarchive', { namespace: this.namespace.title }) :
|
this.$t('namespace.archive.titleUnarchive', {namespace: this.namespace.title}) :
|
||||||
this.$t('namespace.archive.titleArchive', { namespace: this.namespace.title })
|
this.$t('namespace.archive.titleArchive', {namespace: this.namespace.title})
|
||||||
this.setTitle(this.title)
|
this.setTitle(this.title)
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
async archiveNamespace() {
|
async archiveNamespace() {
|
||||||
this.namespace.isArchived = !this.namespace.isArchived
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const namespace = await this.namespaceService.update(this.namespace)
|
const namespace = await this.namespaceService.update({
|
||||||
|
...this.namespace,
|
||||||
|
isArchived: !this.namespace.isArchived,
|
||||||
|
})
|
||||||
this.$store.commit('namespaces/setNamespaceById', namespace)
|
this.$store.commit('namespaces/setNamespaceById', namespace)
|
||||||
this.$message.success({message: this.$t('namespace.archive.success')})
|
this.$message.success({message: this.$t('namespace.archive.success')})
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in a new issue