Skip to content

Commit

Permalink
feat: add key to secrets tables (#528)
Browse files Browse the repository at this point in the history
Co-authored-by: David May <[email protected]>
  • Loading branch information
kaymckay and wass3r authored Mar 11, 2022
1 parent 75d375d commit 2fb6f92
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/elm/Pages/Secrets/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import Vela
( Secret
, SecretType(..)
, Secrets
, secretToKey
, secretTypeToString
, secretsErrorLabel
)
Expand Down Expand Up @@ -256,6 +257,7 @@ secretsToRowsForSharedSecrets type_ secrets =
tableHeaders : Table.Columns
tableHeaders =
[ ( Nothing, "name" )
, ( Nothing, "key" )
, ( Nothing, "type" )
, ( Nothing, "events" )
, ( Nothing, "images" )
Expand All @@ -269,6 +271,7 @@ tableHeadersForSharedSecrets : Table.Columns
tableHeadersForSharedSecrets =
[ ( Nothing, "name" )
, ( Nothing, "team" )
, ( Nothing, "key" )
, ( Nothing, "type" )
, ( Nothing, "events" )
, ( Nothing, "images" )
Expand All @@ -288,6 +291,12 @@ renderSecret type_ secret =
, Util.testAttribute <| "secrets-row-name"
]
[ a [ updateSecretHref type_ secret ] [ text secret.name ] ]
, td
[ attribute "data-label" "key"
, scope "row"
, class "break-word"
]
[ text <| secretToKey secret ]
, td
[ attribute "data-label" "type"
, scope "row"
Expand Down Expand Up @@ -336,6 +345,12 @@ renderSharedSecret type_ secret =
, Util.testAttribute <| "secrets-row-team"
]
[ a [ Routes.href <| Routes.SharedSecrets "native" (percentEncode secret.org) (percentEncode secret.team) Nothing Nothing ] [ text secret.team ] ]
, td
[ attribute "data-label" "key"
, scope "row"
, class "break-word"
]
[ text <| secretToKey secret ]
, td
[ attribute "data-label" "type"
, scope "row"
Expand Down
18 changes: 18 additions & 0 deletions src/elm/Vela.elm
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ module Vela exposing
, encodeUpdateSecret
, encodeUpdateUser
, isComplete
, secretToKey
, secretTypeToString
, secretsErrorLabel
, statusToFavicon
Expand Down Expand Up @@ -1702,6 +1703,7 @@ type alias Secret =
, org : Org
, repo : Repo
, team : Key
, key : String
, name : String
, type_ : SecretType
, images : List String
Expand Down Expand Up @@ -1789,13 +1791,29 @@ maybeSecretTypeToMaybeString type_ =
Nothing


{-| secretToKey : helper to create secret key
-}
secretToKey : Secret -> String
secretToKey secret =
case secret.type_ of
SharedSecret ->
secret.org ++ "/" ++ secret.team ++ "/" ++ secret.name

OrgSecret ->
secret.org ++ "/" ++ secret.name

RepoSecret ->
secret.org ++ "/" ++ secret.repo ++ "/" ++ secret.name


decodeSecret : Decoder Secret
decodeSecret =
Decode.succeed Secret
|> optional "id" int -1
|> optional "org" string ""
|> optional "repo" string ""
|> optional "team" string ""
|> optional "key" string ""
|> optional "name" string ""
|> optional "type" secretTypeDecoder RepoSecret
|> optional "images" (Decode.list string) []
Expand Down

0 comments on commit 2fb6f92

Please sign in to comment.