Skip to content

Commit c5d41bb

Browse files
m-masatakasimonpasquier
authored andcommitted
Grouping label's expand button with grouping id (#2012)
* Expand button with id Signed-off-by: m-masataka <[email protected]> * fixed indexedMap Signed-off-by: m-masataka <[email protected]> * rebuild Signed-off-by: m-masataka <[email protected]>
1 parent 5fe5ea7 commit c5d41bb

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

Diff for: asset/assets_vfsdata.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ui/app/src/Views/AlertList/Types.elm

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type AlertListMsg
2525
| ToggleSilenced Bool
2626
| ToggleInhibited Bool
2727
| SetActive (Maybe String)
28-
| ActiveGroups Labels
28+
| ActiveGroups Int
2929
| SetTab Tab
3030
| ToggleExpandAll Bool
3131

@@ -43,7 +43,7 @@ type alias Model =
4343
, filterBar : FilterBar.Model
4444
, tab : Tab
4545
, activeId : Maybe String
46-
, activeGroups : Set Labels
46+
, activeGroups : Set Int
4747
, key : Key
4848
, expandAll : Bool
4949
}

Diff for: ui/app/src/Views/AlertList/Updates.elm

+2-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ update msg ({ groupBar, alerts, filterBar, receiverBar, alertGroups } as model)
9595
, filterBar = newFilterBar
9696
, groupBar = newGroupBar
9797
, activeId = Nothing
98+
, activeGroups = Set.empty
9899
}
99100
, Cmd.batch
100101
[ if filter.customGrouping then
@@ -159,7 +160,7 @@ update msg ({ groupBar, alerts, filterBar, receiverBar, alertGroups } as model)
159160
allGroupLabels =
160161
case ( alertGroups, expanded ) of
161162
( Success groups, True ) ->
162-
List.map (.labels >> Dict.toList) groups
163+
List.range 0 (List.length groups)
163164
|> Set.fromList
164165

165166
_ ->

Diff for: ui/app/src/Views/AlertList/Views.elm

+12-12
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ view { alerts, alertGroups, groupBar, filterBar, receiverBar, tab, activeId, act
8787
]
8888

8989

90-
defaultAlertGroups : Maybe String -> Set Labels -> Bool -> List AlertGroup -> Html Msg
90+
defaultAlertGroups : Maybe String -> Set Int -> Bool -> List AlertGroup -> Html Msg
9191
defaultAlertGroups activeId activeGroups expandAll groups =
9292
case groups of
9393
[] ->
@@ -98,23 +98,23 @@ defaultAlertGroups activeId activeGroups expandAll groups =
9898
labels_ =
9999
Dict.toList labels
100100
in
101-
alertGroup activeId (Set.singleton labels_) labels_ alerts expandAll
101+
alertGroup activeId (Set.singleton 0) labels_ alerts 0 expandAll
102102

103103
_ ->
104104
div [ class "pl-5" ]
105-
(List.map
106-
(\{ labels, alerts } ->
107-
alertGroup activeId activeGroups (Dict.toList labels) alerts expandAll
105+
(List.indexedMap
106+
(\index group ->
107+
alertGroup activeId activeGroups (Dict.toList group.labels) group.alerts index expandAll
108108
)
109109
groups
110110
)
111111

112112

113-
alertGroup : Maybe String -> Set Labels -> Labels -> List GettableAlert -> Bool -> Html Msg
114-
alertGroup activeId activeGroups labels alerts expandAll =
113+
alertGroup : Maybe String -> Set Int -> Labels -> List GettableAlert -> Int -> Bool -> Html Msg
114+
alertGroup activeId activeGroups labels alerts groupId expandAll =
115115
let
116116
groupActive =
117-
expandAll || Set.member labels activeGroups
117+
expandAll || Set.member groupId activeGroups
118118

119119
labels_ =
120120
case labels of
@@ -144,7 +144,7 @@ alertGroup activeId activeGroups labels alerts expandAll =
144144
labels
145145

146146
expandButton =
147-
expandAlertGroup groupActive labels
147+
expandAlertGroup groupActive groupId
148148
|> Html.map (\msg -> MsgForAlertList (ActiveGroups msg))
149149

150150
alertCount =
@@ -170,8 +170,8 @@ alertGroup activeId activeGroups labels alerts expandAll =
170170
]
171171

172172

173-
expandAlertGroup : Bool -> Labels -> Html Labels
174-
expandAlertGroup expanded labels =
173+
expandAlertGroup : Bool -> Int -> Html Int
174+
expandAlertGroup expanded groupId =
175175
let
176176
icon =
177177
if expanded then
@@ -181,7 +181,7 @@ expandAlertGroup expanded labels =
181181
"fa-plus"
182182
in
183183
button
184-
[ onClick labels
184+
[ onClick groupId
185185
, class "btn btn-outline-info border-0 mr-1 mb-1"
186186
, style "margin-left" "-3rem"
187187
]

0 commit comments

Comments
 (0)