diff --git a/dbm-ui/frontend/src/common/const/clusterTypes.ts b/dbm-ui/frontend/src/common/const/clusterTypes.ts index 4f6f2fbd69..dab6801cea 100644 --- a/dbm-ui/frontend/src/common/const/clusterTypes.ts +++ b/dbm-ui/frontend/src/common/const/clusterTypes.ts @@ -43,6 +43,7 @@ export enum ClusterTypes { } // sqlserver export enum ClusterTypes { + SQLSERVER = 'sqlserver', SQLSERVER_SINGLE = 'sqlserver_single', // SQLServer单节点版 SQLSERVER_HA = 'sqlserver_ha', // SQLServer主从版 } diff --git a/dbm-ui/frontend/src/components/db-table/index.vue b/dbm-ui/frontend/src/components/db-table/index.vue index e12407a21d..e831c85e44 100644 --- a/dbm-ui/frontend/src/components/db-table/index.vue +++ b/dbm-ui/frontend/src/components/db-table/index.vue @@ -597,7 +597,8 @@ getAllData: fetchAllData, // 清空选择 clearSelected() { - bkTableRef.value?.clearSelection(); + // bkTableRef.value?.clearSelection(); + handleClearWholeSelect(); }, updateTableKey() { tableKey.value = Date.now().toString(); diff --git a/dbm-ui/frontend/src/locales/zh-cn.json b/dbm-ui/frontend/src/locales/zh-cn.json index e3dd84cc37..aa009cf308 100644 --- a/dbm-ui/frontend/src/locales/zh-cn.json +++ b/dbm-ui/frontend/src/locales/zh-cn.json @@ -3633,5 +3633,21 @@ "DB名称支持通配符_如Data_区分大小写_多个使用英文逗号_分号或换行分隔": "DB名称支持通配符 %,如 Data%,区分大小写,多个使用英文逗号、分号或换行分隔", "删除规则会创建单据,需此规则所有过往调用方审批后才执行删除。": "删除规则会创建单据,需此规则所有过往调用方审批后才执行删除。", "不允许 *": "不允许 *", + "确定启用集群": "确定启用集群", + "确定禁用集群": "确定禁用集群", + "确定删除集群": "确定删除集群", + "仅可删除状态为“已禁用”的集群": "仅可删除状态为“已禁用”的集群", + "仅可启用状态为“已禁用”的集群": "仅可启用状态为“已禁用”的集群", + "仅可禁用状态为“已启用”的集群": "仅可禁用状态为“已启用”的集群", + "确定启用集群?": "确定启用集群?", + "确定禁用集群?": "确定禁用集群?", + "仅已启用集群可以提取 Key": "仅已启用集群可以提取 Key", + "仅已启用集群可以删除 Key": "仅已启用集群可以删除 Key", + "仅已启用集群可以备份": "仅已启用集群可以备份", + "仅已启用集群可以清档": "仅已启用集群可以清档", + "仅可订阅状态为“已启用”的集群": "仅可订阅状态为“已启用”的集群", + "仅可授权状态为“已启用”的集群": "仅可授权状态为“已启用”的集群", + "请先禁用集群": "请先禁用集群", + "无运维节点": "无运维节点", "这行勿动!新增翻译请在上一行添加!": "" } diff --git a/dbm-ui/frontend/src/services/model/es/es.ts b/dbm-ui/frontend/src/services/model/es/es.ts index bcfbe0ed05..921baad7ee 100644 --- a/dbm-ui/frontend/src/services/model/es/es.ts +++ b/dbm-ui/frontend/src/services/model/es/es.ts @@ -14,7 +14,7 @@ import { uniq } from 'lodash'; import type { ClusterListEntry, ClusterListNode, ClusterListOperation } from '@services/types'; -import { utcDisplayTime } from '@utils'; +import { isRecentDays, utcDisplayTime } from '@utils'; import { t } from '@locales/index'; @@ -233,6 +233,10 @@ export default class Es { })); } + get isNew() { + return isRecentDays(this.create_at, 24); + } + initOperations(payload = [] as Es['operations']) { if (!Array.isArray(payload)) { return []; diff --git a/dbm-ui/frontend/src/services/model/hdfs/hdfs.ts b/dbm-ui/frontend/src/services/model/hdfs/hdfs.ts index 14fade02a5..a6b4761b95 100644 --- a/dbm-ui/frontend/src/services/model/hdfs/hdfs.ts +++ b/dbm-ui/frontend/src/services/model/hdfs/hdfs.ts @@ -14,7 +14,7 @@ import { uniq } from 'lodash'; import type { ClusterListEntry, ClusterListNode, ClusterListOperation } from '@services/types'; -import { utcDisplayTime } from '@utils'; +import { isRecentDays, utcDisplayTime } from '@utils'; import { t } from '@locales/index'; @@ -238,4 +238,8 @@ export default class Hdfs { get isStarting() { return Boolean(this.operations.find((item) => item.ticket_type === Hdfs.HDFS_ENABLE)); } + + get isNew() { + return isRecentDays(this.create_at, 24); + } } diff --git a/dbm-ui/frontend/src/services/model/mysql/tendbha.ts b/dbm-ui/frontend/src/services/model/mysql/tendbha.ts index ac6e5a98c8..260afa7763 100644 --- a/dbm-ui/frontend/src/services/model/mysql/tendbha.ts +++ b/dbm-ui/frontend/src/services/model/mysql/tendbha.ts @@ -14,7 +14,7 @@ import { uniq } from 'lodash'; import type { ClusterListEntry, ClusterListNode, ClusterListOperation } from '@services/types'; -import { utcDisplayTime } from '@utils'; +import { isRecentDays, utcDisplayTime } from '@utils'; import { t } from '@locales/index'; @@ -232,4 +232,8 @@ export default class Tendbha { ticketId: item.ticket_id, })); } + + get isNew() { + return isRecentDays(this.create_at, 24); + } } diff --git a/dbm-ui/frontend/src/services/model/mysql/tendbsingle.ts b/dbm-ui/frontend/src/services/model/mysql/tendbsingle.ts index 2063d12292..787b08e7f0 100644 --- a/dbm-ui/frontend/src/services/model/mysql/tendbsingle.ts +++ b/dbm-ui/frontend/src/services/model/mysql/tendbsingle.ts @@ -14,7 +14,7 @@ import { uniq } from 'lodash'; import type { ClusterListEntry, ClusterListNode, ClusterListOperation } from '@services/types'; -import { utcDisplayTime } from '@utils'; +import { isRecentDays, utcDisplayTime } from '@utils'; import { t } from '@locales/index'; @@ -210,4 +210,8 @@ export default class Tendbsingle { ticketId: item.ticket_id, })); } + + get isNew() { + return isRecentDays(this.create_at, 24); + } } diff --git a/dbm-ui/frontend/src/services/model/redis/redis.ts b/dbm-ui/frontend/src/services/model/redis/redis.ts index 2a1b5abb74..3fb6918561 100644 --- a/dbm-ui/frontend/src/services/model/redis/redis.ts +++ b/dbm-ui/frontend/src/services/model/redis/redis.ts @@ -23,15 +23,15 @@ export default class Redis { static REDIS_PROXY_CLOSE = 'REDIS_PROXY_CLOSE'; static REDIS_PROXY_OPEN = 'REDIS_PROXY_OPEN'; static REDIS_INSTANCE_DESTROY = 'REDIS_INSTANCE_DESTROY'; - static REDIS_INSTANCE_PROXY_CLOSE = 'REDIS_INSTANCE_PROXY_CLOSE'; - static REDIS_INSTANCE_PROXY_OPEN = 'REDIS_INSTANCE_PROXY_OPEN'; + static REDIS_INSTANCE_CLOSE = 'REDIS_INSTANCE_CLOSE'; + static REDIS_INSTANCE_OPEN = 'REDIS_INSTANCE_OPEN'; static operationIconMap = { [Redis.REDIS_PROXY_OPEN]: t('启用中'), [Redis.REDIS_PROXY_CLOSE]: t('禁用中'), [Redis.REDIS_DESTROY]: t('删除中'), - [Redis.REDIS_INSTANCE_PROXY_OPEN]: t('启用中'), - [Redis.REDIS_INSTANCE_PROXY_CLOSE]: t('禁用中'), + [Redis.REDIS_INSTANCE_OPEN]: t('启用中'), + [Redis.REDIS_INSTANCE_CLOSE]: t('禁用中'), [Redis.REDIS_INSTANCE_DESTROY]: t('删除中'), }; @@ -40,8 +40,8 @@ export default class Redis { [Redis.REDIS_PROXY_CLOSE]: t('禁用任务执行中'), [Redis.REDIS_PROXY_OPEN]: t('启用任务执行中'), [Redis.REDIS_INSTANCE_DESTROY]: t('删除任务执行中'), - [Redis.REDIS_INSTANCE_PROXY_CLOSE]: t('禁用任务执行中'), - [Redis.REDIS_INSTANCE_PROXY_OPEN]: t('启用任务执行中'), + [Redis.REDIS_INSTANCE_CLOSE]: t('禁用任务执行中'), + [Redis.REDIS_INSTANCE_OPEN]: t('启用任务执行中'), }; bk_biz_id: number; diff --git a/dbm-ui/frontend/src/views/db-manage/redis/common/cluster-oprations/BatchEditKeys.vue b/dbm-ui/frontend/src/views/db-manage/common/RedisBatchEditKeys.vue similarity index 100% rename from dbm-ui/frontend/src/views/db-manage/redis/common/cluster-oprations/BatchEditKeys.vue rename to dbm-ui/frontend/src/views/db-manage/common/RedisBatchEditKeys.vue diff --git a/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/Index.vue b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/Index.vue new file mode 100644 index 0000000000..b568617d4e --- /dev/null +++ b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/Index.vue @@ -0,0 +1,153 @@ + + + + + + + + + + diff --git a/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/mongo-replica-set/Index.vue b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/mongo-replica-set/Index.vue new file mode 100644 index 0000000000..6fad9a3fd7 --- /dev/null +++ b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/mongo-replica-set/Index.vue @@ -0,0 +1,127 @@ + + + diff --git a/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/mongo-sharded-cluster/Index.vue b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/mongo-sharded-cluster/Index.vue new file mode 100644 index 0000000000..d5821dfc1d --- /dev/null +++ b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/mongo-sharded-cluster/Index.vue @@ -0,0 +1,127 @@ + + + diff --git a/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/redis-ha/Index.vue b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/redis-ha/Index.vue new file mode 100644 index 0000000000..eacc24cbf4 --- /dev/null +++ b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/redis-ha/Index.vue @@ -0,0 +1,229 @@ + + + diff --git a/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/redis/Index.vue b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/redis/Index.vue new file mode 100644 index 0000000000..61dad53db2 --- /dev/null +++ b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/redis/Index.vue @@ -0,0 +1,171 @@ + + + diff --git a/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/sqlserver-ha/Index.vue b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/sqlserver-ha/Index.vue new file mode 100644 index 0000000000..079aab313f --- /dev/null +++ b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/sqlserver-ha/Index.vue @@ -0,0 +1,127 @@ + + + diff --git a/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/sqlserver-single/Index.vue b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/sqlserver-single/Index.vue new file mode 100644 index 0000000000..6b5b4a9f22 --- /dev/null +++ b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/sqlserver-single/Index.vue @@ -0,0 +1,127 @@ + + + diff --git a/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/tendb-cluster/Index.vue b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/tendb-cluster/Index.vue new file mode 100644 index 0000000000..e8aec1725b --- /dev/null +++ b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/tendb-cluster/Index.vue @@ -0,0 +1,127 @@ + + + diff --git a/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/tendb-ha/Index.vue b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/tendb-ha/Index.vue new file mode 100644 index 0000000000..e58ac8065a --- /dev/null +++ b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/tendb-ha/Index.vue @@ -0,0 +1,155 @@ + + + diff --git a/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/tendb-single/Index.vue b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/tendb-single/Index.vue new file mode 100644 index 0000000000..68b0083f6d --- /dev/null +++ b/dbm-ui/frontend/src/views/db-manage/common/cluster-batch-opration/components/tendb-single/Index.vue @@ -0,0 +1,127 @@ + + + diff --git a/dbm-ui/frontend/src/views/db-manage/common/hooks/index.ts b/dbm-ui/frontend/src/views/db-manage/common/hooks/index.ts new file mode 100644 index 0000000000..c741d03c33 --- /dev/null +++ b/dbm-ui/frontend/src/views/db-manage/common/hooks/index.ts @@ -0,0 +1 @@ +export * from './useOperateClusterBasic'; diff --git a/dbm-ui/frontend/src/views/db-manage/common/hooks/useOperateClusterBasic.tsx b/dbm-ui/frontend/src/views/db-manage/common/hooks/useOperateClusterBasic.tsx new file mode 100644 index 0000000000..91083028be --- /dev/null +++ b/dbm-ui/frontend/src/views/db-manage/common/hooks/useOperateClusterBasic.tsx @@ -0,0 +1,254 @@ +/* + * TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. + * + * Copyright (C) 2017-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 https://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. + */ + +import { InfoBox } from 'bkui-vue'; +import { useI18n } from 'vue-i18n'; + +import { createTicket } from '@services/source/ticket'; + +import { useTicketMessage } from '@hooks'; + +import { ClusterTypes, TicketTypes } from '@common/const'; + +interface ClusterCommon { + cluster_alias: string; + cluster_name: string; + cluster_type: string; + id: number; + phase: string; +} + +export const useOperateClusterBasic = (clusterType: ClusterTypes, options: { onSuccess: () => void }) => { + const { t } = useI18n(); + const ticketMessage = useTicketMessage(); + + // 除 大数据 和 redis集群 暂未支持,其余都已支持批量提单 + const batchOperateTicketTypeList: string[] = [ + TicketTypes.MYSQL_SINGLE_DISABLE, + TicketTypes.MYSQL_SINGLE_ENABLE, + TicketTypes.MYSQL_SINGLE_DESTROY, + TicketTypes.MYSQL_HA_DISABLE, + TicketTypes.MYSQL_HA_ENABLE, + TicketTypes.MYSQL_HA_DESTROY, + TicketTypes.TENDBCLUSTER_DISABLE, + TicketTypes.TENDBCLUSTER_ENABLE, + TicketTypes.TENDBCLUSTER_DESTROY, + TicketTypes.REDIS_INSTANCE_OPEN, + TicketTypes.REDIS_INSTANCE_CLOSE, + TicketTypes.REDIS_INSTANCE_DESTROY, + TicketTypes.MONGODB_DISABLE, + TicketTypes.MONGODB_ENABLE, + TicketTypes.MONGODB_DESTROY, + TicketTypes.SQLSERVER_DISABLE, + TicketTypes.SQLSERVER_ENABLE, + TicketTypes.SQLSERVER_DESTROY, + ]; + + const getDetailParam = (ticketType: TicketTypes, dataList: { id: number }[]) => { + const idList = dataList.map((item) => item.id); + if (batchOperateTicketTypeList.includes(ticketType as string)) { + return { + cluster_ids: idList, + }; + } + return { + cluster_id: idList[0], + }; + }; + + const ticketTypeMap: Record< + string, + { + disable: TicketTypes; + enable: TicketTypes; + delete: TicketTypes; + } + > = { + [ClusterTypes.TENDBSINGLE]: { + disable: TicketTypes.MYSQL_SINGLE_DISABLE, + enable: TicketTypes.MYSQL_SINGLE_ENABLE, + delete: TicketTypes.MYSQL_SINGLE_DESTROY, + }, + [ClusterTypes.TENDBHA]: { + disable: TicketTypes.MYSQL_HA_DISABLE, + enable: TicketTypes.MYSQL_HA_ENABLE, + delete: TicketTypes.MYSQL_HA_DESTROY, + }, + [ClusterTypes.TENDBCLUSTER]: { + disable: TicketTypes.TENDBCLUSTER_DISABLE, + enable: TicketTypes.TENDBCLUSTER_ENABLE, + delete: TicketTypes.TENDBCLUSTER_DESTROY, + }, + [ClusterTypes.REDIS]: { + disable: TicketTypes.REDIS_PROXY_CLOSE, + enable: TicketTypes.REDIS_PROXY_OPEN, + delete: TicketTypes.REDIS_DESTROY, + }, + [ClusterTypes.REDIS_INSTANCE]: { + disable: TicketTypes.REDIS_INSTANCE_CLOSE, + enable: TicketTypes.REDIS_INSTANCE_OPEN, + delete: TicketTypes.REDIS_INSTANCE_DESTROY, + }, + [ClusterTypes.MONGODB]: { + disable: TicketTypes.MONGODB_DISABLE, + enable: TicketTypes.MONGODB_ENABLE, + delete: TicketTypes.MONGODB_DESTROY, + }, + [ClusterTypes.SQLSERVER]: { + disable: TicketTypes.SQLSERVER_DISABLE, + enable: TicketTypes.SQLSERVER_ENABLE, + delete: TicketTypes.SQLSERVER_DESTROY, + }, + [ClusterTypes.DORIS]: { + disable: TicketTypes.DORIS_DISABLE, + enable: TicketTypes.DORIS_ENABLE, + delete: TicketTypes.DORIS_DESTROY, + }, + [ClusterTypes.ES]: { + disable: TicketTypes.ES_DISABLE, + enable: TicketTypes.ES_ENABLE, + delete: TicketTypes.ES_DESTROY, + }, + [ClusterTypes.HDFS]: { + disable: TicketTypes.HDFS_DISABLE, + enable: TicketTypes.HDFS_ENABLE, + delete: TicketTypes.HDFS_DESTROY, + }, + [ClusterTypes.KAFKA]: { + disable: TicketTypes.KAFKA_DISABLE, + enable: TicketTypes.KAFKA_ENABLE, + delete: TicketTypes.KAFKA_DESTROY, + }, + [ClusterTypes.PULSAR]: { + disable: TicketTypes.PULSAR_DISABLE, + enable: TicketTypes.PULSAR_ENABLE, + delete: TicketTypes.PULSAR_DESTROY, + }, + [ClusterTypes.RIAK]: { + disable: TicketTypes.RIAK_CLUSTER_DISABLE, + enable: TicketTypes.RIAK_CLUSTER_ENABLE, + delete: TicketTypes.RIAK_CLUSTER_DESTROY, + }, + }; + + const ticketTypeInfo = ticketTypeMap[clusterType]; + + const handleConfirm = (ticketType: TicketTypes, dataList: { id: number }[]) => { + createTicket({ + bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, + ticket_type: ticketType, + details: getDetailParam(ticketType, dataList), + }).then((data) => { + options.onSuccess(); + ticketMessage(data.id); + }); + }; + + const handleDisableCluster = (dataList: T[]) => { + const subTitle = ( +
+
+ {t('集群')} : + + {dataList.map((item) => item.cluster_name).join(',')} + +
+
{t('被禁用后将无法访问,如需恢复访问,可以再次「启用」')}
+
+ ); + InfoBox({ + title: t('确定禁用集群?'), + subTitle, + infoType: 'warning', + theme: 'danger', + confirmText: t('禁用'), + cancelText: t('取消'), + headerAlign: 'center', + contentAlign: 'left', + footerAlign: 'center', + onConfirm: () => { + handleConfirm(ticketTypeInfo.disable, dataList); + }, + }); + }; + + const handleEnableCluster = (dataList: T[]) => { + const subTitle = ( +
+
+ {t('集群')} : + + {dataList.map((item) => item.cluster_name).join(',')} + +
+
{t('启用后,将会恢复访问')}
+
+ ); + InfoBox({ + title: t('确定启用集群?'), + subTitle, + confirmText: t('启用'), + cancelText: t('取消'), + headerAlign: 'center', + contentAlign: 'left', + footerAlign: 'center', + onConfirm: () => { + handleConfirm(ticketTypeInfo.enable, dataList); + }, + }); + }; + + const handleDeleteCluster = (dataList: T[]) => { + const clusterNames = dataList.map((item) => item.cluster_name).join(','); + const subTitle = ( +
+
+ {t('集群')} : + + {clusterNames} + +
+
{t('删除后将产生以下影响')}:
+
1. {t('删除xxx集群', [clusterNames])}
+
2. {t('删除xxx实例数据,停止相关进程', [clusterNames])}
+
3. {t('回收主机')}:
+
+ ); + InfoBox({ + title: t('确定删除集群?'), + subTitle, + infoType: 'warning', + theme: 'danger', + confirmText: t('删除'), + cancelText: t('取消'), + headerAlign: 'center', + contentAlign: 'left', + footerAlign: 'center', + onConfirm: () => { + handleConfirm(ticketTypeInfo.delete, dataList); + }, + }); + }; + + return { + handleDisableCluster, + handleEnableCluster, + handleDeleteCluster, + }; +}; diff --git a/dbm-ui/frontend/src/views/db-manage/redis/common/cluster-oprations/Backup.vue b/dbm-ui/frontend/src/views/db-manage/common/redis-backup/Index.vue similarity index 99% rename from dbm-ui/frontend/src/views/db-manage/redis/common/cluster-oprations/Backup.vue rename to dbm-ui/frontend/src/views/db-manage/common/redis-backup/Index.vue index 34932dee45..4bb4c86504 100644 --- a/dbm-ui/frontend/src/views/db-manage/redis/common/cluster-oprations/Backup.vue +++ b/dbm-ui/frontend/src/views/db-manage/common/redis-backup/Index.vue @@ -88,7 +88,7 @@ import { generateId } from '@utils'; - import BatchEdit from './BatchEdit.vue'; + import BatchEdit from './components/BatchEdit.vue'; interface DataItem extends RedisModel { target: string, diff --git a/dbm-ui/frontend/src/views/db-manage/redis/common/cluster-oprations/BatchEdit.vue b/dbm-ui/frontend/src/views/db-manage/common/redis-backup/components/BatchEdit.vue similarity index 100% rename from dbm-ui/frontend/src/views/db-manage/redis/common/cluster-oprations/BatchEdit.vue rename to dbm-ui/frontend/src/views/db-manage/common/redis-backup/components/BatchEdit.vue diff --git a/dbm-ui/frontend/src/views/db-manage/common/redis-backup/hooks/useShowBackup.ts b/dbm-ui/frontend/src/views/db-manage/common/redis-backup/hooks/useShowBackup.ts new file mode 100644 index 0000000000..74365af676 --- /dev/null +++ b/dbm-ui/frontend/src/views/db-manage/common/redis-backup/hooks/useShowBackup.ts @@ -0,0 +1,49 @@ +/* + * TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. + * + * Copyright (C) 2017-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 https://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. + */ + +import _ from 'lodash'; + +import RedisModel from '@services/model/redis/redis'; + +import { TicketTypes } from '@common/const'; + +import { messageWarn } from '@utils'; + +import { t } from '@locales/index'; + +export const useShowBackup = () => { + const state = reactive({ + isShow: false, + data: [] as RedisModel[], + }); + + const handleShow = (data: RedisModel[]) => { + if ( + data.some( + (item) => + item.operations.length > 0 && + item.operations.map((op) => op.ticket_type).includes(TicketTypes.REDIS_INSTANCE_DESTROY), + ) + ) { + messageWarn(t('选中集群存在删除中的集群无法操作')); + return; + } + state.isShow = true; + state.data = _.cloneDeep(data); + }; + + return { + state, + handleShow, + }; +}; diff --git a/dbm-ui/frontend/src/views/db-manage/redis/common/cluster-oprations/DeleteKeys.vue b/dbm-ui/frontend/src/views/db-manage/common/redis-delete-keys/Index.vue similarity index 99% rename from dbm-ui/frontend/src/views/db-manage/redis/common/cluster-oprations/DeleteKeys.vue rename to dbm-ui/frontend/src/views/db-manage/common/redis-delete-keys/Index.vue index 296dbd62d9..19df359c18 100644 --- a/dbm-ui/frontend/src/views/db-manage/redis/common/cluster-oprations/DeleteKeys.vue +++ b/dbm-ui/frontend/src/views/db-manage/common/redis-delete-keys/Index.vue @@ -109,7 +109,7 @@ import { generateId } from '@utils'; - import BatchEditKeys from './BatchEditKeys.vue'; + import BatchEditKeys from '../RedisBatchEditKeys.vue'; interface DataItem extends RedisModel { white_regex: string, diff --git a/dbm-ui/frontend/src/views/db-manage/common/redis-delete-keys/hooks/useShowDeleteKeys.ts b/dbm-ui/frontend/src/views/db-manage/common/redis-delete-keys/hooks/useShowDeleteKeys.ts new file mode 100644 index 0000000000..29344f9063 --- /dev/null +++ b/dbm-ui/frontend/src/views/db-manage/common/redis-delete-keys/hooks/useShowDeleteKeys.ts @@ -0,0 +1,53 @@ +/* + * TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. + * + * Copyright (C) 2017-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 https://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. + */ + +import _ from 'lodash'; + +import RedisModel from '@services/model/redis/redis'; + +import { TicketTypes } from '@common/const'; + +import { messageWarn } from '@utils'; + +import { t } from '@locales/index'; + +export const useShowDeleteKeys = () => { + const state = reactive({ + isShow: false, + data: [] as RedisModel[], + }); + + const handleShow = (data: RedisModel[]) => { + if ( + data.some( + (item) => + item.operations.length > 0 && + item.operations.map((op) => op.ticket_type).includes(TicketTypes.REDIS_INSTANCE_DESTROY), + ) + ) { + messageWarn(t('选中集群存在删除中的集群无法操作')); + return; + } + if (data.some((item) => item.bk_cloud_id > 0)) { + messageWarn(t('暂不支持跨管控区域删除Key')); + return; + } + state.isShow = true; + state.data = _.cloneDeep(data); + }; + + return { + state, + handleShow, + }; +}; diff --git a/dbm-ui/frontend/src/views/db-manage/redis/common/cluster-oprations/ExtractKeys.vue b/dbm-ui/frontend/src/views/db-manage/common/redis-extract-keys/Index.vue similarity index 99% rename from dbm-ui/frontend/src/views/db-manage/redis/common/cluster-oprations/ExtractKeys.vue rename to dbm-ui/frontend/src/views/db-manage/common/redis-extract-keys/Index.vue index ceb918eb7b..94da7abb80 100644 --- a/dbm-ui/frontend/src/views/db-manage/redis/common/cluster-oprations/ExtractKeys.vue +++ b/dbm-ui/frontend/src/views/db-manage/common/redis-extract-keys/Index.vue @@ -108,7 +108,7 @@ import { generateId } from '@utils'; - import BatchEditKeys from './BatchEditKeys.vue'; + import BatchEditKeys from '../RedisBatchEditKeys.vue'; interface ExtractItem extends RedisModel { white_regex: string, diff --git a/dbm-ui/frontend/src/views/db-manage/common/redis-extract-keys/hooks/useShowExtractKeys.ts b/dbm-ui/frontend/src/views/db-manage/common/redis-extract-keys/hooks/useShowExtractKeys.ts new file mode 100644 index 0000000000..1c2239924a --- /dev/null +++ b/dbm-ui/frontend/src/views/db-manage/common/redis-extract-keys/hooks/useShowExtractKeys.ts @@ -0,0 +1,54 @@ +/* + * TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. + * + * Copyright (C) 2017-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 https://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. + */ + +import _ from 'lodash'; + +import RedisModel from '@services/model/redis/redis'; + +import { TicketTypes } from '@common/const'; + +import { messageWarn } from '@utils'; + +import { t } from '@locales/index'; + +export const useShowExtractKeys = () => { + const state = reactive({ + isShow: false, + data: [] as RedisModel[], + }); + + const handleShow = (data: RedisModel[]) => { + if ( + data.some( + (item) => + item.operations.length > 0 && + item.operations.map((op) => op.ticket_type).includes(TicketTypes.REDIS_INSTANCE_DESTROY), + ) + ) { + messageWarn(t('选中集群存在删除中的集群无法操作')); + return; + } + if (data.some((item) => item.bk_cloud_id > 0)) { + messageWarn(t('暂不支持跨管控区域提取Key')); + return; + } + + state.isShow = true; + state.data = _.cloneDeep(data); + }; + + return { + state, + handleShow, + }; +}; diff --git a/dbm-ui/frontend/src/views/db-manage/redis/common/cluster-oprations/Purge.vue b/dbm-ui/frontend/src/views/db-manage/common/redis-purge/Index.vue similarity index 100% rename from dbm-ui/frontend/src/views/db-manage/redis/common/cluster-oprations/Purge.vue rename to dbm-ui/frontend/src/views/db-manage/common/redis-purge/Index.vue diff --git a/dbm-ui/frontend/src/views/db-manage/common/redis-purge/hooks/useShowPurge.ts b/dbm-ui/frontend/src/views/db-manage/common/redis-purge/hooks/useShowPurge.ts new file mode 100644 index 0000000000..98c8262199 --- /dev/null +++ b/dbm-ui/frontend/src/views/db-manage/common/redis-purge/hooks/useShowPurge.ts @@ -0,0 +1,50 @@ +/* + * TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. + * + * Copyright (C) 2017-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 https://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. + */ + +import _ from 'lodash'; + +import RedisModel from '@services/model/redis/redis'; + +import { TicketTypes } from '@common/const'; + +import { messageWarn } from '@utils'; + +import { t } from '@locales/index'; + +export const useShowPurge = () => { + const state = reactive({ + isShow: false, + data: [] as RedisModel[], + }); + + const handleShow = (data: RedisModel[]) => { + if ( + data.some( + (item) => + item.operations.length > 0 && + item.operations.map((op) => op.ticket_type).includes(TicketTypes.REDIS_INSTANCE_DESTROY), + ) + ) { + messageWarn(t('选中集群存在删除中的集群无法操作')); + return; + } + + state.isShow = true; + state.data = _.cloneDeep(data); + }; + + return { + state, + handleShow, + }; +}; diff --git a/dbm-ui/frontend/src/views/db-manage/doris/list/components/list/Index.vue b/dbm-ui/frontend/src/views/db-manage/doris/list/components/list/Index.vue index 6937208303..e5e6609b34 100644 --- a/dbm-ui/frontend/src/views/db-manage/doris/list/components/list/Index.vue +++ b/dbm-ui/frontend/src/views/db-manage/doris/list/components/list/Index.vue @@ -89,7 +89,7 @@