From 9292e9ebdbd94506f8b525ef5064dce415061c65 Mon Sep 17 00:00:00 2001 From: Jason Song Date: Fri, 21 Oct 2022 11:36:33 +0800 Subject: [PATCH] fix: add methods of status --- models/bots/status.go | 24 ++++++++++++++++++++++++ templates/repo/builds/status.tmpl | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/models/bots/status.go b/models/bots/status.go index 68cdc2e6b5..b80df074ee 100644 --- a/models/bots/status.go +++ b/models/bots/status.go @@ -27,6 +27,30 @@ func (s Status) IsDone() bool { return s > StatusUnknown && s <= StatusSkipped } +func (s Status) IsSuccess() bool { + return s == StatusSuccess +} + +func (s Status) IsFailure() bool { + return s == StatusFailure +} + +func (s Status) IsCancelled() bool { + return s == StatusCancelled +} + +func (s Status) IsSkipped() bool { + return s == StatusSkipped +} + +func (s Status) IsWaiting() bool { + return s == StatusWaiting +} + +func (s Status) IsRunning() bool { + return s == StatusRunning +} + var statusNames = map[Status]string{ StatusUnknown: "unknown", StatusWaiting: "waiting", diff --git a/templates/repo/builds/status.tmpl b/templates/repo/builds/status.tmpl index 454c951eb1..fd8a683bda 100644 --- a/templates/repo/builds/status.tmpl +++ b/templates/repo/builds/status.tmpl @@ -1,4 +1,4 @@ -{{if .IsPending}} +{{if .IsWaiting}} {{end}} {{if .IsRunning}} @@ -7,6 +7,6 @@ {{if .IsSuccess}} {{end}} -{{if .IsFailed}} +{{if .IsFailure}} {{end}}