Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto test space archive status color by status #3143

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions apistructs/autotest_space.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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{}{},
Expand All @@ -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)
Expand All @@ -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
Expand Down