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: [M3-8012] - Fix PG event text formatting #10420

Merged
merged 8 commits into from
May 2, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Upcoming Features
---

Update Placement Group event types ([#10420](https://github.com/linode/manager/pull/10420))
11 changes: 6 additions & 5 deletions packages/api-v4/src/account/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,12 @@ export type EventAction =
| 'nodebalancer_update'
| 'password_reset'
| 'placement_group_assign'
| 'placement_group_created'
| 'placement_group_assigned'
| 'placement_group_unassigned'
| 'placement_group_updated'
| 'placement_group_deleted'
| 'placement_group_became_non_compliant'
| 'placement_group_became_compliant'
| 'placement_group_create'
| 'placement_group_unassign'
| 'placement_group_update'
| 'placement_group_delete'
| 'profile_update'
| 'stackscript_create'
| 'stackscript_delete'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Fix Placement Group action event formatting ([#10420](https://github.com/linode/manager/pull/10420))
11 changes: 6 additions & 5 deletions packages/manager/src/features/Events/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ export const EVENT_ACTIONS: Event['action'][] = [
'nodebalancer_update',
'password_reset',
'placement_group_assign',
'placement_group_created',
'placement_group_assigned',
'placement_group_unassigned',
'placement_group_updated',
'placement_group_deleted',
'placement_group_became_non_compliant',
'placement_group_became_compliant',
'placement_group_create',
'placement_group_unassign',
'placement_group_update',
'placement_group_delete',
'profile_update',
'stackscript_create',
'stackscript_delete',
Expand Down
22 changes: 13 additions & 9 deletions packages/manager/src/features/Events/eventMessageGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,27 +708,31 @@ export const eventMessageCreators: { [index: string]: CreatorsForStatus } = {
payment_submitted: {
notification: (e) => `A payment was successfully submitted.`,
},
// This event action denotes when a Placement Group has been selected during the Linode Create flow.
// This event action captures Linode assignment to a Placement Group from Linode Create flow and from PlacementGroupAssignLinodeDrawer.
placement_group_assign: {
notification: (e) => `Placement Group successfully assigned.`,
},
// This event action denotes an existing Linode instance has been assigned to an existing Placement Group.
placement_group_assigned: {
notification: (e) =>
carrillo-erik marked this conversation as resolved.
Show resolved Hide resolved
`Linode ${e.secondary_entity?.label} has been assigned to Placement Group ${e.entity?.label}.`,
},
placement_group_created: {
placement_group_became_compliant: {
notification: (e) =>
`Placement Group ${e.entity?.label} has become compliant.`,
},
placement_group_became_non_compliant: {
notification: (e) =>
`Placement Group ${e.entity?.label} has become non-compliant.`,
},
placement_group_create: {
notification: (e) =>
`Placement Group ${e.entity?.label} has been successfully created.`,
},
placement_group_deleted: {
placement_group_delete: {
notification: (e) => `Placement Group ${e.entity?.label} has been deleted.`,
},
placement_group_unassigned: {
placement_group_unassign: {
notification: (e) =>
`Linode ${e.secondary_entity?.label} has been unassigned from Placement Group ${e.entity?.label}.`,
},
placement_group_updated: {
placement_group_update: {
notification: (e) => `Placement Group ${e.entity?.label} has been updated.`,
},
profile_update: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ export const PlacementGroupsAssignLinodesDrawer = (

try {
await assignLinodes(payload);
const toastMessage = 'Linode successfully assigned';
const toastMessage = `Linode ${selectedLinode.label} successfully assigned.`;
enqueueSnackbar(toastMessage, {
variant: 'success',
});
handleDrawerClose();
} catch (errorResponse) {
const error = getErrorStringOrDefault(
errorResponse,
'An error occurred while adding the Linode to the group'
'An error occurred while adding the Linode to the group.'
);
setGeneralError(error);
enqueueSnackbar(error, { variant: 'error' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const PlacementGroupsCreateDrawer = (
try {
const response = await mutateAsync(values);

enqueueSnackbar(`Placement Group ${values.label} successfully created`, {
enqueueSnackbar(`Placement Group ${values.label} successfully created.`, {
variant: 'success',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,20 @@ export const PlacementGroupsDeleteModal = (props: Props) => {

await unassignLinodes(payload);

enqueueSnackbar('Linode successfully unassigned', {
enqueueSnackbar(`Linode ${linode.label} successfully unassigned.`, {
variant: 'success',
});
};

const onDelete = async () => {
await deletePlacementGroup();

enqueueSnackbar('Placement Group successfully deleted.', {
variant: 'success',
});
enqueueSnackbar(
`Placement Group ${selectedPlacementGroup?.label} successfully deleted.`,
{
variant: 'success',
}
);
onClose();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const PlacementGroupsEditDrawer = (
try {
const response = await mutateAsync(values);

enqueueSnackbar(`Placement Group ${values.label} successfully updated`, {
enqueueSnackbar(`Placement Group ${values.label} successfully updated.`, {
variant: 'success',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,22 @@ interface Props {
export const PlacementGroupsUnassignModal = (props: Props) => {
const { onClose, onExited, open, selectedLinode } = props;
const { enqueueSnackbar } = useSnackbar();

const { id: placementGroupId, linodeId } = useParams<{
id: string;
linodeId: string;
}>();

const [linode, setLinode] = React.useState<Linode | undefined>(
selectedLinode
);

const {
error,
isLoading,
mutateAsync: unassignLinodes,
} = useUnassignLinodesFromPlacementGroup(+placementGroupId ?? -1);

const { data: linodeFromQuery, isFetching } = useLinodeQuery(
+linodeId ?? -1,
open && selectedLinode === undefined
Expand All @@ -56,7 +60,9 @@ export const PlacementGroupsUnassignModal = (props: Props) => {

const onUnassign = async () => {
await unassignLinodes(payload);
const toastMessage = 'Linode successfully unassigned';
const toastMessage = linode
? `Linode ${linode?.label} successfully unassigned.`
: 'Linode successfully unassigned.';
enqueueSnackbar(toastMessage, {
variant: 'success',
});
Expand Down
4 changes: 2 additions & 2 deletions packages/manager/src/mocks/serverHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1609,14 +1609,14 @@ export const handlers = [
status: 'notification',
});
const placementGroupCreateEvent = eventFactory.buildList(1, {
action: 'placement_group_created',
action: 'placement_group_create',
entity: { id: 999, label: 'PG-1', type: 'placement_group' },
message: 'Placement Group successfully created.',
percent_complete: 100,
status: 'notification',
});
const placementGroupAssignedEvent = eventFactory.buildList(1, {
action: 'placement_group_assigned',
action: 'placement_group_assign',
entity: { id: 990, label: 'PG-2', type: 'placement_group' },
message: 'Placement Group successfully assigned.',
percent_complete: 100,
Expand Down
Loading