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-20928] - Introduce label for all global filters #11118

Merged
merged 36 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bddb5b9
upcoming: [DI-20928] - Filter titles initial changes
venkat199501 Oct 10, 2024
1e7ad15
upcoming: [DI-20928] - ESLint issue fix
venkat199501 Oct 12, 2024
4141099
upcoming: [DI-20928] - Name to label alias change
venkat199501 Oct 12, 2024
bd61ad4
upcoming: [DI-20928] - Add a margin below filter button to look neat …
venkat199501 Oct 12, 2024
c76b146
upcoming: [DI-20928] - Fix UT issues
venkat199501 Oct 12, 2024
484a5a1
upcoming: [DI-20928] - Remove unused import
venkat199501 Oct 12, 2024
c31def0
upcoming: [DI-20928] - PR comments
venkat199501 Oct 14, 2024
9f8ddcf
upcoming: [DI-20928] - PR comments
venkat199501 Oct 14, 2024
b7a9c78
upcoming: [DI-20928] - Title name updates
venkat199501 Oct 15, 2024
8fb44c3
upcoming: [DI-20928] - Title name for dashboard and time range select…
venkat199501 Oct 16, 2024
6657e92
upcoming: [DI-20928] - Title name for dashboard and time range select…
venkat199501 Oct 16, 2024
03160f5
upcoming: [DI-20928] - Test fixes
venkat199501 Oct 16, 2024
4660ad8
upcoming: [DI-20928] - CSS changes
venkat199501 Oct 17, 2024
6492a3d
upcoming: [DI-20928] - Code refactoring and UT additions
venkat199501 Oct 17, 2024
c431f17
upcoming: [DI-20928] - Code refactoring and edits
venkat199501 Oct 17, 2024
0332671
upcoming: [DI-20928] - Destructure properties from objects and use
venkat199501 Oct 17, 2024
c3ea831
upcoming: [DI-20928] - Resource to Resources
venkat199501 Oct 17, 2024
6913878
label changes
agorthi-akamai Oct 17, 2024
dd1b959
upcoming: [DI-20928] - Popper placement changes
venkat199501 Oct 17, 2024
231515d
Merge pull request #58 from agorthi-akamai/label-changes
venkymano-akamai Oct 17, 2024
b0956b8
upcoming: [DI-20928] - PR comments
venkat199501 Oct 17, 2024
de32f8b
Merge branch 'feature/global_filter_titles' of github.com:venkymano-a…
venkat199501 Oct 20, 2024
b03c799
upcoming: [DI-20928] - ESLint issue fix
venkat199501 Oct 20, 2024
7ded56e
upcoming: [DI-20928] - Added comments
venkat199501 Oct 20, 2024
63f5a7a
upcoming: [DI-20928] - remove unwanted changes in package.json
venkat199501 Oct 20, 2024
7c59712
upcoming: [DI-20928] - use theme and add changeset
venkat199501 Oct 21, 2024
bd64ca2
upcoming: [DI-20928] - more simplification
venkat199501 Oct 21, 2024
df14b70
upcoming: [DI-20928] - more space for filters max height
venkat199501 Oct 21, 2024
2486f45
upcoming: [DI-20928] - remove comment
venkat199501 Oct 21, 2024
a39ca76
upcoming: [DI-20928] - destructure props
venkat199501 Oct 21, 2024
f3f1664
upcoming: [DI-20928] - DB to Databases
venkat199501 Oct 22, 2024
e84fb40
upcoming: [DI-20928] - DB to Databases for engine
venkat199501 Oct 22, 2024
04343c5
upcoming: [DI-20928] - Minor PR comments
venkat199501 Oct 22, 2024
3c70079
upcoming: [DI-20928] - Minor PR comments
venkat199501 Oct 22, 2024
adb72de
upcoming: [DI-20928] - Minor PR comments
venkat199501 Oct 22, 2024
127dc20
upcoming: [DI-20928] - Delete unused imports
venkat199501 Oct 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Add title / label for all global filters in ACLP ([#11118](https://github.com/linode/manager/pull/11118))
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,21 @@ describe('Integration Tests for DBaaS Dashboard ', () => {

// Selecting a dashboard from the autocomplete input.
ui.autocomplete
.findByLabel('Select a Dashboard')
.findByLabel('Dashboard')
.should('be.visible')
.type(`${dashboardName}{enter}`)
.should('be.visible');

// Select a time duration from the autocomplete input.
ui.autocomplete
.findByLabel('Select a Time Duration')
.findByLabel('Time Range')
.should('be.visible')
.type(`${timeDurationToSelect}{enter}`)
.should('be.visible');

//Select a Engine from the autocomplete input.
ui.autocomplete
.findByLabel('Select an Engine')
.findByLabel('Database Engine')
.should('be.visible')
.type(`${engine}{enter}`)
.should('be.visible');
Expand All @@ -191,15 +191,15 @@ describe('Integration Tests for DBaaS Dashboard ', () => {

// Select a resource from the autocomplete input.
ui.autocomplete
.findByLabel('Select a Resource')
.findByLabel('Database Clusters')
.should('be.visible')
.type(`${clusterName}{enter}`)
.click();
cy.findByText(clusterName).should('be.visible');

//Select a Node from the autocomplete input.
ui.autocomplete
.findByLabel('Select a Node Type')
.findByLabel('Node Type')
.should('be.visible')
.type(`${nodeType}{enter}`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ describe('Integration Tests for Linode Dashboard ', () => {

// Selecting a dashboard from the autocomplete input.
ui.autocomplete
.findByLabel('Select a Dashboard')
.findByLabel('Dashboard')
.should('be.visible')
.type(`${dashboardName}{enter}`)
.should('be.visible');

// Select a time duration from the autocomplete input.
ui.autocomplete
.findByLabel('Select a Time Duration')
.findByLabel('Time Range')
.should('be.visible')
.type(`${timeDurationToSelect}{enter}`)
.should('be.visible');
Expand All @@ -156,7 +156,7 @@ describe('Integration Tests for Linode Dashboard ', () => {

// Select a resource from the autocomplete input.
ui.autocomplete
.findByLabel('Select a Resource')
.findByLabel('Resources')
.should('be.visible')
.type(`${resource}{enter}`)
.click();
Expand Down
9 changes: 3 additions & 6 deletions packages/manager/cypress/support/util/cloudpulse.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
// Function to generate random values based on the number of points

import type { CloudPulseMetricsResponseData } from '@linode/api-v4';
import type { Labels } from 'src/features/CloudPulse/shared/CloudPulseTimeRangeSelect';

export const generateRandomMetricsData = (
time:
| 'Last 7 Days'
| 'Last 12 Hours'
| 'Last 24 Hours'
| 'Last 30 Days'
| 'Last 30 Minutes',
time: Labels,
granularityData: '1 day' | '1 hr' | '5 min' | 'Auto'
): CloudPulseMetricsResponseData => {
const currentTime = Math.floor(Date.now() / 1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const SelectedIcon = styled(DoneIcon, {
}));

export const CustomPopper = (props: PopperProps) => {
const { style, ...rest } = props;
const { placement, style, ...rest } = props;

const updatedStyle = {
...style,
Expand All @@ -58,9 +58,13 @@ export const CustomPopper = (props: PopperProps) => {
return (
<Popper
{...rest}
modifiers={[
{ enabled: false, name: 'preventOverflow' },
{ enabled: !placement, name: 'flip' },
]}
data-qa-autocomplete-popper
data-testid="autocomplete-popper"
modifiers={[{ enabled: false, name: 'preventOverflow' }]}
placement={placement}
style={updatedStyle}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const RegionSelect = <
helperText,
ignoreAccountAvailability,
label,
noMarginTop,
onChange,
placeholder,
regionFilter,
Expand Down Expand Up @@ -172,6 +173,7 @@ export const RegionSelect = <
label={label ?? 'Region'}
loading={accountAvailabilityLoading}
loadingText="Loading regions..."
noMarginTop={noMarginTop ?? false}
Copy link
Member

Choose a reason for hiding this comment

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

No need to put the ?? false. This component can accept undefined

Suggested change
noMarginTop={noMarginTop ?? false}
noMarginTop={noMarginTop}

noOptionsText="No results"
onChange={onChange}
options={regionOptions}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('Global filters component test', () => {
expect(timeRangeSelect).toBeInTheDocument();

expect(
screen.getByRole('combobox', { name: 'Select a Time Duration' })
screen.getByRole('combobox', { name: 'Time Range' })
).toHaveAttribute('value', 'Last 30 Minutes');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,14 @@ export const GlobalFilters = React.memo((props: GlobalFilterProperties) => {
defaultValue={preferences?.timeDuration}
handleStatsChange={handleTimeRangeChange}
hideLabel
label="Select Time Range"
label="Time Range"
savePreferences
/>
<CloudPulseTooltip placement="bottom-end" title="Refresh">
<IconButton
sx={{
marginBlockEnd: 'auto',
marginTop: theme.spacing(3.5),
}}
aria-label="Refresh Dashboard Metrics"
data-testid="global-refresh"
Expand Down
106 changes: 74 additions & 32 deletions packages/manager/src/features/CloudPulse/Utils/FilterBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,37 +31,49 @@ it('test getRegionProperties method', () => {
expect(regionConfig).toBeDefined();

if (regionConfig) {
const result = getRegionProperties(
const {
handleRegionChange,
label,
selectedDashboard,
} = getRegionProperties(
{
config: regionConfig,
dashboard: mockDashboard,
isServiceAnalyticsIntegration: false,
},
vi.fn()
);
expect(result['handleRegionChange']).toBeDefined();
expect(result['selectedDashboard']).toEqual(mockDashboard);
const { name } = regionConfig.configuration;
expect(handleRegionChange).toBeDefined();
expect(selectedDashboard).toEqual(mockDashboard);
expect(label).toEqual(name);
}
});

it('test getTimeDuratonProperties method', () => {
const timeDurationConfig = linodeConfig?.filters.find(
(filterObj) => filterObj.name === 'Time Duration'
({ name }) => name === 'Time Range'
);

expect(timeDurationConfig).toBeDefined();

if (timeDurationConfig) {
const result = getTimeDurationProperties(
const {
handleStatsChange,
label,
savePreferences,
} = getTimeDurationProperties(
{
config: timeDurationConfig,
dashboard: mockDashboard,
isServiceAnalyticsIntegration: false,
},
vi.fn()
);
expect(result['handleStatsChange']).toBeDefined();
expect(result['savePreferences']).toEqual(true);
const { name } = timeDurationConfig.configuration;
expect(handleStatsChange).toBeDefined();
expect(savePreferences).toEqual(true);
expect(label).toEqual(name);
}
});

Expand All @@ -73,7 +85,13 @@ it('test getResourceSelectionProperties method', () => {
expect(resourceSelectionConfig).toBeDefined();

if (resourceSelectionConfig) {
const result = getResourcesProperties(
const {
disabled,
handleResourcesSelection,
label,
savePreferences,
xFilter,
} = getResourcesProperties(
{
config: resourceSelectionConfig,
dashboard: mockDashboard,
Expand All @@ -82,12 +100,12 @@ it('test getResourceSelectionProperties method', () => {
},
vi.fn()
);
expect(result['handleResourcesSelection']).toBeDefined();
expect(result['savePreferences']).toEqual(false);
expect(result['disabled']).toEqual(false);
expect(JSON.stringify(result['xFilter'])).toEqual(
'{"+and":[{"region":"us-east"}]}'
);
const { name } = resourceSelectionConfig.configuration;
expect(handleResourcesSelection).toBeDefined();
expect(savePreferences).toEqual(false);
expect(disabled).toEqual(false);
expect(JSON.stringify(xFilter)).toEqual('{"+and":[{"region":"us-east"}]}');
expect(label).toEqual(name);
}
});

Expand All @@ -99,7 +117,13 @@ it('test getResourceSelectionProperties method with disabled true', () => {
expect(resourceSelectionConfig).toBeDefined();

if (resourceSelectionConfig) {
const result = getResourcesProperties(
const {
disabled,
handleResourcesSelection,
label,
savePreferences,
xFilter,
} = getResourcesProperties(
{
config: resourceSelectionConfig,
dashboard: mockDashboard,
Expand All @@ -108,10 +132,12 @@ it('test getResourceSelectionProperties method with disabled true', () => {
},
vi.fn()
);
expect(result['handleResourcesSelection']).toBeDefined();
expect(result['savePreferences']).toEqual(false);
expect(result['disabled']).toEqual(true);
expect(JSON.stringify(result['xFilter'])).toEqual('{"+and":[]}');
const { name } = resourceSelectionConfig.configuration;
expect(handleResourcesSelection).toBeDefined();
expect(savePreferences).toEqual(false);
expect(disabled).toEqual(true);
expect(JSON.stringify(xFilter)).toEqual('{"+and":[]}');
expect(label).toEqual(name);
}
});

Expand Down Expand Up @@ -201,7 +227,14 @@ it('test getCustomSelectProperties method', () => {
expect(customSelectEngineConfig).toBeDefined();

if (customSelectEngineConfig) {
let result = getCustomSelectProperties(
const {
clearDependentSelections,
disabled,
isMultiSelect,
label,
options,
savePreferences,
} = getCustomSelectProperties(
{
config: customSelectEngineConfig,
dashboard: { ...mockDashboard, service_type: 'dbaas' },
Expand All @@ -210,21 +243,27 @@ it('test getCustomSelectProperties method', () => {
vi.fn()
);

expect(result.options).toBeDefined();
expect(result.options?.length).toEqual(2);
expect(result.savePreferences).toEqual(false);
expect(result.isMultiSelect).toEqual(false);
expect(result.disabled).toEqual(false);
expect(result.clearDependentSelections).toBeDefined();
expect(result.clearDependentSelections?.includes(RESOURCES)).toBe(true);
expect(options).toBeDefined();
expect(options?.length).toEqual(2);
expect(savePreferences).toEqual(false);
expect(isMultiSelect).toEqual(false);
expect(label).toEqual(customSelectEngineConfig.configuration.name);
expect(disabled).toEqual(false);
expect(clearDependentSelections).toBeDefined();
expect(clearDependentSelections?.includes(RESOURCES)).toBe(true);

customSelectEngineConfig.configuration.type = CloudPulseSelectTypes.dynamic;
customSelectEngineConfig.configuration.apiV4QueryKey =
databaseQueries.engines;
customSelectEngineConfig.configuration.isMultiSelect = true;
customSelectEngineConfig.configuration.options = undefined;

result = getCustomSelectProperties(
const {
apiV4QueryKey,
isMultiSelect: isMultiSelectApi,
savePreferences: savePreferencesApi,
type,
} = getCustomSelectProperties(
{
config: customSelectEngineConfig,
dashboard: mockDashboard,
Expand All @@ -233,10 +272,13 @@ it('test getCustomSelectProperties method', () => {
vi.fn()
);

expect(result.apiV4QueryKey).toEqual(databaseQueries.engines);
expect(result.type).toEqual(CloudPulseSelectTypes.dynamic);
expect(result.savePreferences).toEqual(false);
expect(result.isMultiSelect).toEqual(true);
const { name } = customSelectEngineConfig.configuration;

expect(apiV4QueryKey).toEqual(databaseQueries.engines);
expect(type).toEqual(CloudPulseSelectTypes.dynamic);
expect(savePreferencesApi).toEqual(false);
expect(isMultiSelectApi).toEqual(true);
expect(label).toEqual(name);
}
});

Expand Down
Loading