Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
chore: list elements show by permission
Browse files Browse the repository at this point in the history
  • Loading branch information
hibig committed Aug 18, 2023
1 parent 0778b49 commit d59770b
Show file tree
Hide file tree
Showing 17 changed files with 189 additions and 160 deletions.
4 changes: 4 additions & 0 deletions src/assets/style/global.less
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ body {
}
}

.fill-width {
width: 100%;
}

.font-16 {
font-size: 16px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@
import { getListLabel } from '@/utils/func';
import { RowData } from '@/views/system/config/interface';
import { querySubjects } from '@/views/system/api/users';
import { queryProjectSubjects, addProjectSubjects } from '../api';
import { projectRoles } from '../config';
import { ProjectRolesRowData } from '../config/interface';
import { queryProjectSubjects, addProjectSubjects } from '../../projects/api';
import { projectRoles } from '../../projects/config';
import { ProjectRolesRowData } from '../../projects/config/interface';
const props = defineProps({
action: {
Expand Down Expand Up @@ -300,7 +300,6 @@
const handleSubmit = async () => {
try {
await addProjectSubjects({ items: selectedList.value });
getProjectSubjects();
emits('save');
emits('update:show', false);
} catch (error) {
Expand Down
1 change: 1 addition & 0 deletions src/views/application-management/members/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,27 @@
</template>
<template #button-group>
<a-button
v-permission-app="{
projectID: route.params.projectId,
resource: Resources.ProjectSubjects,
actions: [Actions.POST]
}"
v-if="
userStore.hasProjectResourceActions({
resource: Resources.ProjectSubjects,
projectID: route.params.projectId,
actions: [Actions.POST]
}) &&
userStore.hasRolesActionsPermission({
resource: Resources.Subjects,
actions: [Actions.GET]
})
"
type="primary"
@click="handleAdd"
>{{ $t('applications.applications.add.member') }}</a-button
>
<a-button
v-permission-app="{
projectID: route.params.projectId,
resource: Resources.ProjectSubjects,
actions: [Actions.DELETE]
}"
type="primary"
status="warning"
:disabled="!selectedKeys.length"
Expand All @@ -52,7 +63,15 @@
:data="projectVisitors"
:pagination="false"
row-key="id"
:row-selection="rowSelection"
:row-selection="
userStore.hasProjectResourceActions({
resource: Resources.ProjectSubjects,
projectID: route.params.projectId,
actions: [Actions.DELETE]
})
? rowSelection
: null
"
@selection-change="handleSelectChange"
>
<template #columns>
Expand Down Expand Up @@ -102,17 +121,22 @@
import _ from 'lodash';
import { Resources, Actions } from '@/permissions/config';
import { ref, reactive, PropType } from 'vue';
import { useUserStore } from '@/store';
import useCallCommon from '@/hooks/use-call-common';
import FilterBox from '@/components/filter-box/index.vue';
import { deleteModal, execSucceed } from '@/utils/monitor';
import useRowSelect from '@/hooks/use-row-select';
import { getListLabel } from '@/utils/func';
import { queryProjectSubjects, deleteProjectSubjects } from '../api';
import { projectRoles } from '../config';
import { ProjectRolesRowData } from '../config/interface';
import {
queryProjectSubjects,
deleteProjectSubjects
} from '../../projects/api';
import { projectRoles } from '../../projects/config';
import { ProjectRolesRowData } from '../../projects/config/interface';
import AssignRoles from '../components/assign-roles.vue';
const { route } = useCallCommon();
const userStore = useUserStore();
const { rowSelection, selectedKeys, handleSelectChange } = useRowSelect();
const loading = ref(false);
const showModal = ref(false);
Expand Down
2 changes: 1 addition & 1 deletion src/views/application-management/projects/pages/detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@
import HeaderInfo from '@/components/header-info/index.vue';
import EnviromentList from '@/views/application-management/environments/pages/list.vue';
import variableList from '@/views/application-management/variables/pages/list.vue';
import members from '@/views/application-management/members/pages/list.vue';
import basicInfo from '@/views/application-management/services/components/basic-info.vue';
import ConnectorList from '@/views/operation-hub/connectors/components/table-list.vue';
import useBasicInfoData from '../hooks/use-basicInfo-data';
import { queryItemProject } from '../api';
import { basicInfoConfig, projectDetailTabs } from '../config';
import userProjectBreadcrumbData from '../hooks/use-project-breadcrumb-data';
import members from './members.vue';
const {
pageLevelMap,
Expand Down
16 changes: 2 additions & 14 deletions src/views/application-management/projects/pages/list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,32 +180,26 @@
:info="projectInfo"
@save="handleSaveProject"
></CreateProjectModal>
<AssignRoles
v-model:show="showModal"
:project-i-d="projectID"
></AssignRoles>
</SpinCard>
</div>
</template>

<script lang="ts" setup>
import { PROJECT } from '@/router/config';
import { Resources, Actions } from '@/permissions/config';
import QuestionPopup from '@/components/question-popup/index.vue';
import { QAlinkMap, USER_DEFAULT_PROJECT } from '@/views/config';
import _, { cloneDeep, map, pickBy, remove } from 'lodash';
import { ref, reactive } from 'vue';
import dayjs from 'dayjs';
import localStore from '@/utils/localStore';
import { useUserStore, useProjectStore } from '@/store';
import HeaderInfo from '@/components/header-info/index.vue';
import useCallCommon from '@/hooks/use-call-common';
import FilterBox from '@/components/filter-box/index.vue';
import { deleteModal, execSucceed } from '@/utils/monitor';
import { UseSortDirection } from '@/utils/common';
import useRowSelect from '@/hooks/use-row-select';
import QuestionPopup from '@/components/question-popup/index.vue';
import CreateProjectModal from '../components/create-project.vue';
import AssignRoles from '../components/assign-roles.vue';
import { ProjectRowData } from '../config/interface';
import { queryProjects, deleteProjects } from '../api';
Expand All @@ -226,7 +220,6 @@
const projectInfo = ref<any>({});
const projectID = ref('');
const action = ref<'create' | 'edit'>('create');
const showModal = ref(false);
const queryParams = reactive({
query: '',
page: 1,
Expand Down Expand Up @@ -260,12 +253,7 @@
params: { projectId: row.id }
});
};
const handleAuthorize = (row) => {
projectID.value = row.id;
setTimeout(() => {
showModal.value = true;
}, 100);
};
const fetchData = async () => {
try {
loading.value = true;
Expand Down
15 changes: 0 additions & 15 deletions src/views/application-management/services/pages/list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,6 @@
></StatusLabel>
</template>
</a-table-column>
<!-- <a-table-column
ellipsis
:cell-style="{ minWidth: '40px' }"
data-index="driftResult.drifted"
:title="$t('applications.service.resource.drift')"
>
<template #cell="{ record }">
<a-link
v-if="record?.driftResult?.drifted"
@click="handleClickDriftResource(record)"
>{{ $t('common.button.view') }}</a-link
>
<span v-else>-</span>
</template>
</a-table-column> -->
<a-table-column
ellipsis
tooltip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
:data="dataList"
:pagination="false"
row-key="id"
:row-selection="rowSelection"
:row-selection="rowSelectionStatue"
@sorter-change="handleSortChange"
@selection-change="handleSelectChange"
>
Expand Down Expand Up @@ -150,11 +150,16 @@
</a-table-column>
<a-table-column
v-if="
[
scopeMap.ENVIRONMENT,
scopeMap.GLOBAL,
scopeMap.PROJECT
].includes(scope)
scope === scopeMap.GLOBAL
? userStore.hasRolesActionsPermission({
resource: Resources.Variables,
actions: [Actions.PUT]
})
: userStore.hasProjectResourceActions({
projectID: route.params.projectId,
resource: Resources.Variables,
actions: [Actions.PUT]
})
"
align="center"
:width="210"
Expand All @@ -166,18 +171,7 @@
<template #cell="{ record }">
<a-space :size="16">
<a-tooltip
v-if="
scope === scopeMap.GLOBAL
? userStore.hasRolesActionsPermission({
resource: Resources.Variables,
actions: [Actions.PUT]
})
: userStore.hasProjectResourceActions({
projectID: route.params.projectId,
resource: Resources.Variables,
actions: [Actions.PUT]
}) && visibleInScope(record)
"
v-if="visibleInScope(record)"
:content="$t('common.button.edit')"
>
<a-link
Expand Down Expand Up @@ -292,6 +286,17 @@
return t('applications.secret.edit');
});
const rowSelectionStatue = computed(() => {
if (props.scope === scopeMap.GLOBAL) {
return userStore.hasRolesActionsPermission({
resource: Resources.Variables,
actions: [Actions.PUT]
})
? rowSelection
: null;
}
return rowSelection;
});
const visibleInScope = (row) => {
if (props.scope === scopeMap.PROJECT) {
return _.get(row, 'project.id') && !_.get(row, 'environment.id');
Expand Down
24 changes: 18 additions & 6 deletions src/views/cost-management/analyse/pages/list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<a-button
v-permission="{
resource: `roles.${Resources.Perspectives}`,
actions: ['POST']
actions: [Actions.POST]
}"
type="primary"
@click="handleCreate"
Expand All @@ -37,7 +37,7 @@
<a-button
v-permission="{
resource: `roles.${Resources.Perspectives}`,
actions: ['DELETE']
actions: [Actions.DELETE]
}"
type="primary"
status="warning"
Expand All @@ -47,7 +47,6 @@
>
</template>
</FilterBox>
<!-- <a-divider :margin="8"></a-divider> -->
<a-table
column-resizable
style="margin-bottom: 20px"
Expand All @@ -56,7 +55,14 @@
:data="dataList"
:pagination="false"
row-key="id"
:row-selection="rowSelection"
:row-selection="
userStore.hasRolesActionsPermission({
resource: Resources.Perspectives,
actions: [Actions.DELETE]
})
? rowSelection
: null
"
@sorter-change="handleSortChange"
@selection-change="handleSelectChange"
>
Expand All @@ -73,7 +79,7 @@
v-if="
userStore.hasRolesActionsPermission({
resource: Resources.Costs,
actions: ['POST']
actions: [Actions.POST]
})
"
size="small"
Expand Down Expand Up @@ -140,6 +146,12 @@
</template>
</a-table-column>
<a-table-column
v-if="
userStore.hasRolesActionsPermission({
resource: Resources.Perspectives,
actions: [Actions.PUT]
})
"
ellipsis
tooltip
:cell-style="{ minWidth: '40px' }"
Expand Down Expand Up @@ -177,7 +189,7 @@

<script lang="ts" setup>
import { COSTMANAGEMENT } from '@/router/config';
import { Resources } from '@/permissions/config';
import { Actions, Resources } from '@/permissions/config';
import { useUserStore } from '@/store';
import { map, find, toLower, pickBy, includes } from 'lodash';
import dayjs from 'dayjs';
Expand Down
Loading

0 comments on commit d59770b

Please sign in to comment.