Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
154
Issues
154
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
purescript-gargantext
Commits
8b09569f
Verified
Commit
8b09569f
authored
Jul 10, 2025
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[notifications] implement "danger" for errors and "warning" for warnings
This way errors are red, warnings are yellow.
parent
c383ebb7
Pipeline
#7741
passed with stages
in 28 minutes and 33 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
59 deletions
+25
-59
ErrorsView.purs
src/Gargantext/Components/ErrorsView.purs
+7
-40
Utils.purs
src/Gargantext/Config/Utils.purs
+3
-5
Types.purs
src/Gargantext/Types.purs
+15
-14
No files found.
src/Gargantext/Components/ErrorsView.purs
View file @
8b09569f
...
@@ -36,53 +36,20 @@ componentCpt = here.component "main" cpt
...
@@ -36,53 +36,20 @@ componentCpt = here.component "main" cpt
{}
{}
(mapWithIndex (showError errors) errors')
(mapWithIndex (showError errors) errors')
showError errors i (FStringError { error }) =
showError errors i (FStringError { error }) = errorAlert errors i "danger" error
RB.alert
showError errors i (FStringWarning { warning }) = errorAlert errors i "warning" warning
{ dismissible: true
showError errors i (FRESTError { error }) = errorAlert errors i "danger" (show error)
, onClose
showError errors i (FOtherError { error }) = errorAlert errors i "danger" (show error)
, variant: "danger"
}
[ H.text error ]
where
onClose = do
here.error2 "click!" error
T.modify_
( \es -> case deleteAt i es of
Nothing -> es
Just es' -> es'
)
errors
showError errors i (FRESTError { error }) =
RB.alert
{ dismissible: true
, onClose
, variant: "danger"
}
[ H.text $ show error ]
where
onClose = do
here.error2 "click!" error
T.modify_
( \es -> case deleteAt i es of
Nothing -> es
Just es' -> es'
)
errors
showError errors i (FOtherError { error })
=
errorAlert errors i variant txt
=
RB.alert
RB.alert
{ dismissible: true
{ dismissible: true
, onClose
, onClose
, variant
: "danger"
, variant
}
}
[ H.text $ show error ]
[ H.text txt ]
where
where
onClose = do
onClose = do
here.error2 "click!" error
T.modify_
T.modify_
( \es -> case deleteAt i es of
( \es -> case deleteAt i es of
Nothing -> es
Nothing -> es
...
...
src/Gargantext/Config/Utils.purs
View file @
8b09569f
...
@@ -6,11 +6,12 @@ import Data.Array as A
...
@@ -6,11 +6,12 @@ import Data.Array as A
import Data.Either (Either(..))
import Data.Either (Either(..))
import Data.Foldable (foldl)
import Data.Foldable (foldl)
import Data.Maybe (fromMaybe, Maybe(..))
import Data.Maybe (fromMaybe, Maybe(..))
import Data.Traversable (traverse_)
import Effect (Effect)
import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Gargantext.Config.REST (RESTError, logRESTError)
import Gargantext.Config.REST (RESTError, logRESTError)
import Gargantext.Types (AsyncEvent(..), AsyncTaskLog(..), FrontendError(..), async
TaskLogEventsErrorMessage
)
import Gargantext.Types (AsyncEvent(..), AsyncTaskLog(..), FrontendError(..), async
ErrorToFrontendError, asyncTaskLogEventsErrors
)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Toestand as T
import Toestand as T
...
@@ -54,7 +55,4 @@ handleErrorInAsyncTaskLog
...
@@ -54,7 +55,4 @@ handleErrorInAsyncTaskLog
-> AsyncTaskLog
-> AsyncTaskLog
-> Effect Unit
-> Effect Unit
handleErrorInAsyncTaskLog errors atl =
handleErrorInAsyncTaskLog errors atl =
case asyncTaskLogEventsErrorMessage atl of
traverse_ (\e -> T.modify_ (A.cons $ asyncErrorToFrontendError e) errors) (asyncTaskLogEventsErrors atl)
Nothing -> pure unit
Just error ->
T.modify_ (A.cons $ FStringError { error }) errors
src/Gargantext/Types.purs
View file @
8b09569f
...
@@ -838,9 +838,17 @@ derive instance Generic AsyncEvent _
...
@@ -838,9 +838,17 @@ derive instance Generic AsyncEvent _
derive instance Newtype AsyncEvent _
derive instance Newtype AsyncEvent _
derive newtype instance JSON.ReadForeign AsyncEvent
derive newtype instance JSON.ReadForeign AsyncEvent
asyncEventErrorMessage :: AsyncEvent -> Maybe String
data AsyncError
asyncEventErrorMessage (AsyncEvent { level: "ERROR", message }) = Just message
= AsyncErrorMessage String
asyncEventErrorMessage (AsyncEvent { level: "WARNING", message }) = Just message
| AsyncWarningMessage String
asyncErrorToFrontendError :: AsyncError -> FrontendError
asyncErrorToFrontendError (AsyncErrorMessage error) = FStringError { error }
asyncErrorToFrontendError (AsyncWarningMessage warning) = FStringWarning { warning }
asyncEventErrorMessage :: AsyncEvent -> Maybe AsyncError
asyncEventErrorMessage (AsyncEvent { level: "ERROR", message }) = Just $ AsyncErrorMessage message
asyncEventErrorMessage (AsyncEvent { level: "WARNING", message }) = Just $ AsyncWarningMessage message
asyncEventErrorMessage _ = Nothing
asyncEventErrorMessage _ = Nothing
newtype AsyncTaskLog = AsyncTaskLog
newtype AsyncTaskLog = AsyncTaskLog
...
@@ -854,17 +862,9 @@ derive instance Generic AsyncTaskLog _
...
@@ -854,17 +862,9 @@ derive instance Generic AsyncTaskLog _
derive instance Newtype AsyncTaskLog _
derive instance Newtype AsyncTaskLog _
derive newtype instance JSON.ReadForeign AsyncTaskLog
derive newtype instance JSON.ReadForeign AsyncTaskLog
asyncTaskLogEventsErrorMessage :: AsyncTaskLog -> Maybe String
asyncTaskLogEventsErrors :: AsyncTaskLog -> Array AsyncError
asyncTaskLogEventsErrorMessage (AsyncTaskLog { events }) =
asyncTaskLogEventsErrors (AsyncTaskLog { events }) =
foldl eventErrorMessage' Nothing events
A.mapMaybe asyncEventErrorMessage events
where
eventErrorMessage' acc ae =
case asyncEventErrorMessage ae of
Nothing -> acc
Just e' ->
case acc of
Nothing -> Just e'
Just acc' -> Just $ e' <> "\n" <> acc'
asyncTaskLogPercent :: AsyncTaskLog -> Number
asyncTaskLogPercent :: AsyncTaskLog -> Number
asyncTaskLogPercent (AsyncTaskLog { failed, remaining, succeeded }) = 100.0 * nom / denom
asyncTaskLogPercent (AsyncTaskLog { failed, remaining, succeeded }) = 100.0 * nom / denom
...
@@ -921,6 +921,7 @@ toggleSidePanelState Opened = Closed
...
@@ -921,6 +921,7 @@ toggleSidePanelState Opened = Closed
data FrontendError
data FrontendError
= FStringError { error :: String }
= FStringError { error :: String }
| FStringWarning { warning :: String }
| FRESTError { error :: RESTError }
| FRESTError { error :: RESTError }
| FOtherError { error :: String }
| FOtherError { error :: String }
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment