-
Notifications
You must be signed in to change notification settings - Fork 266
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
refactor: share code for bulk deletion #5847
base: main
Are you sure you want to change the base?
Conversation
Thanks for the PR, @trmendes. The goal of #5745 was to reduce common code, but by putting the function calls to delete in one place, the typing means that there's almost as much code as before in Util with the switch and I was thinking the delete utility would be untyped and allow a delete function to be passed in, something like I'm not sure what to do about containers, but maybe multiple delete functions could optionally be passed in so that it can delete in two passes. |
21c1e3c
to
212779c
Compare
Thank you so much for your suggestion @deboer-tim I made some changes as a second draft. The common code is all moved inside the common function inside utils, and the component itself decides what is the correct way to handle the deletion. For the container component, as a simple implementation, what I have in mind is to call the But, taking a look at the component container, I notice that |
212779c
to
d83606d
Compare
Much better 👍🏼, but I think callback should be on individual items so that Yes, it would be fine IMHO to at least defer container to a second PR (so 'Fixes most of' in this PR to avoid closing the issue). More drastic options I had thought of were renaming status or state to the other :-/ , but that's fairly extreme and would be a separate discussion, might be better options. |
a49883b
to
fda3360
Compare
Getting better 👍🏼, but if callback is on each individual item then iterating over them and try/catch logic can be shared in delete function. |
share code for multiple delete Signed-off-by: Thiago Mendes <tzig@tutanota.de>
fda3360
to
5f2203e
Compare
I see, and I agree. Thanks again @deboer-tim. Now we have one more draft before I develop some test cases. I left One question is still remaining is “what to do when the deletion of an object fails?”
At the moment, we are only logging an error message but, to the user, there is no visual feedback. The object I suggest setting it as 'FAILURE'. I would like to hear what are your thoughts and concerns to set status to 'FAILURE' in such cases? |
Unfortunately, I think setting it to FAILURE would just mean that you're stranded because some of the actions you might take to fix it or try again are going to be disabled, and we still wouldn't tell you anything about why it failed or what to try. That is probably also the case with DELETING forever :) , but I don't think changing that improves the situation. For right now, you should be able to go to another screen and come back to clear things. So first: let's keep this PR to fixing a single issue, and if you feel strongly I would at most revert to the previous status. Long term we could probably store any error message in the object like ContainerInfoUI does with actionError, and show this in the UI somewhere - but that is a much bigger refactoring / discussion to have separately. |
validate if the deleteSelection when called with different types of objects Signed-off-by: Thiago Mendes <tzig@tutanota.de>
What does this PR do?
Refactor code to have one common function shared between different types of delete
Screenshot / video of UI
No Screenshot
What issues does this PR fix or reference?
Fixes #5745
How to test this PR?