-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [M3-7267] - Add AGLB Rule Delete Dialog (#9804)
* add initial delete rule dialog * add basic delete rule test * Added changeset: Add AGLB Rule Delete Dialog * Update packages/manager/src/features/LoadBalancers/LoadBalancerDetail/Routes/DeleteRuleDialog.tsx Co-authored-by: Dajahi Wiley <114682940+dwiley-akamai@users.noreply.github.com> * rename `Remove` to `Delete` --------- Co-authored-by: Banks Nussman <banks@nussman.us> Co-authored-by: Dajahi Wiley <114682940+dwiley-akamai@users.noreply.github.com>
- Loading branch information
1 parent
54b5f00
commit b0dba9d
Showing
6 changed files
with
152 additions
and
4 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-9804-upcoming-features-1697563268544.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 Rule Delete Dialog ([#9804](https://github.com/linode/manager/pull/9804)) |
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
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
63 changes: 63 additions & 0 deletions
63
packages/manager/src/features/LoadBalancers/LoadBalancerDetail/Routes/DeleteRuleDialog.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,63 @@ | ||
import React from 'react'; | ||
|
||
import { ActionsPanel } from 'src/components/ActionsPanel/ActionsPanel'; | ||
import { ConfirmationDialog } from 'src/components/ConfirmationDialog/ConfirmationDialog'; | ||
import { useLoadBalancerRouteUpdateMutation } from 'src/queries/aglb/routes'; | ||
|
||
import type { Route } from '@linode/api-v4'; | ||
|
||
interface Props { | ||
loadbalancerId: number; | ||
onClose: () => void; | ||
open: boolean; | ||
route: Route | undefined; | ||
ruleIndex: number | undefined; | ||
} | ||
|
||
export const DeleteRuleDialog = (props: Props) => { | ||
const { loadbalancerId, onClose, open, route, ruleIndex } = props; | ||
|
||
const { error, isLoading, mutateAsync } = useLoadBalancerRouteUpdateMutation( | ||
loadbalancerId, | ||
route?.id ?? -1 | ||
); | ||
|
||
const onDelete = async () => { | ||
if (!route || ruleIndex === undefined) { | ||
return; | ||
} | ||
|
||
const newRules = [...route.rules]; | ||
|
||
newRules.splice(ruleIndex, 1); | ||
|
||
await mutateAsync({ | ||
rules: newRules, | ||
}); | ||
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 Rule?" | ||
> | ||
Are you sure you want to delete this rule? | ||
</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
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