From 74142f0d1ae828ae574903b0bdfcca792ee5d644 Mon Sep 17 00:00:00 2001 From: Felix Jordan Date: Thu, 10 Feb 2022 10:19:30 +0100 Subject: [PATCH 1/2] fix: add members tab when user logs in (independent of users role) --- src/views/Project.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/Project.vue b/src/views/Project.vue index 616433ba..e7d7cee1 100644 --- a/src/views/Project.vue +++ b/src/views/Project.vue @@ -295,7 +295,7 @@ export default defineComponent({ if (!oidcIsAuthenticated.value && membersItemId > -1) { tabItems.value.splice(membersItemId, 1); } - if (oidcIsAuthenticated.value && project.value.userContext?.projectRole === 'ProjectAdmin') { + if (oidcIsAuthenticated.value) { if (membersItemId === -1) { tabItems.value.push( { From 5bf1ffcd1e50c1581af1baef13ae8e43cdf6f002 Mon Sep 17 00:00:00 2001 From: Felix Jordan Date: Thu, 10 Feb 2022 10:25:14 +0100 Subject: [PATCH 2/2] refactor: reduce code duplicated code --- src/views/Project.vue | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/views/Project.vue b/src/views/Project.vue index e7d7cee1..da8ec67b 100644 --- a/src/views/Project.vue +++ b/src/views/Project.vue @@ -265,20 +265,18 @@ export default defineComponent({ watch(oidcIsAuthenticated, () => store.dispatch(ActionTypes.FetchProject, projectId)); + const MEMBERS_TAB_LABEL = 'Members'; + const MEMBERS_TAB_ITEM = { + label: MEMBERS_TAB_LABEL, + to: `/projects/${projectId}/members` + }; + const tabItems = ref([ { label: 'All Categories', // was: 'Overview' to: `/projects/${projectId}` }, - { - label: 'Members', - to: `/projects/${projectId}/members` - } - /* - { - label: 'All Categories', - to: `/projects/${projectId}/all` - },*/ + MEMBERS_TAB_ITEM ]); const projectEditorName = ref(''); @@ -291,18 +289,14 @@ export default defineComponent({ //const role = project.value.userContext?.projectRole; //if (['ProjectAdmin', 'SystemAdmin'].includes(role)) { - const membersItemId = tabItems.value.findIndex(item => item.label === 'Members'); + const membersItemId = tabItems.value.findIndex(item => item.label === MEMBERS_TAB_LABEL); if (!oidcIsAuthenticated.value && membersItemId > -1) { tabItems.value.splice(membersItemId, 1); } if (oidcIsAuthenticated.value) { if (membersItemId === -1) { - tabItems.value.push( - { - label: 'Members', - to: `/projects/${projectId}/members` - } - ); + // user is authentivated and memebrs tab not visible yet -> add to tab items + tabItems.value.push(MEMBERS_TAB_ITEM); } } });