Skip to content

Commit ca99e13

Browse files
committed
fix: nits
1 parent 42f5398 commit ca99e13

File tree

5 files changed

+23
-21
lines changed

5 files changed

+23
-21
lines changed

src/elements/content-sharing/ContentSharing.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,18 @@ function ContentSharing({
116116

117117
if (isFeatureEnabled(features, 'contentSharingV2')) {
118118
return (
119-
<ContentSharingV2
120-
api={api}
121-
itemID={itemID}
122-
itemType={itemType}
123-
hasProviders={hasProviders}
124-
language={language}
125-
messages={messages}
126-
>
127-
{children}
128-
</ContentSharingV2>
119+
api && (
120+
<ContentSharingV2
121+
api={api}
122+
itemID={itemID}
123+
itemType={itemType}
124+
hasProviders={hasProviders}
125+
language={language}
126+
messages={messages}
127+
>
128+
{children}
129+
</ContentSharingV2>
130+
)
129131
);
130132
}
131133

src/elements/content-sharing/__tests__/ContentSharingV2.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const getWrapper = (props): RenderResult =>
4747
itemType={MOCK_ITEM.type}
4848
hasProviders={true}
4949
{...props}
50-
></ContentSharingV2>,
50+
/>,
5151
);
5252

5353
describe('elements/content-sharing/ContentSharingV2', () => {
@@ -127,6 +127,6 @@ describe('elements/content-sharing/ContentSharingV2', () => {
127127
},
128128
);
129129
});
130-
expect(await screen.findByText('BLUE')).toBeVisible();
130+
expect(screen.getByText('BLUE')).toBeVisible();
131131
});
132132
});

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export const withCustomButton = {
1010
args: {
1111
displayInModal: true,
1212
customButton: <Button>&#10047; Launch ContentSharing &#10047;</Button>,
13+
itemID: '1990109255716',
14+
token: 'bdcf9zdeDEEILZLw1krLmJRJ3R3HNxpu',
1315
},
1416
};
1517

@@ -20,6 +22,8 @@ export const withContentSharingV2Enabled = {
2022
...global.FEATURE_FLAGS,
2123
contentSharingV2: true,
2224
},
25+
token: 'bdcf9zdeDEEILZLw1krLmJRJ3R3HNxpu',
26+
itemID: '1990109255716',
2327
},
2428
};
2529

src/elements/content-sharing/utils/convertItemResponse.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ export const convertItemResponse = (itemAPIData: ContentSharingItemAPIResponse):
1313
name,
1414
permissions,
1515
shared_link,
16-
shared_link_features: { password: isPasswordAvailable },
16+
shared_link_features,
1717
type,
1818
} = itemAPIData;
1919

20+
const { password: isPasswordAvailable } = shared_link_features;
21+
2022
const {
2123
can_download: isDownloadSettingAvailable,
2224
can_invite_collaborator: canInvite,
@@ -67,7 +69,7 @@ export const convertItemResponse = (itemAPIData: ContentSharingItemAPIResponse):
6769
canChangeVanityName: false, // vanity URLs cannot be set via the API,
6870
isDownloadAvailable: isDownloadSettingAvailable,
6971
isDownloadEnabled: isDownloadAllowed,
70-
isPasswordAvailable,
72+
isPasswordAvailable: isPasswordAvailable ?? false,
7173
isPasswordEnabled,
7274
},
7375
url,

src/elements/content-sharing/utils/getAllowedAccessLevels.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,5 @@ import { ACCESS_COLLAB, ACCESS_COMPANY, ACCESS_OPEN } from '../../../constants';
22

33
export const getAllowedAccessLevels = (levels?: Array<string>): Array<string> | null => {
44
if (!levels) return [ACCESS_OPEN, ACCESS_COMPANY, ACCESS_COLLAB];
5-
6-
const allowedAccessLevels = [];
7-
levels.forEach(level => {
8-
allowedAccessLevels.push(level);
9-
});
10-
11-
return allowedAccessLevels;
5+
return [...levels];
126
};

0 commit comments

Comments
 (0)