Skip to content

Commit 24bbec8

Browse files
chore: Create a story for SharingModal component
Co-Authored-By: Joseph Gross <[email protected]>
1 parent 5de13ca commit 24bbec8

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import React from 'react';
2+
import type { Meta, StoryObj } from '@storybook/react';
3+
import { IntlProvider } from 'react-intl';
4+
import API from '../../../api';
5+
import SharingModal from '../SharingModal';
6+
import { TYPE_FILE, TYPE_FOLDER } from '../../../constants';
7+
import {
8+
MOCK_ITEM_API_RESPONSE,
9+
MOCK_USER_API_RESPONSE,
10+
MOCK_ITEM_ID,
11+
} from '../../../features/unified-share-modal/utils/__mocks__/USMMocks';
12+
13+
const createMockAPI = () => {
14+
const api = new API({
15+
apiHost: 'https://api.box.com',
16+
clientName: 'box-ui-elements',
17+
id: `file_${MOCK_ITEM_ID}`,
18+
token: 'dummy-token',
19+
});
20+
21+
// Mock API methods
22+
api.getFileAPI = () => ({
23+
getFile: (id, successCallback) => {
24+
successCallback(MOCK_ITEM_API_RESPONSE);
25+
return Promise.resolve(MOCK_ITEM_API_RESPONSE);
26+
},
27+
});
28+
29+
api.getFolderAPI = () => ({
30+
getFolderFields: (id, successCallback) => {
31+
successCallback(MOCK_ITEM_API_RESPONSE);
32+
return Promise.resolve(MOCK_ITEM_API_RESPONSE);
33+
},
34+
});
35+
36+
api.getUsersAPI = () => ({
37+
getUser: (id, successCallback) => {
38+
successCallback(MOCK_USER_API_RESPONSE);
39+
return Promise.resolve(MOCK_USER_API_RESPONSE);
40+
},
41+
});
42+
43+
return api;
44+
};
45+
46+
const meta: Meta<typeof SharingModal> = {
47+
title: 'Elements/ContentSharing/SharingModal',
48+
component: SharingModal,
49+
parameters: {
50+
docs: {
51+
description: {
52+
component:
53+
'A modal component for sharing Box files and folders that provides sharing settings and collaboration features.',
54+
},
55+
},
56+
},
57+
argTypes: {
58+
api: { control: 'object' },
59+
config: { control: 'object' },
60+
displayInModal: { control: 'boolean' },
61+
isVisible: { control: 'boolean' },
62+
itemID: { control: 'text' },
63+
itemType: {
64+
control: 'select',
65+
options: [TYPE_FILE, TYPE_FOLDER],
66+
description: 'The type of item being shared - either file or folder',
67+
},
68+
language: { control: 'text' },
69+
messages: { control: 'object' },
70+
setIsVisible: { control: 'function' },
71+
uuid: { control: 'text' },
72+
},
73+
args: {
74+
displayInModal: true,
75+
isVisible: true,
76+
itemID: MOCK_ITEM_ID,
77+
itemType: TYPE_FILE,
78+
language: 'en',
79+
},
80+
decorators: [
81+
Story => (
82+
<IntlProvider locale="en">
83+
<Story />
84+
</IntlProvider>
85+
),
86+
],
87+
};
88+
89+
export default meta;
90+
type Story = StoryObj<typeof SharingModal>;
91+
92+
export const DefaultStory: Story = {
93+
args: {
94+
api: createMockAPI(),
95+
setIsVisible: () => {
96+
// eslint-disable-next-line no-console
97+
console.log('Modal visibility changed');
98+
},
99+
},
100+
};
101+
102+
DefaultStory.storyName = 'Default';

0 commit comments

Comments
 (0)