Skip to content

Commit

Permalink
fix(frontend): 集群授权访问源选择包含白名单ip TencentBlueKing#7597
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 21928
  • Loading branch information
JustaCattt authored and hLinx committed Oct 25, 2024
1 parent 763e278 commit cae7133
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,23 @@
:is-cloud-area-restrictions="false"
:panel-list="['staticTopo', 'manualInput', 'dbmWhitelist']"
service-mode="all"
@change="handleChangeIP" />
@change="handleChangeIP"
@change-whitelist="handleChangeWhitelist" />
</DbFormItem>
</template>

<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { getWhitelist } from '@services/source/whitelist';
import type { HostInfo } from '@services/types';
import IpSelector from '@components/ip-selector/IpSelector.vue';
export interface SourceIp {
ip: string;
bk_host_id: number;
bk_biz_id: number;
bk_host_id?: number;
bk_biz_id?: number;
}
interface Exposes {
Expand Down Expand Up @@ -58,6 +60,14 @@
}));
};
const handleChangeWhitelist = (data: ServiceReturnType<typeof getWhitelist>['results']) => {
// 避免与 handleChangeIP 同时修改 source_ips 参数
nextTick(() => {
const formatData = data.flatMap((item) => item.ips).map((ip) => ({ ip }));
sourceIps.value.push(...formatData);
});
};
defineExpose<Exposes>({
init(data: HostInfo[]) {
handleChangeIP(data);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<BkFormItem
ref="formRef"
v-model="targetInstances"
class="cluster-authorize-bold"
:label="t('目标集群')"
Expand Down Expand Up @@ -75,6 +76,7 @@
const { t } = useI18n();
const copy = useCopy();
const formRef = ref();
const rules = [
{
trigger: 'change',
Expand Down Expand Up @@ -248,6 +250,7 @@
};
const updateTableData = (data: ResourceItem[]) => {
formRef.value.clearValidate();
state.tableProps.data = data;
state.tableProps.pagination.count = data.length;
targetInstances.value = data.map(item => item.master_domain);
Expand Down

0 comments on commit cae7133

Please sign in to comment.