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

View File

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

View File

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