diff --git a/apistructs/autotest_space.go b/apistructs/autotest_space.go index a20b52ce99c..5bd03978739 100644 --- a/apistructs/autotest_space.go +++ b/apistructs/autotest_space.go @@ -58,6 +58,19 @@ func (s AutoTestSpaceArchiveStatus) GetZhName() string { } } +func (s AutoTestSpaceArchiveStatus) GetFrontEndStatus() string { + switch s { + case TestSpaceInit: + return "default" + case TestSpaceInProgress: + return "processing" + case TestSpaceCompleted: + return "success" + default: + return "" + } +} + func (s AutoTestSpaceArchiveStatus) Valid() bool { switch s { case TestSpaceInit, TestSpaceInProgress, TestSpaceCompleted: diff --git a/modules/openapi/component-protocol/scenarios/auto-test-space-list/components/spaceList/operation.go b/modules/openapi/component-protocol/scenarios/auto-test-space-list/components/spaceList/operation.go index b1b49e8010a..83a28d8e8a8 100644 --- a/modules/openapi/component-protocol/scenarios/auto-test-space-list/components/spaceList/operation.go +++ b/modules/openapi/component-protocol/scenarios/auto-test-space-list/components/spaceList/operation.go @@ -77,7 +77,7 @@ type operationData struct { Meta meta `json:"meta"` } -func setCommand(space spaceItem) map[string]interface{} { +func setCommand(space spaceItem, status apistructs.AutoTestSpaceArchiveStatus) map[string]interface{} { return map[string]interface{}{ "key": "set", "state": spaceFormModal.State{ @@ -87,7 +87,7 @@ func setCommand(space spaceItem) map[string]interface{} { "id": space.ID, "name": space.Title, "desc": space.Description, - "archiveStatus": space.ArchiveStatus.Status, + "archiveStatus": status, }, }, "target": "spaceFormModal", diff --git a/modules/openapi/component-protocol/scenarios/auto-test-space-list/components/spaceList/render.go b/modules/openapi/component-protocol/scenarios/auto-test-space-list/components/spaceList/render.go index 00a50232690..defda09426d 100644 --- a/modules/openapi/component-protocol/scenarios/auto-test-space-list/components/spaceList/render.go +++ b/modules/openapi/component-protocol/scenarios/auto-test-space-list/components/spaceList/render.go @@ -65,9 +65,8 @@ type spaceItem struct { } type ArchiveStatus struct { - Color string `json:"color"` - Status apistructs.AutoTestSpaceArchiveStatus `json:"status"` - Text string `json:"text"` + Status string `json:"status"` + Text string `json:"text"` } type ExtraInfos struct { @@ -249,8 +248,7 @@ func (a *ComponentSpaceList) setData(projectID int64, spaces apistructs.AutoTest Description: each.Description, PrefixImg: "default_test_case", ArchiveStatus: ArchiveStatus{ - Color: "red", - Status: each.ArchiveStatus, + Status: each.ArchiveStatus.GetFrontEndStatus(), Text: i18nLocale.Get(fmt.Sprintf("autoTestSpace%s", each.ArchiveStatus)), }, Operations: map[string]interface{}{}, @@ -271,7 +269,7 @@ func (a *ComponentSpaceList) setData(projectID int64, spaces apistructs.AutoTest }, } if each.Status == apistructs.TestSpaceFailed { - edit.Command = setCommand(item) + edit.Command = setCommand(item, each.ArchiveStatus) edit.Disabled = true item.Operations["a-edit"] = edit deleteOp.Meta = setMeta(item) @@ -283,7 +281,7 @@ func (a *ComponentSpaceList) setData(projectID int64, spaces apistructs.AutoTest item.Operations["export"] = export item.Operations["retry"] = retry } else { - edit.Command = setCommand(item) + edit.Command = setCommand(item, each.ArchiveStatus) copyOp.Meta = setMeta(item) deleteOp.Meta = setMeta(item) deleteOp.Disabled = true