Skip to content

Commit

Permalink
Merge pull request #1408 from luofann/fix_test_0923
Browse files Browse the repository at this point in the history
feat: 【ITSM 2.X】 项目管理鉴权优化 --story=119850967
  • Loading branch information
luofann authored Sep 25, 2024
2 parents a305790 + 2ec5ebc commit b4cede1
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 30 deletions.
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

0 comments on commit b4cede1

Please sign in to comment.