feat: locale status for runner

This commit is contained in:
Jason Song 2023-01-06 15:07:44 +08:00
parent 91dfef0425
commit 243b769754
No known key found for this signature in database
GPG Key ID: 8402EEEE4511A8B5
4 changed files with 11 additions and 2 deletions

View File

@ -13,6 +13,7 @@ import (
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/translation"
"code.gitea.io/gitea/modules/util"
runnerv1 "code.gitea.io/actions-proto-go/runner/v1"
@ -74,6 +75,10 @@ func (r *ActionRunner) StatusName() string {
return strings.ToLower(strings.TrimPrefix(r.Status().String(), "RUNNER_STATUS_"))
}
func (r *ActionRunner) StatusLocaleName(lang translation.Locale) string {
return lang.Tr("actions.runners.status." + r.StatusName())
}
func (r *ActionRunner) IsOnline() bool {
status := r.Status()
if status == runnerv1.RunnerStatus_RUNNER_STATUS_IDLE || status == runnerv1.RunnerStatus_RUNNER_STATUS_ACTIVE {

View File

@ -3271,6 +3271,10 @@ 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
runners.status.unspecified = Unknown
runners.status.idle = Idle
runners.status.active = Active
runners.status.offline = Offline
status.unknown = "Unknown"
status.waiting = "Waiting"

View File

@ -10,7 +10,7 @@
<div class="runner-basic-info">
<div class="field dib disabled">
<label>{{.locale.Tr "actions.runners.status"}}</label>
<span class="runner-status-{{if .Runner.IsOnline}}online{{else}}offline{{end}}">{{.Runner.StatusName}}</span>
<span class="runner-status-{{if .Runner.IsOnline}}online{{else}}offline{{end}}">{{.Runner.StatusLocaleName $.locale}}</span>
</div>
<div class="field dib disabled">
<label>{{.locale.Tr "actions.runners.latest_online"}}</label>

View File

@ -58,7 +58,7 @@
{{range .Runners}}
<tr>
<td>
<span class="runner-status-{{if .IsOnline}}online{{else}}offline{{end}}">{{.StatusName}}</span>
<span class="runner-status-{{if .IsOnline}}online{{else}}offline{{end}}">{{.StatusLocaleName $.locale}}</span>
</td>
<td>
{{if .Editable $.RunnerOnwerID $.RunnerRepoID}}