Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 【ITSM 2.X】 项目管理鉴权优化 --story=119850967 #1408

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 39 additions & 26 deletions frontend/pc/src/views/processManagement/apiConfigure/apiTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@
<p class="bk-api-title">{{ $t(`m.systemConfig["API列表"]`) }}</p>
<div class="bk-api-button">
<bk-dropdown-menu class="mr10 access-btn" @show="dropdownShow" @hide="dropdownHide" ref="apiDropdown" :disabled="disableImport">
<div class="dropdown-trigger-btn" style="padding-left: 12px;" slot="dropdown-trigger">
<div
slot="dropdown-trigger"
class="dropdown-trigger-btn"
style="padding-left: 12px;">
<span style="font-size: 14px;">{{ $t(`m.systemConfig['API接入']`)}}</span>
<i :class="['bk-icon icon-angle-down',{ 'icon-flip': isDropdownShow }]"></i>
</div>
<ul class="bk-dropdown-list" slot="dropdown-content">
<li>
<a href="javascript:;"
v-cursor="{ active: !projectId && !hasPermission(['public_api_create']) }"
:class="{ 'text-permission-disable': !projectId && !hasPermission(['public_api_create']) }"
v-cursor="{ active: !hasPermission(['system_settings_manage'], $store.state.project.projectAuthActions) }"
:class="{ 'text-permission-disable': !hasPermission(['system_settings_manage'], $store.state.project.projectAuthActions) }"
:title="$t(`m.systemConfig['接入API']`)"
data-test-id="api_a_apiTableAccessApi"
@click="openShade('JOIN')">
Expand All @@ -44,23 +47,23 @@
<li>
<a href="javascript:;"
data-test-id="api_a_apiTableCreateApi"
v-cursor="{ active: !projectId && !hasPermission(['public_api_create']) }"
:class="{ 'text-permission-disable': !projectId && !hasPermission(['public_api_create']) }"
v-cursor="{ active: !hasPermission(['system_settings_manage'], $store.state.project.projectAuthActions) }"
:class="{ 'text-permission-disable': !hasPermission(['system_settings_manage'], $store.state.project.projectAuthActions) }"
:title="$t(`m.systemConfig['新增API']`)"
@click="openShade('ADD')">
{{$t(`m.systemConfig['新增API']`)}}
</a>
</li>
</ul>
</bk-dropdown-menu>
<bk-button :theme="'default'"
<bk-button
data-test-id="api_button_apiTableuploadApi"
:theme="'default'"
:disabled="disableImport"
v-cursor="{ active: !projectId && !hasPermission(['public_api_create']) }"
:class="{ 'btn-permission-disable': !projectId && !hasPermission(['public_api_create']) }"
:title="$t(`m.systemConfig['点击上传']`)"
class="mr10 bk-btn-file">
<input :disabled="disableImport" :type="!projectId && !hasPermission(['public_api_create']) ? 'button' : 'file'" :value="fileVal" class="bk-input-file" @change="handleFile" @click="hasImportPermission">
v-cursor="{ active: !hasPermission(['system_settings_manage'], $store.state.project.projectAuthActions) }"
:class="['mr10 bk-btn-file', { 'btn-permission-disable': !hasPermission(['system_settings_manage'], $store.state.project.projectAuthActions) }]"
:title="$t(`m.systemConfig['点击上传']`)">
<input :disabled="disableImport" :type="!hasPermission(['system_settings_manage'], $store.state.project.projectAuthActions) ? 'button' : 'file'" :value="fileVal" class="bk-input-file" @change="handleFile" @click="hasImportPermission">
{{$t(`m.systemConfig['导入']`)}}
</bk-button>
<bk-button :theme="'default'"
Expand Down Expand Up @@ -353,18 +356,23 @@
},
// 新增
openShade(type) {
if (!this.projectId) {
if (!this.hasPermission(['public_api_create'])) {
this.applyForPermission(['public_api_create'], [], {});
return;
}
if (!this.hasPermission(['system_settings_manage'], this.$store.state.project.projectAuthActions)) {
const projectInfo = this.$store.state.project.projectInfo;
const resourceData = {
project: [{
id: projectInfo.key,
name: projectInfo.name,
}],
};
this.applyForPermission(['system_settings_manage'], this.$store.state.project.projectAuthActions, resourceData);
} else {
this.typeInfo = type;
this.entryInfo.title = type === 'ADD'
? this.$t('m.systemConfig["新增接口"]') : this.$t('m.systemConfig["接入接口"]');
this.$refs.apiDropdown.hide();
this.entryInfo.show = !this.entryInfo.show;
this.isFormChanged = false;
}
this.typeInfo = type;
this.entryInfo.title = type === 'ADD'
? this.$t('m.systemConfig["新增接口"]') : this.$t('m.systemConfig["接入接口"]');
this.$refs.apiDropdown.hide();
this.entryInfo.show = !this.entryInfo.show;
this.isFormChanged = false;
},
dropdownShow() {
this.isDropdownShow = true;
Expand Down Expand Up @@ -485,10 +493,15 @@
},
//
hasImportPermission() {
if (!this.projectId) {
if (!this.hasPermission(['public_api_create'])) {
this.applyForPermission(['public_api_create'], [], {});
}
if (!this.hasPermission(['system_settings_manage'], this.$store.state.project.projectAuthActions)) {
const projectInfo = this.$store.state.project.projectInfo;
const resourceData = {
project: [{
id: projectInfo.key,
name: projectInfo.name,
}],
};
this.applyForPermission(['system_settings_manage'], this.$store.state.project.projectAuthActions, resourceData);
}
},
// 上传文件模板
Expand Down
31 changes: 27 additions & 4 deletions frontend/pc/src/views/service/serviceList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@
@click="onServiceCreatePermissonCheck">
{{$t(`m.serviceConfig['新增']`)}}
</bk-button>
<bk-button :theme="'default'"
class="mr10"
<bk-button
v-cursor="{ active: !hasPermission(['service_create'], $store.state.project.projectAuthActions) }"
:class="['mr10', { 'btn-permission-disable': !hasPermission(['service_create'], $store.state.project.projectAuthActions) }]"
data-test-id="service_button_batchImportService"
:title="$t(`m['导入']`)"
@click="importService">
{{$t(`m['导入']`)}}
</bk-button>
<bk-button :theme="'default'"
<bk-button
data-test-id="service_button_batchDeleteService"
:title="$t(`m.serviceConfig['批量删除']`)"
:disabled="!checkList.length"
Expand Down Expand Up @@ -324,6 +325,17 @@
</bk-button>
</template>
<bk-button
v-if="!hasPermission(['service_manage'], [...props.row.auth_actions, ...$store.state.project.projectAuthActions])"
style="font-size: 12px;"
v-cursor
text
theme="primary"
class="btn-permission-disable"
@click="onServicePermissonCheck(['service_manage'], props.row)">
{{ $t('m["导出"]') }}
</bk-button>
<bk-button
v-else
style="font-size: 12px; display: block"
data-test-id="service_button_deleteService3"
theme="primary"
Expand Down Expand Up @@ -704,7 +716,18 @@
});
},
importService() {
this.isImportServiceShow = true;
if (!this.hasPermission(['service_create'], this.$store.state.project.projectAuthActions)) {
const projectInfo = this.$store.state.project.projectInfo;
const resourceData = {
project: [{
id: projectInfo.key,
name: projectInfo.name,
}],
};
this.applyForPermission(['service_create'], this.$store.state.project.projectAuthActions, resourceData);
} else {
this.isImportServiceShow = true;
}
},
exportService(row) {
window.open(`${window.SITE_URL}api/service/projects/${row.id}/export/`);
Expand Down
Loading