2021-01-30 16:17:04 +00:00
|
|
|
<template>
|
|
|
|
<modal
|
|
|
|
@close="$router.back()"
|
|
|
|
@submit="archiveNamespace()"
|
|
|
|
>
|
2021-08-19 17:55:13 +00:00
|
|
|
<template #header><span>{{ title }}</span></template>
|
2022-01-26 13:36:32 +00:00
|
|
|
|
2021-08-19 17:55:13 +00:00
|
|
|
<template #text>
|
2022-01-26 13:36:32 +00:00
|
|
|
<p>
|
|
|
|
{{ namespace.isArchived ? $t('namespace.archive.unarchiveText') : $t('namespace.archive.archiveText')}}
|
|
|
|
</p>
|
2021-08-19 17:55:13 +00:00
|
|
|
</template>
|
2021-01-30 16:17:04 +00:00
|
|
|
</modal>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import NamespaceService from '@/services/namespace'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'namespace-setting-archive',
|
|
|
|
data() {
|
|
|
|
return {
|
2021-09-08 09:59:38 +00:00
|
|
|
namespaceService: new NamespaceService(),
|
2021-01-30 16:17:04 +00:00
|
|
|
namespace: null,
|
2021-07-19 09:18:22 +00:00
|
|
|
title: '',
|
2021-01-30 16:17:04 +00:00
|
|
|
}
|
|
|
|
},
|
2021-10-11 17:37:20 +00:00
|
|
|
|
2021-01-30 16:17:04 +00:00
|
|
|
created() {
|
|
|
|
this.namespace = this.$store.getters['namespaces/getNamespaceById'](this.$route.params.id)
|
2021-06-23 23:24:57 +00:00
|
|
|
this.title = this.namespace.isArchived ?
|
2022-01-26 13:36:32 +00:00
|
|
|
this.$t('namespace.archive.titleUnarchive', {namespace: this.namespace.title}) :
|
|
|
|
this.$t('namespace.archive.titleArchive', {namespace: this.namespace.title})
|
2021-06-23 23:24:57 +00:00
|
|
|
this.setTitle(this.title)
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
|
|
|
|
2021-10-11 17:37:20 +00:00
|
|
|
methods: {
|
|
|
|
async archiveNamespace() {
|
|
|
|
try {
|
2022-01-26 13:41:41 +00:00
|
|
|
const isArchived = !this.namespace.isArchived
|
2022-01-26 13:36:32 +00:00
|
|
|
const namespace = await this.namespaceService.update({
|
|
|
|
...this.namespace,
|
2022-01-26 13:41:41 +00:00
|
|
|
isArchived,
|
2022-01-26 13:36:32 +00:00
|
|
|
})
|
2021-10-11 17:37:20 +00:00
|
|
|
this.$store.commit('namespaces/setNamespaceById', namespace)
|
2022-01-26 13:41:41 +00:00
|
|
|
this.$message.success({message: this.$t(isArchived ? 'namespace.archive.success' : 'namespace.archive.unarchiveSuccess')})
|
2021-10-11 17:37:20 +00:00
|
|
|
} finally {
|
|
|
|
this.$router.back()
|
|
|
|
}
|
2021-01-30 16:17:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|