Skip to content

Commit fa7cf77

Browse files
committed
fix: address comments
1 parent eadbc19 commit fa7cf77

File tree

6 files changed

+53
-63
lines changed

6 files changed

+53
-63
lines changed

src/elements/content-sharing/ContentSharing.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import { withBlueprintModernization } from '../common/withBlueprintModernization
1414
import { isFeatureEnabled } from '../common/feature-checking';
1515
import SharingModal from './SharingModal';
1616
// $FlowFixMe
17-
import { ContentSharingV2 } from './ContentSharingV2';
17+
import ContentSharingV2 from './ContentSharingV2';
1818
import { CLIENT_NAME_CONTENT_SHARING, CLIENT_VERSION, DEFAULT_HOSTNAME_API } from '../../constants';
19-
import type { ItemType, StringMap } from '../../common/types/core';
2019

20+
import type { ItemType, StringMap } from '../../common/types/core';
2121
import type { USMConfig } from '../../features/unified-share-modal/flowTypes';
2222
import type { FeatureConfig } from '../common/feature-checking';
2323

@@ -46,6 +46,8 @@ type ContentSharingProps = {
4646
displayInModal: boolean,
4747
/** features - Features for the element */
4848
features?: FeatureConfig,
49+
/** hasProviders - Whether the element has providers for USM already */
50+
hasProviders?: boolean,
4951
/** itemID - Box file or folder ID */
5052
itemID: string,
5153
/** itemType - "file" or "folder" */
@@ -76,6 +78,7 @@ function ContentSharing({
7678
customButton,
7779
displayInModal,
7880
features = {},
81+
hasProviders = true,
7982
itemID,
8083
itemType,
8184
language,
@@ -113,7 +116,13 @@ function ContentSharing({
113116

114117
if (isFeatureEnabled(features, 'contentSharingV2')) {
115118
return (
116-
<ContentSharingV2 itemID={itemID} itemType={itemType} language={language} messages={messages}>
119+
<ContentSharingV2
120+
itemID={itemID}
121+
itemType={itemType}
122+
hasProviders={hasProviders}
123+
language={language}
124+
messages={messages}
125+
>
117126
{children}
118127
</ContentSharingV2>
119128
);

src/elements/content-sharing/ContentSharingV2.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,24 @@ import { UnifiedShareModal } from '@box/unified-share-modal';
55
import Internationalize from '../common/Internationalize';
66
import Providers from '../common/Providers';
77

8-
import type { ContentSharingV2Props } from './types';
8+
import type { ItemType, StringMap } from '../../common/types/core';
99

10-
function ContentSharingV2({ children, itemID, itemType, language, messages }: ContentSharingV2Props) {
10+
export interface ContentSharingV2Props {
11+
/** children - Children for the element to open the Unified Share Modal */
12+
children?: React.ReactElement;
13+
/** itemID - Box file or folder ID */
14+
itemID: string;
15+
/** itemType - "file" or "folder" */
16+
itemType: ItemType;
17+
/** hasProviders - Whether the element has providers for USM already */
18+
hasProviders: boolean;
19+
/** language - Language used for the element */
20+
language?: string;
21+
/** messages - Localized strings used by the element */
22+
messages?: StringMap;
23+
}
24+
25+
function ContentSharingV2({ children, itemID, itemType, hasProviders, language, messages }: ContentSharingV2Props) {
1126
// Retrieve item from API later
1227
const mockItem = {
1328
id: itemID,
@@ -17,11 +32,11 @@ function ContentSharingV2({ children, itemID, itemType, language, messages }: Co
1732

1833
return (
1934
<Internationalize language={language} messages={messages}>
20-
<Providers hasProviders>
35+
<Providers hasProviders={hasProviders}>
2136
<UnifiedShareModal item={mockItem}>{children}</UnifiedShareModal>
2237
</Providers>
2338
</Internationalize>
2439
);
2540
}
2641

27-
export { ContentSharingV2 };
42+
export default ContentSharingV2;

src/elements/content-sharing/stories/ContentSharing.stories.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ export const withCustomButton = {
1313
},
1414
};
1515

16+
export const withContentSharingV2Enabled = {
17+
args: {
18+
children: <button>Open Unified Share Modal</button>,
19+
features: {
20+
...global.FEATURE_FLAGS,
21+
contentSharingV2: true,
22+
},
23+
},
24+
};
25+
1626
export default {
1727
title: 'Elements/ContentSharing',
1828
component: ContentSharing,
@@ -31,13 +41,3 @@ export default {
3141
},
3242
},
3343
};
34-
35-
export const ContentSharingV2Enabled: StoryObj = {
36-
args: {
37-
children: <button>Open Unified Share Modal</button>,
38-
features: {
39-
...global.FEATURE_FLAGS,
40-
contentSharingV2: true,
41-
},
42-
},
43-
};

src/elements/content-sharing/stories/ContentSharingV2.stories.tsx

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
1-
import { DEFAULT_HOSTNAME_API, TYPE_FILE, TYPE_FOLDER } from '../../../constants';
2-
import { ContentSharingV2 } from '../ContentSharingV2';
1+
import * as React from 'react';
2+
import { TYPE_FILE, TYPE_FOLDER } from '../../../constants';
3+
import ContentSharingV2 from '../ContentSharingV2';
34

45
export const Basic = {};
56

67
export default {
78
title: 'Elements/ContentSharingV2',
89
component: ContentSharingV2,
910
args: {
10-
apiHost: DEFAULT_HOSTNAME_API,
11-
features: global.FEATURE_FLAGS,
12-
hasProviders: true,
13-
language: 'en',
11+
children: <button>Open Unified Share Modal</button>,
1412
itemType: TYPE_FILE,
1513
itemID: global.FILE_ID,
16-
messages: {
17-
en: {
18-
contentSharingV2: 'Content Sharing V2',
19-
},
20-
},
21-
token: global.TOKEN,
22-
theme: 'light',
2314
},
2415
argTypes: {
2516
itemType: {
Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,17 @@
1-
import { DEFAULT_HOSTNAME_API, TYPE_FILE } from '../../../../constants';
2-
import { ContentSharingV2 } from '../../ContentSharingV2';
1+
import { TYPE_FILE } from '../../../../constants';
2+
import ContentSharingV2 from '../../ContentSharingV2';
3+
4+
export const withModernization = {
5+
args: {
6+
enableModernizedComponents: true,
7+
},
8+
};
39

410
export default {
511
title: 'Elements/ContentSharingV2/tests/visual-regression-tests',
612
component: ContentSharingV2,
713
args: {
8-
apiHost: DEFAULT_HOSTNAME_API,
9-
features: global.FEATURE_FLAGS,
10-
hasProviders: true,
11-
language: 'en',
1214
itemType: TYPE_FILE,
1315
itemID: global.FILE_ID,
14-
messages: {
15-
en: {
16-
contentSharingV2: 'Content Sharing V2',
17-
},
18-
},
19-
token: global.TOKEN,
20-
theme: 'light',
21-
},
22-
};
23-
24-
export const Modernization = {
25-
args: {
26-
enableModernizedComponents: true,
2716
},
2817
};

src/elements/content-sharing/types.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)