-
Notifications
You must be signed in to change notification settings - Fork 364
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
feat: [M3-7109] - Add AGLB Delete Route Dialog #9735
Merged
bnussman-akamai
merged 2 commits into
linode:develop
from
bnussman-akamai:M3-7109-add-aglb-route-delete-dialog
Oct 2, 2023
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-9735-upcoming-features-1696265642529.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Upcoming Features | ||
--- | ||
|
||
Add AGLB Route Delete Dialog ([#9735](https://github.com/linode/manager/pull/9735)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
packages/manager/src/features/LoadBalancers/LoadBalancerDetail/Routes/DeleteRouteDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from 'react'; | ||
|
||
import { ActionsPanel } from 'src/components/ActionsPanel/ActionsPanel'; | ||
import { ConfirmationDialog } from 'src/components/ConfirmationDialog/ConfirmationDialog'; | ||
import { useLoadBalancerRouteDeleteMutation } from 'src/queries/aglb/routes'; | ||
|
||
import type { Route } from '@linode/api-v4'; | ||
|
||
interface Props { | ||
loadbalancerId: number; | ||
onClose: () => void; | ||
open: boolean; | ||
route: Route | undefined; | ||
} | ||
|
||
export const DeleteRouteDialog = (props: Props) => { | ||
const { loadbalancerId, onClose, open, route } = props; | ||
|
||
const { error, isLoading, mutateAsync } = useLoadBalancerRouteDeleteMutation( | ||
loadbalancerId, | ||
route?.id ?? -1 | ||
); | ||
|
||
const onDelete = async () => { | ||
await mutateAsync(); | ||
onClose(); | ||
}; | ||
|
||
return ( | ||
<ConfirmationDialog | ||
actions={ | ||
<ActionsPanel | ||
primaryButtonProps={{ | ||
label: 'Delete', | ||
loading: isLoading, | ||
onClick: onDelete, | ||
}} | ||
secondaryButtonProps={{ | ||
label: 'Cancel', | ||
onClick: onClose, | ||
}} | ||
/> | ||
} | ||
error={error?.[0]?.reason} | ||
onClose={onClose} | ||
open={open} | ||
title={`Delete Route ${route?.label}?`} | ||
> | ||
Are you sure you want to delete this route? | ||
</ConfirmationDialog> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried conditionally rendering like how we discussed in cafe, but the animation close breaks so I'm using our normal pattern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually do wonder if there is actual benefit in conditionally rendering the dialog, since the element isn't even mounted unless
open
is true. It sounds to me like performance issues would be more relevant when mounting a Dialog with a big tree (maybe like the Linode Resize dialog for instance). The docs mention akeepMounted
prop to that effect, but it sounds like the opposite of what we usually want to do. From what I could read, it's a case that should be supported by performance benchmarks to justify its usage (when it outside the scope of a micro optimisation).