Skip to content

Commit

Permalink
fix: 【BSCP+v1.29.0-alpha.187】目前配置上线流程缺少对比 --bug=120653381 (#2966)
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 2829
  • Loading branch information
luofann committed Feb 23, 2024
1 parent 0c20fd2 commit 0c70261
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 38 deletions.
2 changes: 1 addition & 1 deletion bcs-services/bcs-bscp/ui/src/i18n/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export default {
除以下分组之外的所有实例: 'All instances except the following groupings',
对比并上线: 'Compare and go online',
版本已上线: 'Version is online',
请选择上线分组: 'Please select an online group',
请选择分组实例: 'Please select an online group',
本次上线分组: 'This online group',
上线说明: 'Online instructions',
确定上线: 'Confirm to go online',
Expand Down
2 changes: 1 addition & 1 deletion bcs-services/bcs-bscp/ui/src/i18n/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export default {
除以下分组之外的所有实例: '除以下分组之外的所有实例',
对比并上线: '对比并上线',
版本已上线: '版本已上线',
请选择上线分组: '请选择上线分组',
请选择分组实例: '请选择分组实例',
本次上线分组: '本次上线分组',
上线说明: '上线说明',
确定上线: '确定上线',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,11 @@
}
.version-operations {
position: absolute;
top: 5px;
top: 0;
right: 24px;
display: flex;
align-items: center;
height: 100%;
z-index: 10;
.released-groups {
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
</select-group>
<template #footer>
<section class="actions-wrapper">
<bk-button class="publish-btn" theme="primary" @click="handleDiffOrPublish">{{
versionList.length ? t('对比并上线') : t('上线版本')
}}</bk-button>
<bk-button class="publish-btn" theme="primary" @click="handlePublishOrOpenDiff">
{{ diffableVersionList.length ? t('对比并上线') : t('上线版本') }}
</bk-button>
<bk-button @click="handlePanelClose">取消</bk-button>
</section>
</template>
Expand All @@ -55,8 +55,8 @@
:current-version="versionData"
:base-version-id="baseVersionId"
:show-publish-btn="true"
@publish="handleOpenPublishDialog"
:version-diff-list="versionList" />
:version-diff-list="diffableVersionList"
@publish="handleOpenPublishDialog" />
</section>
</template>
<script setup lang="ts">
Expand Down Expand Up @@ -107,6 +107,23 @@
// 已上线分组
const releasedGroups = computed(() => versionData.value.status.released_groups.map((group) => group.id));
// 包含分组变更的版本,用来对比线上版本
const diffableVersionList = computed(() => {
const list = [] as IConfigVersion[];
versionList.value.forEach((version) => {
version.status.released_groups.some((group) => {
if (
group.id === 0 ||
groups.value.find((item) => item.id === group.id && !releasedGroups.value.includes(group.id))
) {
list.push(version);
return true;
}
});
});
return list;
});
const permissionQueryResource = computed(() => [
{
biz_id: props.bkBizId,
Expand All @@ -119,24 +136,24 @@
]);
// 判断是否需要对比上线版本
const handleDiffOrPublish = () => {
const handlePublishOrOpenDiff = () => {
if (selectGroupRef.value.validate()) {
if (versionList.value.length) {
baseVersionId.value = versionList.value[0].id;
if (diffableVersionList.value.length) {
baseVersionId.value = diffableVersionList.value[0].id;
isDiffSliderShow.value = true;
return;
}
handleOpenPublishDialog();
}
};
// 获取所有对比基准版本
// 获取所有已上线版本(已上线或灰度中)
const getVersionList = async () => {
try {
const res = await getConfigVersionList(props.bkBizId, props.appId, { start: 0, all: true });
versionList.value = res.data.details.filter((item: IConfigVersion) => {
const { id, status } = item;
return id !== versionData.value.id && status.publish_status === 'partial_released';
return id !== versionData.value.id && status.publish_status !== 'not_released';
});
} catch (e) {
console.error(e);
Expand Down Expand Up @@ -174,7 +191,7 @@
// 打开上线版本确认弹窗
const handleOpenPublishDialog = () => {
if (groups.value.length === 0) {
BkMessage({ theme: 'error', message: '请选择上线分组' });
BkMessage({ theme: 'error', message: '请选择分组实例' });
return;
}
isConfirmDialogShow.value = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
@change="groups = $event" />
<template #footer>
<section class="actions-wrapper">
<bk-button class="publish-btn" theme="primary" @click="handleDiffOrPublish">{{
versionListByGroup.length ? t('对比并上线') : t('上线版本')
}}</bk-button>
<bk-button class="publish-btn" theme="primary" @click="handlePublishOrOpenDiff">
{{ diffableVersionList.length ? t('对比并上线') : t('上线版本') }}
</bk-button>
<bk-button @click="handlePanelClose">{{ t('取消') }}</bk-button>
</section>
</template>
Expand All @@ -52,8 +52,8 @@
:current-version="versionData"
:base-version-id="baseVersionId"
:show-publish-btn="true"
@publish="handleOpenPublishDialog"
:version-diff-list="versionListByGroup" />
:version-diff-list="diffableVersionList"
@publish="handleOpenPublishDialog" />
</section>
</template>
<script setup lang="ts">
Expand Down Expand Up @@ -115,34 +115,45 @@
},
]);
// 获取所有选择上线范围的上线版本
const versionListByGroup = computed(() => {
// 包含分组变更的版本,用来对比线上版本
const diffableVersionList = computed(() => {
const list = [] as IConfigVersion[];
versionList.value.forEach((version) => {
groups.value.forEach((group) => {
if (version.spec.name === group.release_name && !list.includes(version)) list.push(version);
version.status.released_groups.some((group) => {
if (group.id === 0 || groups.value.findIndex((item) => item.id === group.id)) {
list.push(version);
return true;
}
});
});
return list;
});
// 判断是否需要对比上线版本
const handleDiffOrPublish = () => {
if (versionListByGroup.value.length) {
baseVersionId.value = versionListByGroup.value[0].id;
/**
* @description 直接上线或先对比再上线
* 所有分组都为首次上线,则直接上线,反之先对比再上线
*/
const handlePublishOrOpenDiff = () => {
if (groups.value.length === 0) {
BkMessage({ theme: 'error', message: t('请选择分组实例') });
return;
}
if (diffableVersionList.value.length) {
baseVersionId.value = diffableVersionList.value[0].id;
isDiffSliderShow.value = true;
return;
}
handleOpenPublishDialog();
};
// 获取所有对比基准版本
// 获取所有已上线版本(已上线或灰度中)
const getVersionList = async () => {
try {
const res = await getConfigVersionList(bkBizId, appId, { start: 0, all: true });
versionList.value = res.data.details.filter((item: IConfigVersion) => {
const { id, status } = item;
return id !== versionData.value.id && status.publish_status === 'partial_released';
return id !== versionData.value.id && status.publish_status !== 'not_released';
});
} catch (e) {
console.error(e);
Expand All @@ -160,10 +171,6 @@
};
const handleOpenPublishDialog = () => {
if (groups.value.length === 0) {
BkMessage({ theme: 'error', message: t('请选择上线分组') });
return;
}
isConfirmDialogShow.value = true;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,7 @@
// 加载全量版本列表
const getAllVersionData = async () => {
versionListLoading.value = true;
const params = {
start: 0,
limit: 1000,
};
const res = await getConfigVersionList(spaceId.value, Number(appData.value.id), params);
const res = await getConfigVersionList(spaceId.value, Number(appData.value.id), { start: 0, all: true });
// 只需要已上线版本,且版本中不包含默认分组
versionList.value = res.data.details.filter((item: IConfigVersion) => {
const { publish_status, released_groups } = item.status;
Expand Down

0 comments on commit 0c70261

Please sign in to comment.