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

DI-23223: Update the EditAlertResources component to save the added / removed resources and Show only selected resources #11613

Merged

Conversation

venkymano-akamai
Copy link
Contributor

@venkymano-akamai venkymano-akamai commented Feb 5, 2025

Description 📝

Update the EditAlertResources component to save the added / removed resources.

Changes 🔄

  1. Enhanced the Alert Resources component to show only the selected resources.
  2. Add a new notice component to show the selections of the resources.
  3. Enhanced the EditAlertResources component to save the added / removed resources.

Target release date 🗓️

11-02-2025

Preview 📷

Before/Mobile/Theme After/Mobile/Theme
Screenshot 2025-02-05 at 8 11 46 AM Screenshot 2025-02-05 at 8 10 06 AM
Screenshot 2025-02-05 at 8 10 14 AM Screenshot 2025-02-05 at 8 10 25 AM
Screenshot 2025-02-05 at 8 10 32 AM Screenshot 2025-02-05 at 8 10 53 AM
Screenshot 2025-02-05 at 12 10 31 PM Screenshot 2025-02-05 at 12 10 39 PM
Screenshot 2025-02-05 at 12 09 52 PM Screenshot 2025-02-05 at 12 10 00 PM

How to test 🧪

  1. Login as mock as some of the endpoints are not available.
  2. Navigate to Monitor tab and then to Alerts.
  3. Select a dbaas related alert (mocks are good here) and if you find Edit(only for system alerts) click on that.
  4. You will be able to see the changes
Author Checklists

As an Author, to speed up the review process, I considered 🤔

👀 Doing a self review
❔ Our contribution guidelines
🤏 Splitting feature into small PRs
➕ Adding a changeset
🧪 Providing/improving test coverage
🔐 Removing all sensitive information from the code and PR description
🚩 Using a feature flag to protect the release
👣 Providing comprehensive reproduction steps
📑 Providing or updating our documentation
🕛 Scheduling a pair reviewing session
📱 Providing mobile support
♿ Providing accessibility support


  • I have read and considered all applicable items listed above.

As an Author, before moving this PR from Draft to Open, I confirmed ✅

  • All unit tests are passing
  • TypeScript compilation succeeded without errors
  • Code passes all linting rules

@venkymano-akamai venkymano-akamai changed the title Update the EditAlertResources component to save the added / removed resources. DI-23201: Update the EditAlertResources component to save the added / removed resources and Show selected only resources Feb 5, 2025
@venkymano-akamai venkymano-akamai self-assigned this Feb 5, 2025
@venkymano-akamai venkymano-akamai changed the title DI-23201: Update the EditAlertResources component to save the added / removed resources and Show selected only resources DI-23201: Update the EditAlertResources component to save the added / removed resources and Show only selected resources Feb 5, 2025
@venkymano-akamai venkymano-akamai changed the title DI-23201: Update the EditAlertResources component to save the added / removed resources and Show only selected resources DI-23223: Update the EditAlertResources component to save the added / removed resources and Show only selected resources Feb 5, 2025
Comment on lines +184 to +198
export const isResourcesEqual = (
originalResourceIds: string[] | undefined,
selectedResourceIds: string[]
): boolean => {
if (!originalResourceIds) {
return selectedResourceIds.length === 0;
}

if (originalResourceIds?.length !== selectedResourceIds.length) {
return false;
}

const originalSet = new Set(originalResourceIds);
return selectedResourceIds.every((id) => originalSet.has(id));
};
Copy link
Contributor

Choose a reason for hiding this comment

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

@venkymano-akamai can we re-use functions from dashboards for cases like this? ex - deepequal func ..

Copy link
Contributor Author

@venkymano-akamai venkymano-akamai Feb 5, 2025

Choose a reason for hiding this comment

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

But here we don't need deep equals, we need deep equals in case of comparing complex objects, here it is primitive type, we can just use what we have

@venkymano-akamai venkymano-akamai marked this pull request as ready for review February 5, 2025 07:53
@venkymano-akamai venkymano-akamai requested a review from a team as a code owner February 5, 2025 07:53
},
})}
data-testid="show_selected_only"
disabled={!(Boolean(selectedResources.length) || selectedOnly)}
Copy link
Contributor

Choose a reason for hiding this comment

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

no need Boolean function

Suggested change
disabled={!(Boolean(selectedResources.length) || selectedOnly)}
disabled={!selectedResources.length || selectedOnly}


const { mutateAsync: editAlert } = useEditAlertDefinition(
serviceType,
Number(alertId)
Copy link
Contributor

Choose a reason for hiding this comment

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

is it necessary to send it as number? can't it go just as string?

@venkymano-akamai
Copy link
Contributor Author

@nikhagra-akamai , Thanks for the approval, addressed your comments as well.

@venkymano-akamai venkymano-akamai added the Add'tl Approval Needed Waiting on another approval! label Feb 5, 2025
Copy link

github-actions bot commented Feb 5, 2025

Coverage Report:
Base Coverage: 78.94%
Current Coverage: 78.94%

@venkymano-akamai venkymano-akamai requested review from pmakode-akamai and removed request for pmakode-akamai February 6, 2025 01:11
<Grid container spacing={3}>
<Grid columnSpacing={1} container item rowSpacing={3} xs={12}>
<Grid columnSpacing={2} container item rowSpacing={3} xs={12}>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think alignItems="center" would benefit things here if we remove some of the checkbox styling.

maxHeight: '34px',
pt: theme.spacing(1.2),
svg: {
backgroundColor: theme.color.white,
Copy link
Contributor

@jaalah-akamai jaalah-akamai Feb 6, 2025

Choose a reason for hiding this comment

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

Suggested change
backgroundColor: theme.color.white,
backgroundColor: theme.tokens.color.Neutrals.White,

Comment on lines 261 to 262
maxHeight: '34px',
pt: theme.spacing(1.2),
Copy link
Contributor

Choose a reason for hiding this comment

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

We should remove both of these. The alignItems of the parent should center things

Comment on lines 77 to 79
marginLeft: theme.spacing(1),
minHeight: 'auto',
minWidth: 'auto',
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove this entire styled component in place of StyledLinkButton which you can import from linode/ui

Comment on lines 66 to 73
alignItems: 'center',
background: theme.bg.bgPaper,
borderRadius: 1,
display: 'flex',
flexWrap: 'nowrap',
height: '54px',
marginBottom: 0,
padding: theme.spacing(2),
Copy link
Contributor

Choose a reason for hiding this comment

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

I would see how many of these we can remove, some of these are redundant and already provided by the Notice component.

borderRadius: 1,
display: 'flex',
flexWrap: 'nowrap',
height: '54px',
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove the height and ensure we have the proper padding

Comment on lines 160 to 162
sx={{
ml: 1,
}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to apply gap={1} display="flex" to the containing Box

open={openConfirmationDialog}
title="Confirm alert updates"
>
<Typography fontSize="16px" variant="body1">
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no 16px token as depicted in the design, this is going to have to be 14px unless they want to add a new token

Suggested change
<Typography fontSize="16px" variant="body1">
<Typography sx={(theme) => ({
font: theme.tokens.typography.Body,
})} variant="body1">

</StyledButton>
)}
{!isSelectAll && (
<StyledButton
Copy link
Contributor

Choose a reason for hiding this comment

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

Use StyledLinkButton

const isSelectAll = selectedResources !== totalResources;

return (
<StyledNotice variant="info">
Copy link
Contributor

Choose a reason for hiding this comment

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

Add gap={1} for the spacing you need between text and button

@jaalah-akamai jaalah-akamai added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Feb 7, 2025
@linode-gh-bot
Copy link
Collaborator

Cloud Manager UI test results

🎉 500 passing tests on test run #25 ↗︎

❌ Failing✅ Passing↪️ Skipped🕐 Duration
0 Failing500 Passing2 Skipped104m 7s

@venkymano-akamai
Copy link
Contributor Author

Merging since tests passed, lint passed, jobs passed and we have enough approvals

@venkymano-akamai venkymano-akamai merged commit 08b8627 into linode:develop Feb 7, 2025
23 checks passed
Copy link

cypress bot commented Feb 7, 2025

Cloud Manager E2E    Run #7195

Run Properties:  status check passed Passed #7195  •  git commit 08b86275ce: DI-23223: Update the EditAlertResources component to save the added / removed re...
Project Cloud Manager E2E
Branch Review develop
Run status status check passed Passed #7195
Run duration 30m 34s
Commit git commit 08b86275ce: DI-23223: Update the EditAlertResources component to save the added / removed re...
Committer venkatmano-akamai
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 3
Tests that did not run due to a developer annotating a test with .skip  Pending 2
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 500
View all changes introduced in this branch ↗︎

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

Successfully merging this pull request may close these issues.

5 participants