Refactor 'GroupContentMenu' component

This commit is contained in:
Wolfgang Huß 2022-09-28 16:38:56 +02:00
parent 2eda102a71
commit ac9be9e2a3
3 changed files with 13 additions and 25 deletions

View File

@ -47,34 +47,27 @@ export default {
return value.match(/(groupTeaser|groupProfile)/)
},
},
resource: { type: Object, required: true },
resourceType: {
type: String,
required: true,
validator: (value) => {
return value.match(/(group)/)
},
},
group: { type: Object, required: true },
placement: { type: String, default: 'bottom-end' },
},
computed: {
routes() {
const routes = []
if (this.resourceType === 'group') {
if (this.usage !== 'groupProfile') {
routes.push({
label: this.$t('group.contentMenu.visitGroupPage'),
icon: 'home',
name: 'group-id-slug',
params: { id: this.resource.id, slug: this.resource.slug },
params: { id: this.group.id, slug: this.group.slug },
})
}
if (this.group.myRole === 'owner') {
routes.push({
label: this.$t('admin.settings.name'),
path: `/group/edit/${this.group.id}`,
icon: 'edit',
})
if (this.resource.myRole === 'owner') {
routes.push({
label: this.$t('admin.settings.name'),
path: `/group/edit/${this.resource.id}`,
icon: 'edit',
})
}
}
return routes

View File

@ -58,12 +58,7 @@
<div v-else class="categories-placeholder"></div>
<!-- group context menu -->
<client-only>
<group-content-menu
:usage="'groupProfile'"
:resourceType="'group'"
:resource="group"
:group="group"
/>
<group-content-menu :usage="'groupTeaser'" :group="group || {}" placement="bottom-end" />
</client-only>
</footer>
<footer class="footer">

View File

@ -18,10 +18,10 @@
<!-- Menu -->
<client-only>
<group-content-menu
v-if="isGroupOwner"
class="group-content-menu"
:usage="'groupProfile'"
:resourceType="'group'"
:resource="group || {}"
:group="group || {}"
placement="bottom-end"
/>
<!-- TODO: implement later on -->