Skip to content

Commit ba33b07

Browse files
refactor: [M3-9266] - Make RegionSelect pure (linode#11790)
* Initial commit: Make RegionSelect Pure * Import fix * Fix import * Refactor & add accountAvailability props to RegionSelect * Fix RegionSelect cypress component tests * Refactor & add accountAvailability props to RegionMultiSelect * Clean up * More clean up... * Clean up comments * Move regionsData to `utilities` package * Move ListItemOption to `ui` package * Update comment * Update todo comments * Update comment * Added changeset: Make `RegionSelect` and `RegionMultiSelect` pure * Added changeset: Move `ListItemOption` from `manager` to `ui` package * Added changeset: Move `ListItemOption` from `manager` to `ui` package * Added changeset: Move `regionsData` from `manager` to `utilities` package * Added changeset: Move `regionsData` from `manager` to `utilities` package * Add todo comments * Update remaining imports * Move `LinodeCreateType` to @linode/utilities types * Move regions factory to utilities package * Update todo comments * Add/update todo comments * More updates * Add Flag Component as a prop to `RegionSelect` and `RegionMultiSelect` * RegionOption to except Flag component prop and move accountAvability factory * Fix storybook * fix: Temporarily add flags CDN in RegionSelect and update tests * Update image alt * Revert `Flag` as a prop to `RegionSelect` & `RegionMultiSelect` * Revert accountAvailability query data as a prop * regions query as a prop clean up * Added changeset: Move `LinodeCreateType` to `utilities` package * Added changeset: Move `LinodeCreateType` to `utilities` package * Clean up: unnecessary code comments
1 parent 491a0cd commit ba33b07

File tree

161 files changed

+421
-277
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+421
-277
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Removed
3+
---
4+
5+
Move `ListItemOption` from `manager` to `ui` package ([#11790](https://github.com/linode/manager/pull/11790))
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Removed
3+
---
4+
5+
Move `regionsData` from `manager` to `utilities` package ([#11790](https://github.com/linode/manager/pull/11790))
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Removed
3+
---
4+
5+
Move `LinodeCreateType` to `utilities` package ([#11790](https://github.com/linode/manager/pull/11790))
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Tech Stories
3+
---
4+
5+
Make `RegionSelect` and `RegionMultiSelect` pure ([#11790](https://github.com/linode/manager/pull/11790))

packages/manager/cypress/component/components/region-select.spec.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { accountAvailabilityFactory, regionFactory } from '@linode/utilities';
12
import * as React from 'react';
23
import { mockGetAccountAvailability } from 'support/intercepts/account';
34
import { ui } from 'support/ui';
@@ -6,7 +7,6 @@ import { createSpy } from 'support/util/components';
67
import { componentTests, visualTests } from 'support/util/components';
78

89
import { RegionSelect } from 'src/components/RegionSelect/RegionSelect';
9-
import { accountAvailabilityFactory, regionFactory } from 'src/factories';
1010

1111
componentTests('RegionSelect', (mount) => {
1212
beforeEach(() => {
@@ -26,6 +26,7 @@ componentTests('RegionSelect', (mount) => {
2626
mount(
2727
<RegionSelect
2828
currentCapability="Object Storage"
29+
flags={{}}
2930
onChange={() => {}}
3031
regions={[region]}
3132
value={undefined}
@@ -54,6 +55,7 @@ componentTests('RegionSelect', (mount) => {
5455
mount(
5556
<RegionSelect
5657
currentCapability="Object Storage"
58+
flags={{}}
5759
onChange={() => {}}
5860
regions={[region]}
5961
value={undefined}
@@ -83,6 +85,7 @@ componentTests('RegionSelect', (mount) => {
8385
mount(
8486
<RegionSelect
8587
currentCapability="Object Storage"
88+
flags={{}}
8689
onChange={() => {}}
8790
regions={[region]}
8891
value={undefined}
@@ -112,6 +115,7 @@ componentTests('RegionSelect', (mount) => {
112115
<span id="other-element">Other Element</span>
113116
<RegionSelect
114117
currentCapability="Object Storage"
118+
flags={{}}
115119
onChange={() => {}}
116120
regions={[region]}
117121
value={undefined}
@@ -145,6 +149,7 @@ componentTests('RegionSelect', (mount) => {
145149
mount(
146150
<RegionSelect
147151
currentCapability={undefined}
152+
flags={{}}
148153
onChange={() => {}}
149154
regions={regions}
150155
value={undefined}
@@ -179,6 +184,7 @@ componentTests('RegionSelect', (mount) => {
179184
mount(
180185
<RegionSelect
181186
currentCapability={undefined}
187+
flags={{}}
182188
onChange={() => {}}
183189
regions={regions}
184190
value={regionToPreselect.id}
@@ -214,6 +220,7 @@ componentTests('RegionSelect', (mount) => {
214220
mount(
215221
<RegionSelect
216222
currentCapability={undefined}
223+
flags={{}}
217224
onChange={() => {}}
218225
regions={regions}
219226
value={regionToSelect.id}
@@ -241,6 +248,7 @@ componentTests('RegionSelect', (mount) => {
241248
<RegionSelect
242249
currentCapability={undefined}
243250
disableClearable={true}
251+
flags={{}}
244252
onChange={() => {}}
245253
regions={regions}
246254
value={regionToSelect.id}
@@ -260,6 +268,7 @@ componentTests('RegionSelect', (mount) => {
260268
mount(
261269
<RegionSelect
262270
currentCapability={undefined}
271+
flags={{}}
263272
onChange={() => {}}
264273
regions={regions}
265274
value={undefined}
@@ -277,6 +286,7 @@ componentTests('RegionSelect', (mount) => {
277286
mount(
278287
<RegionSelect
279288
currentCapability={undefined}
289+
flags={{}}
280290
onChange={spyFn}
281291
regions={regions}
282292
value={undefined}
@@ -301,6 +311,7 @@ componentTests('RegionSelect', (mount) => {
301311
mount(
302312
<RegionSelect
303313
currentCapability={undefined}
314+
flags={{}}
304315
onChange={spyFn}
305316
regions={regions}
306317
value={regionToSelect.id}
@@ -345,6 +356,7 @@ componentTests('RegionSelect', (mount) => {
345356
mount(
346357
<RegionSelect
347358
currentCapability="Object Storage"
359+
flags={{}}
348360
onChange={() => {}}
349361
regions={regions}
350362
value={undefined}
@@ -379,6 +391,7 @@ componentTests('RegionSelect', (mount) => {
379391
mount(
380392
<RegionSelect
381393
currentCapability="Object Storage"
394+
flags={{}}
382395
onChange={() => {}}
383396
regions={regions}
384397
value={undefined}
@@ -408,6 +421,7 @@ componentTests('RegionSelect', (mount) => {
408421
mount(
409422
<RegionSelect
410423
currentCapability={undefined}
424+
flags={{}}
411425
onChange={() => {}}
412426
regions={regions}
413427
value={undefined}
@@ -438,6 +452,7 @@ componentTests('RegionSelect', (mount) => {
438452
mount(
439453
<RegionSelect
440454
currentCapability={undefined}
455+
flags={{}}
441456
onChange={() => {}}
442457
regions={regions}
443458
value={undefined}
@@ -450,6 +465,7 @@ componentTests('RegionSelect', (mount) => {
450465
mount(
451466
<RegionSelect
452467
currentCapability={undefined}
468+
flags={{}}
453469
onChange={() => {}}
454470
regions={regions}
455471
value={selectedRegion.id}
@@ -462,6 +478,7 @@ componentTests('RegionSelect', (mount) => {
462478
mount(
463479
<RegionSelect
464480
currentCapability={undefined}
481+
flags={{}}
465482
onChange={() => {}}
466483
regions={regions}
467484
value={selectedRegion.id}

packages/manager/cypress/e2e/core/cloudpulse/alert-show-details.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This file contains Cypress tests that validate the display and content of the Alerts Show Detail Page in the CloudPulse application.
55
* It ensures that all alert details, criteria, and resource information are displayed correctly.
66
*/
7-
import { capitalize } from '@linode/utilities';
7+
import { capitalize, regionFactory } from '@linode/utilities';
88
import {
99
aggregationTypeMap,
1010
dimensionOperatorTypeMap,
@@ -28,7 +28,6 @@ import {
2828
alertRulesFactory,
2929
databaseFactory,
3030
notificationChannelFactory,
31-
regionFactory,
3231
} from 'src/factories';
3332
import { formatDate } from 'src/utilities/formatDate';
3433

packages/manager/cypress/e2e/core/cloudpulse/cloudpulse-dashboard-errors.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @file Error Handling Tests for CloudPulse Dashboard.
33
*/
4+
import { regionFactory } from '@linode/utilities';
45
import { widgetDetails } from 'support/constants/widgets';
56
import { mockGetAccount } from 'support/intercepts/account';
67
import {
@@ -32,7 +33,6 @@ import {
3233
dashboardFactory,
3334
dashboardMetricFactory,
3435
databaseFactory,
35-
regionFactory,
3636
widgetFactory,
3737
} from 'src/factories';
3838

packages/manager/cypress/e2e/core/cloudpulse/create-user-alert.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* @fileoverview Cypress test suite for the "Create Alert" functionality.
33
*/
44

5+
import { regionFactory } from '@linode/utilities';
56
import { statusMap } from 'support/constants/alert';
67
import { widgetDetails } from 'support/constants/widgets';
78
import { mockGetAccount } from 'support/intercepts/account';
@@ -26,7 +27,6 @@ import {
2627
databaseFactory,
2728
memoryRulesFactory,
2829
notificationChannelFactory,
29-
regionFactory,
3030
triggerConditionFactory,
3131
} from 'src/factories';
3232
import { formatDate } from 'src/utilities/formatDate';

packages/manager/cypress/e2e/core/cloudpulse/dbaas-widgets-verification.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @file Integration Tests for CloudPulse Dbass Dashboard.
33
*/
4+
import { regionFactory } from '@linode/utilities';
45
import { widgetDetails } from 'support/constants/widgets';
56
import { mockGetAccount } from 'support/intercepts/account';
67
import {
@@ -27,7 +28,6 @@ import {
2728
databaseFactory,
2829
kubeLinodeFactory,
2930
linodeFactory,
30-
regionFactory,
3131
widgetFactory,
3232
} from 'src/factories';
3333
import { generateGraphData } from 'src/features/CloudPulse/Utils/CloudPulseWidgetUtils';

packages/manager/cypress/e2e/core/cloudpulse/edit-system-alert.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* This file contains Cypress tests for the Edit Alert page of the CloudPulse application.
55
* It ensures that users can navigate to the Edit Alert Page and that alerts are correctly displayed and interactive on the Edit page.
66
*/
7+
import { regionFactory } from '@linode/utilities';
78
import { mockGetAccount } from 'support/intercepts/account';
89
import {
910
mockGetAlertDefinitions,
@@ -15,12 +16,7 @@ import { mockAppendFeatureFlags } from 'support/intercepts/feature-flags';
1516
import { mockGetRegions } from 'support/intercepts/regions';
1617
import { ui } from 'support/ui';
1718

18-
import {
19-
accountFactory,
20-
alertFactory,
21-
databaseFactory,
22-
regionFactory,
23-
} from 'src/factories';
19+
import { accountFactory, alertFactory, databaseFactory } from 'src/factories';
2420

2521
import type { Alert, Database } from '@linode/api-v4';
2622
import type { Flags } from 'src/featureFlags';

0 commit comments

Comments
 (0)