Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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/api-v4": Upcoming Features
---

Placement Groups events and notifications ([#10221](https://github.com/linode/manager/pull/10221))
6 changes: 6 additions & 0 deletions packages/api-v4/src/account/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,12 @@ export type EventAction =
| 'nodebalancer_delete'
| 'nodebalancer_update'
| 'password_reset'
| 'placement_group_assign'
| 'placement_group_created'
| 'placement_group_assigned'
| 'placement_group_unassigned'
| 'placement_group_updated'
| 'placement_group_deleted'
| '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
---

Placement Groups events and notifications ([#10221](https://github.com/linode/manager/pull/10221))
1 change: 1 addition & 0 deletions packages/manager/src/features/Events/EventRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface RowProps {
| 'domain'
| 'linode'
| 'nodebalancer'
| 'placement_group'
Comment thread
abailly-akamai marked this conversation as resolved.
| 'stackscript'
| 'subnet'
| 'volume'
Expand Down
6 changes: 6 additions & 0 deletions packages/manager/src/features/Events/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ export const EVENT_ACTIONS: Event['action'][] = [
'nodebalancer_delete',
'nodebalancer_update',
'password_reset',
'placement_group_assign',
'placement_group_created',
'placement_group_assigned',
'placement_group_unassigned',
'placement_group_updated',
'placement_group_deleted',
'profile_update',
'stackscript_create',
'stackscript_delete',
Expand Down
23 changes: 23 additions & 0 deletions packages/manager/src/features/Events/eventMessageGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,29 @@ 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.
placement_group_assign: {
notification: (e) => `Placement Group successfully assigned.`,
},
Comment thread
carrillo-erik marked this conversation as resolved.
// This event action denotes an existing Linode instance has been assigned to an existing Placement Group.
placement_group_assigned: {
notification: (e) =>
`Linode ${e.secondary_entity?.label} has been assigned to Placement Group ${e.entity?.label}.`,
},
Comment thread
carrillo-erik marked this conversation as resolved.
placement_group_created: {
notification: (e) =>
`Placement Group ${e.entity?.label} has been successfully created.`,
},
placement_group_deleted: {
notification: (e) => `Placement Group ${e.entity?.label} has been deleted.`,
},
placement_group_unassigned: {
notification: (e) =>
`Linode ${e.secondary_entity?.label} has been unassigned from Placement Group ${e.entity?.label}.`,
},
placement_group_updated: {
notification: (e) => `Placement Group ${e.entity?.label} has been updated.`,
},
profile_update: {
notification: (e) => `Your profile has been updated.`,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AFFINITY_TYPES } from '@linode/api-v4';
import { useSnackbar } from 'notistack';
import * as React from 'react';

import { ActionsPanel } from 'src/components/ActionsPanel/ActionsPanel';
Expand Down Expand Up @@ -43,6 +44,7 @@ export const PlacementGroupsAssignLinodesDrawer = (
data: allPlacementGroups,
error: allPlacementGroupsError,
} = useUnpaginatedPlacementGroupsQuery();
const { enqueueSnackbar } = useSnackbar();

// We display a notice and disable inputs in case the user reaches this drawer somehow
// (not supposed to happen as the "Assign Linode to Placement Group" button should be disabled
Expand Down Expand Up @@ -117,13 +119,18 @@ export const PlacementGroupsAssignLinodesDrawer = (

try {
await assignLinodes(payload);
const toastMessage = 'Linode successfully assigned';
enqueueSnackbar(toastMessage, {
variant: 'success',
});
handleDrawerClose();
} catch (error) {
setGeneralError(
error?.[0]?.reason
? error[0].reason
: 'An error occurred while assigning the Linode to the group'
: 'An error occurred while adding the Linode to the group'
);
enqueueSnackbar(error[0]?.reason, { variant: 'error' });
}
};

Expand Down Expand Up @@ -171,7 +178,6 @@ export const PlacementGroupsAssignLinodesDrawer = (
text="Only displaying Linodes that aren’t assigned to a Placement Group"
/>
</Box>

<ActionsPanel
primaryButtonProps={{
'data-testid': 'submit',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AFFINITY_TYPES } from '@linode/api-v4';
import { useSnackbar } from 'notistack';
import * as React from 'react';
import { useParams } from 'react-router-dom';

Expand Down Expand Up @@ -53,6 +54,8 @@ export const PlacementGroupsDeleteModal = (props: Props) => {
reset: resetUnassignLinodes,
} = useUnassignLinodesFromPlacementGroup(selectedPlacementGroup?.id ?? -1);

const { enqueueSnackbar } = useSnackbar();

const error = deletePlacementError || unassignLinodeError;

React.useEffect(() => {
Expand All @@ -68,10 +71,18 @@ export const PlacementGroupsDeleteModal = (props: Props) => {
};

await unassignLinodes(payload);
const toastMessage = `Linode successfully unassigned`;
enqueueSnackbar(toastMessage, {
variant: 'success',
});
};

const onDelete = async () => {
await deletePlacementGroup();
const toastMessage = `Placement Group successfully deleted.`;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
const toastMessage = `Placement Group successfully deleted.`;
const toastMessage = 'Placement Group successfully deleted.';

enqueueSnackbar(toastMessage, {
variant: 'success',
});
onClose();
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useSnackbar } from 'notistack';
import * as React from 'react';
import { useParams } from 'react-router-dom';

Expand Down Expand Up @@ -26,6 +27,9 @@ export const PlacementGroupsUnassignModal = (props: Props) => {
isLoading,
mutateAsync: unassignLinodes,
} = useUnassignLinodesFromPlacementGroup(+placementGroupId ?? -1);

const { enqueueSnackbar } = useSnackbar();

const { data: selectedLinode } = useLinodeQuery(
+linodeId ?? -1,
Boolean(linodeId)
Expand All @@ -37,6 +41,10 @@ export const PlacementGroupsUnassignModal = (props: Props) => {

const onUnassign = async () => {
await unassignLinodes(payload);
const toastMessage = 'Linode successfully unassigned';
enqueueSnackbar(toastMessage, {
variant: 'success',
});
onClose();
};

Expand Down
23 changes: 23 additions & 0 deletions packages/manager/src/mocks/serverHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1609,12 +1609,35 @@ export const handlers = [
percent_complete: 100,
status: 'notification',
});
const placementGroupCreateEvent = eventFactory.buildList(1, {
action: 'placement_group_created',
entity: { id: 999, label: 'PG-1', type: 'placement_group' },
message: 'Placement Group successfully created.',
percent_complete: 100,
status: 'notification',
});
Comment thread
abailly-akamai marked this conversation as resolved.
const placementGroupAssignedEvent = eventFactory.buildList(1, {
action: 'placement_group_assigned',
entity: { id: 990, label: 'PG-2', type: 'placement_group' },
message: 'Placement Group successfully assigned.',
percent_complete: 100,
secondary_entity: {
id: 1,
label: 'My Config',
type: 'linode',
url: '/v4/linode/instances/1/configs/1',
},
status: 'notification',
});
Comment thread
carrillo-erik marked this conversation as resolved.

return res.once(
ctx.json(
makeResourcePage([
...events,
...dbEvents,
...oldEvents,
...placementGroupAssignedEvent,
...placementGroupCreateEvent,
eventWithSpecialCharacters,
])
)
Expand Down
5 changes: 5 additions & 0 deletions packages/manager/src/utilities/getEventsActionLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ export const getLinkForEvent = (action: EventAction, entity: Entity | null) => {
case 'vpc':
return `/vpcs/${id}`;

case 'placement_group':
return `/placement-groups/${id}`;

default:
return;
}
Expand Down Expand Up @@ -139,6 +142,8 @@ export const getLinkTargets = (entity: Entity | null) => {
return '/longview';
case 'volume':
return '/volumes';
case 'placement_group':
return `/placement-groups/${entity.id}`;
default:
return null;
}
Expand Down