Skip to content

Commit

Permalink
upcoming: [M3-7608]: Placement Groups Landing page empty state (#10075)
Browse files Browse the repository at this point in the history
* upcoming: [M3-7608]: Placement Groups Landing page empty state

* upcoming: [M3-7608]: Add changeset and remove unnecessary file

* fix docs link unit test
  • Loading branch information
carrillo-erik authored Jan 22, 2024
1 parent 4e78680 commit f845204
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Placement Groups Landing Page empty state ([#10075](https://github.com/linode/manager/pull/10075))
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ describe('PlacementGroupsLanding', () => {
it('renders docs link and create button', () => {
queryMocks.usePlacementGroupsQuery.mockReturnValue({
data: {
data: [],
results: 0,
data: [
placementGroupFactory.build({
label: 'group 1',
}),
],
results: 1,
},
});

Expand Down Expand Up @@ -72,4 +76,21 @@ describe('PlacementGroupsLanding', () => {
expect(getByText(/group 1/i)).toBeInTheDocument();
expect(getByText(/group 2/i)).toBeInTheDocument();
});

it('should render placement group landing with empty state', () => {
queryMocks.usePlacementGroupsQuery.mockReturnValue({
data: {
data: [],
results: 0,
},
});

const { getByText } = renderWithTheme(<PlacementGroupsLanding />);

expect(
getByText(
'Control the physical placement or distribution of virtual machines (VMs) instances within a data center or availability zone.'
)
).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { usePlacementGroupsQuery } from 'src/queries/placementGroups';
import { getAPIErrorOrDefault } from 'src/utilities/errorUtils';

import { MAX_NUMBER_OF_PLACEMENT_GROUPS } from '../constants';
import { PlacementGroupsLandingEmptyState } from './PlacementGroupsLandingEmptyState';
import { PlacementGroupsRow } from './PlacementGroupsRow';

import type { PlacementGroup } from '@linode/api-v4';
Expand Down Expand Up @@ -63,15 +64,21 @@ export const PlacementGroupsLanding = React.memo(() => {
filter
);

const onOpenCreateDrawer = () => {
history.push('/placement-groups/create');
};

if (isLoading) {
return <CircleProgress />;
}

// if (placementGroups?.results === 0) {
// return {
// /* TODO VM_Placement: add <PlacementGroupsEmptyState /> */
// };
// }
if (placementGroups?.results === 0) {
return (
<PlacementGroupsLandingEmptyState
openCreatePlacementGroupDrawer={onOpenCreateDrawer}
/>
);
}

if (error) {
return (
Expand All @@ -84,10 +91,6 @@ export const PlacementGroupsLanding = React.memo(() => {
);
}

const onOpenCreateDrawer = () => {
history.push('/placement-groups/create');
};

const handleRenamePlacementGroup = (placementGroup: PlacementGroup) => {
setSelectedPlacementGroup(placementGroup);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as React from 'react';

import PlacementGroups from 'src/assets/icons/entityIcons/placement-groups.svg';
import { ResourcesSection } from 'src/components/EmptyLandingPageResources/ResourcesSection';
import { sendEvent } from 'src/utilities/analytics';

import {
gettingStartedGuides,
headers,
linkAnalyticsEvent,
} from './PlacementGroupsLandingEmptyStateData';

interface Props {
openCreatePlacementGroupDrawer: () => void;
}

export const PlacementGroupsLandingEmptyState = (props: Props) => {
const { openCreatePlacementGroupDrawer } = props;

return (
<ResourcesSection
buttonProps={[
{
children: 'Create Placement Groups',
onClick: () => {
sendEvent({
action: 'Click:button',
category: linkAnalyticsEvent.category,
label: 'Create Placement Group',
});
openCreatePlacementGroupDrawer();
},
},
]}
gettingStartedGuidesData={gettingStartedGuides}
headers={headers}
icon={PlacementGroups}
linkAnalyticsEvent={linkAnalyticsEvent}
/>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { PLACEMENT_GROUP_LABEL } from 'src/features/PlacementGroups/constants';

import type {
ResourcesHeaders,
ResourcesLinkSection,
ResourcesLinks,
} from 'src/components/EmptyLandingPageResources/ResourcesLinksTypes';

export const headers: ResourcesHeaders = {
description:
'Control the physical placement or distribution of virtual machines (VMs) instances within a data center or availability zone.',
subtitle: '',
title: PLACEMENT_GROUP_LABEL,
};

export const gettingStartedGuides: ResourcesLinkSection = {
links: [
{
text: '',
to: '',
},
],
moreInfo: {
text: '',
to: '',
},
title: '',
};

export const linkAnalyticsEvent: ResourcesLinks['linkAnalyticsEvent'] = {
action: 'Click:link',
category: 'Placement Groups landing page empty',
};
3 changes: 3 additions & 0 deletions packages/manager/src/features/PlacementGroups/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
// Labels
export const PLACEMENT_GROUP_LABEL = 'Placement Groups';

export const MAX_NUMBER_OF_PLACEMENT_GROUPS = 5;

0 comments on commit f845204

Please sign in to comment.