Skip to content

Commit

Permalink
fix(deployments): add correct build variable to declared params (#837)
Browse files Browse the repository at this point in the history
Co-authored-by: wass3r <1301201+wass3r@users.noreply.github.com>
  • Loading branch information
ecrupper and wass3r authored Jan 24, 2025
1 parent bad7d38 commit db5e562
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 15 deletions.
55 changes: 50 additions & 5 deletions cypress/integration/deployment.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,67 @@ context('Deployment', () => {
});
});

cy.get('[data-test=parameters-list]')
cy.get('[data-test=parameters-list]').should('exist');

cy.get('[data-test=button-parameter-remove-key1]')
.should('exist')
.children()
.first()
.children()
.last()
.should('contain.text', 'remove');

cy.get('[data-test=parameters-inputs]').within(() => {
cy.get('[data-test=input-parameter-key]')
.should('exist')
.should('have.value', '');

cy.get('[data-test=input-parameter-value]')
.should('exist')
.should('have.value', '');

cy.get('[data-test=input-parameter-key]').type('key2');
cy.get('[data-test=input-parameter-value]').type('val2');
cy.get('[data-test=button-parameter-add]').click();

cy.get('[data-test=input-parameter-key]').type('key3');
cy.get('[data-test=input-parameter-value]').type('val3');
cy.get('[data-test=button-parameter-add]').click();
});

cy.get('[data-test=parameters-list]')
.children()
.first()
.contains('remove')
.click();

cy.get('[data-test=parameters-list]')
.should('exist')
.children()
.first()
.should('contain.text', 'key2=val2remove$DEPLOYMENT_PARAMETER_KEY2');
});

it('should handle multiple parameters', () => {
cy.login('/github/octocat/deployments/add');
cy.get('[data-test=parameters-inputs]').within(() => {
cy.get('[data-test=input-parameter-key]').type('key4');
cy.get('[data-test=input-parameter-value]').type('val4');
cy.get('[data-test=button-parameter-add]').click();
cy.get('[data-test=input-parameter-key]').type('key5');
cy.get('[data-test=input-parameter-value]').type('val5');
cy.get('[data-test=button-parameter-add]').click();
});

cy.get('[data-test=parameters-list]').children().should('have.length', 2);
cy.get('[data-test=parameters-list]')
.children()
.first()
.children()
.first()
.should('contain.text', 'key4=val4');
cy.get('[data-test=parameters-list]')
.children()
.last()
.children()
.first()
.should('contain.text', 'key5=val5');
});

it('add config parameters should work as intended', () => {
Expand Down
42 changes: 34 additions & 8 deletions src/elm/Pages/Org_/Repo_/Deployments/Add.elm
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import Components.Loading as Loading
import Components.Nav
import Dict exposing (Dict)
import Effect exposing (Effect)
import FeatherIcons
import Html exposing (Html, a, button, code, div, em, h2, main_, p, section, small, span, strong, text)
import Html.Attributes exposing (class, disabled, href)
import Html.Attributes exposing (attribute, class, disabled, href)
import Html.Events exposing (onClick)
import Http
import Http.Detailed
Expand Down Expand Up @@ -568,14 +569,39 @@ view shared route model =
if List.length model.parameters > 0 then
let
viewParameter parameter =
div [ class "parameter", class "chevron" ]
[ div [ class "name" ] [ text (parameter.key ++ "=" ++ parameter.value) ]
, button
[ class "button"
, class "-outline"
, onClick <| RemoveParameter parameter
div [ class "set-parameter" ]
[ div [ class "parameter", class "chevron" ]
[ div [ class "name" ] [ text (parameter.key ++ "=" ++ parameter.value) ]
, button
[ class "button"
, class "-outline"
, Util.testAttribute ("button-parameter-remove-" ++ parameter.key)
, onClick <| RemoveParameter parameter
]
[ text "remove"
]
]
[ text "remove"
, div [ class "small no-wrap" ]
[ span
[ class "copy-text"
, Util.testAttribute ("copy-parameter-" ++ parameter.key)
]
[ text ("$DEPLOYMENT_PARAMETER_" ++ String.toUpper parameter.key) ]
, div [ class "vert-icon-container" ]
[ button
[ class "copy-button"
, class "button"
, class "-icon"
, class "-white"
, attribute "data-clipboard-text" ("$DEPLOYMENT_PARAMETER_" ++ String.toUpper parameter.key)
, attribute "aria-label" "copy token"
, Util.testAttribute ("copy-parameter" ++ parameter.key)
]
[ FeatherIcons.copy
|> FeatherIcons.withSize 18
|> FeatherIcons.toHtml []
]
]
]
]
in
Expand Down
36 changes: 34 additions & 2 deletions src/scss/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1616,10 +1616,12 @@ details.build-toggle {
display: flex;
flex-direction: column;
align-items: flex-start;
margin-bottom: 2rem;
}

.parameters {
margin: 1rem 0;
.set-parameter {
display: flex;
align-items: center;
}

.image,
Expand Down Expand Up @@ -1788,3 +1790,33 @@ code.shell {
content: '$';
}
}

.small.no-wrap {
display: flex;
align-items: center;

font-size: 0.8em;
white-space: nowrap;
}

.copy-text {
margin-right: 5px;
margin-left: 5px;

font-family: monospace;

background-color: var(--color-bg-dark);
}

.copy-button {
margin-left: 5px;
padding: 0;

background: none;
border: none;
cursor: pointer;
}

.copy-icon {
font-size: 0.8em;
}

0 comments on commit db5e562

Please sign in to comment.