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

upcoming: [DI-20357] - Changes for ACLP Dashboard with Filters component #10845

Conversation

venkymano-akamai
Copy link
Contributor

@venkymano-akamai venkymano-akamai commented Aug 28, 2024

Description 📝

Added a new CloudPulseDashboardWithFilters component which has the capability to build the filters needed in service provider page as well as the dashboard. This component will be integrated in the service provider pages.

Changes 🔄

  1. Added new CloudPulseDashboardWithFilters component that has the capability to build the filters needed in service provider page as well as the dashboard. This will be integrated only in the service provider pages.
  2. Modified the dbaas config to introduce a new filter nodeType and changed needInServicePage prop to false

Target release date 🗓️

03-09-2024

Preview 📷

Before After
Screenshot 2024-08-28 at 11 40 04 AM Screenshot 2024-08-28 at 11 40 29 AM
Screenshot 2024-08-28 at 11 40 38 AM
Screenshot 2024-08-28 at 11 41 19 AM Screenshot 2024-08-28 at 11 41 12 AM

How to test 🧪

To test this, we need to integrate the CloudPulseDashboardWithFilters in a service Provider page. The below commit shows the test integration we made in database details index page

venkymano-akamai@e0f3598

  1. Copy the code in the commit in the same file mentioned in the commit
  2. Start the cloud manager UI application
  3. Login and enable mock user as some API endpoints are not available still.
  4. Navigate to any database instance details page, and navigate to the monitor tab.
  5. You will see filters needed in service provide page as well as a mock dashboard rendered.

Note - We support only linode and dbaas, so the sample integration revolves around Managed Databases

As an Author I have considered 🤔

Check all that apply

  • 👀 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

@venkymano-akamai venkymano-akamai requested a review from a team as a code owner August 28, 2024 06:49
@venkymano-akamai venkymano-akamai requested review from jdamore-linode and harsh-akamai and removed request for a team August 28, 2024 06:49
@venkymano-akamai venkymano-akamai changed the title upcoming: [DI-20357] - Changes for ACLP single reusable component upcoming: [DI-20357] - Changes for ACLP Dashboard with Filters component Aug 28, 2024
Copy link

github-actions bot commented Aug 29, 2024

Coverage Report:
Base Coverage: 86.2%
Current Coverage: 86.2%

</Grid>
</Paper>
</Grid>
</Grid>
Copy link
Contributor

Choose a reason for hiding this comment

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

There's so many grid components here, do we need all these for some future additions or something?
This can all be done with a single Box essentially

<>
        <Paper>
          <Box
            sx={{
              justifyContent: {
                sm: 'flex-start',
                xs: 'center',
              },
            }}
            display="flex"
            paddingX={2}
            paddingY={1}
          >
            <CloudPulseTimeRangeSelect
              disabled={!dashboard}
              handleStatsChange={handleTimeRangeChange}
              savePreferences={true}
            />
          </Box>
          <Divider />
          {isFilterBuilderNeeded && (
            <CloudPulseDashboardFilterBuilder
              dashboard={dashboard}
              emitFilterChange={onFilterChange}
              isServiceAnalyticsIntegration={true}
            />
          )}
          <Divider />
        </Paper>
        {isMandatoryFiltersSelected ? (
          <CloudPulseDashboard
            {...getDashboardProperties({
              dashboardObj: dashboard,
              filterValue,
              resource,
              timeDuration,
            })}
          />
        ) : (
          renderPlaceHolder('Mandatory Filters not Selected')
        )}
      </>

Copy link
Contributor Author

@venkymano-akamai venkymano-akamai Aug 30, 2024

Choose a reason for hiding this comment

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

@jaalah-akamai , in future we might add elements like TimeRangeSelect that are common for all service providers. I also agree we don't need this much Grids. I updated the code to have a single Grid Container, and placed the TimeRangeSelect inside it, so in future if we add elements, we can easily configure the responsiveness in grid and achieve the rows and columns of our needed choice. The below looks more or less the same as suggested approach.

<>
        <Paper>
          <Grid
            justifyContent={{
              sm: 'flex-end',
              xs: 'center',
            }}
            columnSpacing={2}
            container
            display={'flex'}
            item
            maxHeight={'120px'}
            mb={1}
            overflow={'auto'}
            px={2}
            py={1}
            rowGap={2}
            xs={12}
          >
            <Grid item md={4} sm={6} xs={12}>
              <CloudPulseTimeRangeSelect
                disabled={!dashboard}
                handleStatsChange={handleTimeRangeChange}
                savePreferences={true}
              />
            </Grid>
          </Grid>
          <Divider />
          {isFilterBuilderNeeded && (
            <CloudPulseDashboardFilterBuilder
              dashboard={dashboard}
              emitFilterChange={onFilterChange}
              isServiceAnalyticsIntegration={true}
            />
          )}
          {isFilterBuilderNeeded && <Divider />}
        </Paper>
        {isMandatoryFiltersSelected ? (
          <CloudPulseDashboard
            {...getDashboardProperties({
              dashboardObj: dashboard,
              filterValue,
              resource,
              timeDuration,
            })}
          />
        ) : (
          renderPlaceHolder('Mandatory Filters not Selected')
        )}
      </>

@jaalah-akamai jaalah-akamai added the Add'tl Approval Needed Waiting on another approval! label Sep 3, 2024
Copy link
Contributor

@coliu-akamai coliu-akamai left a comment

Choose a reason for hiding this comment

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

I feel like there might be a way to simplify a few of the methods in ReusableDashboardFilterUtils.ts in addition to what I commented on - will think on this a bit and get back to you!

Comment on lines 24 to 26
/**
* These properties are required for rendering the component
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick - this comment could be removed, since the props are already required props/not marked as optional

Comment on lines +61 to +63
if (!serviceTypeConfig) {
return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need this since we're checking whether serviceTypeConfig is truthy at line 69/70. We can either keep this check or lines 69/70, but we don't need both

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, here kept this and removed line 69 and 70

Comment on lines 107 to 109
if (!filter) {
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need this check? Doesn't seem like filter will ever be undefined/null:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

don't need, removed

@venkymano-akamai
Copy link
Contributor Author

@coliu-akamai , I have addressed those you have given

expect(result[0].filterValue).toEqual('primary');
});

it('test checkIfFilterBuilderNeeded method', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we also have a test for an undefined dashboard?

Comment on lines +25 to +30
let result = checkMandatoryFiltersSelected({
dashboardObj: mockDashboard,
filterValue: { region: 'us-east' },
resource: 0,
});
expect(result).toBe(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

could we add a test where we check for timeDuration and resource falsy values individually? So we can keep this test (but make resource here a truthy value), and then have another test like


let result = checkMandatoryFiltersSelected({
    dashboardObj: mockDashboard,
    filterValue: { region: 'us-east' },
    timeDuration: { unit: 'min', value: 30 },
    resource: 0,
  });
expect(result).toBe(false);

that way we're checking for each of the cases individually

Copy link
Contributor Author

@venkymano-akamai venkymano-akamai Sep 4, 2024

Choose a reason for hiding this comment

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

Added as individual test cases for time duration undefined value and resource 0 value

@@ -0,0 +1,92 @@
import { dashboardFactory } from 'src/factories';
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add tests for checkIfFilterNeededInMetricsCall?

Comment on lines 104 to 105
return serviceTypeConfig.filters.some((filter) => {
const { configuration } = filter;
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed at line 69 you destructured filter - you could do something similar here if you want

Suggested change
return serviceTypeConfig.filters.some((filter) => {
const { configuration } = filter;
return serviceTypeConfig.filters.some(({ configuration }) => {

* @param serviceType The serviceType of the selected dashboard
* @returns True, if the filter is needed in the metrics call, else false
*/
export const checkIfFilterNeededInMetricsCall = (
Copy link
Contributor

@coliu-akamai coliu-akamai Sep 3, 2024

Choose a reason for hiding this comment

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

thought about simplifying this a bit more but to be honest, there could be a bit of a readability tradeback. This is 100% optional in case you prefer this, but it's definitely not necessary (and having the if (!serviceTypeConfig) check might actually be a bit more readable and straightforward). If you end up going this route, you could do something similar with checkIfFilterBuilderNeeded too

export const checkIfFilterNeededInMetricsCall = (
  filterKey: string,
  serviceType: string
): boolean => {
  const serviceTypeConfig = FILTER_CONFIG.get(serviceType);

  return (
    serviceTypeConfig?.filters.some(({ configuration }) => {
      const {
        filterKey: configFilterKey,
        isFilterable,
        neededInServicePage,
      } = configuration;

      return (
        configFilterKey === filterKey &&
        Boolean(isFilterable) &&
        neededInServicePage // Indicates if this filter should be included in the metrics call
      );
    }) ?? false
  );
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lets, have the readability one for now

@venkymano-akamai
Copy link
Contributor Author

@coliu-akamai , Addressed the comments, can you please check if this is good now?

Copy link
Contributor

@coliu-akamai coliu-akamai left a comment

Choose a reason for hiding this comment

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

Thanks for the changes!

✅ confirmed mocked dashboard for dbaas instances

@coliu-akamai coliu-akamai added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Sep 4, 2024
@jaalah-akamai jaalah-akamai merged commit 2630aed into linode:develop Sep 4, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Multiple approvals and ready to merge! CloudPulse
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants