From a5ccb79a51f62360f0f3c38c8c7742f466090cf1 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 23 Jun 2020 10:10:19 +0200 Subject: [PATCH] Fix settings menu allowing showing everything for everyone Signed-off-by: Thomas Citharel --- js/src/views/Settings.vue | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/js/src/views/Settings.vue b/js/src/views/Settings.vue index d14517eea..fdc7dd925 100644 --- a/js/src/views/Settings.vue +++ b/js/src/views/Settings.vue @@ -28,6 +28,8 @@ import RouteName from "../router/name"; import { ISettingMenuSection } from "../types/setting-menu.model"; import { IPerson, Person } from "../types/actor"; import { IDENTITIES } from "../graphql/actor"; +import { CURRENT_USER_CLIENT } from "../graphql/user"; +import { ICurrentUser, ICurrentUserRole } from "../types/current-user.model"; @Component({ components: { SettingsMenu }, @@ -36,6 +38,7 @@ import { IDENTITIES } from "../graphql/actor"; query: IDENTITIES, update: (data) => data.identities.map((identity: IPerson) => new Person(identity)), }, + currentUser: CURRENT_USER_CLIENT, }, }) export default class Settings extends Vue { @@ -47,6 +50,8 @@ export default class Settings extends Vue { newIdentity!: ISettingMenuSection; + currentUser!: ICurrentUser; + mounted() { this.newIdentity = { title: this.$t("New profile") as string, @@ -76,7 +81,11 @@ export default class Settings extends Vue { to: { name: RouteName.IDENTITIES } as Route, items: [this.newIdentity], }, - { + ]; + if ( + [ICurrentUserRole.MODERATOR, ICurrentUserRole.ADMINISTRATOR].includes(this.currentUser.role) + ) { + this.menu.push({ title: this.$t("Moderation") as string, to: { name: RouteName.MODERATION } as Route, items: [ @@ -94,9 +103,19 @@ export default class Settings extends Vue { title: this.$t("Moderation log") as string, to: { name: RouteName.REPORT_LOGS } as Route, }, + { + title: this.$t("Users") as string, + to: { name: RouteName.USERS } as Route, + }, + { + title: this.$t("Profiles") as string, + to: { name: RouteName.PROFILES } as Route, + }, ], - }, - { + }); + } + if (this.currentUser.role === ICurrentUserRole.ADMINISTRATOR) { + this.menu.push({ title: this.$t("Admin") as string, to: { name: RouteName.ADMIN } as Route, items: [ @@ -122,17 +141,9 @@ export default class Settings extends Vue { }, ], }, - { - title: this.$t("Users") as string, - to: { name: RouteName.USERS } as Route, - }, - { - title: this.$t("Profiles") as string, - to: { name: RouteName.PROFILES } as Route, - }, ], - }, - ]; + }); + } } @Watch("identities")