UI: add 'Link' button to alerts in list (#2880)

* add 'Link' button

adds a button to each alert that allows linking to a single alert.
This works by generating a link that filters on _all_ of the alert's
label values, similar to the button to create a new silence from an
alert.

Signed-off-by: Christopher Taylor <chris.taylor@soundcloud.com>

* update asset/assets_vfsdata.go

Signed-off-by: Christopher Taylor <chris.taylor@soundcloud.com>

Signed-off-by: Christopher Taylor <chris.taylor@soundcloud.com>
This commit is contained in:
Christopher Taylor 2022-10-05 18:29:12 +02:00 committed by GitHub
parent ae510d09c0
commit 2c04c5aaa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@ -6,6 +6,7 @@ import Html exposing (..)
import Html.Attributes exposing (class, href, style, title, value)
import Html.Events exposing (onClick)
import Types exposing (Msg(..))
import Url exposing (percentEncode)
import Utils.Filter
import Views.AlertList.Types exposing (AlertListMsg(..))
import Views.FilterBar.Types as FilterBarTypes
@ -47,6 +48,7 @@ view labels maybeActiveId alert =
text ""
, silenceButton alert
, inhibitedIcon alert
, linkButton alert
]
, if maybeActiveId == Just alert.fingerprint then
table [ class "table w-100 mb-1" ] (List.map annotation <| Dict.toList alert.annotations)
@ -97,6 +99,26 @@ addLabelMsg ( key, value ) =
|> MsgForAlertList
linkButton : GettableAlert -> Html Msg
linkButton alert =
let
link =
alert.labels
|> Dict.toList
|> List.map (\( k, v ) -> Utils.Filter.Matcher k Utils.Filter.Eq v)
|> Utils.Filter.stringifyFilter
|> percentEncode
|> (++) "#/alerts?filter="
in
a
[ class "btn btn-outline-info border-0"
, href link
]
[ i [ class "fa fa-link mr-2" ] []
, text "Link"
]
silenceButton : GettableAlert -> Html Msg
silenceButton alert =
case List.head alert.status.silencedBy of