fix(项目管理): 修复git文件关联详情不显示关联用例信息的问题

--bug=1023101 --user=宋天阳 【项目管理】文件管理,接口中关联第三方存储库的文件,文件详情里不显示
https://www.tapd.cn/55049933/s/1336764
This commit is contained in:
song-tianyang 2023-02-16 18:02:51 +08:00 committed by 建国
parent 97db3c7c70
commit 981e9006b0
3 changed files with 108 additions and 79 deletions

View File

@ -11,11 +11,11 @@ import io.metersphere.remote.dto.ApiDefinitionRequest;
import io.metersphere.remote.dto.ApiScenarioRequest;
import io.metersphere.request.ApiTestCaseRequest;
import io.metersphere.service.MicroService;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@ -32,7 +32,7 @@ public class ApiRelateService {
request.setIds(apiIds);
try {
return microService.postForDataArray(MicroServiceName.API_TEST,
"/api/definition/select/by/id/",
"/api/definition/select/by/id",
request, ApiDefinition.class);
} catch (Exception e) {
LogUtil.error("调用 接口测试服务失败", e);
@ -47,7 +47,7 @@ public class ApiRelateService {
request.setIds(apiTestCaseIds);
try {
return microService.postForDataArray(MicroServiceName.API_TEST,
"/api/testcase/select/by/id/",
"/api/testcase/select/by/id",
request, ApiTestCase.class);
} catch (Exception e) {
LogUtil.error("调用 接口测试服务失败", e);
@ -63,7 +63,7 @@ public class ApiRelateService {
request.setIds(scenarioIdList);
try {
return microService.postForDataArray(MicroServiceName.API_TEST,
"/api/automation/select/by/id/",
"/api/automation/select/by/id",
request, ApiScenario.class);
} catch (Exception e) {
LogUtil.error("调用 接口测试服务失败", e);

View File

@ -5,11 +5,11 @@ import io.metersphere.commons.utils.LogUtil;
import io.metersphere.remote.dto.LoadTestBatchRequest;
import io.metersphere.remote.dto.LoadTestFileDTO;
import io.metersphere.service.MicroService;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@ -28,7 +28,7 @@ public class LoadTestRemoteService {
request.setIds(idList);
try {
return microService.postForDataArray(SERVICE_NAME,
"/performance/file/list/",
"/performance/file/list",
request, LoadTestFileDTO.class);
} catch (Exception e) {
LogUtil.error("调用 性能测试服务 失败", e);

View File

@ -1,35 +1,57 @@
<template>
<el-dialog :title="dialogTitle"
:visible.sync="dialogFormVisible"
:before-close="close"
width="600px">
<el-form :model="metadataForm" :rules="metadataRule" ref="form" label-width="80px" @submit.native.prevent>
<el-dialog
:title="dialogTitle"
:visible.sync="dialogFormVisible"
:before-close="close"
width="600px"
>
<el-form
:model="metadataForm"
:rules="metadataRule"
ref="form"
label-width="80px"
@submit.native.prevent
>
<el-form-item
:label="$t('project.project_file.file.branch')"
prop="repositoryBranch">
prop="repositoryBranch"
>
<el-input v-model="metadataForm.repositoryBranch"></el-input>
</el-form-item>
<el-form-item
:label="$t('project.project_file.file.path')"
prop="repositoryPath">
prop="repositoryPath"
>
<el-input v-model="metadataForm.repositoryPath"></el-input>
</el-form-item>
</el-form>
<template v-slot:footer>
<el-button @click="close">{{ $t('commons.cancel') }}</el-button>
<el-button v-xpack v-prevent-re-click type="primary" :loading="isSaveBtnLoading" @click="saveFileMetadata"
@keydown.enter.native.prevent>{{ $t('commons.confirm') }}
<el-button @click="close">{{ $t("commons.cancel") }}</el-button>
<el-button
v-prevent-re-click
type="primary"
:loading="isSaveBtnLoading"
@click="saveFileMetadata"
@keydown.enter.native.prevent
>{{ $t("commons.confirm") }}
</el-button>
</template>
</el-dialog>
</template>
<script>
import {getCurrentProjectID, getCurrentUserId} from "metersphere-frontend/src/utils/token";
import {getUUID, listenGoBack, removeGoBackListener} from "metersphere-frontend/src/utils";
import {
getCurrentProjectID,
getCurrentUserId,
} from "metersphere-frontend/src/utils/token";
import {
getUUID,
listenGoBack,
removeGoBackListener,
} from "metersphere-frontend/src/utils";
import MsDialogFooter from "metersphere-frontend/src/components/MsDialogFooter";
import {createFileMeta, editFileMeta} from "@/api/file";
import { createFileMeta, editFileMeta } from "@/api/file";
export default {
name: "FileMetadataDialog",
@ -39,23 +61,33 @@ export default {
data() {
return {
dialogFormVisible: false,
dialogTitle: '',
operationType: '',
dialogTitle: "",
operationType: "",
isSaveBtnLoading: false,
projectId: getCurrentProjectID(),
metadataForm: {
repositoryBranch: '',
repositoryPath: '',
repositoryBranch: "",
repositoryPath: "",
},
metadataRule: {
repositoryBranch: [
{required: true, message: this.$t('project.project_file.validation.input_file_branch'), trigger: 'blur'},
{
required: true,
message: this.$t(
"project.project_file.validation.input_file_branch"
),
trigger: "blur",
},
],
repositoryPath: [
{required: true, message: this.$t('project.project_file.validation.input_file_path'), trigger: 'blur'},
{
required: true,
message: this.$t("project.project_file.validation.input_file_path"),
trigger: "blur",
},
],
},
}
};
},
watch: {},
props: {
@ -64,45 +96,47 @@ export default {
computed: {},
methods: {
saveFileMetadata() {
this.$refs.form.validate(valid => {
if (valid) {
let url = '';
let param = JSON.parse(JSON.stringify(this.metadataForm));
param.storage = 'GIT';
this.isSaveBtnLoading = true;
if (param.id) {
editFileMeta(null, param).then(() => {
this.$success(this.$t('commons.save_success'));
this.$emit('refresh');
this.$refs.form.validate((valid) => {
if (valid) {
let url = "";
let param = JSON.parse(JSON.stringify(this.metadataForm));
param.storage = "GIT";
this.isSaveBtnLoading = true;
if (param.id) {
editFileMeta(null, param)
.then(() => {
this.$success(this.$t("commons.save_success"));
this.$emit("refresh");
this.isSaveBtnLoading = false;
this.close();
}).catch(() => {
this.$emit('refresh');
})
.catch(() => {
this.$emit("refresh");
this.isSaveBtnLoading = false;
});
} else {
param.id = getUUID();
param.createUser = getCurrentUserId();
param.updateUser = getCurrentUserId();
param.projectId = this.projectId;
param.moduleId = this.moduleId;
createFileMeta(null, param).then(() => {
this.$success(this.$t('commons.save_success'));
this.$emit('refresh');
this.isSaveBtnLoading = false;
this.close();
}).catch(() => {
this.$emit('refresh');
this.isSaveBtnLoading = false;
});
}
} else {
return false;
param.id = getUUID();
param.createUser = getCurrentUserId();
param.updateUser = getCurrentUserId();
param.projectId = this.projectId;
param.moduleId = this.moduleId;
createFileMeta(null, param)
.then(() => {
this.$success(this.$t("commons.save_success"));
this.$emit("refresh");
this.isSaveBtnLoading = false;
this.close();
})
.catch(() => {
this.$emit("refresh");
this.isSaveBtnLoading = false;
});
}
} else {
return false;
}
)
;
});
},
open(operationType, param) {
this.isSaveBtnLoading = false;
@ -112,42 +146,37 @@ export default {
this.metadataForm = JSON.parse(JSON.stringify(param));
} else {
this.metadataForm = {
repositoryBranch: '',
repositoryPath: '',
repositoryBranch: "",
repositoryPath: "",
};
}
this.dialogFormVisible = true;
}
,
},
close() {
this.isSaveBtnLoading = false;
removeGoBackListener(this.close);
this.$refs.form.resetFields();
this.dialogFormVisible = false;
}
,
},
initDialog(operationType) {
this.operationType = operationType;
//-title
if (operationType === 'create') {
this.dialogTitle = this.$t('commons.create');
} else if (operationType === 'edit') {
this.dialogTitle = this.$t('commons.edit');
if (operationType === "create") {
this.dialogTitle = this.$t("commons.create");
} else if (operationType === "edit") {
this.dialogTitle = this.$t("commons.edit");
} else {
this.dialogTitle = '';
this.dialogTitle = "";
}
}
,
},
clearForm() {
this.metadataForm = {
repositoryBranch: '',
repositoryPath: '',
repositoryBranch: "",
repositoryPath: "",
};
}
}
}
},
},
};
</script>
<style scoped>
</style>
<style scoped></style>