Skip to content

Commit

Permalink
fix: move worker status
Browse files Browse the repository at this point in the history
this was behind admin page before, but the endpoint doesn't require
special perms. chose to place this at /status/workers (instead of
/admin/workers). "status" is a reserved word at the org level (for
GitHub), so it shouldn't cause an issue.
  • Loading branch information
wass3r committed Sep 26, 2024
1 parent 7deddfb commit c2a745f
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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');
Expand All @@ -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');
Expand Down Expand Up @@ -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(() => {
Expand Down
5 changes: 0 additions & 5 deletions src/elm/Components/Tabs.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
144 changes: 72 additions & 72 deletions src/elm/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -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 ->
Expand Down Expand Up @@ -3688,9 +3688,6 @@ isAuthProtected routePath =
Route.Path.Admin_Settings ->
True

Route.Path.Admin_Workers ->
True

Route.Path.Dash_Secrets_Engine__Org_Org_ _ ->
True

Expand Down Expand Up @@ -3724,6 +3721,9 @@ isAuthProtected routePath =
Route.Path.Dashboards_Dashboard_ _ ->
True

Route.Path.Status_Workers ->
True

Route.Path.Org_ _ ->
True

Expand Down
4 changes: 2 additions & 2 deletions src/elm/Main/Pages/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down Expand Up @@ -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)


Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/elm/Main/Pages/Msg.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit c2a745f

Please sign in to comment.