diff --git a/src/frontend/src/components/audit-navigation/index.vue b/src/frontend/src/components/audit-navigation/index.vue index ddba95ce..3df50530 100644 --- a/src/frontend/src/components/audit-navigation/index.vue +++ b/src/frontend/src/components/audit-navigation/index.vue @@ -103,19 +103,17 @@ ref, } from 'vue'; - import NoticeService from '@service/notice'; - import useEventBus from '@hooks/use-event-bus'; + import useFeature from '@hooks/use-feature'; import NoticeComponent from '@blueking/notice-component'; - import useRequest from '@/hooks/use-request'; - interface Emits{ (e: 'menu-flod', value: boolean):void } const emit = defineEmits(); const { emit: emits } = useEventBus(); + const { feature: showNotice } = useFeature('bknotice'); const apiUrl = `${window.PROJECT_CONFIG.AJAX_URL_PREFIX}/api/v1/bk-notice/announcements/`; const TOGGLE_CACHE = 'navigation_toggle_status'; @@ -227,18 +225,6 @@ }; const resizeHandler = _.throttle(init, 100); - const { - data: showNotice, - } = useRequest(NoticeService.fetchNoticeFeature, { - defaultValue: { - enabled: false, - }, - defaultParams: { - feature_id: 'bknotice', - }, - manual: true, - }); - onMounted(() => { init(); emit('menu-flod', !isSideMenuFixed.value); diff --git a/src/frontend/src/domain/service/collector-manage.ts b/src/frontend/src/domain/service/collector-manage.ts index 5517bfe9..3c838631 100644 --- a/src/frontend/src/domain/service/collector-manage.ts +++ b/src/frontend/src/domain/service/collector-manage.ts @@ -228,13 +228,6 @@ export default { return CollectorSource.getSnapShotStatus(params) .then(({ data }) => data); }, - /** - * @desc 判断资源表格操作列是否显示 - */ - fetchResourceFeature() { - return CollectorSource.getResourceFeature() - .then(({ data }) => data); - }, /** * @desc 清洗字段历史 * @param { String } id @@ -280,13 +273,6 @@ export default { return CollectorSource.updateBcs(params) .then(({ data }) => data); }, - /** - * @desc 判断API Push是否启用 - */ - fetchApiPushFeature(params: {feature_id: string}) { - return CollectorSource.getApiPushFeature(params) - .then(({ data }) => data); - }, /** * @desc 获取启用状态&上报host (无需单独鉴权) */ @@ -317,11 +303,4 @@ export default { return CollectorSource.createApiPush(params) .then(({ data }) => data); }, - /** - * @desc 是否显示:上报方式,计算平台已有数据源 - */ - fetchBkbaseFeature(params: {feature_id: string}) { - return CollectorSource.getBkbaseFeature(params) - .then(({ data }) => data); - }, }; diff --git a/src/frontend/src/domain/service/meta-manage.ts b/src/frontend/src/domain/service/meta-manage.ts index 4a9d901e..34f1749b 100644 --- a/src/frontend/src/domain/service/meta-manage.ts +++ b/src/frontend/src/domain/service/meta-manage.ts @@ -33,6 +33,14 @@ export default { }) .then(({ data }) => data); }, + /** + * @desc 根据特性id获取特性开关 + * @param { String } feature_id + */ + fetchFeature(params: {feature_id: string}) { + return MetaManageSource.getFeature(params) + .then(({ data }) => data); + }, /** * @desc 获取 Namespace 列表 */ diff --git a/src/frontend/src/domain/service/notice.ts b/src/frontend/src/domain/service/notice.ts deleted file mode 100644 index 8e4446f0..00000000 --- a/src/frontend/src/domain/service/notice.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - TencentBlueKing is pleased to support the open source community by making - 蓝鲸智云 - 审计中心 (BlueKing - Audit Center) available. - Copyright (C) 2023 THL A29 Limited, - a Tencent company. All rights reserved. - Licensed under the MIT License (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at http://opensource.org/licenses/MIT - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on - an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - either express or implied. See the License for the - specific language governing permissions and limitations under the License. - We undertake not to change the open source license (MIT license) applicable - to the current version of the project delivered to anyone in the future. -*/ -import NoticeSource from '../source/notice'; - -export default { - /** - * @desc 判断notice是否启用 - */ - fetchNoticeFeature(params: {feature_id: string}) { - return NoticeSource.getNoticeFeature(params) - .then(({ data }) => data); - }, -}; diff --git a/src/frontend/src/domain/service/statement-manage.ts b/src/frontend/src/domain/service/statement-manage.ts index 7a644799..ede266d3 100644 --- a/src/frontend/src/domain/service/statement-manage.ts +++ b/src/frontend/src/domain/service/statement-manage.ts @@ -26,8 +26,4 @@ export default { }) .then(({ data }) => data); }, - fetchHasBkvision() { - return StatementManageSource.getHasBkvision() - .then(({ data }) => data); - }, }; diff --git a/src/frontend/src/domain/source/collector-manage.ts b/src/frontend/src/domain/source/collector-manage.ts index 02621dae..f5e3d11f 100644 --- a/src/frontend/src/domain/source/collector-manage.ts +++ b/src/frontend/src/domain/source/collector-manage.ts @@ -167,10 +167,6 @@ class CollectorManage extends ModuleBase { params, }); } - // 判断资源表格操作列是否显示 - getResourceFeature() { - return Request.get>('/api/v1/feature/bkbase_aiops/'); - } // 清洗字段历史 getFieldHistory(params: { id: string}) { return Request.get>(`${this.path}/collectors/${params.id}/etl_field_history/`); @@ -203,10 +199,6 @@ class CollectorManage extends ModuleBase { params, }); } - // 判断API Push是否启用 - getApiPushFeature(params: {feature_id: string}) { - return Request.get>(`/api/v1/feature/${params.feature_id}/`); - } // 获取启用状态&上报host (无需单独鉴权) getApiPushHost(params: {system_id: string}) { return Request.get>(`${this.path}/collectors/api_push_host/`, { @@ -238,10 +230,6 @@ class CollectorManage extends ModuleBase { payload, }); } - // 判断上报方式,计算平台已有数据源是否显示 - getBkbaseFeature(params: {feature_id: string}) { - return Request.get>(`/api/v1/feature/${params.feature_id}/`); - } } export default new CollectorManage(); diff --git a/src/frontend/src/domain/source/meta-manage.ts b/src/frontend/src/domain/source/meta-manage.ts index 78a3ba06..4edd0d2a 100644 --- a/src/frontend/src/domain/source/meta-manage.ts +++ b/src/frontend/src/domain/source/meta-manage.ts @@ -45,6 +45,10 @@ class MetaManage extends ModuleBase { payload, }); } + // 根据特性id获取特性开关,用于判断是否显示按钮、菜单等 + getFeature(params: {feature_id: string}) { + return Request.get>(`/api/v1/feature/${params.feature_id}/`); + } // 获取 Namespace 列表 getAllNamespace() { return Request.get(`${this.module}/namespaces/`); diff --git a/src/frontend/src/domain/source/notice.ts b/src/frontend/src/domain/source/notice.ts deleted file mode 100644 index 553d5cda..00000000 --- a/src/frontend/src/domain/source/notice.ts +++ /dev/null @@ -1,30 +0,0 @@ -/* - TencentBlueKing is pleased to support the open source community by making - 蓝鲸智云 - 审计中心 (BlueKing - Audit Center) available. - Copyright (C) 2023 THL A29 Limited, - a Tencent company. All rights reserved. - Licensed under the MIT License (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at http://opensource.org/licenses/MIT - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on - an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - either express or implied. See the License for the - specific language governing permissions and limitations under the License. - We undertake not to change the open source license (MIT license) applicable - to the current version of the project delivered to anyone in the future. -*/ - -import Request from '@utils/request'; - -import ModuleBase from './module-base'; - - -class NoticeManage extends ModuleBase { - // 是否显示通知中心 - getNoticeFeature(params: {feature_id: string}) { - return Request.get>(`/api/v1/feature/${params.feature_id}/`); - } -} - -export default new NoticeManage(); diff --git a/src/frontend/src/domain/source/statement-manage.ts b/src/frontend/src/domain/source/statement-manage.ts index 32a9b579..9446d42f 100644 --- a/src/frontend/src/domain/source/statement-manage.ts +++ b/src/frontend/src/domain/source/statement-manage.ts @@ -33,12 +33,6 @@ class Statement extends ModuleBase { payload, }); } - - getHasBkvision() { - return Request.get<{ - enabled: boolean - }>('/api/v1/feature/bkvision/'); - } } export default new Statement(); diff --git a/src/frontend/src/hooks/use-feature.ts b/src/frontend/src/hooks/use-feature.ts new file mode 100644 index 00000000..2ad124e6 --- /dev/null +++ b/src/frontend/src/hooks/use-feature.ts @@ -0,0 +1,21 @@ +import MetaManageService from '@service/meta-manage'; + +import useRequest from '@hooks/use-request'; + +export default function (featureId: string) { + const { + data, + } = useRequest(MetaManageService.fetchFeature, { + defaultValue: { + enabled: false, + }, + defaultParams: { + feature_id: featureId, + }, + manual: true, + }); + + return { + feature: data, + }; +} diff --git a/src/frontend/src/layout.vue b/src/frontend/src/layout.vue index a26d2ef0..8354cc66 100644 --- a/src/frontend/src/layout.vue +++ b/src/frontend/src/layout.vue @@ -209,13 +209,11 @@ useRouter, } from 'vue-router'; - import StatementManageService from '@service/statement-manage'; - import ConfigModel from '@model/root/config'; import useEventBus from '@hooks/use-event-bus'; + import useFeature from '@hooks/use-feature'; import usePlatformConfig from '@hooks/use-platform-config'; - import useRequest from '@hooks/use-request'; import AuditMenu from '@components/audit-menu/index.vue'; import AuditMenuItem from '@components/audit-menu/item.vue'; @@ -247,12 +245,7 @@ const platformConfig = usePlatformConfig(); // 是否展示审计报表导航 - const { - data: hasBkvision, - } = useRequest(StatementManageService.fetchHasBkvision, { - manual: true, - defaultValue: { enabled: false }, - }); + const { feature: hasBkvision } = useFeature('bkvision'); const titleRef = ref(''); const menuData = ref>([]); on('statement-menuData', (data) => { diff --git a/src/frontend/src/views/storage-manage/list/index.vue b/src/frontend/src/views/storage-manage/list/index.vue index 6badf92c..d2054280 100644 --- a/src/frontend/src/views/storage-manage/list/index.vue +++ b/src/frontend/src/views/storage-manage/list/index.vue @@ -128,6 +128,7 @@ import type StorageModel from '@model/storage/storage'; + import useFeature from '@hooks/use-feature'; import useMessage from '@hooks/use-message'; import useRequest from '@hooks/use-request'; @@ -140,6 +141,7 @@ } const isSearching = ref(false); const search = ref(''); + const { feature: showStorageEdit } = useFeature('storage_edit'); const tableColumn = [ { label: () => 'ID', @@ -247,23 +249,27 @@ {t('设为默认')} - handleEdit(data)} - class="ml8"> - {t('编辑')} - + { + showStorageEdit.value.enabled + ? handleEdit(data)} + className="ml8"> + {t('编辑')} + + : '' + } handleRemove(data)}> + title={t('确认删除?')} + content={t('删除后不可恢复')} + class="ml8" + confirmHandler={() => handleRemove(data)}> diff --git a/src/frontend/src/views/system-manage/collector-create/pages/step1/index.vue b/src/frontend/src/views/system-manage/collector-create/pages/step1/index.vue index 9f02c756..b7b7d114 100644 --- a/src/frontend/src/views/system-manage/collector-create/pages/step1/index.vue +++ b/src/frontend/src/views/system-manage/collector-create/pages/step1/index.vue @@ -219,6 +219,8 @@ ref, } from 'vue'; + import useFeature from '@hooks/use-feature'; + let formData = reactive({ // 计算平台数据 bk_data_id: '', @@ -298,6 +300,7 @@ searchParams, removeSearchParam, } = useUrlSearch(); + const { feature: showBkbase } = useFeature('bkbase_data_source'); const comMap = { physics: RenderPhysics, container: RenderContainer, @@ -518,19 +521,6 @@ }); } - const { - data: showBkbase, - } = useRequest(CollectorManageService.fetchBkbaseFeature, { - defaultValue: { - enabled: false, - }, - defaultParams: { - feature_id: 'bkbase_data_source', - }, - manual: true, - }); - - const { run: fecthDetail, } = useRequest(DataIdManageService.fecthDetail, { diff --git a/src/frontend/src/views/system-manage/detail/components/access-model/components/resource-type-list/index.vue b/src/frontend/src/views/system-manage/detail/components/access-model/components/resource-type-list/index.vue index 00e866fc..be783b77 100644 --- a/src/frontend/src/views/system-manage/detail/components/access-model/components/resource-type-list/index.vue +++ b/src/frontend/src/views/system-manage/detail/components/access-model/components/resource-type-list/index.vue @@ -164,7 +164,9 @@ */ const checkPermission = async () => { const { access_global_setting: accessGlobalSetting = false } = await IamManageService.check({ action_ids: 'access_global_setting' }); - const { enabled = false } = await CollectorManageService.fetchResourceFeature(); + const { enabled = false } = await MetaManageService.fetchFeature({ + feature_id: 'bkbase_aiops', + }); controlsPermission.value = accessGlobalSetting && enabled; }; diff --git a/src/frontend/src/views/system-manage/detail/components/data-report/index.vue b/src/frontend/src/views/system-manage/detail/components/data-report/index.vue index 8eed5c95..b079af8e 100644 --- a/src/frontend/src/views/system-manage/detail/components/data-report/index.vue +++ b/src/frontend/src/views/system-manage/detail/components/data-report/index.vue @@ -36,9 +36,7 @@ ref, } from 'vue'; - import CollectorManageService from '@service/collector-manage'; - - import useRequest from '@hooks/use-request'; + import useFeature from '@hooks/use-feature'; import ApiPush from './components/api-push.vue'; import LogCollection from './components/log-collection/index.vue'; @@ -53,17 +51,7 @@ const apiRef = ref(); const collectorData = ref < CollectorData >({ id: 0, name: '' }); - const { - data: showApiPush, - } = useRequest(CollectorManageService.fetchApiPushFeature, { - defaultValue: { - enabled: false, - }, - defaultParams: { - feature_id: 'bklog_otlp', - }, - manual: true, - }); + const { feature: showApiPush } = useFeature('bklog_otlp'); const handleChecked = (value: {id: number|string, name: string}) => { collectorData.value = value;