3
0

Fallback to namespaceID where slug is used

This commit is contained in:
Jože Fortun
2022-11-22 18:21:35 +01:00
parent 83f2068d91
commit f740dd0020
4 changed files with 13 additions and 12 deletions
@@ -41,7 +41,7 @@
data-test-id="button-public"
variant="light"
class="w-100 mb-2"
:to="{ name: 'pages', params: { slug: namespace.slug } }"
:to="{ name: 'pages', params: { slug: namespace.slug || namespace.namespaceID } }"
>
{{ $t('publicPages') }}
</b-button>
@@ -51,7 +51,7 @@
data-test-id="button-admin"
variant="light"
class="w-100 mb-2"
:to="{ name: 'admin.modules', params: { slug: namespace.slug } }"
:to="{ name: 'admin.modules', params: { slug: namespace.slug || namespace.namespaceID } }"
>
{{ $t('adminPanel') }}
</b-button>
@@ -310,14 +310,14 @@ export default {
'$route.params.slug': {
immediate: true,
handler (slug = '') {
this.namespace = slug ? this.namespaces.find(n => n.slug === slug) : undefined
this.query = ''
this.namespace = this.$store.getters['namespace/getByUrlPart'](slug)
},
},
},
methods: {
namespaceSelected ({ canManageNamespace, slug = '' }) {
namespaceSelected ({ namespaceID, canManageNamespace, slug = '' }) {
let { name, params } = this.$route
// Try to match page, otherwise redirect to pages root
@@ -331,7 +331,7 @@ export default {
name = !params.pageID && canManageNamespace && !name.includes('namespace.') ? name : 'pages'
this.$router.push({ name, params: { slug } })
this.$router.push({ name, params: { slug: slug || namespaceID } })
},
pageIndex (wraps) {
@@ -1084,7 +1084,7 @@ export default {
name: 'page.record',
label: 'Record page',
params: {
slug: this.namespace.slug,
slug: this.namespace.slug || this.namespace.namespaceID,
pageID: this.recordPageID,
recordID: recordID,
},
@@ -1104,7 +1104,7 @@ export default {
...e,
namespaceID,
moduleID,
filename: `${this.namespace.slug} - ${this.recordListModule.name}`,
filename: `${this.namespace.slug || namespaceID} - ${this.recordListModule.name}`,
}
if (filterRaw.rangeType === 'range') {
@@ -602,9 +602,9 @@ export default {
async handleApplicationSave () {
if (this.application) {
this.application.name = this.namespace.slug
this.application.name = this.namespace.slug || this.namespace.namespaceID
this.application.unify.name = this.namespace.name
this.application.unify.url = `/compose/ns/${this.namespace.slug}/pages`
this.application.unify.url = `/compose/ns/${this.application.name}/pages`
let enabled = this.application.enabled
if (this.isApplication && !this.application.enabled) {
@@ -626,12 +626,12 @@ export default {
} else if (this.isApplication) {
// If namespace not an application - create one and enable
const application = {
name: this.namespace.slug,
name: this.namespace.slug || this.namespace.namespaceID,
enabled: true,
unify: {
name: this.namespace.name,
listed: true,
url: `compose/ns/${this.namespace.slug}/pages`,
url: `compose/ns/${this.namespace.slug || this.namespace.namespaceID}/pages`,
icon: this.namespace.meta.icon || this.$Settings.attachment('ui.iconLogo'),
logo: this.namespace.meta.logo || this.$Settings.attachment('ui.mainLogo'),
},
@@ -106,7 +106,8 @@ export default {
},
rowClicked ({ namespace, module }) {
window.open(`/compose/ns/${namespace.slug}/admin/modules/${module.moduleID}/edit`, '_blank')
const { namespaceID, slug } = namespace
window.open(`/compose/ns/${slug || namespaceID}/admin/modules/${module.moduleID}/edit`, '_blank')
},
},
}