fix(项目管理): 修复环境重命名失败的缺陷

--bug=1037584 --user=王孝刚 【项目管理】环境管理-环境名称重命名功能未实现
https://www.tapd.cn/55049933/s/1501133
This commit is contained in:
wxg0103 2024-04-18 16:39:42 +08:00 committed by 刘瑞斌
parent f6936b5ce8
commit ea9fa5aa1c
4 changed files with 12 additions and 8 deletions

View File

@ -320,11 +320,10 @@ public class EnvironmentService extends MoveNodeService {
environmentMapper.updateByPrimaryKeySelective(environment); environmentMapper.updateByPrimaryKeySelective(environment);
EnvironmentBlob environmentBlob = new EnvironmentBlob(); EnvironmentBlob environmentBlob = new EnvironmentBlob();
environmentBlob.setId(environment.getId()); environmentBlob.setId(environment.getId());
if (request.getConfig() == null) { if (request.getConfig() != null) {
request.setConfig(new EnvironmentConfig()); environmentBlob.setConfig(JSON.toJSONBytes(request.getConfig()));
environmentBlobMapper.updateByPrimaryKeySelective(environmentBlob);
} }
environmentBlob.setConfig(JSON.toJSONBytes(request.getConfig()));
environmentBlobMapper.updateByPrimaryKeySelective(environmentBlob);
uploadFileToMinio(sslFiles, environment); uploadFileToMinio(sslFiles, environment);
return environment; return environment;
} }

View File

@ -5,6 +5,7 @@ export interface EnvListItem {
mock?: boolean; mock?: boolean;
name: string; name: string;
id: string; id: string;
description: string;
} }
export interface EnvGroupProjectListItem { export interface EnvGroupProjectListItem {

View File

@ -42,7 +42,7 @@
import { useAppStore } from '@/store'; import { useAppStore } from '@/store';
import useProjectEnvStore, { NEW_ENV_GROUP } from '@/store/modules/setting/useProjectEnvStore'; import useProjectEnvStore, { NEW_ENV_GROUP } from '@/store/modules/setting/useProjectEnvStore';
import { EnvListItem } from '@/models/projectManagement/environmental'; import { EnvDetailItem, EnvListItem } from '@/models/projectManagement/environmental';
import { EnvAuthScopeEnum } from '@/enums/envEnum'; import { EnvAuthScopeEnum } from '@/enums/envEnum';
import type { FormInstance, ValidatedError } from '@arco-design/web-vue'; import type { FormInstance, ValidatedError } from '@arco-design/web-vue';
@ -81,7 +81,7 @@
if (value === props.defaultName) { if (value === props.defaultName) {
callback(); callback();
} else { } else {
const isExist = props.list.some((item) => item.name === value); const isExist = props.list.some((item) => item.name === value && item.id !== props.id);
if (isExist) { if (isExist) {
callback(t('system.userGroup.userGroupNameIsExist', { name: value })); callback(t('system.userGroup.userGroupNameIsExist', { name: value }));
} }
@ -103,7 +103,9 @@
loading.value = true; loading.value = true;
if (props.type === EnvAuthScopeEnum.PROJECT) { if (props.type === EnvAuthScopeEnum.PROJECT) {
await updateOrAddEnv({ fileList: [], request: { ...store.currentEnvDetailInfo, name: form.name } }); const envListItem = props.list.filter((item) => item.id === props.id)[0] as EnvDetailItem;
envListItem.name = form.name;
await updateOrAddEnv({ fileList: [], request: envListItem });
} else { } else {
const id = store.currentGroupId === NEW_ENV_GROUP ? undefined : store.currentGroupId; const id = store.currentGroupId === NEW_ENV_GROUP ? undefined : store.currentGroupId;
if (id) { if (id) {

View File

@ -34,7 +34,7 @@
<div <div
class="env-item justify-between font-medium text-[var(--color-text-1)] hover:bg-[rgb(var(--primary-1))]" class="env-item justify-between font-medium text-[var(--color-text-1)] hover:bg-[rgb(var(--primary-1))]"
:class="{ 'bg-[rgb(var(--primary-1))] !text-[rgb(var(--primary-5))]': activeKey === ALL_PARAM }" :class="{ 'bg-[rgb(var(--primary-1))] !text-[rgb(var(--primary-5))]': activeKey === ALL_PARAM }"
@click="handleListItemClick({ id: 'allParam', name: 'allParam' })" @click="handleListItemClick({ id: 'allParam', name: 'allParam', description: '' })"
> >
{{ t('project.environmental.allParam') }} {{ t('project.environmental.allParam') }}
<div class="node-extra"> <div class="node-extra">
@ -437,6 +437,7 @@
tmpArr.unshift({ tmpArr.unshift({
id: NEW_ENV_PARAM, id: NEW_ENV_PARAM,
name: t('project.environmental.newEnv'), name: t('project.environmental.newEnv'),
description: '',
}); });
store.setCurrentId(NEW_ENV_PARAM); store.setCurrentId(NEW_ENV_PARAM);
envList.value = tmpArr; envList.value = tmpArr;
@ -448,6 +449,7 @@
tmpArr.unshift({ tmpArr.unshift({
id: NEW_ENV_GROUP, id: NEW_ENV_GROUP,
name: t('project.environmental.newEnv'), name: t('project.environmental.newEnv'),
description: '',
}); });
store.setCurrentGroupId(NEW_ENV_GROUP); store.setCurrentGroupId(NEW_ENV_GROUP);
evnGroupList.value = tmpArr; evnGroupList.value = tmpArr;