From e2aa22c823754c62f69f1c76a52a3886406ababd Mon Sep 17 00:00:00 2001 From: Win San Date: Tue, 21 May 2024 17:11:22 -0500 Subject: [PATCH] enhance(schedule): show next run for a schedule (#800) Co-authored-by: Kelly Merrick --- cypress/fixtures/schedules.json | 6 ++++-- cypress/integration/schedules.spec.js | 5 +++++ src/elm/Pages/Org_/Repo_/Hooks.elm | 4 ++-- src/elm/Pages/Org_/Repo_/Schedules.elm | 11 ++++++++++- src/elm/Vela.elm | 2 ++ 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/cypress/fixtures/schedules.json b/cypress/fixtures/schedules.json index 5297fa20a..377f29795 100644 --- a/cypress/fixtures/schedules.json +++ b/cypress/fixtures/schedules.json @@ -61,7 +61,8 @@ "updated_by": "CookieCat", "scheduled_at": 0, "branch": "main", - "error": "" + "error": "", + "next_run": 1685037152 }, { "id": 2, @@ -125,6 +126,7 @@ "updated_by": "CookieCat", "scheduled_at": 0, "branch": "main", - "error": "unable to trigger build for schedule Hourly: unable to schedule build: unable to compile pipeline configuration for github/octocat: 1 error occurred: * no \"version:\" YAML property provided" + "error": "unable to trigger build for schedule Hourly: unable to schedule build: unable to compile pipeline configuration for github/octocat: 1 error occurred: * no \"version:\" YAML property provided", + "next_run": 1685037152 } ] diff --git a/cypress/integration/schedules.spec.js b/cypress/integration/schedules.spec.js index f85959de9..b0447a382 100644 --- a/cypress/integration/schedules.spec.js +++ b/cypress/integration/schedules.spec.js @@ -117,6 +117,11 @@ context('Schedules', () => { cy.get('[data-label=scheduled-at]').should('exist'); }); }); + it('should show next run', () => { + cy.get('@dailySchedule').within(() => { + cy.get('[data-label=next-run]').should('exist'); + }); + }); it('should show updated by', () => { cy.get('@dailySchedule').within(() => { cy.get('[data-label=updated-by]').contains('CookieCat'); diff --git a/src/elm/Pages/Org_/Repo_/Hooks.elm b/src/elm/Pages/Org_/Repo_/Hooks.elm index 2394a042b..5252f2805 100644 --- a/src/elm/Pages/Org_/Repo_/Hooks.elm +++ b/src/elm/Pages/Org_/Repo_/Hooks.elm @@ -445,7 +445,7 @@ viewHookError hook = case hook.status of "skipped" -> tr [ class "skipped-data", Util.testAttribute "hooks-skipped" ] - [ td [ attribute "colspan" "6" ] + [ td [ attribute "colspan" (String.fromInt <| List.length tableHeaders) ] [ span [ class "skipped-content" ] [ text hook.error ] @@ -454,7 +454,7 @@ viewHookError hook = _ -> tr [ class "error-data", Util.testAttribute "hooks-error" ] - [ td [ attribute "colspan" "6" ] + [ td [ attribute "colspan" (String.fromInt <| List.length tableHeaders) ] [ code [ class "error-content" ] [ text hook.error ] diff --git a/src/elm/Pages/Org_/Repo_/Schedules.elm b/src/elm/Pages/Org_/Repo_/Schedules.elm index d2aa0cec5..a1094b5a4 100644 --- a/src/elm/Pages/Org_/Repo_/Schedules.elm +++ b/src/elm/Pages/Org_/Repo_/Schedules.elm @@ -333,6 +333,7 @@ tableHeaders = , ( Nothing, "enabled" ) , ( Nothing, "branch" ) , ( Nothing, "last scheduled at" ) + , ( Nothing, "next run" ) , ( Nothing, "updated by" ) , ( Nothing, "updated at" ) ] @@ -391,6 +392,14 @@ viewSchedule zone org repo schedule = [ text <| Util.humanReadableDateTimeWithDefault zone schedule.scheduled_at ] } + , Components.Table.viewItemCell + { dataLabel = "next-run" + , parentClassList = [] + , itemClassList = [] + , children = + [ text <| Util.humanReadableDateTimeWithDefault zone schedule.next_run + ] + } , Components.Table.viewItemCell { dataLabel = "updated-by" , parentClassList = [] @@ -426,7 +435,7 @@ viewScheduleError schedule = let msgRow = tr [ class "error-data", Util.testAttribute "schedules-error" ] - [ td [ attribute "colspan" "6" ] + [ td [ attribute "colspan" (String.fromInt <| List.length tableHeaders) ] [ code [ class "error-content" ] [ text schedule.error ] diff --git a/src/elm/Vela.elm b/src/elm/Vela.elm index 432709ec7..27d3fa70e 100644 --- a/src/elm/Vela.elm +++ b/src/elm/Vela.elm @@ -1565,6 +1565,7 @@ type alias Schedule = , updated_by : String , branch : String , error : String + , next_run : Int } @@ -1606,6 +1607,7 @@ decodeSchedule = |> optional "updated_by" string "" |> optional "branch" string "" |> optional "error" string "" + |> optional "next_run" int 0 decodeSchedules : Decoder (List Schedule)