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

Storage UI: Delete Drive (in proposal; Remove the configuration for this device) #1934

Draft
wants to merge 2 commits into
base: storage-config-ui
Choose a base branch
from

Conversation

mvidner
Copy link
Contributor

@mvidner mvidner commented Jan 22, 2025

Problem

https://trello.com/c/JQ3blpRm

remove

Solution

WIP

Testing

  • Added a new unit test
  • Tested manually

Screenshots

If the fix affects the UI attach some screenshots here.

(the menu item only appears when I first delete the root partition from it)

except it crashes!? and I am pretty sure useDrive has worked before

> Unexpected Application Error!
> _useDrive4 is undefined
>
> RemoveDriveOption@https://localhost:10443/index.js:42094:22
> renderWithHooks@https://localhost:10443/index.js:84540:27
> updateFunctionComponent@https://localhost:10443/index.js:88666:20
> beginWork@https://localhost:10443/index.js:90689:16
> beginWork$1@https://localhost:10443/index.js:96514:14
> performUnitOfWork@https://localhost:10443/index.js:95645:12
> ...
> 💿 Hey developer 👋
> You can provide a way better UX than this when your app throws errors by providing your own ErrorBoundary or errorElement prop on your route.
@mvidner mvidner force-pushed the delete-proposed-drive branch from 9dd9190 to ad15af6 Compare January 23, 2025 21:18
@@ -393,7 +393,7 @@ const RemoveDriveOption = ({ drive }) => {
return (
<>
<Divider component="hr" />
<MenuItem description={_("Remove the configuration for this device")}>
<MenuItem description={_("REMOVE the configuration for this device")} onClick={deleteDrive}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why uppercase?

For visually grabbing user attention about the destructive effect of the action I'd use the isDanger MenuItem prop instead of playing with text that, somehow, is out of our control

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for confusing you, that is just my WIP debugging way to make sure my browser is seeing the intended branch

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, understood.

Anyway, goes for isDanger prop with this option :)

@mvidner
Copy link
Contributor Author

mvidner commented Jan 24, 2025

I will need help with this:
After I select the menu item, a React backtrace appears, saying "_useDrive4 is undefined "
IIUC, it happens after the drive has been deleted and findDrive doesn't find it (correct) so useDrive returns undefined.
This looks like a workflow problem that is too advanced for me now.

The interface was crashing when deleting a drive due to the
`RemoveDriveOption` component attempting to destructure an `undefined`
value after the delete action was performed.

Most likely, after the delete action, a parent component in the tree is
re-rendered, which causes `RemoveDriveOption` to re-render as well. As a
quick fix, this commit postpones the destructuring until the value
returned by the `useDrive` hook is known, returning early if it is
`undefined`. A more refined solution is welcome, but will be addressed
once the overall storage UI is more polished.
@dgdavid
Copy link
Contributor

dgdavid commented Jan 24, 2025

I will need help with this: After I select the menu item, a React backtrace appears, saying "_useDrive4 is undefined " IIUC, it happens after the drive has been deleted and findDrive doesn't find it (correct) so useDrive returns undefined. This looks like a workflow problem that is too advanced for me now.

Yes, it is a workflow problem because the combination of re-renders, hooks, and the mentioned undefined. The quick fix could be the one proposed at 8a9477d, but actually Agama should stop re-rendering components that are going to be unmounted.

Let's go ahead and commit the right fix later, when all the storage interface pieces are more polished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants