Skip to content

Commit

Permalink
fix: fix qa things (#2690)
Browse files Browse the repository at this point in the history
* chore: fix getting wrong `isWorkspaceOwner`

Signed-off-by: yuda <[email protected]>

* fix(dashboard-create): hide workspace scope when it's WORKSPACE_MEMBER

Signed-off-by: yuda <[email protected]>

* chore: edit style

Signed-off-by: yuda <[email protected]>

* chore(dashboard-lnb): edit style when it's admin mode

Signed-off-by: yuda <[email protected]>

* fix: show workspace dashboard for WORKSPACE_MEMBER

Signed-off-by: yuda <[email protected]>

* Revert "fix: show workspace dashboard for WORKSPACE_MEMBER"

This reverts commit cf009f3.

* fix: hide workspace scope for WORKSPACE_MEMBER

Signed-off-by: yuda <[email protected]>

---------

Signed-off-by: yuda <[email protected]>
  • Loading branch information
yuda110 authored Dec 28, 2023
1 parent caffd2a commit 2416826
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { COST_EXPLORER_ROUTE } from '@/services/cost-explorer/routes/route-const
const appContextStore = useAppContextStore();
const storeState = reactive({
isAdminMode: computed(() => appContextStore.getters.isAdminMode),
isWorkspaceOwner: () => store.getters['user/getCurrentRoleInfo']?.roleType === ROLE_TYPE.WORKSPACE_OWNER,
isWorkspaceOwner: computed(() => store.getters['user/getCurrentRoleInfo']?.roleType === ROLE_TYPE.WORKSPACE_OWNER),
});
const handleCreateBudgetSelect = () => {
Expand Down
12 changes: 11 additions & 1 deletion apps/web/src/services/dashboards/DashboardsLNB.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
import { PIconButton } from '@spaceone/design-system';
import type { PublicDashboardModel } from '@/schema/dashboard/public-dashboard/model';
import { ROLE_TYPE } from '@/schema/identity/role/constant';
import { store } from '@/store';
import { i18n } from '@/translations';
Expand All @@ -31,6 +32,7 @@ const appContextStore = useAppContextStore();
const dashboardStore = useDashboardStore();
const dashboardGetters = dashboardStore.getters;
const storeState = reactive({
isWorkspaceOwner: computed(() => store.getters['user/getCurrentRoleInfo']?.roleType === ROLE_TYPE.WORKSPACE_OWNER),
isAdminMode: computed(() => appContextStore.getters.isAdminMode),
projects: computed(() => allReferenceStore.getters.project),
});
Expand Down Expand Up @@ -118,7 +120,7 @@ const state = reactive({
}
return [
...defaultMenuSet,
...filterLNBItemsByPagePermission('WORKSPACE', filterFavoriteItems(state.workspaceMenuSet)),
...(storeState.isWorkspaceOwner ? filterLNBItemsByPagePermission('WORKSPACE', filterFavoriteItems(state.workspaceMenuSet)) : []),
...filterLNBItemsByPagePermission('PROJECT', filterFavoriteItems(state.projectMenuSet)),
...filterLNBItemsByPagePermission('PRIVATE', filterFavoriteItems(state.privateMenuSet)),
];
Expand Down Expand Up @@ -201,6 +203,7 @@ const filterFavoriteItems = (menuItems: LNBMenu[] = []): LNBMenu[] => {

<template>
<l-n-b class="dashboards-lnb"
:class="{'admin-mode': storeState.isAdminMode}"
:menu-set="state.menuSet"
:show-favorite-only.sync="state.showFavoriteOnly"
>
Expand All @@ -222,5 +225,12 @@ const filterFavoriteItems = (menuItems: LNBMenu[] = []): LNBMenu[] => {
@apply flex justify-between items-center font-bold;
padding-right: 1.25rem;
}
/* custom lnb */
&.admin-mode {
:deep(.favorite-only-wrapper) {
padding-bottom: 0.5rem;
}
}
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
import { PSelectDropdown, PSelectStatus } from '@spaceone/design-system';
import { ROLE_TYPE } from '@/schema/identity/role/constant';
import { store } from '@/store';
import { i18n } from '@/translations';
Expand All @@ -13,13 +14,22 @@ import { useDashboardStore } from '@/store/dashboard/dashboard-store';
const dashboardStore = useDashboardStore();
const dashboardState = dashboardStore.state;
const storeState = reactive({
isWorkspaceOwner: computed(() => store.getters['user/getCurrentRoleInfo']?.roleType === ROLE_TYPE.WORKSPACE_OWNER),
});
const state = reactive({
scopeFilterList: computed(() => [
{ label: i18n.t('DASHBOARDS.ALL_DASHBOARDS.FILTER_ALL'), name: 'ALL' },
{ label: i18n.t('DASHBOARDS.ALL_DASHBOARDS.WORKSPACE'), name: 'WORKSPACE' },
{ label: i18n.t('DASHBOARDS.ALL_DASHBOARDS.FILTER_SINGLE_PROJECT'), name: 'PROJECT' },
{ label: i18n.t('DASHBOARDS.ALL_DASHBOARDS.FILTER_PRIVATE'), name: 'PRIVATE' },
]),
scopeFilterList: computed(() => {
const results = [
{ label: i18n.t('DASHBOARDS.ALL_DASHBOARDS.FILTER_ALL'), name: 'ALL' },
{ label: i18n.t('DASHBOARDS.ALL_DASHBOARDS.WORKSPACE'), name: 'WORKSPACE' },
{ label: i18n.t('DASHBOARDS.ALL_DASHBOARDS.FILTER_SINGLE_PROJECT'), name: 'PROJECT' },
{ label: i18n.t('DASHBOARDS.ALL_DASHBOARDS.FILTER_PRIVATE'), name: 'PRIVATE' },
];
if (!storeState.isWorkspaceOwner) {
return results.filter((d) => d.name !== 'WORKSPACE');
}
return results;
}),
scopeStatus: computed(() => dashboardState.scope || 'ALL'),
pagePermission: computed(() => store.getters['user/pageAccessPermissionMap']),
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<script lang="ts" setup>
import { computed, reactive, watch } from 'vue';
import {
PRadio, PRadioGroup, PFieldTitle, PI,
} from '@spaceone/design-system';
import { ROLE_TYPE } from '@/schema/identity/role/constant';
import { store } from '@/store';
import ProjectSelectDropdown from '@/common/modules/project/ProjectSelectDropdown.vue';
import { useDashboardDetailInfoStore } from '@/services/dashboards/stores/dashboard-detail-info-store';
Expand All @@ -15,6 +20,9 @@ const emit = defineEmits<{(event: 'set-project', project: ProjectTreeNodeData):
const dashboardDetailStore = useDashboardDetailInfoStore();
const dashboardDetailState = dashboardDetailStore.state;
const storeState = reactive({
isWorkspaceOwner: computed(() => store.getters['user/getCurrentRoleInfo']?.roleType === ROLE_TYPE.WORKSPACE_OWNER),
});
/* Event */
const handleSelectScope = (scopeType: DashboardScope) => {
Expand All @@ -29,6 +37,12 @@ const handleSelectScope = (scopeType: DashboardScope) => {
const handleSelectProjects = (projects: Array<ProjectTreeNodeData>) => {
emit('set-project', projects[0]);
};
watch(() => storeState.isWorkspaceOwner, (val) => {
if (!val) {
dashboardDetailStore.setDashboardScope('PROJECT');
}
}, { immediate: true });
</script>

<template>
Expand All @@ -38,7 +52,8 @@ const handleSelectProjects = (projects: Array<ProjectTreeNodeData>) => {
<p-radio-group direction="vertical"
class="dashboard-scope-radio-group"
>
<p-radio :selected="dashboardDetailState.dashboardScope"
<p-radio v-if="storeState.isWorkspaceOwner"
:selected="dashboardDetailState.dashboardScope"
value="WORKSPACE"
@change="handleSelectScope('WORKSPACE')"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const dashboardState = dashboardStore.state;
const dashboardGetters = dashboardStore.getters;
const state = reactive({
loading: computed(() => dashboardState.loading),
isWorkspaceOwner: () => store.getters['user/getCurrentRoleInfo']?.roleType === ROLE_TYPE.WORKSPACE_OWNER,
isWorkspaceOwner: computed(() => store.getters['user/getCurrentRoleInfo']?.roleType === ROLE_TYPE.WORKSPACE_OWNER),
workspaceDashboardList: computed<DashboardModel[]>(() => {
if (dashboardState.scope && dashboardState.scope !== 'WORKSPACE' && !state.isWorkspaceOwner) return [];
let target = dashboardGetters.workspaceItems || [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ watch([() => projectPageState.isInitiated, () => state.groupId], async ([isIniti
.card-top-wrapper {
@apply flex-grow flex flex-col;
justify-content: space-between;
margin: 1rem 1rem 0.5rem 1rem;
.group-name-wrapper {
@apply flex justify-between items-center;
Expand Down

1 comment on commit 2416826

@vercel
Copy link

@vercel vercel bot commented on 2416826 Dec 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.