Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(secrets): large names and general table render improvements #674

Merged
merged 13 commits into from
Jun 16, 2023
54 changes: 29 additions & 25 deletions src/elm/Pages/Secrets/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import Vela
, SecretType(..)
, Secrets
, secretTypeToString
, secretsErrorLabel
)


Expand Down Expand Up @@ -299,28 +298,28 @@ secretsToRowsForSharedSecrets type_ secrets =
-}
tableHeaders : Table.Columns
tableHeaders =
[ ( Nothing, "" )
[ ( Just "-icon", "" )
, ( Nothing, "name" )
, ( Nothing, "key" )
, ( Nothing, "type" )
, ( Nothing, "events" )
, ( Nothing, "images" )
, ( Nothing, "allow command" )
, ( Nothing, "allow commands" )
]


{-| tableHeadersForSharedSecrets : returns table headers for secrets table
-}
tableHeadersForSharedSecrets : Table.Columns
tableHeadersForSharedSecrets =
[ ( Nothing, "" )
[ ( Just "-icon", "" )
, ( Nothing, "name" )
, ( Nothing, "team" )
, ( Nothing, "key" )
, ( Nothing, "type" )
, ( Nothing, "events" )
, ( Nothing, "images" )
, ( Nothing, "allow command" )
, ( Nothing, "allow commands" )
]


Expand All @@ -340,6 +339,7 @@ renderSecret type_ secret =
[ attribute "data-label" "name"
, scope "row"
, class "break-word"
, class "secret-name"
, Util.testAttribute <| "secrets-row-name"
]
[ a [ updateSecretHref type_ secret ] [ text secret.name ] ]
Expand All @@ -349,7 +349,8 @@ renderSecret type_ secret =
, class "break-word"
, Util.testAttribute <| "secrets-row-key"
]
[ text <| secret.key ]
[ listItemView "" secret.key
]
, td
[ attribute "data-label" "type"
, scope "row"
Expand All @@ -369,7 +370,7 @@ renderSecret type_ secret =
, class "break-word"
]
<|
renderListCell secret.images "no images" "secret-image"
renderListCell secret.images "all images" "secret-image"
, td
[ attribute "data-label" "allow command"
, scope "row"
Expand Down Expand Up @@ -411,7 +412,8 @@ renderSharedSecret type_ secret =
, class "break-word"
, Util.testAttribute <| "secrets-row-key"
]
[ text <| secret.key ]
[ listItemView "" secret.key
]
, td
[ attribute "data-label" "type"
, scope "row"
Expand All @@ -431,7 +433,7 @@ renderSharedSecret type_ secret =
, class "break-word"
]
<|
renderListCell secret.images "no images" "secret-image"
renderListCell secret.images "all images" "secret-image"
, td
[ attribute "data-label" "allow command"
, scope "row"
Expand All @@ -449,22 +451,24 @@ renderListCell items none itemClassName =
[ text none ]

else
let
content =
items
|> List.sort
|> List.indexedMap
(\i item ->
if i + 1 < List.length items then
Just <| item ++ ", "

else
Just item
)
|> List.filterMap identity
|> String.concat
in
[ Html.code [ class itemClassName ] [ span [] [ text content ] ] ]
items
|> List.sort
|> List.map
(\item ->
listItemView itemClassName item
)


{-| listItemView : takes classname, text and size constraints and renders a list element
-}
listItemView : String -> String -> Html msg
listItemView className text_ =
div [ class className ]
[ span
[ class "list-item"
]
[ text text_ ]
]


{-| updateSecretHref : takes secret and secret type and returns href link for routing to view/edit secret page
Expand Down
21 changes: 21 additions & 0 deletions src/scss/_table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,35 @@

.table-base th {
padding: 0.625em;
overflow: hidden;

font-weight: bold;
white-space: nowrap;
text-align: left;
text-overflow: ellipsis;
}

.table-base td {
padding: 0.625em;

vertical-align: top;
}

.table-base td.secret-name {
max-width: 15rem;
}

.table-base td .list-item {
display: flex;
max-width: 12rem;
margin: 0.2rem 0;
padding: 0.4rem 0.8rem;
overflow: scroll;

color: var(--color-text);
font-size: 1rem;

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

.table-base .source-id {
Expand Down