From 6178d88773e4a6754029e2615ba25bde6c1f6e32 Mon Sep 17 00:00:00 2001 From: davidvader Date: Wed, 14 Feb 2024 16:44:29 -0600 Subject: [PATCH] refactor: add link to alerts --- src/elm/Components/Alerts.elm | 7 ++-- src/elm/Effect.elm | 8 ++--- src/elm/Layouts/Default.elm | 6 +++- src/elm/Layouts/Default/Build.elm | 35 +++++++++++++------ src/elm/Pages/Account/Settings.elm | 6 +++- src/elm/Pages/Account/SourceRepos.elm | 6 +++- src/elm/Pages/Org_/Builds.elm | 34 ++++++++++++------ src/elm/Pages/Org_/Repo_.elm | 34 ++++++++++++------ src/elm/Pages/Org_/Repo_/Deployments/Add.elm | 1 + src/elm/Pages/Org_/Repo_/Hooks.elm | 6 +++- src/elm/Pages/Org_/Repo_/Schedules/Add.elm | 1 + src/elm/Pages/Org_/Repo_/Schedules/Edit_.elm | 2 ++ src/elm/Pages/Org_/Repo_/Settings.elm | 12 ++++++- src/elm/Pages/Secrets/Engine_/Org/Org_.elm | 6 +++- .../Pages/Secrets/Engine_/Org/Org_/Add.elm | 1 + .../Pages/Secrets/Engine_/Org/Org_/Edit_.elm | 2 ++ .../Pages/Secrets/Engine_/Repo/Org_/Repo_.elm | 6 +++- .../Secrets/Engine_/Repo/Org_/Repo_/Add.elm | 1 + .../Secrets/Engine_/Repo/Org_/Repo_/Edit_.elm | 2 ++ .../Secrets/Engine_/Shared/Org_/Team_.elm | 6 +++- .../Secrets/Engine_/Shared/Org_/Team_/Add.elm | 1 + .../Engine_/Shared/Org_/Team_/Edit_.elm | 2 ++ src/elm/Shared.elm | 17 ++++----- src/elm/Shared/Msg.elm | 8 ++--- 24 files changed, 153 insertions(+), 57 deletions(-) diff --git a/src/elm/Components/Alerts.elm b/src/elm/Components/Alerts.elm index f3948987f..5106348e9 100644 --- a/src/elm/Components/Alerts.elm +++ b/src/elm/Components/Alerts.elm @@ -3,12 +3,13 @@ SPDX-License-Identifier: Apache-2.0 --} -module Components.Alerts exposing (Alert(..), errorConfig, successConfig, view) +module Components.Alerts exposing (Alert(..), Link, errorConfig, successConfig, view) import FeatherIcons import Html exposing (Html, a, button, div, h1, p, text) import Html.Attributes exposing (attribute, class, href) import Html.Events +import Route.Path import Toasty as Alerting import Toasty.Defaults as Alerts import Utils.Helpers as Util @@ -27,7 +28,7 @@ type alias Label = type alias Destination = - String + Route.Path.Path type Alert @@ -139,4 +140,4 @@ errorConfig = -} toHyperlink : Link -> Html msg toHyperlink ( label, destination ) = - a [ href destination, Util.testAttribute "alert-hyperlink" ] [ text label ] + a [ Route.Path.href destination, Util.testAttribute "alert-hyperlink" ] [ text label ] diff --git a/src/elm/Effect.elm b/src/elm/Effect.elm index f8307ed9d..da4b6a8af 100644 --- a/src/elm/Effect.elm +++ b/src/elm/Effect.elm @@ -27,7 +27,7 @@ import Api.Api as Api import Api.Operations import Auth.Session import Browser.Navigation -import Components.Alerts exposing (Alert) +import Components.Alerts import Dict exposing (Dict) import Http import Http.Detailed @@ -1202,17 +1202,17 @@ handleHttpError options = SendSharedMsg <| Shared.Msg.HandleHttpError options.httpError -addAlertSuccess : { content : String, addToastIfUnique : Bool } -> Effect msg +addAlertSuccess : { content : String, addToastIfUnique : Bool, link : Maybe Components.Alerts.Link } -> Effect msg addAlertSuccess options = SendSharedMsg <| Shared.Msg.AddAlertSuccess options -addAlertError : { content : String, addToastIfUnique : Bool } -> Effect msg +addAlertError : { content : String, addToastIfUnique : Bool, link : Maybe Components.Alerts.Link } -> Effect msg addAlertError options = SendSharedMsg <| Shared.Msg.AddAlertError options -alertsUpdate : { alert : Alerting.Msg Alert } -> Effect msg +alertsUpdate : { alert : Alerting.Msg Components.Alerts.Alert } -> Effect msg alertsUpdate options = SendSharedMsg <| Shared.Msg.AlertsUpdate options.alert diff --git a/src/elm/Layouts/Default.elm b/src/elm/Layouts/Default.elm index 77f287e38..1718b1e35 100644 --- a/src/elm/Layouts/Default.elm +++ b/src/elm/Layouts/Default.elm @@ -122,7 +122,11 @@ update msg model = AddAlertCopiedToClipboard contentCopied -> ( model - , Effect.addAlertSuccess { content = "'" ++ contentCopied ++ "' copied to clipboard.", addToastIfUnique = False } + , Effect.addAlertSuccess + { content = "'" ++ contentCopied ++ "' copied to clipboard." + , addToastIfUnique = False + , link = Nothing + } ) diff --git a/src/elm/Layouts/Default/Build.elm b/src/elm/Layouts/Default/Build.elm index 63200cd3f..ecc871c44 100644 --- a/src/elm/Layouts/Default/Build.elm +++ b/src/elm/Layouts/Default/Build.elm @@ -5,6 +5,7 @@ SPDX-License-Identifier: Apache-2.0 module Layouts.Default.Build exposing (Model, Msg, Props, layout, map) +import Components.Alerts import Components.Build import Components.Crumbs import Components.Help @@ -194,13 +195,15 @@ update props shared route msg model = restartedBuild = "Build " ++ String.join "/" [ options.org, options.repo, options.buildNumber ] - newBuildNumber = - String.fromInt <| build.number - - newBuild = - String.join "/" [ "", options.org, options.repo, newBuildNumber ] - - -- todo: create new build link, add to toastie, refresh builds + newBuildLink = + Just + ( "View Build #" ++ String.fromInt build.number + , Route.Path.Org_Repo_Build_ + { org = options.org + , repo = options.repo + , buildNumber = String.fromInt build.number + } + ) in ( model , Effect.batch @@ -211,7 +214,11 @@ update props shared route msg model = , org = props.org , repo = props.repo } - , Effect.addAlertSuccess { content = restartedBuild ++ " restarted.", addToastIfUnique = True } + , Effect.addAlertSuccess + { content = restartedBuild ++ " restarted." + , addToastIfUnique = True + , link = newBuildLink + } ] ) @@ -249,7 +256,11 @@ update props shared route msg model = , repo = props.repo , buildNumber = props.buildNumber } - , Effect.addAlertSuccess { content = canceledBuild ++ " canceled.", addToastIfUnique = True } + , Effect.addAlertSuccess + { content = canceledBuild ++ " canceled." + , addToastIfUnique = True + , link = Nothing + } ] ) @@ -287,7 +298,11 @@ update props shared route msg model = , repo = props.repo , buildNumber = props.buildNumber } - , Effect.addAlertSuccess { content = approvedBuild ++ " approved.", addToastIfUnique = True } + , Effect.addAlertSuccess + { content = approvedBuild ++ " approved." + , addToastIfUnique = True + , link = Nothing + } ] ) diff --git a/src/elm/Pages/Account/Settings.elm b/src/elm/Pages/Account/Settings.elm index 3874333be..e76d3c3ab 100644 --- a/src/elm/Pages/Account/Settings.elm +++ b/src/elm/Pages/Account/Settings.elm @@ -106,7 +106,11 @@ update msg model = -- ALERTS AddAlertCopiedToClipboard contentCopied -> ( model - , Effect.addAlertSuccess { content = "'" ++ contentCopied ++ "' copied to clipboard.", addToastIfUnique = False } + , Effect.addAlertSuccess + { content = "'" ++ contentCopied ++ "' copied to clipboard." + , addToastIfUnique = False + , link = Nothing + } ) diff --git a/src/elm/Pages/Account/SourceRepos.elm b/src/elm/Pages/Account/SourceRepos.elm index c7ea6f7f4..9ea18b43f 100644 --- a/src/elm/Pages/Account/SourceRepos.elm +++ b/src/elm/Pages/Account/SourceRepos.elm @@ -187,7 +187,10 @@ update shared msg model = } , Effect.batch [ Effect.addAlertSuccess - { content = "Repo " ++ repo.full_name ++ " enabled.", addToastIfUnique = True } + { content = "Repo " ++ repo.full_name ++ " enabled." + , addToastIfUnique = True + , link = Nothing + } , Effect.updateFavorites { org = repo.org, maybeRepo = Just repo.name, updateType = Favorites.Add } ] ) @@ -201,6 +204,7 @@ update shared msg model = , Effect.addAlertSuccess { content = "Repo " ++ options.repo.full_name ++ " enabled." , addToastIfUnique = False + , link = Nothing } ) diff --git a/src/elm/Pages/Org_/Builds.elm b/src/elm/Pages/Org_/Builds.elm index 72843d695..695109226 100644 --- a/src/elm/Pages/Org_/Builds.elm +++ b/src/elm/Pages/Org_/Builds.elm @@ -190,13 +190,15 @@ update shared route msg model = restartedBuild = "Build " ++ String.join "/" [ options.org, options.repo, options.buildNumber ] - newBuildNumber = - String.fromInt <| build.number - - newBuild = - String.join "/" [ "", options.org, options.repo, newBuildNumber ] - - -- todo: create new build link, add to toastie, refresh builds + newBuildLink = + Just + ( "View Build #" ++ String.fromInt build.number + , Route.Path.Org_Repo_Build_ + { org = options.org + , repo = options.repo + , buildNumber = String.fromInt build.number + } + ) in ( model , Effect.batch @@ -209,7 +211,11 @@ update shared route msg model = , maybeEvent = Dict.get "event" route.query , org = route.params.org } - , Effect.addAlertSuccess { content = restartedBuild ++ " restarted.", addToastIfUnique = True } + , Effect.addAlertSuccess + { content = restartedBuild ++ " restarted." + , addToastIfUnique = True + , link = newBuildLink + } ] ) @@ -248,7 +254,11 @@ update shared route msg model = , maybeEvent = Dict.get "event" route.query , org = route.params.org } - , Effect.addAlertSuccess { content = canceledBuild ++ " canceled.", addToastIfUnique = True } + , Effect.addAlertSuccess + { content = canceledBuild ++ " canceled." + , addToastIfUnique = True + , link = Nothing + } ] ) @@ -287,7 +297,11 @@ update shared route msg model = , maybeEvent = Dict.get "event" route.query , org = route.params.org } - , Effect.addAlertSuccess { content = approvedBuild ++ " approved.", addToastIfUnique = True } + , Effect.addAlertSuccess + { content = approvedBuild ++ " approved." + , addToastIfUnique = True + , link = Nothing + } ] ) diff --git a/src/elm/Pages/Org_/Repo_.elm b/src/elm/Pages/Org_/Repo_.elm index c0bc36cb4..c38a2cfbd 100644 --- a/src/elm/Pages/Org_/Repo_.elm +++ b/src/elm/Pages/Org_/Repo_.elm @@ -200,13 +200,15 @@ update shared route msg model = restartedBuild = "Build " ++ String.join "/" [ options.org, options.repo, options.buildNumber ] - newBuildNumber = - String.fromInt <| build.number - - newBuild = - String.join "/" [ "", options.org, options.repo, newBuildNumber ] - - -- todo: create new build link, add to toastie, refresh builds + newBuildLink = + Just + ( "View Build #" ++ String.fromInt build.number + , Route.Path.Org_Repo_Build_ + { org = options.org + , repo = options.repo + , buildNumber = String.fromInt build.number + } + ) in ( model , Effect.batch @@ -220,7 +222,11 @@ update shared route msg model = , org = route.params.org , repo = route.params.repo } - , Effect.addAlertSuccess { content = restartedBuild ++ " restarted.", addToastIfUnique = True } + , Effect.addAlertSuccess + { content = restartedBuild ++ " restarted." + , addToastIfUnique = True + , link = newBuildLink + } ] ) @@ -260,7 +266,11 @@ update shared route msg model = , org = route.params.org , repo = route.params.repo } - , Effect.addAlertSuccess { content = canceledBuild ++ " canceled.", addToastIfUnique = True } + , Effect.addAlertSuccess + { content = canceledBuild ++ " canceled." + , addToastIfUnique = True + , link = Nothing + } ] ) @@ -300,7 +310,11 @@ update shared route msg model = , org = route.params.org , repo = route.params.repo } - , Effect.addAlertSuccess { content = approvedBuild ++ " approved.", addToastIfUnique = True } + , Effect.addAlertSuccess + { content = approvedBuild ++ " approved." + , addToastIfUnique = True + , link = Nothing + } ] ) diff --git a/src/elm/Pages/Org_/Repo_/Deployments/Add.elm b/src/elm/Pages/Org_/Repo_/Deployments/Add.elm index 3f34cbe60..fdbbf14a5 100644 --- a/src/elm/Pages/Org_/Repo_/Deployments/Add.elm +++ b/src/elm/Pages/Org_/Repo_/Deployments/Add.elm @@ -155,6 +155,7 @@ update shared route msg model = , Effect.addAlertSuccess { content = "Added deployment for commit " ++ deployment.commit ++ "." , addToastIfUnique = True + , link = Nothing } ) diff --git a/src/elm/Pages/Org_/Repo_/Hooks.elm b/src/elm/Pages/Org_/Repo_/Hooks.elm index a259ace1c..bacdfe2ec 100644 --- a/src/elm/Pages/Org_/Repo_/Hooks.elm +++ b/src/elm/Pages/Org_/Repo_/Hooks.elm @@ -159,7 +159,11 @@ update shared route msg model = case response of Ok ( _, result ) -> ( model - , Effect.addAlertSuccess { content = result, addToastIfUnique = False } + , Effect.addAlertSuccess + { content = result + , addToastIfUnique = False + , link = Nothing + } ) Err error -> diff --git a/src/elm/Pages/Org_/Repo_/Schedules/Add.elm b/src/elm/Pages/Org_/Repo_/Schedules/Add.elm index 3ef8b1458..607b340bc 100644 --- a/src/elm/Pages/Org_/Repo_/Schedules/Add.elm +++ b/src/elm/Pages/Org_/Repo_/Schedules/Add.elm @@ -98,6 +98,7 @@ update shared route msg model = , Effect.addAlertSuccess { content = schedule.name ++ " added to repo schedules." , addToastIfUnique = True + , link = Nothing } ) diff --git a/src/elm/Pages/Org_/Repo_/Schedules/Edit_.elm b/src/elm/Pages/Org_/Repo_/Schedules/Edit_.elm index b3dab72c0..14dfbaa9d 100644 --- a/src/elm/Pages/Org_/Repo_/Schedules/Edit_.elm +++ b/src/elm/Pages/Org_/Repo_/Schedules/Edit_.elm @@ -142,6 +142,7 @@ update shared route msg model = , Effect.addAlertSuccess { content = schedule.name ++ " updated in repo schedules." , addToastIfUnique = True + , link = Nothing } ) @@ -158,6 +159,7 @@ update shared route msg model = [ Effect.addAlertSuccess { content = result , addToastIfUnique = True + , link = Nothing } , Effect.pushPath <| Route.Path.Org_Repo_Schedules diff --git a/src/elm/Pages/Org_/Repo_/Settings.elm b/src/elm/Pages/Org_/Repo_/Settings.elm index d760ec903..06fb2f0de 100644 --- a/src/elm/Pages/Org_/Repo_/Settings.elm +++ b/src/elm/Pages/Org_/Repo_/Settings.elm @@ -163,6 +163,7 @@ update shared route msg model = , Effect.addAlertSuccess { content = "Repo " ++ options.alertLabel ++ " updated." , addToastIfUnique = False + , link = Nothing } ) @@ -211,6 +212,7 @@ update shared route msg model = , Effect.addAlertSuccess { content = "Repo " ++ repo.full_name ++ " enabled." , addToastIfUnique = False + , link = Nothing } ) @@ -234,6 +236,7 @@ update shared route msg model = , Effect.addAlertSuccess { content = "Repo " ++ repo.full_name ++ " enabled." , addToastIfUnique = False + , link = Nothing } ) @@ -308,6 +311,7 @@ update shared route msg model = , Effect.addAlertSuccess { content = result , addToastIfUnique = False + , link = Nothing } ) @@ -342,6 +346,7 @@ update shared route msg model = , Effect.addAlertSuccess { content = result , addToastIfUnique = False + , link = Nothing } ] ) @@ -377,6 +382,7 @@ update shared route msg model = , Effect.addAlertSuccess { content = result , addToastIfUnique = False + , link = Nothing } ] ) @@ -584,7 +590,11 @@ update shared route msg model = -- ALERTS AddAlertCopiedToClipboard contentCopied -> ( model - , Effect.addAlertSuccess { content = "'" ++ contentCopied ++ "' copied to clipboard.", addToastIfUnique = False } + , Effect.addAlertSuccess + { content = "'" ++ contentCopied ++ "' copied to clipboard." + , addToastIfUnique = False + , link = Nothing + } ) -- REFRESH diff --git a/src/elm/Pages/Secrets/Engine_/Org/Org_.elm b/src/elm/Pages/Secrets/Engine_/Org/Org_.elm index cb6e4f7d7..cd50dd084 100644 --- a/src/elm/Pages/Secrets/Engine_/Org/Org_.elm +++ b/src/elm/Pages/Secrets/Engine_/Org/Org_.elm @@ -174,7 +174,11 @@ update shared route msg model = -- ALERTS AddAlertCopiedToClipboard contentCopied -> ( model - , Effect.addAlertSuccess { content = "'" ++ contentCopied ++ "' copied to clipboard.", addToastIfUnique = False } + , Effect.addAlertSuccess + { content = "'" ++ contentCopied ++ "' copied to clipboard." + , addToastIfUnique = False + , link = Nothing + } ) -- REFRESH diff --git a/src/elm/Pages/Secrets/Engine_/Org/Org_/Add.elm b/src/elm/Pages/Secrets/Engine_/Org/Org_/Add.elm index b019d2b0e..b8b41d220 100644 --- a/src/elm/Pages/Secrets/Engine_/Org/Org_/Add.elm +++ b/src/elm/Pages/Secrets/Engine_/Org/Org_/Add.elm @@ -104,6 +104,7 @@ update shared route msg model = , Effect.addAlertSuccess { content = secret.name ++ " added to org secrets." , addToastIfUnique = True + , link = Nothing } ) diff --git a/src/elm/Pages/Secrets/Engine_/Org/Org_/Edit_.elm b/src/elm/Pages/Secrets/Engine_/Org/Org_/Edit_.elm index a3d885b1e..8fcabb950 100644 --- a/src/elm/Pages/Secrets/Engine_/Org/Org_/Edit_.elm +++ b/src/elm/Pages/Secrets/Engine_/Org/Org_/Edit_.elm @@ -139,6 +139,7 @@ update shared route msg model = , Effect.addAlertSuccess { content = "Org secret " ++ secret.name ++ " updated." , addToastIfUnique = True + , link = Nothing } ) @@ -155,6 +156,7 @@ update shared route msg model = [ Effect.addAlertSuccess { content = result , addToastIfUnique = True + , link = Nothing } , Effect.pushPath <| Route.Path.SecretsEngine_OrgOrg_ diff --git a/src/elm/Pages/Secrets/Engine_/Repo/Org_/Repo_.elm b/src/elm/Pages/Secrets/Engine_/Repo/Org_/Repo_.elm index 422761663..2b7c5fbd0 100644 --- a/src/elm/Pages/Secrets/Engine_/Repo/Org_/Repo_.elm +++ b/src/elm/Pages/Secrets/Engine_/Repo/Org_/Repo_.elm @@ -177,7 +177,11 @@ update shared route msg model = -- ALERTS AddAlertCopiedToClipboard contentCopied -> ( model - , Effect.addAlertSuccess { content = "'" ++ contentCopied ++ "' copied to clipboard.", addToastIfUnique = False } + , Effect.addAlertSuccess + { content = "'" ++ contentCopied ++ "' copied to clipboard." + , addToastIfUnique = False + , link = Nothing + } ) -- REFRESH diff --git a/src/elm/Pages/Secrets/Engine_/Repo/Org_/Repo_/Add.elm b/src/elm/Pages/Secrets/Engine_/Repo/Org_/Repo_/Add.elm index 9b934f060..24330b23c 100644 --- a/src/elm/Pages/Secrets/Engine_/Repo/Org_/Repo_/Add.elm +++ b/src/elm/Pages/Secrets/Engine_/Repo/Org_/Repo_/Add.elm @@ -104,6 +104,7 @@ update shared route msg model = , Effect.addAlertSuccess { content = secret.name ++ " added to repo secrets." , addToastIfUnique = True + , link = Nothing } ) diff --git a/src/elm/Pages/Secrets/Engine_/Repo/Org_/Repo_/Edit_.elm b/src/elm/Pages/Secrets/Engine_/Repo/Org_/Repo_/Edit_.elm index f8fda9bfd..dfc74beb7 100644 --- a/src/elm/Pages/Secrets/Engine_/Repo/Org_/Repo_/Edit_.elm +++ b/src/elm/Pages/Secrets/Engine_/Repo/Org_/Repo_/Edit_.elm @@ -143,6 +143,7 @@ update shared route msg model = , Effect.addAlertSuccess { content = "Repo secret " ++ secret.name ++ " updated." , addToastIfUnique = True + , link = Nothing } ) @@ -159,6 +160,7 @@ update shared route msg model = [ Effect.addAlertSuccess { content = result , addToastIfUnique = True + , link = Nothing } , Effect.pushPath <| Route.Path.SecretsEngine_RepoOrg_Repo_ diff --git a/src/elm/Pages/Secrets/Engine_/Shared/Org_/Team_.elm b/src/elm/Pages/Secrets/Engine_/Shared/Org_/Team_.elm index 8bfb44470..ff0b1cfba 100644 --- a/src/elm/Pages/Secrets/Engine_/Shared/Org_/Team_.elm +++ b/src/elm/Pages/Secrets/Engine_/Shared/Org_/Team_.elm @@ -142,7 +142,11 @@ update shared route msg model = -- ALERTS AddAlertCopiedToClipboard contentCopied -> ( model - , Effect.addAlertSuccess { content = "'" ++ contentCopied ++ "' copied to clipboard.", addToastIfUnique = False } + , Effect.addAlertSuccess + { content = "'" ++ contentCopied ++ "' copied to clipboard." + , addToastIfUnique = False + , link = Nothing + } ) -- REFRESH diff --git a/src/elm/Pages/Secrets/Engine_/Shared/Org_/Team_/Add.elm b/src/elm/Pages/Secrets/Engine_/Shared/Org_/Team_/Add.elm index f24c73c16..9c1bf9626 100644 --- a/src/elm/Pages/Secrets/Engine_/Shared/Org_/Team_/Add.elm +++ b/src/elm/Pages/Secrets/Engine_/Shared/Org_/Team_/Add.elm @@ -113,6 +113,7 @@ update shared route msg model = , Effect.addAlertSuccess { content = secret.name ++ " added to shared secrets." , addToastIfUnique = True + , link = Nothing } ) diff --git a/src/elm/Pages/Secrets/Engine_/Shared/Org_/Team_/Edit_.elm b/src/elm/Pages/Secrets/Engine_/Shared/Org_/Team_/Edit_.elm index f8c0b5233..570b02b8c 100644 --- a/src/elm/Pages/Secrets/Engine_/Shared/Org_/Team_/Edit_.elm +++ b/src/elm/Pages/Secrets/Engine_/Shared/Org_/Team_/Edit_.elm @@ -143,6 +143,7 @@ update shared route msg model = , Effect.addAlertSuccess { content = "Shared secret " ++ secret.name ++ " updated." , addToastIfUnique = True + , link = Nothing } ) @@ -159,6 +160,7 @@ update shared route msg model = [ Effect.addAlertSuccess { content = result , addToastIfUnique = True + , link = Nothing } , Effect.pushPath <| Route.Path.SecretsEngine_SharedOrg_Team_ diff --git a/src/elm/Shared.elm b/src/elm/Shared.elm index a9fb5ec51..dec27253f 100644 --- a/src/elm/Shared.elm +++ b/src/elm/Shared.elm @@ -11,7 +11,7 @@ import Auth.Jwt import Auth.Session import Browser.Dom import Browser.Events exposing (Visibility(..)) -import Components.Alerts as Alerts +import Components.Alerts import Dict import Effect exposing (Effect) import File.Download @@ -356,6 +356,7 @@ update route msg model = , Effect.addAlertError { content = "Your session has expired or you logged in somewhere else, please log in again." , addToastIfUnique = True + , link = Nothing } ] in @@ -487,7 +488,7 @@ update route msg model = options.favorite ++ " removed from favorites." in ( { model | user = RemoteData.succeed user } - , Effect.addAlertSuccess { content = alertMsg, addToastIfUnique = True } + , Effect.addAlertSuccess { content = alertMsg, addToastIfUnique = True, link = Nothing } ) Err error -> @@ -549,7 +550,7 @@ update route msg model = -- ALERTS Shared.Msg.AlertsUpdate subMsg -> - Alerting.update Alerts.successConfig Shared.Msg.AlertsUpdate subMsg model + Alerting.update Components.Alerts.successConfig Shared.Msg.AlertsUpdate subMsg model |> Tuple.mapSecond Effect.sendCmd Shared.Msg.AddAlertSuccess options -> @@ -561,9 +562,9 @@ update route msg model = else Alerting.addToast in - addAlertFn Alerts.successConfig + addAlertFn Components.Alerts.successConfig Shared.Msg.AlertsUpdate - (Alerts.Success "Success" options.content Nothing) + (Components.Alerts.Success "Success" options.content options.link) ( model, Cmd.none ) |> Tuple.mapSecond Effect.sendCmd @@ -576,9 +577,9 @@ update route msg model = else Alerting.addToast in - addAlertFn Alerts.errorConfig + addAlertFn Components.Alerts.errorConfig Shared.Msg.AlertsUpdate - (Alerts.Error "Error" options.content) + (Components.Alerts.Error "Error" options.content) ( model, Cmd.none ) |> Tuple.mapSecond Effect.sendCmd @@ -604,7 +605,7 @@ update route msg model = in ( shared , Effect.batch - [ Effect.addAlertError { content = Utils.Errors.detailedErrorToString error, addToastIfUnique = True } + [ Effect.addAlertError { content = Utils.Errors.detailedErrorToString error, addToastIfUnique = True, link = Nothing } , redirect ] ) diff --git a/src/elm/Shared/Msg.elm b/src/elm/Shared/Msg.elm index 06e7f6a96..c5eb09a7f 100644 --- a/src/elm/Shared/Msg.elm +++ b/src/elm/Shared/Msg.elm @@ -8,7 +8,7 @@ module Shared.Msg exposing (Msg(..)) import Auth.Jwt import Browser.Dom import Browser.Events -import Components.Alerts exposing (Alert) +import Components.Alerts import Http import Http.Detailed import Time @@ -55,9 +55,9 @@ type Msg -- THEME | SetTheme { theme : Theme.Theme } -- ALERTS - | AddAlertError { content : String, addToastIfUnique : Bool } - | AddAlertSuccess { content : String, addToastIfUnique : Bool } - | AlertsUpdate (Alerting.Msg Alert) + | AddAlertError { content : String, addToastIfUnique : Bool, link : Maybe Components.Alerts.Link } + | AddAlertSuccess { content : String, addToastIfUnique : Bool, link : Maybe Components.Alerts.Link } + | AlertsUpdate (Alerting.Msg Components.Alerts.Alert) -- ERRORS | HandleHttpError (Http.Detailed.Error String) -- REFRESH