Skip to content

Commit 8dd6057

Browse files
upcoming: [UIE-9402] - Update pagination in the owned groups table (#13535)
* Added missing padding around the Managed dashboard card * changed spacing to spacingFunction * Replace PaginationFooter by CDS pagination component * Add sharegroup factory for testing and mocking * Update pagination to show only when sharegroups count exceeds 25 * Added changeset: Add shareGroup factory for testing and mocking data * Move shareGroup factory to linode utilities * Added changeset: Private Image Sharing: update pagination footer in Owned groups tab * Fix formatting in sharegroups.ts
1 parent 442fc17 commit 8dd6057

9 files changed

Lines changed: 143 additions & 27 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Upcoming Features
3+
---
4+
5+
Private Image Sharing: update pagination footer in Owned groups tab ([#13535](https://github.com/linode/manager/pull/13535))

packages/manager/src/features/Images/ImagesLanding/v2/ShareGroups/ShareGroupsTable.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
useTheme,
88
ZeroStateSearchNarrowIcon,
99
} from '@linode/ui';
10+
import { Pagination } from 'akamai-cds-react-components';
1011
import {
1112
Table,
1213
TableBody,
@@ -18,8 +19,8 @@ import {
1819
import React from 'react';
1920

2021
import { DocsLink } from 'src/components/DocsLink/DocsLink';
21-
import { PaginationFooter } from 'src/components/PaginationFooter/PaginationFooter';
2222

23+
import { DEFAULT_PAGE_SIZES } from '../constants';
2324
import {
2425
StyledImageContainer,
2526
StyledImageTableContainer,
@@ -52,15 +53,14 @@ interface ShareGroupsTableProps {
5253
main: string;
5354
};
5455
error?: APIError[] | null;
55-
eventCategory: string;
5656
handleOrderChange: (newOrderBy: string, newOrder: Order) => void;
5757
headerProps?: HeaderProps;
5858
order: Order;
5959
orderBy: string;
6060
pagination: {
6161
count: number;
62-
handlePageChange: (newPage: number) => void;
63-
handlePageSizeChange: (newSize: number) => void;
62+
onPageChange: (event: CustomEvent<{ page: number }>) => void;
63+
onPageSizeChange: (event: CustomEvent<{ pageSize: number }>) => void;
6464
page: number;
6565
pageSize: number;
6666
};
@@ -72,7 +72,6 @@ export const ShareGroupsTable = (props: ShareGroupsTableProps) => {
7272
const {
7373
columns,
7474
headerProps,
75-
eventCategory,
7675
shareGroups,
7776
query,
7877
handleOrderChange,
@@ -183,7 +182,7 @@ export const ShareGroupsTable = (props: ShareGroupsTableProps) => {
183182
style={{
184183
display: 'flex',
185184
justifyContent: 'center',
186-
padding: 0
185+
padding: 0,
187186
}}
188187
>
189188
<Box
@@ -220,14 +219,16 @@ export const ShareGroupsTable = (props: ShareGroupsTableProps) => {
220219
))}
221220
</TableBody>
222221
</Table>
223-
<PaginationFooter
224-
count={pagination.count}
225-
eventCategory={eventCategory}
226-
handlePageChange={pagination.handlePageChange}
227-
handleSizeChange={pagination.handlePageSizeChange}
228-
page={pagination.page}
229-
pageSize={pagination.pageSize}
230-
/>
222+
{pagination.count > DEFAULT_PAGE_SIZES[0] && (
223+
<Pagination
224+
count={pagination.count}
225+
onPageChange={pagination.onPageChange}
226+
onPageSizeChange={pagination.onPageSizeChange}
227+
page={pagination.page}
228+
pageSize={pagination.pageSize}
229+
pageSizes={DEFAULT_PAGE_SIZES}
230+
/>
231+
)}
231232
</StyledImageTableContainer>
232233
</StyledImageContainer>
233234
);

packages/manager/src/features/Images/ImagesLanding/v2/ShareGroups/ShareGroupsView.test.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ type ShareGroupsConfigMock = {
2020
description: string;
2121
docsLink: { href: string; label: string };
2222
emptyMessage: { instruction: string; main: string };
23-
eventCategory: string;
2423
orderByDefault: string;
2524
orderDefault: 'asc' | 'desc';
2625
preferenceKey: string;
@@ -40,7 +39,6 @@ const queryMocks = vi.hoisted(() => {
4039
main: 'No Share groups to display',
4140
instruction: 'Create your first share group',
4241
},
43-
eventCategory: 'shareGroups',
4442
orderByDefault: 'label',
4543
orderDefault: 'asc' as const,
4644
preferenceKey: 'owned-sharegroups',
@@ -319,7 +317,6 @@ describe('For Owned groups', () => {
319317
expect(queryMocks.tableProps).toMatchObject({
320318
columns: queryMocks.shareGroupsConfig['owned-groups'].columns,
321319
emptyMessage: queryMocks.shareGroupsConfig['owned-groups'].emptyMessage,
322-
eventCategory: queryMocks.shareGroupsConfig['owned-groups'].eventCategory,
323320
handleOrderChange,
324321
order: 'desc',
325322
orderBy: 'created',

packages/manager/src/features/Images/ImagesLanding/v2/ShareGroups/ShareGroupsView.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ export const ShareGroupsView = (props: Props) => {
102102
);
103103
}
104104

105+
const handlePageChange = (event: CustomEvent<{ page: number }>) => {
106+
pagination.handlePageChange(Number(event.detail));
107+
};
108+
109+
const handlePageSizeChange = (event: CustomEvent<{ pageSize: number }>) => {
110+
const newSize = event.detail.pageSize;
111+
pagination.handlePageSizeChange(newSize);
112+
};
113+
105114
const tableHeaderProps = {
106115
title: config.title,
107116
buttonProps: config.buttonProps
@@ -145,7 +154,6 @@ export const ShareGroupsView = (props: Props) => {
145154
columns={config.columns}
146155
emptyMessage={config.emptyMessage}
147156
error={shareGroupsError}
148-
eventCategory={config.eventCategory}
149157
handleOrderChange={handleShareGroupsOrderChange}
150158
headerProps={tableHeaderProps}
151159
order={shareGroupsOrder}
@@ -154,8 +162,8 @@ export const ShareGroupsView = (props: Props) => {
154162
page: pagination.page,
155163
pageSize: pagination.pageSize,
156164
count: shareGroups?.results ?? 0,
157-
handlePageChange: pagination.handlePageChange,
158-
handlePageSizeChange: pagination.handlePageSizeChange,
165+
onPageChange: handlePageChange,
166+
onPageSizeChange: handlePageSizeChange,
159167
}}
160168
query={search.query}
161169
shareGroups={shareGroups?.data ?? []}

packages/manager/src/features/Images/ImagesLanding/v2/ShareGroups/shareGroupsTabsConfig.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export interface ShareGroupsTabsConfig {
3434
main: string;
3535
};
3636
error?: APIError[] | null;
37-
eventCategory: string;
3837
orderByDefault: string;
3938
orderDefault: 'asc' | 'desc';
4039
preferenceKey: string;
@@ -132,10 +131,9 @@ export const SHAREGROUPS_CONFIG: Record<
132131
instruction:
133132
'Click \u2018Create Share Group\u2019 to create your first share group and share your custom images with other accounts.',
134133
},
135-
eventCategory: 'owned-groups',
136134
orderByDefault: 'label',
137135
orderDefault: 'asc',
138-
preferenceKey: 'owned-groups',
136+
preferenceKey: 'owned-groups-table',
139137
buttonProps: {
140138
buttonText: 'Create Share Group',
141139
navigateTo: '/images/share-groups/create',
@@ -158,10 +156,9 @@ export const SHAREGROUPS_CONFIG: Record<
158156
instruction:
159157
"Go to 'My membership requests' to make a request and join a group",
160158
},
161-
eventCategory: 'joined-groups',
162159
orderByDefault: 'label',
163160
orderDefault: 'asc',
164-
preferenceKey: 'joined-groups',
161+
preferenceKey: 'joined-groups-table',
165162
},
166163
'membership-requests': {
167164
title: 'Membership requests',
@@ -177,9 +174,8 @@ export const SHAREGROUPS_CONFIG: Record<
177174
instruction:
178175
"Click 'Request Membership' to create your first membership request",
179176
},
180-
eventCategory: 'membership-requests',
181177
orderByDefault: 'label',
182178
orderDefault: 'asc',
183-
preferenceKey: 'membership-requests',
179+
preferenceKey: 'membership-requests-table',
184180
},
185181
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const DEFAULT_PAGE_SIZES = [25, 50, 75, 100];
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/utilities": Upcoming Features
3+
---
4+
5+
Add shareGroup factory for testing and mocking data ([#13535](https://github.com/linode/manager/pull/13535))

packages/utilities/src/factories/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ export * from './linodes';
1111
export * from './nodebalancer';
1212
export * from './profile';
1313
export * from './regions';
14+
export * from './sharegroups';
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import { Factory } from './factoryProxy';
2+
3+
import type {
4+
AddSharegroupImagesPayload,
5+
AddSharegroupMemberPayload,
6+
CreateSharegroupPayload,
7+
GenerateSharegroupTokenPayload,
8+
Sharegroup,
9+
SharegroupImagePayload,
10+
SharegroupMember,
11+
SharegroupToken,
12+
UpdateSharegroupImagePayload,
13+
UpdateSharegroupMemberPayload,
14+
UpdateSharegroupPayload,
15+
} from '@linode/api-v4';
16+
17+
export const sharegroupImagePayloadFactory =
18+
Factory.Sync.makeFactory<SharegroupImagePayload>({
19+
description: 'A shared image for the sharegroup.',
20+
id: Factory.each((id) => `private/${id}`),
21+
label: Factory.each((id) => `sharegroup-image-${id}`),
22+
});
23+
24+
export const sharegroupFactory = Factory.Sync.makeFactory<Sharegroup>({
25+
created: new Date().toISOString(),
26+
description: 'A test sharegroup.',
27+
expiry: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30).toISOString(),
28+
id: Factory.each((id) => id),
29+
images_count: 3,
30+
is_suspended: false,
31+
label: Factory.each((id) => `sharegroup-${id}`),
32+
members_count: 2,
33+
updated: new Date().toISOString(),
34+
uuid: Factory.each(() => crypto.randomUUID()),
35+
});
36+
37+
export const createSharegroupPayloadFactory =
38+
Factory.Sync.makeFactory<CreateSharegroupPayload>({
39+
description: 'A test sharegroup.',
40+
images: sharegroupImagePayloadFactory.buildList(2),
41+
label: Factory.each((id) => `sharegroup-${id}`),
42+
});
43+
44+
export const updateSharegroupPayloadFactory =
45+
Factory.Sync.makeFactory<UpdateSharegroupPayload>({
46+
description: 'An updated test sharegroup.',
47+
disk_id: 1,
48+
label: Factory.each((id) => `updated-sharegroup-${id}`),
49+
});
50+
51+
export const addSharegroupImagesPayloadFactory =
52+
Factory.Sync.makeFactory<AddSharegroupImagesPayload>({
53+
images: sharegroupImagePayloadFactory.buildList(2),
54+
});
55+
56+
export const updateSharegroupImagePayloadFactory =
57+
Factory.Sync.makeFactory<UpdateSharegroupImagePayload>({
58+
description: 'An updated shared image.',
59+
label: Factory.each((id) => `updated-sharegroup-image-${id}`),
60+
});
61+
62+
export const sharegroupMemberFactory =
63+
Factory.Sync.makeFactory<SharegroupMember>({
64+
created: new Date().toISOString(),
65+
expiry: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30).toISOString(),
66+
label: Factory.each((id) => `sharegroup-member-${id}`),
67+
status: 'active',
68+
token_uuid: Factory.each(() => crypto.randomUUID()),
69+
updated: new Date().toISOString(),
70+
});
71+
72+
export const addSharegroupMemberPayloadFactory =
73+
Factory.Sync.makeFactory<AddSharegroupMemberPayload>({
74+
label: Factory.each((id) => `sharegroup-member-${id}`),
75+
token: Factory.each((id) => `sharegroup-token-${id}`),
76+
});
77+
78+
export const updateSharegroupMemberPayloadFactory =
79+
Factory.Sync.makeFactory<UpdateSharegroupMemberPayload>({
80+
label: Factory.each((id) => `updated-sharegroup-member-${id}`),
81+
});
82+
83+
export const generateSharegroupTokenPayloadFactory =
84+
Factory.Sync.makeFactory<GenerateSharegroupTokenPayload>({
85+
label: Factory.each((id) => `sharegroup-token-${id}`),
86+
valid_for_sharegroup_uuid: Factory.each(() => crypto.randomUUID()),
87+
});
88+
89+
export const sharegroupTokenFactory = Factory.Sync.makeFactory<SharegroupToken>(
90+
{
91+
created: new Date().toISOString(),
92+
expiry: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30).toISOString(),
93+
label: Factory.each((id) => `sharegroup-token-${id}`),
94+
sharegroup_label: Factory.each((id) => `sharegroup-${id}`),
95+
sharegroup_uuid: Factory.each(() => crypto.randomUUID()),
96+
status: 'active',
97+
token: Factory.each((id) => `token-${id}`),
98+
token_uuid: Factory.each(() => crypto.randomUUID()),
99+
updated: new Date().toISOString(),
100+
valid_for_sharegroup_uuid: Factory.each(() => crypto.randomUUID()),
101+
},
102+
);

0 commit comments

Comments
 (0)