feat: LocaleString for status

This commit is contained in:
Jason Song 2023-01-06 15:02:03 +08:00
parent a6f8f10670
commit 91dfef0425
No known key found for this signature in database
GPG Key ID: 8402EEEE4511A8B5
4 changed files with 21 additions and 3 deletions

View File

@ -3,7 +3,11 @@
package actions
import runnerv1 "code.gitea.io/actions-proto-go/runner/v1"
import (
"code.gitea.io/gitea/modules/translation"
runnerv1 "code.gitea.io/actions-proto-go/runner/v1"
)
// Status represents the status of ActionRun, ActionRunJob, ActionTask, or ActionTaskStep
type Status int
@ -35,6 +39,11 @@ func (s Status) String() string {
return statusNames[s]
}
// LocaleString returns the locale string name of the Status
func (s Status) LocaleString(lang translation.Locale) string {
return lang.Tr("actions.status." + s.String())
}
// IsDone returns whether the Status is final
func (s Status) IsDone() bool {
return s.In(StatusSuccess, StatusFailure, StatusCancelled, StatusSkipped)

View File

@ -3271,3 +3271,12 @@ runners.delete_runner_failed = Failed to delete runner
runners.delete_runner_header = Confirm to delete this runner
runners.delete_runner_notice = If a task is running on this runner, it will be terminated and mark as failed. It may break building workflow.
runners.delete_runner_confirm = Delete this runner
status.unknown = "Unknown"
status.waiting = "Waiting"
status.running = "Running"
status.success = "Success"
status.failure = "Failure"
status.cancelled = "Cancelled"
status.skipped = "Skipped"
status.blocked = "Blocked"

View File

@ -148,7 +148,7 @@ func ViewPost(ctx *context_module.Context) {
resp.StateData.CurrentJobInfo.Title = current.Name
resp.StateData.CurrentJobSteps = make([]ViewJobStep, 0)
resp.LogsData.StreamingLogs = make([]ViewStepLog, 0, len(req.StepLogCursors))
resp.StateData.CurrentJobInfo.Detail = current.Status.String()
resp.StateData.CurrentJobInfo.Detail = current.Status.LocaleString(ctx.Locale)
if task != nil {
steps := actions.FullSteps(task)

View File

@ -70,7 +70,7 @@
{{range .Tasks}}
<tr>
<td><a href="{{.GetBuildViewLink}}" target="_blank">{{template "shared/actions/runner_id" .ID}}</a></td>
<td><span class="ui label task-status-{{.Status.String}}">{{.Status.String}}</span></td>
<td><span class="ui label task-status-{{.Status.String}}">{{.Status.LocaleString $.locale}}</span></td>
<td>{{.GetRepoName}}</td>
<td><strong>
<a href="{{.GetCommitLink}}" target="_blank">{{.GetCommitSHAShort}}</a>