Skip to content

Commit

Permalink
Merge pull request #2824 from TencentBlueKing/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
nannan00 authored Nov 7, 2024
2 parents 0444851 + 472ec09 commit b6ebbfe
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 137 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/choose-ip/grade/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@
async handleAsyncNodes (node, index, flag) {
const chainLen = this.curChain.length;
// 兼容如果是实例视图最后一个节点且child_type为空,则代表没有下一级不需要调接口
if (!node.child_type && node.level + 1 >= chainLen) {
if (!node.childType && node.level + 1 >= chainLen) {
node.expanded = false;
node.async = false;
this.emptyTreeData = formatCodeData(0, this.emptyData, true);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/choose-ip/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@
console.log('handleAsyncNodes', node, index);
const chainLen = this.curChain.length;
// 兼容如果是实例视图最后一个节点且child_type为空,则代表没有下一级不需要调接口
if (!node.child_type && node.level + 1 >= chainLen) {
if (!node.childType && node.level + 1 >= chainLen) {
node.expanded = false;
node.async = false;
this.emptyTreeData = formatCodeData(0, this.emptyData, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@
</div>
<div slot="footer" style="margin-left: 25px;">
<bk-button theme="primary" :disabled="disabled" :loading="sliderLoading" @click="handlerResourceSubmit">{{ $t(`m.common['保存']`) }}</bk-button>
<bk-button style="margin-left: 10px;" :disabled="disabled" @click="handlerResourcePreview" v-if="isShowPreview">{{ $t(`m.common['预览']`) }}</bk-button>
<bk-button style="margin-left: 10px;" :disabled="disabled" @click="handleResourceCancel('cancel')">{{ $t(`m.common['取消']`) }}</bk-button>
</div>
</bk-sideslider>
Expand Down Expand Up @@ -332,12 +331,6 @@
.related_resource_types[this.curResIndex];
return curData.selectionMode;
},
isShowPreview () {
if (this.curIndex === -1) {
return false;
}
return this.tableList[this.curIndex].policy_id !== '';
},
// 处理无限制和聚合后多个tab数据结构不兼容情况
formatDisplayValue () {
return (payload) => {
Expand Down Expand Up @@ -707,35 +700,7 @@
this.curResIndex = -1;
this.curGroupIndex = -1;
},
handlerResourcePreview () {
const { id } = this.tableList[this.curIndex].resource_groups[this.curGroupIndex];
const { system_id, type, name } = this.tableList[this.curIndex].resource_groups[this.curGroupIndex]
.related_resource_types[this.curResIndex];
const condition = [];
const conditionData = this.$refs.renderResourceRef.handleGetPreviewValue();
conditionData.forEach(item => {
const { id, attribute, instance } = item;
condition.push({
id,
attributes: attribute ? attribute.filter(item => item.values.length > 0) : [],
instances: instance ? instance.filter(item => item.path.length > 0) : []
});
});
this.previewResourceParams = {
policy_id: this.tableList[this.curIndex].policy_id,
resource_group_id: id,
related_resource_type: {
system_id,
type,
name,
condition: condition.filter(item => item.attributes.length > 0 || item.instances.length > 0)
}
};
this.previewDialogTitle = this.$t(`m.info['操作侧边栏操作的资源实例差异对比']`, { value: `${this.$t(`m.common['【']`)}${this.tableList[this.curIndex].name}${this.$t(`m.common['】']`)}` });
this.isShowPreviewDialog = true;
},
handlerConditionMouseover (payload) {
if (Object.keys(this.curCopyParams).length < 1 && this.curCopyMode === 'normal') {
return;
Expand Down
13 changes: 9 additions & 4 deletions frontend/src/views/group/components/preview-resource-dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,27 @@
methods: {
async fetchData () {
// debugger
this.isLoading = true;
const isTemplate = this.params.isTemplate;
const method = isTemplate ? 'groupTemplateCompare' : 'groupPolicyCompare';
const { groupId, related_resource_type, resource_group_id: resourceGroupId } = this.params;
const requestParams = {
id: this.params.groupId,
id: groupId,
data: {
related_resource_type: this.params.related_resource_type,
resource_group_id: this.params.resource_group_id
related_resource_type,
resource_group_id: resourceGroupId
}
};
// 无实例和属性条件不需要调用接口
if (!related_resource_type.condition.length || !resourceGroupId) {
return;
}
if (!isTemplate) {
requestParams.data.policy_id = this.params.policy_id;
} else {
requestParams.templateId = this.params.id;
requestParams.data.action_id = this.params.action_id;
}
this.isLoading = true;
try {
const res = await this.$store.dispatch(`userGroup/${method}`, requestParams);
this.conditionData = res.data.map(item => new CompareCondition(item));
Expand Down
17 changes: 10 additions & 7 deletions frontend/src/views/group/components/render-instance-table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,12 @@
return curData.selectionMode;
},
isShowPreview () {
if (this.curIndex === -1) {
if (this.curIndex === -1 || this.curGroupIndex === -1) {
return false;
}
return this.tableList[this.curIndex].policy_id !== '';
// 预览模板需要groupId和resourceGroupId
const { policy_id: policyId, resource_groups: resourceGroups } = this.tableList[this.curIndex];
return policyId !== '' && resourceGroups[this.curGroupIndex].id && this.groupId;
},
isShowView () {
return (payload) => {
Expand Down Expand Up @@ -1338,11 +1340,12 @@
ins.path.forEach((p, pathIndex) => {
if (p.length > 0) {
// 处理授权范围是父级,但是选择了子集数据,需要查找所选数据是不是属于授权范围内的子集数据
let curParentChain = [];
const tempPath = p.filter(v => v.id !== '*');
if (tempPath.length) {
curParentChain = tempPath.slice(0, tempPath.length - 1);
}
// let curParentChain = [];
// const tempPath = p.filter(v => v.id !== '*');
// if (tempPath.length) {
// curParentChain = tempPath.slice(0, tempPath.length - 1);
// }
const curParentChain = p.slice(0, p.length - 1);
// 判断授权范围是不是父级数据
const isExistParent = curParentChain.filter((subPath) => scopeInsList.includes(`${subPath.id}&${subPath.name}&${subPath.type}`));
// 只获取授权范围内的资源实例
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@
</div>
<div slot="footer" style="margin-left: 25px;">
<bk-button theme="primary" :disabled="disabled" :loading="sliderLoading" @click="handlerResourceSubmit">{{ $t(`m.common['保存']`) }}</bk-button>
<bk-button style="margin-left: 10px;" :disabled="disabled" @click="handlerResourcePreview" v-if="isShowPreview">{{ $t(`m.common['预览']`) }}</bk-button>
<bk-button style="margin-left: 10px;" :disabled="disabled" @click="handleResourceCancel('cancel')">{{ $t(`m.common['取消']`) }}</bk-button>
</div>
</bk-sideslider>
Expand Down Expand Up @@ -341,12 +340,6 @@
.related_resource_types[this.curResIndex];
return curData.selectionMode;
},
isShowPreview () {
if (this.curIndex === -1) {
return false;
}
return this.tableList[this.curIndex].policy_id !== '';
},
// 处理无限制和聚合后多个tab数据结构不兼容情况
formatDisplayValue () {
return (payload) => {
Expand Down Expand Up @@ -716,40 +709,6 @@
this.curGroupIndex = -1;
},
handlerResourcePreview () {
const { id } = this.tableList[this.curIndex].resource_groups[this.curGroupIndex];
const { system_id, type, name } = this.tableList[this.curIndex].resource_groups[this.curGroupIndex]
.related_resource_types[this.curResIndex];
const condition = [];
const conditionData = this.$refs.renderResourceRef.handleGetPreviewValue();
conditionData.forEach(item => {
const { id, attribute, instance } = item;
condition.push({
id,
attributes: attribute ? attribute.filter(item => item.values.length > 0) : [],
instances: instance ? instance.filter(item => item.path.length > 0) : []
});
});
this.previewResourceParams = {
id: this.templateId,
policy_id: this.tableList[this.curIndex].policy_id,
resource_group_id: id,
related_resource_type: {
system_id,
type,
name,
condition: condition.filter(item => item.attributes.length > 0 || item.instances.length > 0)
},
action_id: this.tableList[this.curIndex].id,
reverse: true,
groupId: this.groupId,
isTemplate: this.tableList[this.curIndex].isTemplate,
isNotLimit: conditionData.length === 0
};
this.previewDialogTitle = this.$t(`m.info['操作侧边栏操作的资源实例差异对比']`, { value: `${this.$t(`m.common['【']`)}${this.tableList[this.curIndex].name}${this.$t(`m.common['】']`)}` });
this.isShowPreviewDialog = true;
},
handlerConditionMouseover (payload) {
if (Object.keys(this.curCopyParams).length < 1 && this.curCopyMode === 'normal') {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@
data-test-id="group_btn_resourceInstanceSubmit">
{{ $t(`m.common['保存']`) }}
</bk-button>
<bk-button style="margin-left: 10px;" :disabled="disabled" v-if="isShowPreview" @click="handleResourcePreview">{{ $t(`m.common['预览']`) }}</bk-button>
<bk-button style="margin-left: 10px;" :disabled="disabled" @click="handleResourceCancel('cancel')">{{ $t(`m.common['取消']`) }}</bk-button>
</div>
</bk-sideslider>
Expand Down Expand Up @@ -457,12 +456,6 @@
.related_resource_types[this.curResIndex];
return curData.selectionMode;
},
isShowPreview () {
if (this.curIndex === -1) {
return false;
}
return this.tableList[this.curIndex].policy_id !== '';
},
isShowView () {
return (payload) => {
return !payload.isEmpty;
Expand Down Expand Up @@ -1017,11 +1010,12 @@
ins.path.forEach((p, pathIndex) => {
if (p.length > 0) {
// 处理授权范围是父级,但是选择了子集数据,需要查找所选数据是不是属于授权范围内的子集数据
let curParentChain = [];
const tempPath = p.filter(v => v.id !== '*');
if (tempPath.length) {
curParentChain = tempPath.slice(0, tempPath.length - 1);
}
// let curParentChain = [];
// const tempPath = p.filter(v => v.id !== '*');
// if (tempPath.length) {
// curParentChain = tempPath.slice(0, tempPath.length - 1);
// }
const curParentChain = p.slice(0, p.length - 1);
// 判断授权范围是不是父级数据
const isExistParent = curParentChain.filter((subPath) => scopeInsList.includes(`${subPath.id}&${subPath.name}&${subPath.type}`));
// 只获取授权范围内的资源实例
Expand Down Expand Up @@ -1220,40 +1214,6 @@
// this.$emit('handleAggregateAction', false)
// }
},
handleResourcePreview () {
// debugger
window.changeDialog = true;
// eslint-disable-next-line max-len
const { system_id, type, name } = this.tableList[this.curIndex].resource_groups[this.curGroupIndex].related_resource_types[this.curResIndex];
const condition = [];
const conditionData = this.$refs.renderResourceRef.handleGetPreviewValue();
conditionData.forEach(item => {
const { id, attribute, instance } = item;
condition.push({
id,
attributes: attribute ? attribute.filter(item => item.values.length > 0) : [],
instances: instance ? instance.filter(item => item.path.length > 0) : []
});
});
this.previewResourceParams = {
id: this.templateId,
action_id: this.tableList[this.curIndex].id,
related_resource_type: {
system_id,
type,
name,
condition: condition.filter(item => item.attributes.length > 0 || item.instances.length > 0)
},
reverse: true,
groupId: this.groupId,
policy_id: this.tableList[this.curIndex].policy_id,
resource_group_id: this.tableList[this.curIndex].resource_groups[this.curGroupIndex].id,
isTemplate: this.tableList[this.curIndex].isTemplate,
isNotLimit: conditionData.length === 0
};
this.previewDialogTitle = this.$t(`m.info['操作侧边栏操作的资源实例差异对比']`, { value: `${this.$t(`m.common['【']`)}${this.tableList[this.curIndex].name}${this.$t(`m.common['】']`)}` });
this.isShowPreviewDialog = true;
},
handlerConditionMouseover (payload) {
if (Object.keys(this.curCopyParams).length < 1 && this.curCopyMode === 'normal') {
return;
Expand Down
2 changes: 1 addition & 1 deletion saas/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.10.36
1.10.37
11 changes: 11 additions & 0 deletions saas/resources/version_log/change_log.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
<!-- 2024-11-07 -->
# V1.10.37 版本更新日志

### 缺陷修复
* 修复用户组无资源实例和属性条件时预览差异对比报错
* 只有用户组模块且该用户组存在才能预览资源实例差异对比
* 修复child_type取值错误导致无法展开非最后一个节点拓扑
* 修复用户组、二级管理空间主操作下关联操作的资源实例过滤掉无限制后,会偶现授权边界溢出问题

---

<!-- 2024-10-11 -->
# V1.10.36 版本更新日志

Expand Down
11 changes: 11 additions & 0 deletions saas/resources/version_log/change_log_en.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
<!-- 2024-11-07 -->
# V1.10.37 Version Update Log

### Fixes
* Fixed an error when previewing difference comparisons if a user group has no resource instances and attribute conditions.
* Resource instance difference comparisons can only be previewed if the user group module exists and the user group itself exists.
* Fixed an issue where incorrect child_type values prevented the expansion of non-terminal node topologies.
* Resolved an issue where, in the main operations of user groups and secondary management spaces, removing unrestricted resource instances from associated operations occasionally caused authorization boundary overflows.

---

<!-- 2024-10-11 -->
# V1.10.36 Version Update Log

Expand Down

0 comments on commit b6ebbfe

Please sign in to comment.