Skip to content

Commit

Permalink
chore: cleaning up code, refactors, css refining
Browse files Browse the repository at this point in the history
chore: more cleanup
  • Loading branch information
plyr4 committed Oct 27, 2023
1 parent 29a5cbc commit eddc076
Show file tree
Hide file tree
Showing 11 changed files with 199 additions and 260 deletions.
2 changes: 1 addition & 1 deletion cypress/integration/graph.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ context('Build Graph', () => {
});
it('legend should show', () => {
cy.get('.elm-build-graph-legend').should('be.visible');
cy.get('.elm-build-graph-legend-item').should('have.length', 6);
cy.get('.elm-build-graph-legend-node').should('have.length', 6);
});
it('actions should show', () => {
cy.get('.elm-build-graph-actions').should('be.visible');
Expand Down
31 changes: 15 additions & 16 deletions src/elm/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ import Vela
, updateHooksPage
, updateHooksPager
, updateHooksPerPage
, updateModels
, updateOrgRepo
, updateOrgReposPage
, updateOrgReposPager
Expand All @@ -239,6 +238,7 @@ import Vela
, updateRepoEnabling
, updateRepoInitialized
, updateRepoLimit
, updateRepoModels
, updateRepoTimeout
)

Expand Down Expand Up @@ -969,7 +969,7 @@ update msg model =
}

um_ =
updateModels model rm bm ugm
updateRepoModels model rm bm ugm
in
( um_
, getBuildGraph um_ org repo buildNumber True
Expand All @@ -983,7 +983,7 @@ update msg model =
}

um_ =
updateModels model rm bm ugm
updateRepoModels model rm bm ugm
in
( um_
, renderBuildGraph um_ False
Expand All @@ -997,7 +997,7 @@ update msg model =
}

um_ =
updateModels model rm bm ugm
updateRepoModels model rm bm ugm
in
( um_
, renderBuildGraph um_ False
Expand All @@ -1011,7 +1011,7 @@ update msg model =
}

um_ =
updateModels model rm bm ugm
updateRepoModels model rm bm ugm
in
( um_
, renderBuildGraph um_ False
Expand All @@ -1032,7 +1032,7 @@ update msg model =
{ gm | focusedNode = -1 }

um_ =
updateModels model rm bm ugm
updateRepoModels model rm bm ugm
in
( ugm, renderBuildGraph um_ False )

Expand All @@ -1042,14 +1042,14 @@ update msg model =
{ gm | focusedNode = Maybe.withDefault -1 <| String.toInt interaction.node_id }

um_ =
updateModels model rm bm ugm
updateRepoModels model rm bm ugm
in
( ugm, renderBuildGraph um_ False )

_ ->
( model.repo.build.graph, Cmd.none )
in
( updateModels model rm bm ugm_
( updateRepoModels model rm bm ugm_
, Cmd.batch
[ Navigation.pushUrl model.navigationKey interaction.href
, cmd
Expand Down Expand Up @@ -1783,7 +1783,6 @@ update msg model =
Err error ->
( { model | repo = updateBuild (toFailure error) rm }, addError error )

-- ( { model | repo = updateBuildGraph (toFailure error) rm }, addError error )
DeploymentResponse response ->
case response of
Ok ( _, deployment ) ->
Expand Down Expand Up @@ -2133,7 +2132,7 @@ update msg model =
{ gm | buildNumber = buildNumber, graph = RemoteData.succeed g }

updatedModel =
updateModels model rm bm ugm
updateRepoModels model rm bm ugm

cmd =
if not sameBuild then
Expand Down Expand Up @@ -2646,7 +2645,7 @@ shouldRefresh page build =
Loading ->
False

-- check services when viewing services tab
-- check graph nodes when viewing graph tab
Pages.BuildGraph _ _ _ ->
case build.graph.graph of
Success graph ->
Expand Down Expand Up @@ -4946,6 +4945,11 @@ getBuildAndPipeline model org repo buildNumber expand =
Api.try (BuildAndPipelineResponse org repo expand) <| Api.getBuild model org repo buildNumber


getBuildGraph : Model -> Org -> Repo -> BuildNumber -> Bool -> Cmd Msg
getBuildGraph model org repo buildNumber refresh =
Api.try (BuildGraphResponse org repo buildNumber refresh) <| Api.getBuildGraph model org repo buildNumber


getDeployment : Model -> Org -> Repo -> DeploymentId -> Cmd Msg
getDeployment model org repo deploymentNumber =
Api.try DeploymentResponse <| Api.getDeployment model org repo <| Just deploymentNumber
Expand Down Expand Up @@ -5004,11 +5008,6 @@ getBuildServicesLogs model org repo buildNumber services logFocus refresh =
services


getBuildGraph : Model -> Org -> Repo -> BuildNumber -> Bool -> Cmd Msg
getBuildGraph model org repo buildNumber refresh =
Api.try (BuildGraphResponse org repo buildNumber refresh) <| Api.getBuildGraph model org repo buildNumber


restartBuild : Model -> Org -> Repo -> BuildNumber -> Cmd Msg
restartBuild model org repo buildNumber =
Api.try (RestartedBuildResponse org repo buildNumber) <| Api.restartBuild model org repo buildNumber
Expand Down
2 changes: 0 additions & 2 deletions src/elm/Pages/Build/Graph/DOT.elm
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ import Visualization.DOT
renderDOT : BuildModel.PartialModel a -> Repository -> Build -> BuildGraph -> String
renderDOT model repo build buildGraph =
let
-- todo: BUG: single step "step" sleep 10 pipeline when you hover
-- the text changes color???
isNodeFocused : String -> BuildGraphNode -> Bool
isNodeFocused filter n =
n.id
Expand Down
25 changes: 8 additions & 17 deletions src/elm/Pages/Build/Graph/Interop.elm
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,21 @@ import Vela exposing (encodeBuildGraphRenderData)
-}
renderBuildGraph : BuildModel.PartialModel a -> Bool -> Cmd msg
renderBuildGraph model centerOnDraw =
let
rm =
model.repo

bm =
rm.build

gm =
rm.build.graph
in
case rm.repo of
-- rendering the full graph requires repo, build and graph
case model.repo.repo of
Success r ->
case bm.build of
case model.repo.build.build of
Success b ->
case gm.graph of
case model.repo.build.graph.graph of
Success g ->
Interop.renderBuildGraph <|
encodeBuildGraphRenderData
{ dot = renderDOT model r b g
, buildID = b.id
, filter = gm.filter
, showServices = gm.showServices
, showSteps = gm.showSteps
, focusedNode = gm.focusedNode
, filter = model.repo.build.graph.filter
, showServices = model.repo.build.graph.showServices
, showSteps = model.repo.build.graph.showSteps
, focusedNode = model.repo.build.graph.focusedNode
, centerOnDraw = centerOnDraw
}

Expand Down
Loading

0 comments on commit eddc076

Please sign in to comment.