refactor(测试跟踪): jira支持编辑平台状态
--bug=1011036 --user=陈建星 【测试跟踪】github##11078,不能在ms上修改jira缺陷的“平台状态” https://www.tapd.cn/55049933/s/1169579
This commit is contained in:
parent
3225aad693
commit
e6f3b8c55f
|
@ -17,6 +17,7 @@ import io.metersphere.notice.annotation.SendNotice;
|
|||
import io.metersphere.track.dto.DemandDTO;
|
||||
import io.metersphere.track.issue.domain.PlatformUser;
|
||||
import io.metersphere.track.issue.domain.jira.JiraIssueType;
|
||||
import io.metersphere.track.issue.domain.jira.JiraTransitionsResponse;
|
||||
import io.metersphere.track.issue.domain.zentao.ZentaoBuild;
|
||||
import io.metersphere.track.request.issues.JiraIssueTypeRequest;
|
||||
import io.metersphere.track.request.testcase.AuthUserIssueRequest;
|
||||
|
@ -170,6 +171,11 @@ public class IssuesController {
|
|||
return issuesService.getIssueTypes(request);
|
||||
}
|
||||
|
||||
@PostMapping("/jira/transitions")
|
||||
public List<JiraTransitionsResponse.Transitions> getJiraTransitions(@RequestBody JiraIssueTypeRequest request) {
|
||||
return issuesService.getJiraTransitions(request);
|
||||
}
|
||||
|
||||
@GetMapping("/demand/list/{projectId}")
|
||||
public List<DemandDTO> getDemandList(@PathVariable String projectId) {
|
||||
return issuesService.getDemandList(projectId);
|
||||
|
|
|
@ -447,6 +447,14 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
// 上传新附件
|
||||
imageFiles.forEach(img -> jiraClientV2.uploadAttachment(request.getPlatformId(), img));
|
||||
|
||||
if (request.getTransitions() != null) {
|
||||
try {
|
||||
jiraClientV2.setTransitions(request.getPlatformId(), request.getTransitions());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
handleIssueUpdate(request);
|
||||
}
|
||||
|
||||
|
@ -534,6 +542,10 @@ public class JiraPlatform extends AbstractIssuePlatform {
|
|||
return setUserConfig(getUserPlatInfo(this.workspaceId));
|
||||
}
|
||||
|
||||
public List<JiraTransitionsResponse.Transitions> getTransitions(String issueKey) {
|
||||
return jiraClientV2.getTransitions(issueKey);
|
||||
}
|
||||
|
||||
public IssueTemplateDao getThirdPartTemplate() {
|
||||
setUserConfig();
|
||||
Set<String> ignoreSet = new HashSet() {{
|
||||
|
|
|
@ -127,6 +127,11 @@ public abstract class JiraAbstractClient extends BaseClient {
|
|||
return (JiraAddIssueResponse) getResultForObject(JiraAddIssueResponse.class, response);
|
||||
}
|
||||
|
||||
public List<JiraTransitionsResponse.Transitions> getTransitions(String issueKey) {
|
||||
ResponseEntity<String> response = restTemplate.exchange(getBaseUrl() + "/issue/{1}/transitions", HttpMethod.GET, getAuthHttpEntity(), String.class, issueKey);
|
||||
return ((JiraTransitionsResponse) getResultForObject(JiraTransitionsResponse.class, response)).getTransitions();
|
||||
}
|
||||
|
||||
public void updateIssue(String id, String body) {
|
||||
LogUtil.info("addIssue: " + body);
|
||||
HttpHeaders headers = getAuthHeader();
|
||||
|
@ -209,6 +214,12 @@ public abstract class JiraAbstractClient extends BaseClient {
|
|||
return getBasicHttpHeaders(USER_NAME, PASSWD);
|
||||
}
|
||||
|
||||
protected HttpHeaders getAuthJsonHeader() {
|
||||
HttpHeaders headers = getAuthHeader();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
return headers;
|
||||
}
|
||||
|
||||
protected String getBaseUrl() {
|
||||
return ENDPOINT + PREFIX;
|
||||
}
|
||||
|
@ -237,4 +248,17 @@ public abstract class JiraAbstractClient extends BaseClient {
|
|||
HttpMethod.GET, getAuthHttpEntity(), String.class, startAt, maxResults, projectKey, issueType);
|
||||
return (JiraIssueListResponse)getResultForObject(JiraIssueListResponse.class, responseEntity);
|
||||
}
|
||||
|
||||
public void setTransitions(String jiraKey, JiraTransitionsResponse.Transitions transitions) {
|
||||
LogUtil.info("setTransitions: " + transitions);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("transition", transitions);
|
||||
HttpEntity<String> requestEntity = new HttpEntity<>(jsonObject.toJSONString(), getAuthJsonHeader());
|
||||
try {
|
||||
restTemplate.exchange(getBaseUrl() + "/issue/{1}/transitions", HttpMethod.POST, requestEntity, String.class, jiraKey);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
MSException.throwException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package io.metersphere.track.issue.domain.jira;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class JiraTransitionsResponse {
|
||||
|
||||
private String expand;
|
||||
private List<Transitions> transitions;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Transitions {
|
||||
private String id;
|
||||
private String name;
|
||||
private To to;
|
||||
private Boolean hasScreen;
|
||||
private Boolean isGlobal;
|
||||
private Boolean isInitial;
|
||||
private Boolean isAvailable;
|
||||
private Boolean isConditional;
|
||||
private Boolean isLooped;
|
||||
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class To {
|
||||
private String self;
|
||||
private String description;
|
||||
private String iconUrl;
|
||||
private String name;
|
||||
private String id;
|
||||
private StatusCategory statusCategory;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class StatusCategory {
|
||||
private String self;
|
||||
private int id;
|
||||
private String key;
|
||||
private String colorName;
|
||||
private String name;
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package io.metersphere.track.request.testcase;
|
|||
|
||||
import io.metersphere.base.domain.IssuesWithBLOBs;
|
||||
import io.metersphere.base.domain.ext.CustomFieldResource;
|
||||
import io.metersphere.track.issue.domain.jira.JiraTransitionsResponse;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
@ -37,4 +38,6 @@ public class IssuesUpdateRequest extends IssuesWithBLOBs {
|
|||
* azure devops bug同步fields
|
||||
*/
|
||||
private String devopsFields;
|
||||
|
||||
private JiraTransitionsResponse.Transitions transitions;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import io.metersphere.track.dto.*;
|
|||
import io.metersphere.track.issue.*;
|
||||
import io.metersphere.track.issue.domain.PlatformUser;
|
||||
import io.metersphere.track.issue.domain.jira.JiraIssueType;
|
||||
import io.metersphere.track.issue.domain.jira.JiraTransitionsResponse;
|
||||
import io.metersphere.track.issue.domain.zentao.ZentaoBuild;
|
||||
import io.metersphere.track.request.issues.JiraIssueTypeRequest;
|
||||
import io.metersphere.track.request.testcase.AuthUserIssueRequest;
|
||||
|
@ -754,4 +755,15 @@ public class IssuesService {
|
|||
request.setOrders(ServiceUtils.getDefaultOrderByField(request.getOrders(), "create_time"));
|
||||
return extIssuesMapper.getIssues(request);
|
||||
}
|
||||
|
||||
public List<JiraTransitionsResponse.Transitions> getJiraTransitions(JiraIssueTypeRequest request) {
|
||||
IssuesRequest issuesRequest = getDefaultIssueRequest(request.getProjectId(), request.getWorkspaceId());
|
||||
JiraPlatform platform = (JiraPlatform) IssueFactory.createPlatform(IssuesManagePlatform.Jira.toString(), issuesRequest);
|
||||
try {
|
||||
return platform.getTransitions(request.getJiraKey());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,19 @@
|
|||
<custom-filed-form-item :form="customFieldForm" :form-label-width="formLabelWidth" :issue-template="issueTemplate"/>
|
||||
</el-form>
|
||||
|
||||
<el-row v-if="jiraTransitions">
|
||||
<el-col :span="8">
|
||||
<el-form-item :label-width="formLabelWidth" :label="$t('test_track.issue.platform_status')"
|
||||
prop="platformStatus">
|
||||
<el-select v-model="form.platformStatus" filterable
|
||||
:placeholder="$t('test_track.issue.please_choose_current_owner')">
|
||||
<el-option v-for="(transition, index) in jiraTransitions" :key="index" :label="transition.to.name"
|
||||
:value="transition.to.name"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<form-rich-text-item v-if="!enableThirdPartTemplate" :title="$t('custom_field.issue_content')" :data="form" prop="description"/>
|
||||
|
||||
<el-row v-if="!enableThirdPartTemplate" class="custom-field-row">
|
||||
|
@ -118,11 +131,12 @@ import CustomFiledComponent from "@/business/components/project/template/CustomF
|
|||
import TestCaseIssueList from "@/business/components/track/issue/TestCaseIssueList";
|
||||
import IssueEditDetail from "@/business/components/track/issue/IssueEditDetail";
|
||||
import {getCurrentProjectID, getCurrentUser, getCurrentUserId, getCurrentWorkspaceId,} from "@/common/js/utils";
|
||||
import {enableThirdPartTemplate, getIssuePartTemplateWithProject, getIssuesListById} from "@/network/Issue";
|
||||
import {enableThirdPartTemplate, getIssuePartTemplateWithProject, getJiraTransitions} from "@/network/Issue";
|
||||
import CustomFiledFormItem from "@/business/components/common/components/form/CustomFiledFormItem";
|
||||
import MsMarkDownText from "@/business/components/track/case/components/MsMarkDownText";
|
||||
import IssueComment from "@/business/components/track/issue/IssueComment";
|
||||
import ReviewCommentItem from "@/business/components/track/review/commom/ReviewCommentItem";
|
||||
import {JIRA} from "@/common/js/constants";
|
||||
|
||||
const {getIssuesById} = require("@/network/Issue");
|
||||
|
||||
|
@ -172,13 +186,15 @@ export default {
|
|||
remark: null,
|
||||
tapdUsers:[],
|
||||
zentaoBuilds:[],
|
||||
zentaoAssigned: ''
|
||||
zentaoAssigned: '',
|
||||
platformStatus: null
|
||||
},
|
||||
tapdUsers: [],
|
||||
zentaoUsers: [],
|
||||
Builds: [],
|
||||
hasTapdId: false,
|
||||
hasZentaoId: false,
|
||||
jiraTransitions: null,
|
||||
currentProject: null,
|
||||
toolbars: {
|
||||
bold: false, // 粗体
|
||||
|
@ -277,12 +293,13 @@ export default {
|
|||
},
|
||||
init(template, data) {
|
||||
this.issueTemplate = template;
|
||||
this.getThirdPartyInfo();
|
||||
this.initEdit(data);
|
||||
this.getThirdPartyInfo();
|
||||
this.result.loading = false;
|
||||
},
|
||||
getThirdPartyInfo() {
|
||||
let platform = this.issueTemplate.platform;
|
||||
this.jiraTransitions = null;
|
||||
if (platform === 'Zentao') {
|
||||
this.hasZentaoId = true;
|
||||
this.result = this.$post("/issues/zentao/builds", {
|
||||
|
@ -299,8 +316,7 @@ export default {
|
|||
this.zentaoUsers = response.data;
|
||||
});
|
||||
});
|
||||
}
|
||||
if (platform === 'Tapd') {
|
||||
} else if (platform === 'Tapd') {
|
||||
this.hasTapdId = true;
|
||||
this.result = this.$post("/issues/tapd/user", {
|
||||
projectId: this.projectId,
|
||||
|
@ -308,6 +324,10 @@ export default {
|
|||
}, (response) => {
|
||||
this.tapdUsers = response.data;
|
||||
});
|
||||
} else if (JIRA === platform && this.form.id) {
|
||||
getJiraTransitions(this.form.platformId, (data) => {
|
||||
this.jiraTransitions = data;
|
||||
});
|
||||
}
|
||||
},
|
||||
initEdit(data) {
|
||||
|
@ -369,6 +389,13 @@ export default {
|
|||
Object.assign(param, this.form);
|
||||
param.projectId = this.projectId;
|
||||
param.workspaceId = getCurrentWorkspaceId();
|
||||
if (this.jiraTransitions) {
|
||||
this.jiraTransitions.forEach(item => {
|
||||
if (item.to.name === this.form.platformStatus) {
|
||||
param.transitions = item;
|
||||
}
|
||||
});
|
||||
}
|
||||
buildCustomFields(this.form, param, this.issueTemplate);
|
||||
if (this.planId) {
|
||||
// 测试计划用例创建缺陷
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import {post, get} from "@/common/js/ajax";
|
||||
import {getPageDate, parseCustomFilesForList} from "@/common/js/tableUtils";
|
||||
import {getCurrentProjectID, hasLicense} from "@/common/js/utils";
|
||||
import {getPageDate} from "@/common/js/tableUtils";
|
||||
import {getCurrentProjectID, getCurrentWorkspaceId, hasLicense} from "@/common/js/utils";
|
||||
import {baseGet, basePost} from "@/network/base-network";
|
||||
import {getCurrentProject} from "@/network/project";
|
||||
import {JIRA, LOCAL} from "@/common/js/constants";
|
||||
|
@ -21,7 +23,6 @@ export function getIssues(page) {
|
|||
return post('issues/list/' + page.currentPage + '/' + page.pageSize, page.condition, (response) => {
|
||||
getPageDate(response, page);
|
||||
parseCustomFilesForList(page.data);
|
||||
// buildIssues(page);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -164,3 +165,11 @@ export function isThirdPartEnable(callback) {
|
|||
export function getJiraIssueType(param, callback) {
|
||||
return basePost('/issues/jira/issuetype', param, callback);
|
||||
}
|
||||
|
||||
export function getJiraTransitions(jiraKey, callback) {
|
||||
return basePost('/issues/jira/transitions', {
|
||||
jiraKey,
|
||||
projectId: getCurrentProjectID(),
|
||||
workspaceId: getCurrentWorkspaceId()
|
||||
}, callback);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue