diff --git a/cypress/integration/admin_workers.spec.js b/cypress/integration/status_workers.spec.js similarity index 91% rename from cypress/integration/admin_workers.spec.js rename to cypress/integration/status_workers.spec.js index fee23f4d0..21644f088 100644 --- a/cypress/integration/admin_workers.spec.js +++ b/cypress/integration/status_workers.spec.js @@ -9,7 +9,7 @@ context('Workers', () => { method: 'GET', url: '*api/v1/user*', status: 200, - response: 'fixture:user_admin.json', + response: 'fixture:user.json', }); }); context('server returning workers error', () => { @@ -20,7 +20,7 @@ context('Workers', () => { status: 500, response: 'server error', }); - cy.loginAdmin('/admin/workers'); + cy.login('/status/workers'); }); it('workers table should not show', () => { cy.get('[data-test=workers]').should('not.be.visible'); @@ -40,7 +40,7 @@ context('Workers', () => { cy.route('GET', '*api/v1/workers*', 'fixture:workers_5.json').as( 'workers', ); - cy.loginAdmin('/admin/workers'); + cy.login('/status/workers'); }); it('workers table should show', () => { cy.get('[data-test=workers-table]').should('be.visible'); @@ -73,23 +73,23 @@ context('Workers', () => { beforeEach(() => { cy.server(); cy.workerPages(); - cy.loginAdmin('/admin/workers'); + cy.login('/status/workers'); }); it('workers table should show 10 workers', () => { cy.get('[data-test=workers-row]').should('have.length', 10); }); it('shows page 2 of the workers', () => { - cy.visit('/admin/workers?page=2'); + cy.visit('/status/workers?page=2'); cy.get('[data-test=workers-row]').should('have.length', 10); cy.get('[data-test=pager-next]').should('be.disabled'); }); it("loads the first page when hitting the 'previous' button", () => { - cy.visit('/admin/workers?page=2'); + cy.visit('/status/workers?page=2'); cy.get('[data-test=pager-previous]') .should('have.length', 2) .first() .click(); - cy.location('pathname').should('eq', '/admin/workers'); + cy.location('pathname').should('eq', '/status/workers'); }); context('force 550, 750 resolution', () => { beforeEach(() => { diff --git a/src/elm/Components/Tabs.elm b/src/elm/Components/Tabs.elm index e0fe8756e..d5ba6b65b 100644 --- a/src/elm/Components/Tabs.elm +++ b/src/elm/Components/Tabs.elm @@ -331,11 +331,6 @@ viewAdminTabs shared props = , isAlerting = False , show = True } - , { name = "Workers" - , toPath = Route.Path.Admin_Workers - , isAlerting = False - , show = True - } ] in view props.tabHistory props.currentPath tabs "jump-bar-admin" diff --git a/src/elm/Main.elm b/src/elm/Main.elm index 501d7e659..d99ca23a9 100644 --- a/src/elm/Main.elm +++ b/src/elm/Main.elm @@ -34,7 +34,6 @@ import Pages.Account.Logout import Pages.Account.Settings import Pages.Account.SourceRepos import Pages.Admin.Settings -import Pages.Admin.Workers import Pages.Dash.Secrets.Engine_.Org.Org_ import Pages.Dash.Secrets.Engine_.Org.Org_.Add import Pages.Dash.Secrets.Engine_.Org.Org_.Name_ @@ -64,6 +63,7 @@ import Pages.Org_.Repo_.Schedules.Add import Pages.Org_.Repo_.Schedules.Name_ import Pages.Org_.Repo_.Settings import Pages.Org_.Repo_.Tags +import Pages.Status.Workers import Route exposing (Route) import Route.Path import Shared @@ -704,30 +704,6 @@ initPageAndLayout model = } ) - Route.Path.Admin_Workers -> - runWhenAuthenticatedWithLayout - model - (\user -> - let - page : Page.Page Pages.Admin.Workers.Model Pages.Admin.Workers.Msg - page = - Pages.Admin.Workers.page user model.shared (Route.fromUrl () model.url) - - ( pageModel, pageEffect ) = - Page.init page () - in - { page = - Tuple.mapBoth - Main.Pages.Model.Admin_Workers - (Effect.map Main.Pages.Msg.Admin_Workers >> fromPageEffect model) - ( pageModel, pageEffect ) - , layout = - Page.layout pageModel page - |> Maybe.map (Layouts.map (Main.Pages.Msg.Admin_Workers >> Page)) - |> Maybe.map (initLayout model) - } - ) - Route.Path.Dash_Secrets_Engine__Org_Org_ params -> runWhenAuthenticatedWithLayout model @@ -992,6 +968,30 @@ initPageAndLayout model = } ) + Route.Path.Status_Workers -> + runWhenAuthenticatedWithLayout + model + (\user -> + let + page : Page.Page Pages.Status.Workers.Model Pages.Status.Workers.Msg + page = + Pages.Status.Workers.page user model.shared (Route.fromUrl () model.url) + + ( pageModel, pageEffect ) = + Page.init page () + in + { page = + Tuple.mapBoth + Main.Pages.Model.Status_Workers + (Effect.map Main.Pages.Msg.Status_Workers >> fromPageEffect model) + ( pageModel, pageEffect ) + , layout = + Page.layout pageModel page + |> Maybe.map (Layouts.map (Main.Pages.Msg.Status_Workers >> Page)) + |> Maybe.map (initLayout model) + } + ) + Route.Path.Org_ params -> runWhenAuthenticatedWithLayout model @@ -1670,16 +1670,6 @@ updateFromPage msg model = (Page.update (Pages.Admin.Settings.page user model.shared (Route.fromUrl () model.url)) pageMsg pageModel) ) - ( Main.Pages.Msg.Admin_Workers pageMsg, Main.Pages.Model.Admin_Workers pageModel ) -> - runWhenAuthenticated - model - (\user -> - Tuple.mapBoth - Main.Pages.Model.Admin_Workers - (Effect.map Main.Pages.Msg.Admin_Workers >> fromPageEffect model) - (Page.update (Pages.Admin.Workers.page user model.shared (Route.fromUrl () model.url)) pageMsg pageModel) - ) - ( Main.Pages.Msg.Dash_Secrets_Engine__Org_Org_ pageMsg, Main.Pages.Model.Dash_Secrets_Engine__Org_Org_ params pageModel ) -> runWhenAuthenticated model @@ -1790,6 +1780,16 @@ updateFromPage msg model = (Page.update (Pages.Dashboards.Dashboard_.page user model.shared (Route.fromUrl params model.url)) pageMsg pageModel) ) + ( Main.Pages.Msg.Status_Workers pageMsg, Main.Pages.Model.Status_Workers pageModel ) -> + runWhenAuthenticated + model + (\user -> + Tuple.mapBoth + Main.Pages.Model.Status_Workers + (Effect.map Main.Pages.Msg.Status_Workers >> fromPageEffect model) + (Page.update (Pages.Status.Workers.page user model.shared (Route.fromUrl () model.url)) pageMsg pageModel) + ) + ( Main.Pages.Msg.Org_ pageMsg, Main.Pages.Model.Org_ params pageModel ) -> runWhenAuthenticated model @@ -2087,12 +2087,6 @@ toLayoutFromPage model = |> Maybe.andThen (Page.layout pageModel) |> Maybe.map (Layouts.map (Main.Pages.Msg.Admin_Settings >> Page)) - Main.Pages.Model.Admin_Workers pageModel -> - Route.fromUrl () model.url - |> toAuthProtectedPage model Pages.Admin.Workers.page - |> Maybe.andThen (Page.layout pageModel) - |> Maybe.map (Layouts.map (Main.Pages.Msg.Admin_Workers >> Page)) - Main.Pages.Model.Dash_Secrets_Engine__Org_Org_ params pageModel -> Route.fromUrl params model.url |> toAuthProtectedPage model Pages.Dash.Secrets.Engine_.Org.Org_.page @@ -2159,6 +2153,12 @@ toLayoutFromPage model = |> Maybe.andThen (Page.layout pageModel) |> Maybe.map (Layouts.map (Main.Pages.Msg.Dashboards_Dashboard_ >> Page)) + Main.Pages.Model.Status_Workers pageModel -> + Route.fromUrl () model.url + |> toAuthProtectedPage model Pages.Status.Workers.page + |> Maybe.andThen (Page.layout pageModel) + |> Maybe.map (Layouts.map (Main.Pages.Msg.Status_Workers >> Page)) + Main.Pages.Model.Org_ params pageModel -> Route.fromUrl params model.url |> toAuthProtectedPage model Pages.Org_.page @@ -2357,15 +2357,6 @@ subscriptions model = ) (Auth.onPageLoad model.shared (Route.fromUrl () model.url)) - Main.Pages.Model.Admin_Workers pageModel -> - Auth.Action.subscriptions - (\user -> - Page.subscriptions (Pages.Admin.Workers.page user model.shared (Route.fromUrl () model.url)) pageModel - |> Sub.map Main.Pages.Msg.Admin_Workers - |> Sub.map Page - ) - (Auth.onPageLoad model.shared (Route.fromUrl () model.url)) - Main.Pages.Model.Dash_Secrets_Engine__Org_Org_ params pageModel -> Auth.Action.subscriptions (\user -> @@ -2465,6 +2456,15 @@ subscriptions model = ) (Auth.onPageLoad model.shared (Route.fromUrl () model.url)) + Main.Pages.Model.Status_Workers pageModel -> + Auth.Action.subscriptions + (\user -> + Page.subscriptions (Pages.Status.Workers.page user model.shared (Route.fromUrl () model.url)) pageModel + |> Sub.map Main.Pages.Msg.Status_Workers + |> Sub.map Page + ) + (Auth.onPageLoad model.shared (Route.fromUrl () model.url)) + Main.Pages.Model.Org_ params pageModel -> Auth.Action.subscriptions (\user -> @@ -2867,15 +2867,6 @@ viewPage model = ) (Auth.onPageLoad model.shared (Route.fromUrl () model.url)) - Main.Pages.Model.Admin_Workers pageModel -> - Auth.Action.view (View.map never (Auth.viewCustomPage model.shared (Route.fromUrl () model.url))) - (\user -> - Page.view (Pages.Admin.Workers.page user model.shared (Route.fromUrl () model.url)) pageModel - |> View.map Main.Pages.Msg.Admin_Workers - |> View.map Page - ) - (Auth.onPageLoad model.shared (Route.fromUrl () model.url)) - Main.Pages.Model.Dash_Secrets_Engine__Org_Org_ params pageModel -> Auth.Action.view (View.map never (Auth.viewCustomPage model.shared (Route.fromUrl () model.url))) (\user -> @@ -2975,6 +2966,15 @@ viewPage model = ) (Auth.onPageLoad model.shared (Route.fromUrl () model.url)) + Main.Pages.Model.Status_Workers pageModel -> + Auth.Action.view (View.map never (Auth.viewCustomPage model.shared (Route.fromUrl () model.url))) + (\user -> + Page.view (Pages.Status.Workers.page user model.shared (Route.fromUrl () model.url)) pageModel + |> View.map Main.Pages.Msg.Status_Workers + |> View.map Page + ) + (Auth.onPageLoad model.shared (Route.fromUrl () model.url)) + Main.Pages.Model.Org_ params pageModel -> Auth.Action.view (View.map never (Auth.viewCustomPage model.shared (Route.fromUrl () model.url))) (\user -> @@ -3238,16 +3238,6 @@ toPageUrlHookCmd model routes = ) (Auth.onPageLoad model.shared (Route.fromUrl () model.url)) - Main.Pages.Model.Admin_Workers pageModel -> - Auth.Action.command - (\user -> - Page.toUrlMessages routes (Pages.Admin.Workers.page user model.shared (Route.fromUrl () model.url)) - |> List.map Main.Pages.Msg.Admin_Workers - |> List.map Page - |> toCommands - ) - (Auth.onPageLoad model.shared (Route.fromUrl () model.url)) - Main.Pages.Model.Dash_Secrets_Engine__Org_Org_ params pageModel -> Auth.Action.command (\user -> @@ -3358,6 +3348,16 @@ toPageUrlHookCmd model routes = ) (Auth.onPageLoad model.shared (Route.fromUrl () model.url)) + Main.Pages.Model.Status_Workers pageModel -> + Auth.Action.command + (\user -> + Page.toUrlMessages routes (Pages.Status.Workers.page user model.shared (Route.fromUrl () model.url)) + |> List.map Main.Pages.Msg.Status_Workers + |> List.map Page + |> toCommands + ) + (Auth.onPageLoad model.shared (Route.fromUrl () model.url)) + Main.Pages.Model.Org_ params pageModel -> Auth.Action.command (\user -> @@ -3688,9 +3688,6 @@ isAuthProtected routePath = Route.Path.Admin_Settings -> True - Route.Path.Admin_Workers -> - True - Route.Path.Dash_Secrets_Engine__Org_Org_ _ -> True @@ -3724,6 +3721,9 @@ isAuthProtected routePath = Route.Path.Dashboards_Dashboard_ _ -> True + Route.Path.Status_Workers -> + True + Route.Path.Org_ _ -> True diff --git a/src/elm/Main/Pages/Model.elm b/src/elm/Main/Pages/Model.elm index c9d771308..48ef00adf 100644 --- a/src/elm/Main/Pages/Model.elm +++ b/src/elm/Main/Pages/Model.elm @@ -11,7 +11,6 @@ import Pages.Account.Logout import Pages.Account.Settings import Pages.Account.SourceRepos import Pages.Admin.Settings -import Pages.Admin.Workers import Pages.Dash.Secrets.Engine_.Org.Org_ import Pages.Dash.Secrets.Engine_.Org.Org_.Add import Pages.Dash.Secrets.Engine_.Org.Org_.Name_ @@ -41,6 +40,7 @@ import Pages.Org_.Repo_.Schedules.Add import Pages.Org_.Repo_.Schedules.Name_ import Pages.Org_.Repo_.Settings import Pages.Org_.Repo_.Tags +import Pages.Status.Workers import View exposing (View) @@ -52,7 +52,6 @@ type Model | Account_Settings Pages.Account.Settings.Model | Account_SourceRepos Pages.Account.SourceRepos.Model | Admin_Settings Pages.Admin.Settings.Model - | Admin_Workers Pages.Admin.Workers.Model | Dash_Secrets_Engine__Org_Org_ { engine : String, org : String } Pages.Dash.Secrets.Engine_.Org.Org_.Model | Dash_Secrets_Engine__Org_Org__Add { engine : String, org : String } Pages.Dash.Secrets.Engine_.Org.Org_.Add.Model | Dash_Secrets_Engine__Org_Org__Name_ { engine : String, org : String, name : String } Pages.Dash.Secrets.Engine_.Org.Org_.Name_.Model @@ -64,6 +63,7 @@ type Model | Dash_Secrets_Engine__Shared_Org__Team__Name_ { engine : String, org : String, team : String, name : String } Pages.Dash.Secrets.Engine_.Shared.Org_.Team_.Name_.Model | Dashboards Pages.Dashboards.Model | Dashboards_Dashboard_ { dashboard : String } Pages.Dashboards.Dashboard_.Model + | Status_Workers Pages.Status.Workers.Model | Org_ { org : String } Pages.Org_.Model | Org__Builds { org : String } Pages.Org_.Builds.Model | Org__Repo_ { org : String, repo : String } Pages.Org_.Repo_.Model diff --git a/src/elm/Main/Pages/Msg.elm b/src/elm/Main/Pages/Msg.elm index 84e1f3f5c..5e123569c 100644 --- a/src/elm/Main/Pages/Msg.elm +++ b/src/elm/Main/Pages/Msg.elm @@ -11,7 +11,6 @@ import Pages.Account.Logout import Pages.Account.Settings import Pages.Account.SourceRepos import Pages.Admin.Settings -import Pages.Admin.Workers import Pages.Dash.Secrets.Engine_.Org.Org_ import Pages.Dash.Secrets.Engine_.Org.Org_.Add import Pages.Dash.Secrets.Engine_.Org.Org_.Name_ @@ -41,6 +40,7 @@ import Pages.Org_.Repo_.Schedules.Add import Pages.Org_.Repo_.Schedules.Name_ import Pages.Org_.Repo_.Settings import Pages.Org_.Repo_.Tags +import Pages.Status.Workers type Msg @@ -51,7 +51,6 @@ type Msg | Account_Settings Pages.Account.Settings.Msg | Account_SourceRepos Pages.Account.SourceRepos.Msg | Admin_Settings Pages.Admin.Settings.Msg - | Admin_Workers Pages.Admin.Workers.Msg | Dash_Secrets_Engine__Org_Org_ Pages.Dash.Secrets.Engine_.Org.Org_.Msg | Dash_Secrets_Engine__Org_Org__Add Pages.Dash.Secrets.Engine_.Org.Org_.Add.Msg | Dash_Secrets_Engine__Org_Org__Name_ Pages.Dash.Secrets.Engine_.Org.Org_.Name_.Msg @@ -63,6 +62,7 @@ type Msg | Dash_Secrets_Engine__Shared_Org__Team__Name_ Pages.Dash.Secrets.Engine_.Shared.Org_.Team_.Name_.Msg | Dashboards Pages.Dashboards.Msg | Dashboards_Dashboard_ Pages.Dashboards.Dashboard_.Msg + | Status_Workers Pages.Status.Workers.Msg | Org_ Pages.Org_.Msg | Org__Builds Pages.Org_.Builds.Msg | Org__Repo_ Pages.Org_.Repo_.Msg diff --git a/src/elm/Pages/Admin/Workers.elm b/src/elm/Pages/Status/Workers.elm similarity index 89% rename from src/elm/Pages/Admin/Workers.elm rename to src/elm/Pages/Status/Workers.elm index 9c8d88472..d1d086798 100644 --- a/src/elm/Pages/Admin/Workers.elm +++ b/src/elm/Pages/Status/Workers.elm @@ -3,29 +3,19 @@ SPDX-License-Identifier: Apache-2.0 --} -module Pages.Admin.Workers exposing (Model, Msg, page) +module Pages.Status.Workers exposing (Model, Msg, page) import Api.Pagination import Auth +import Components.Crumbs import Components.Loading +import Components.Nav import Components.Pager import Components.Table import Dict import Effect exposing (Effect) -import Html - exposing - ( Html - , a - , div - , span - , text - , tr - ) -import Html.Attributes - exposing - ( class - , href - ) +import Html exposing (Html, a, div, main_, span, text, tr) +import Html.Attributes exposing (class, href) import Http import Http.Detailed import Layouts @@ -33,6 +23,7 @@ import LinkHeader exposing (WebLink) import Page exposing (Page) import RemoteData exposing (WebData) import Route exposing (Route) +import Route.Path import Shared import Time import Utils.Errors as Errors @@ -42,8 +33,6 @@ import Vela import View exposing (View) -{-| page : shared model, route, and returns the page. --} page : Auth.User -> Shared.Model -> Route () -> Page Model Msg page user shared route = Page.new @@ -59,22 +48,17 @@ page user shared route = -- LAYOUT -{-| toLayout : takes model and passes the page info to Layouts. +{-| toLayout : takes user, model, and passes the home page info to Layouts. -} toLayout : Auth.User -> Model -> Layouts.Layout Msg toLayout user model = - Layouts.Default_Admin - { navButtons = [] - , utilButtons = [] - , helpCommands = - [ { name = "List Workers" - , content = "vela get workers" - , docs = Just "cli/worker/get" + Layouts.Default + { helpCommands = + [ { name = "" + , content = "resources on this page not yet supported via the CLI" + , docs = Nothing } ] - , crumbs = - [ ( "Admin", Nothing ) - ] } @@ -82,16 +66,12 @@ toLayout user model = -- INIT -{-| Model : alias for model for the page. --} type alias Model = { workers : WebData (List Vela.Worker) , pager : List WebLink } -{-| init : initializes page with no arguments. --} init : Shared.Model -> Route () -> () -> ( Model, Effect Msg ) init shared route () = ( { workers = RemoteData.Loading @@ -111,8 +91,6 @@ init shared route () = -- UPDATE -{-| Msg : custom type with possible messages. --} type Msg = -- WORKERS GetWorkersResponse (Result (Http.Detailed.Error String) ( Http.Metadata, List Vela.Worker )) @@ -121,12 +99,9 @@ type Msg | Tick { time : Time.Posix, interval : Interval.Interval } -{-| update : takes current models, message, and returns an updated model and effect. --} update : Shared.Model -> Route () -> Msg -> Model -> ( Model, Effect Msg ) update shared route msg model = case msg of - -- WORKERS GetWorkersResponse response -> case response of Ok ( meta, workers ) -> @@ -181,8 +156,6 @@ update shared route msg model = -- SUBSCRIPTIONS -{-| subscriptions : takes model and returns subscriptions. --} subscriptions : Model -> Sub Msg subscriptions model = Interval.tickEveryFiveSeconds Tick @@ -192,19 +165,30 @@ subscriptions model = -- VIEW -{-| view : takes models, route, and creates the html for the page. --} view : Shared.Model -> Route () -> Model -> View Msg view shared route model = - { title = "" + let + crumbs = + [ ( "Overview", Just Route.Path.Home_ ) + , ( "Status", Nothing ) + , ( "Workers", Nothing ) + ] + in + { title = "Worker Status" , body = - [ viewWorkers shared model route - , Components.Pager.view - { show = True - , links = model.pager - , labels = Components.Pager.defaultLabels - , msg = GotoPage - } + [ Components.Nav.view + shared + route + { buttons = [], crumbs = Components.Crumbs.view route.path crumbs } + , main_ [ class "content-wrap" ] + [ viewWorkers shared model route + , Components.Pager.view + { show = True + , links = model.pager + , labels = Components.Pager.defaultLabels + , msg = GotoPage + } + ] ] } diff --git a/src/elm/Route/Path.elm b/src/elm/Route/Path.elm index 4381696bb..4a32b6c13 100644 --- a/src/elm/Route/Path.elm +++ b/src/elm/Route/Path.elm @@ -19,7 +19,6 @@ type Path | Account_Settings | Account_SourceRepos | Admin_Settings - | Admin_Workers | Dash_Secrets_Engine__Org_Org_ { engine : String, org : String } | Dash_Secrets_Engine__Org_Org__Add { engine : String, org : String } | Dash_Secrets_Engine__Org_Org__Name_ { engine : String, org : String, name : String } @@ -31,6 +30,7 @@ type Path | Dash_Secrets_Engine__Shared_Org__Team__Name_ { engine : String, org : String, team : String, name : String } | Dashboards | Dashboards_Dashboard_ { dashboard : String } + | Status_Workers | Org_ { org : String } | Org__Builds { org : String } | Org__Repo_ { org : String, repo : String } @@ -87,9 +87,6 @@ fromString urlPath = "admin" :: "settings" :: [] -> Just Admin_Settings - "admin" :: "workers" :: [] -> - Just Admin_Workers - "-" :: "secrets" :: engine_ :: "org" :: org_ :: [] -> Dash_Secrets_Engine__Org_Org_ { engine = engine_ @@ -171,6 +168,9 @@ fromString urlPath = } |> Just + "status" :: "workers" :: [] -> + Just Status_Workers + org_ :: [] -> Org_ { org = org_ @@ -322,9 +322,6 @@ toString path = Admin_Settings -> [ "admin", "settings" ] - Admin_Workers -> - [ "admin", "workers" ] - Dash_Secrets_Engine__Org_Org_ params -> [ "-", "secrets", params.engine, "org", params.org ] @@ -358,6 +355,9 @@ toString path = Dashboards_Dashboard_ params -> [ "dashboards", params.dashboard ] + Status_Workers -> + [ "status", "workers" ] + Org_ params -> [ params.org ]