From 243b769754ea54a38f837742dcf0de82bb3f7d6b Mon Sep 17 00:00:00 2001 From: Jason Song Date: Fri, 6 Jan 2023 15:07:44 +0800 Subject: [PATCH] feat: locale status for runner --- models/actions/runner.go | 5 +++++ options/locale/locale_en-US.ini | 4 ++++ templates/shared/actions/runner_edit.tmpl | 2 +- templates/shared/actions/runner_list.tmpl | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/models/actions/runner.go b/models/actions/runner.go index a8665c943b..94503f2881 100644 --- a/models/actions/runner.go +++ b/models/actions/runner.go @@ -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 { diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 95503c57ad..13f1135401 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -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" diff --git a/templates/shared/actions/runner_edit.tmpl b/templates/shared/actions/runner_edit.tmpl index d3cbb19ba8..8cc119912c 100644 --- a/templates/shared/actions/runner_edit.tmpl +++ b/templates/shared/actions/runner_edit.tmpl @@ -10,7 +10,7 @@
- {{.Runner.StatusName}} + {{.Runner.StatusLocaleName $.locale}}
diff --git a/templates/shared/actions/runner_list.tmpl b/templates/shared/actions/runner_list.tmpl index 86abaa443c..2d2eea475d 100644 --- a/templates/shared/actions/runner_list.tmpl +++ b/templates/shared/actions/runner_list.tmpl @@ -58,7 +58,7 @@ {{range .Runners}} - {{.StatusName}} + {{.StatusLocaleName $.locale}} {{if .Editable $.RunnerOnwerID $.RunnerRepoID}}