-
Notifications
You must be signed in to change notification settings - Fork 402
upcoming: [DI-23778] - Added. confirmation dialog in alerts contextual view #11785
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
Merged
nikhagra-akamai
merged 17 commits into
linode:develop
from
nikhagra-akamai:alerts-context-view-dialog
Mar 12, 2025
Merged
Changes from 7 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
f04e65f
upcoming: [DI-23778] - Added confirmation dialog component
nikhagra-akamai a404d98
upcoming: [DI-23778] - Added confirmation dialog to table component
nikhagra-akamai a595249
upcoming: [DI-23778] - Added queries to add/remove entities from alert
nikhagra-akamai 58c0673
upcoming: [DI-23778] - added changeset
nikhagra-akamai 3d0e2c6
Added index.tsx for PR testing
nikhagra-akamai 6c4454c
upcoming: [DI-23778] - Updated on success method
nikhagra-akamai d7e296d
upcoming: [DI-23778] - Added optimistic update logic
nikhagra-akamai b6b99b0
upcoming: [DI-23778] - Updated queries to add/remove entity to alert
nikhagra-akamai 8078b58
upcoming: [DI-23778] - Updated function name
nikhagra-akamai 204c4b5
upcoming: [DI-23778] - Fixed testcases
nikhagra-akamai c5bfd04
upcoming: [DI-23778] - Added test cases
nikhagra-akamai c86f1d5
upcoming: [DI-23778] - Added todo comment
nikhagra-akamai 6001e23
Merge branch 'develop' of github.com:linode/manager into alerts-conteβ¦
nikhagra-akamai 5738b53
revert testing changes
nikhagra-akamai 13bf1c6
upcoming: [DI-23778] - Updated failing pipeline changes
nikhagra-akamai 84e0029
Merge branch 'develop' of github.com:linode/manager into alerts-conteβ¦
nikhagra-akamai a2b4a74
Merge branch 'linode:develop' into alerts-context-view-dialog
nikhagra-akamai 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/api-v4/.changeset/pr-11785-upcoming-features-1741159921041.md
This file contains hidden or 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/api-v4": Upcoming Features | ||
| --- | ||
|
|
||
| add `EntityAlertUpdatePayload` cloudpulse types.ts ([#11785](https://github.com/linode/manager/pull/11785)) |
This file contains hidden or 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 hidden or 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
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-11785-upcoming-features-1741159867178.md
This file contains hidden or 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 `AlertsConfirmationDialog.tsx`, update `AlertInformationActionTable` to show `confirmation dialog` on toggle ([#11785](https://github.com/linode/manager/pull/11785)) |
42 changes: 42 additions & 0 deletions
42
...ges/manager/src/features/CloudPulse/Alerts/AlertsLanding/AlertConfirmationDialog.test.tsx
This file contains hidden or 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,42 @@ | ||
| import userEvent from '@testing-library/user-event'; | ||
| import React from 'react'; | ||
|
|
||
| import { renderWithTheme } from 'src/utilities/testHelpers'; | ||
|
|
||
| import { AlertConfirmationDialog } from './AlertConfirmationDialog'; | ||
|
|
||
| const alertId = 1; | ||
| const alertName = 'alert-1'; | ||
| const entityName = 'entity-1'; | ||
| const serviceType = 'linode'; | ||
| const confirmFunction = vi.fn(); | ||
| const component = ( | ||
| <AlertConfirmationDialog | ||
| alertId={alertId} | ||
| alertName={alertName} | ||
| entityName={entityName} | ||
| handleCancel={vi.fn()} | ||
| handleConfirm={confirmFunction} | ||
| isActive={true} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add some coverage to this test so that we test both an alert that is active and not active? We could include assertions for whether:
|
||
| isOpen={true} | ||
| serviceType={serviceType} | ||
| /> | ||
| ); | ||
|
|
||
| describe('Alert confirmation dialog', () => { | ||
| it('should show confirmation dialog', () => { | ||
| const { getByTestId, getByText } = renderWithTheme(component); | ||
|
|
||
| expect(getByTestId('confirmation-dialog')).toBeInTheDocument(); | ||
| expect(getByText(`Disable ${alertName} Alert?`)).toBeVisible(); | ||
| }); | ||
| it('should click confirm button', async () => { | ||
| const { getByText } = renderWithTheme(component); | ||
|
|
||
| const cancelButton = getByText('Disable'); | ||
|
|
||
| await userEvent.click(cancelButton); | ||
|
|
||
| expect(confirmFunction).toBeCalledWith(alertId, serviceType, true); | ||
| }); | ||
| }); | ||
105 changes: 105 additions & 0 deletions
105
packages/manager/src/features/CloudPulse/Alerts/AlertsLanding/AlertConfirmationDialog.tsx
This file contains hidden or 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,105 @@ | ||
| import { Typography } from '@linode/ui'; | ||
| import React from 'react'; | ||
|
|
||
| import { ActionsPanel } from 'src/components/ActionsPanel/ActionsPanel'; | ||
| import { ConfirmationDialog } from 'src/components/ConfirmationDialog/ConfirmationDialog'; | ||
|
|
||
| interface AlertConfirmationDialogProps { | ||
| /** | ||
| * Id of the selected alert row | ||
| */ | ||
| alertId: number; | ||
|
|
||
| /** | ||
| * Name of the selected alert row | ||
| */ | ||
| alertName: string; | ||
|
|
||
| /** | ||
| * Name of the selected entity | ||
| */ | ||
| entityName: string; | ||
|
|
||
| /** | ||
| * Handler function for cancel button | ||
| */ | ||
| handleCancel: () => void; | ||
|
|
||
| /** | ||
| * Handler function for enable/disable button | ||
| * @param alertId id of the alert for the selected row | ||
| * @param serviceType service type of the selected entity | ||
| * @param currentStatus current state of the toggle button | ||
| */ | ||
| handleConfirm: ( | ||
| alertId: number, | ||
| serviceType: string, | ||
| currentStatus: boolean | ||
| ) => void; | ||
|
|
||
| /** | ||
| * Current state of the toggle button whether active or not | ||
| */ | ||
| isActive: boolean; | ||
|
|
||
| /** | ||
| * Loading state of the confirmation dialog | ||
| */ | ||
| isLoading?: boolean; | ||
|
|
||
| /** | ||
| * Current state of the confirmation dialoge whether open or not | ||
| */ | ||
| isOpen: boolean; | ||
|
|
||
| /** | ||
| * Service type of the selected entity | ||
| */ | ||
| serviceType: string; | ||
| } | ||
|
|
||
| export const AlertConfirmationDialog = React.memo( | ||
| (props: AlertConfirmationDialogProps) => { | ||
| const { | ||
| alertId, | ||
| alertName, | ||
| entityName, | ||
| handleCancel, | ||
| handleConfirm, | ||
| isActive, | ||
| isLoading = false, | ||
| isOpen, | ||
| serviceType, | ||
| } = props; | ||
|
|
||
| const actionsPanel = React.useCallback(() => { | ||
| return ( | ||
| <ActionsPanel | ||
| primaryButtonProps={{ | ||
| label: isActive ? 'Disable' : 'Enable', | ||
| loading: isLoading, | ||
| onClick: () => handleConfirm(alertId, serviceType, isActive), | ||
| }} | ||
| secondaryButtonProps={{ | ||
| label: 'Cancel', | ||
| onClick: handleCancel, | ||
|
nikhagra-akamai marked this conversation as resolved.
Outdated
|
||
| }} | ||
| /> | ||
| ); | ||
| }, [alertId, handleCancel, handleConfirm, isActive, serviceType]); | ||
| return ( | ||
| <ConfirmationDialog | ||
| actions={actionsPanel} | ||
| data-testid="confirmation-dialog" | ||
| onClose={handleCancel} | ||
| open={isOpen} | ||
| title={`${isActive ? 'Disable' : 'Enable'} ${alertName} Alert?`} | ||
| > | ||
| <Typography variant="subtitle1"> | ||
| Are you sure you want to {isActive ? 'disable' : 'enable'} the alert | ||
| for {entityName}? | ||
| </Typography> | ||
| </ConfirmationDialog> | ||
| ); | ||
| } | ||
| ); | ||
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
@nikhagra-akamai , here we are returning a json object {}, is there any valid return type like, alert with entity details like that?, API should return some response right?
same below as well
Uh oh!
There was an error while loading. Please reload this page.
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.
as of now no any confirmation on its return type because some discussions are going on about this update APIs
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.
So is this PR just for the visual presentation of the confirmation dialog? When is the API response expected to be finalized?
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.
@mjac0bs Yes!! This PR is just for preparing from the UI side. Since it's a reusable component, it wonβt be visible anywhere in the UI until the service-specific APIs are finalized and approved in terms of spec and implementation. Discussions with service owners are ongoing to finalize these APIs. Once thatβs done, weβll integrate them and submit a final PR, allowing this feature to be fully integrated and visible in the UI. Until then, this remains a UI-ready code update.
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.
@nikhagra-akamai May be you can place a comment /ToDo task in this to clear the confusion and setting the expectation.
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've added a todo comment in the query function