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

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

Merged
merged 2 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions asset/assets_vfsdata.go

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions ui/app/src/Views/AlertList/AlertView.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down