Skip to content

Commit

Permalink
upcoming: [M3 7738] - Update Placement Group Create & Edit Drawers (#…
Browse files Browse the repository at this point in the history
…10205)

* Change "rename" nomenclature

* Initial commit - refactor

* Post rebase fix

* Affinity Enforcement

* test

* pg/account limit

* update tests

* Handle region PG limit

* Handle region PG limit test

* Better edit form

* cleanup

* PlacementGroupsAffinityTypeSelect

* PlacementGroupsAffinityEnforcementRadioGroup

* cleanup

* cleanup

* Added changeset: Update Placement Group Create & Edit Drawers

* Make sure id is required

* Added changeset: Allow the disabling of the TypeToConfirm input

* Revert "Make sure id is required"

This reverts commit 82d2fb0.

* Feedback
  • Loading branch information
abailly-akamai authored Mar 5, 2024
1 parent fbf6e39 commit e8b3716
Show file tree
Hide file tree
Showing 25 changed files with 763 additions and 538 deletions.
10 changes: 5 additions & 5 deletions packages/api-v4/src/placement-groups/placement-groups.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
createPlacementGroupSchema,
renamePlacementGroupSchema,
updatePlacementGroupSchema,
} from '@linode/validation';
import { API_ROOT } from '../constants';

Expand Down Expand Up @@ -63,14 +63,14 @@ export const createPlacementGroup = (data: CreatePlacementGroupPayload) =>
);

/**
* renamePlacementGroup
* updatePlacementGroup
*
* Renames a Placement Group (updates label).
* Updates a Placement Group (updates label).
*
* @param placementGroupId { number } The id of the Placement Group to be updated.
* @param data { PlacementGroup } The data for the Placement Group.
*/
export const renamePlacementGroup = (
export const updatePlacementGroup = (
placementGroupId: number,
data: UpdatePlacementGroupPayload
) =>
Expand All @@ -79,7 +79,7 @@ export const renamePlacementGroup = (
`${API_ROOT}/placement/groups/${encodeURIComponent(placementGroupId)}`
),
setMethod('PUT'),
setData(data, renamePlacementGroupSchema)
setData(data, updatePlacementGroupSchema)
);

/**
Expand Down
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-10205-changed-1709570324014.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Changed
---

Allow the disabling of the TypeToConfirm input ([#10205](https://github.com/linode/manager/pull/10205))
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Update Placement Group Create & Edit Drawers ([#10205](https://github.com/linode/manager/pull/10205))
24 changes: 23 additions & 1 deletion packages/manager/src/__data__/regionsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const regions: Region[] = [
'Vlans',
'Block Storage Migrations',
'Managed Databases',
'Placement Group',
],
country: 'in',
id: 'ap-west',
Expand All @@ -37,6 +38,7 @@ export const regions: Region[] = [
'Vlans',
'Block Storage Migrations',
'Managed Databases',
'Placement Group',
],
country: 'ca',
id: 'ca-central',
Expand All @@ -62,6 +64,7 @@ export const regions: Region[] = [
'Vlans',
'Block Storage Migrations',
'Managed Databases',
'Placement Group',
],
country: 'au',
id: 'ap-southeast',
Expand Down Expand Up @@ -89,6 +92,7 @@ export const regions: Region[] = [
'Managed Databases',
'Metadata',
'Premium Plans',
'Placement Group',
],
country: 'us',
id: 'us-iad',
Expand Down Expand Up @@ -143,6 +147,7 @@ export const regions: Region[] = [
'Managed Databases',
'Metadata',
'Premium Plans',
'Placement Group',
],
country: 'fr',
id: 'fr-par',
Expand All @@ -169,6 +174,7 @@ export const regions: Region[] = [
'Vlans',
'Metadata',
'Premium Plans',
'Placement Group',
],
country: 'us',
id: 'us-sea',
Expand All @@ -195,6 +201,7 @@ export const regions: Region[] = [
'Vlans',
'Metadata',
'Premium Plans',
'Placement Group',
],
country: 'br',
id: 'br-gru',
Expand All @@ -221,6 +228,7 @@ export const regions: Region[] = [
'Vlans',
'Metadata',
'Premium Plans',
'Placement Group',
],
country: 'nl',
id: 'nl-ams',
Expand All @@ -247,6 +255,7 @@ export const regions: Region[] = [
'Vlans',
'Metadata',
'Premium Plans',
'Placement Group',
],
country: 'se',
id: 'se-sto',
Expand All @@ -273,6 +282,7 @@ export const regions: Region[] = [
'Vlans',
'Metadata',
'Premium Plans',
'Placement Group',
],
country: 'in',
id: 'in-maa',
Expand All @@ -299,6 +309,7 @@ export const regions: Region[] = [
'Vlans',
'Metadata',
'Premium Plans',
'Placement Group',
],
country: 'jp',
id: 'jp-osa',
Expand All @@ -325,6 +336,7 @@ export const regions: Region[] = [
'Vlans',
'Metadata',
'Premium Plans',
'Placement Group',
],
country: 'it',
id: 'it-mil',
Expand All @@ -351,6 +363,7 @@ export const regions: Region[] = [
'Vlans',
'Metadata',
'Premium Plans',
'Placement Group',
],
country: 'us',
id: 'us-mia',
Expand All @@ -377,6 +390,7 @@ export const regions: Region[] = [
'Vlans',
'Metadata',
'Premium Plans',
'Placement Group',
],
country: 'id',
id: 'id-cgk',
Expand All @@ -403,6 +417,7 @@ export const regions: Region[] = [
'Vlans',
'Metadata',
'Premium Plans',
'Placement Group',
],
country: 'us',
id: 'us-lax',
Expand All @@ -428,6 +443,7 @@ export const regions: Region[] = [
'Vlans',
'Block Storage Migrations',
'Managed Databases',
'Placement Group',
],
country: 'us',
id: 'us-central',
Expand All @@ -452,11 +468,12 @@ export const regions: Region[] = [
'Cloud Firewall',
'Block Storage Migrations',
'Managed Databases',
'Placement Group',
],
country: 'us',
id: 'us-west',
label: 'Fremont, CA',
maximum_pgs_per_customer: 5,
maximum_pgs_per_customer: 0,
maximum_vms_per_pg: 10,
resolvers: {
ipv4:
Expand All @@ -479,6 +496,7 @@ export const regions: Region[] = [
'Vlans',
'Block Storage Migrations',
'Managed Databases',
'Placement Group',
],
country: 'us',
id: 'us-southeast',
Expand Down Expand Up @@ -507,6 +525,7 @@ export const regions: Region[] = [
'Vlans',
'Block Storage Migrations',
'Managed Databases',
'Placement Group',
],
country: 'us',
id: 'us-east',
Expand All @@ -532,6 +551,7 @@ export const regions: Region[] = [
'Vlans',
'Block Storage Migrations',
'Managed Databases',
'Placement Group',
],
country: 'gb',
id: 'eu-west',
Expand Down Expand Up @@ -559,6 +579,7 @@ export const regions: Region[] = [
'Vlans',
'Block Storage Migrations',
'Managed Databases',
'Placement Group',
],
country: 'sg',
id: 'ap-south',
Expand Down Expand Up @@ -586,6 +607,7 @@ export const regions: Region[] = [
'Vlans',
'Block Storage Migrations',
'Managed Databases',
'Placement Group',
],
country: 'de',
id: 'eu-central',
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/src/components/TextField.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import KeyboardArrowDown from '@mui/icons-material/KeyboardArrowDown';
import { Theme, useTheme } from '@mui/material/styles';
import {
default as _TextField,
StandardTextFieldProps,
} from '@mui/material/TextField';
import { Theme, useTheme } from '@mui/material/styles';
import { clamp } from 'ramda';
import * as React from 'react';
import { makeStyles } from 'tss-react/mui';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import * as React from 'react';

import { Box } from 'src/components/Box';
import { FormControlLabel } from 'src/components/FormControlLabel';
import { FormLabel } from 'src/components/FormLabel';
import { Notice } from 'src/components/Notice/Notice';
import { Radio } from 'src/components/Radio/Radio';
import { RadioGroup } from 'src/components/RadioGroup';
import { Typography } from 'src/components/Typography';

import type { FormikHelpers } from 'formik';

interface Props {
handleChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
setFieldValue: FormikHelpers<any>['setFieldValue'];
value: boolean;
}

export const PlacementGroupsAffinityEnforcementRadioGroup = (props: Props) => {
const { handleChange, setFieldValue, value } = props;
return (
<Box sx={{ pt: 2 }}>
<Notice
text="Once you create a placement group, you cannot change its Affinity Enforcement setting."
variant="warning"
/>
<FormLabel htmlFor="affinity-enforcement-radio-group">
Affinity Enforcement
</FormLabel>
<RadioGroup
onChange={(event) => {
handleChange(event);
setFieldValue('is_strict', event.target.value === 'true');
}}
id="affinity-enforcement-radio-group"
name="is_strict"
value={value}
>
<FormControlLabel
label={
<Typography>
<strong>Strict.</strong> You cannot assign a Linode to your
placement group if it will violate the policy of your selected
Affinity Type (best practice).
</Typography>
}
control={<Radio />}
value={true}
/>
<FormControlLabel
label={
<Typography>
<strong>Flexible.</strong> You can assign a Linode to your
placement group, even if it violates the policy of your selected
Affinity Type.
</Typography>
}
control={<Radio />}
sx={{ mt: 2 }}
value={false}
/>
</RadioGroup>
</Box>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import * as React from 'react';

import { Autocomplete } from 'src/components/Autocomplete/Autocomplete';
import { Link } from 'src/components/Link';
import { ListItem } from 'src/components/ListItem';
import { Tooltip } from 'src/components/Tooltip';
import { Typography } from 'src/components/Typography';

import { affinityTypeOptions } from './utils';

import type { FormikHelpers } from 'formik';

interface Props {
error: string | undefined;
setFieldValue: FormikHelpers<any>['setFieldValue'];
}

export const PlacementGroupsAffinityTypeSelect = (props: Props) => {
const { error, setFieldValue } = props;
return (
<Autocomplete
defaultValue={affinityTypeOptions.find(
(option) => option.value === 'anti_affinity'
)}
onChange={(_, value) => {
setFieldValue('affinity_type', value?.value ?? '');
}}
renderOption={(props, option) => {
const isDisabledMenuItem = option.value === 'affinity';

return (
<Tooltip
title={
isDisabledMenuItem ? (
<Typography>
Only supporting Anti-affinity host placement groups for Beta.{' '}
<Link to="TODO VM_Placement: update link">Learn more</Link>.
</Typography>
) : (
''
)
}
disableFocusListener={!isDisabledMenuItem}
disableHoverListener={!isDisabledMenuItem}
disableTouchListener={!isDisabledMenuItem}
enterDelay={200}
enterNextDelay={200}
enterTouchDelay={200}
key={option.value}
>
<ListItem
{...props}
className={
isDisabledMenuItem
? `${props.className} Mui-disabled`
: props.className
}
onClick={(e) =>
isDisabledMenuItem
? e.preventDefault()
: props.onClick
? props.onClick(e)
: null
}
component="li"
>
{option.label}
</ListItem>
</Tooltip>
);
}}
textFieldProps={{
tooltipText: (
<Typography>
Linodes in a placement group that use ‘Affinity’ always exist on the
same host. This can help with performance. Linodes in a placement
group that use ‘Anti-affinity: Host’ are never on the same host. Use
this to support a high-availability model.
<br />
<Link to="TODO VM_Placement: update link">Learn more.</Link>
</Typography>
),
}}
disableClearable={true}
errorText={error}
label="Affinity Type"
options={affinityTypeOptions}
placeholder="Select an Affinity Type"
/>
);
};
Loading

0 comments on commit e8b3716

Please sign in to comment.