Skip to content

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Mar 27, 2025

What does this implement/fix?

There has been a report on Discourse (link below) that deleting groups which still have, e.g., domains assigned to them is not possible without first unassigning said domains from the respective groups. This behavior was different in v5 where deleting a group cascaded down in deleting all the domains, clients, etc. assigned to it.

I don't think that such a massive "cleanup" is actually a good idea as a wrong click can erase quite a bit of work users may have invested into their systems.

Hence, this PR seeks a middle ground: When a group is being deleted, we cascade this into the domain<->group, client<->group, and adlist<->group bindings, effectively disassigning the domains without deleting them. To me, this makes more sense.

This makes it possible to delete groups even when domains are assigned, making the latter orphans without any effect. They can later either be deleted on their own or adopted into new groups.


Related issue or feature (if applicable): https://discourse.pi-hole.net/t/deleting-a-group-is-not-possible-ftl-v6-0-4/77171

Pull request in docs with documentation (if applicable): N/A


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)

Checklist:

  • The code change is tested and works locally.
  • I based my code and PRs against the repositories developmental branch.
  • I signed off all commits. Pi-hole enforces the DCO for all contributions
  • I signed all my commits. Pi-hole requires signatures to verify authorship
  • I have read the above and my PR is ready for review.

@DL6ER DL6ER added the Bug: fixed Contains a bug resolution label Mar 27, 2025
@DL6ER DL6ER requested a review from a team March 27, 2025 12:12
@pralor-bot
Copy link

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/deleting-a-group-is-not-possible-ftl-v6-0-4/77171/9

@dschaper
Copy link
Member

Ah, nice. So deleting a group just deletes the group assignment. Is there a feature that can list domains that are not assigned to any group to give users a quick way to replicate v5 behavior and know any orphan domains that are able to be culled?

@yubiuser
Copy link
Member

Is there a feature that can list domains that are not assigned to any group to give users a quick way to replicate v5 behavior and know any orphan domains that are able to be culled?

One can abuse the sorting function of the table.

2025-03-27_21-21

Copy link
Member

@yubiuser yubiuser left a comment

Choose a reason for hiding this comment

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

I'm not sure about this behavior (the v5 behavior was even worse): Users will delete groups that are still in use by some clients/list/domains and wonder why they have orphan items.
In my opinion the current v6 way is the right one: don't allow to delete groups which still have items assigned to them.

But we should improve the error message (as in amend the SQL provided message with some that users unterstand)

@rdwebdesign
Copy link
Member

I understand your point of view, but some users will assign hundreds of domains/regex and list to a group and when they want to delete the group they will need to manually remove every assignment, one by one.

I think the users already knows how v5 works (and we never received complaints).

In my opinion, replicating v5 behavior won't cause any issues.

@yubiuser
Copy link
Member

In my opinion, replicating v5 behavior won't cause any issues.

If we go that way, I think we should have a big warning that this will mass delete all items assigned to that group. I was not aware that we had such a 'nuclear' handling in v5 and I'm surprised we did not get many complaints.

@rdwebdesign
Copy link
Member

I agree. We can add a confirmation message before deleting groups.

@PromoFaux
Copy link
Member

Surely only the relationship between the groups and items is getting deleted, not the actual items? That said, what purpose does it serve having orphaned items?

@yubiuser
Copy link
Member

Maybe we need both in a modal: ask the user if they want to delete only the group or group + all items in the group too. (Need to make sure, items with more then one group assignment are not deleted but just removed from the particular group!)

@DL6ER
Copy link
Member Author

DL6ER commented Mar 28, 2025

Thank you for the interesting discussion. I am still convinced that the current proposal (delete the links, possibly creating orphans) is the way to go. Making the action configurable makes things a lot more involved. I don't think it'll happen in reality that users want to mass-delete lists they have added manually one-by-one. If they are a lot, they may have interacted with the database directly (sqlite3 ...) in which case they can still do what they want.

This said unless we agree on

In my opinion the current v6 way is the right one: don't allow to delete groups which still have items assigned to them.

But we should improve the error message (as in amend the SQL provided message with some that users unterstand)

@dschaper
Copy link
Member

That said, what purpose does it serve having orphaned items?

That would be a good question to ask at https://discourse.pi-hole.net/t/deleting-a-group-is-not-possible-ftl-v6-0-4/77171/8

In fact, all of the questions and suggestions would be good to discuss there to ask the people requesting this feature how it would best work for them.

@dschaper
Copy link
Member

dschaper commented Apr 2, 2025

Was there a consensus reached on this? I'm still in favor of it.

@PromoFaux
Copy link
Member

I've no strong feelings - no blocker from me!

@DL6ER
Copy link
Member Author

DL6ER commented Apr 5, 2025

The poll was open 8 days. 62% voted for this PR, 38% for status quo. Nobody wanted a cascade that'd finally delete possible sorphans.

@yubiuser
Copy link
Member

yubiuser commented Apr 5, 2025

Ok, if we go forward with this change: should we add a modal to inform the user about the change in behavior? We came up with 3 different variants what 'deleting' a group could mean - we should inform the users what will happen and give them a chance to cancle.

Something like
'Deleting this group will un-assign all lists/clients/adlists from this group without deleting them. This could create orphan items which need to be deleted manually. Proceed/Cancle'

@DL6ER
Copy link
Member Author

DL6ER commented Apr 5, 2025

IMO such a dialog may have been necessary in the case of possible mass-deletion. My feeling is that we won't need it here. Orphans are no issue at all and the users gets what they ask for: the group they want to delete is ... deleted.

@rdwebdesign
Copy link
Member

Orphans are no issue at all

I agree. Some users can even add domains not assigned to any groups and later decide how to group them.

@DL6ER DL6ER merged commit 95c1b1a into development Apr 15, 2025
13 checks passed
@DL6ER DL6ER deleted the tweak/on_delete_cascade branch April 15, 2025 04:24
@PromoFaux PromoFaux mentioned this pull request May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: fixed Contains a bug resolution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants