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

Fixes #19873: Saving a rule with deleted directives/groups does not correct it #3855

Merged
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
Expand Up @@ -151,9 +151,22 @@ tabContent model details isNewRule=
buildListRow ids =
let
--Get more information about directives, to correctly sort them by displayName
directives = model.directives
|> List.filter (\d -> List.member d.id ids)
|> List.sortWith (compareOn .displayName)
directives =
let
knownDirectives = model.directives
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could have been done in one go, but with the sort lost with function from List.Extra

                ids
                  |> List.map (\id ->
                     model.directives
                       |> List.Extra.find (.id >> (==) id)
                       |> Maybe.withDefault (Directive id ("Missing directive with ID "++id.value) "" "" "" False False "")
                     )
                  |> List.sortWith (compareOn .displayName)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway that does not sort the unknown directive to the end, maybe with List.extra.span

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's not important: this is only a workaround for a case that should be rare, and you just want to remove them all in all case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hum, perhaps I didn't understood - did you mean 1/ "that unknow directives, which in the end, are not sorted (on ID for ex)" or "the unknow directives get mixed with the known one?". I understood 1/, but if it was 2/: they are well all grouped together in the end, because of the List.append

|> List.filter (\d -> List.member d.id ids)
|> List.sortWith (compareOn .displayName)
in
-- add missing directives
let
knonwIds = List.map .id knownDirectives
in
List.append
knownDirectives
(ids
|> List.filter (\id -> not (List.member id knonwIds) )
|> List.map (\id -> (Directive id ("Missing directive with ID "++id.value) "" "" "" False False ""))
)

rowDirective : Directive -> Html Msg
rowDirective directive =
Expand Down