Skip to content

Commit e0e0d73

Browse files
committed
fix: import type directly from shared feature
1 parent 3bbe448 commit e0e0d73

File tree

4 files changed

+5
-127
lines changed

4 files changed

+5
-127
lines changed

src/elements/content-sharing/ContentSharingV2.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from 'react';
22
import isEmpty from 'lodash/isEmpty';
33

44
import { UnifiedShareModal } from '@box/unified-share-modal';
5+
import type { CollaborationRole, Item, SharedLink, User } from '@box/unified-share-modal';
56

67
import API from '../../api';
78
import { FIELD_ENTERPRISE, FIELD_HOSTNAME, TYPE_FILE, TYPE_FOLDER } from '../../constants';
@@ -11,7 +12,6 @@ import { CONTENT_SHARING_ITEM_FIELDS } from './constants';
1112
import { convertItemResponse } from './utils';
1213

1314
import type { ItemType, StringMap } from '../../common/types/core';
14-
import type { CollaborationRole, Item, SharedLink, User } from './types';
1515

1616
export interface ContentSharingV2Props {
1717
/** api - API instance */

src/elements/content-sharing/types.js

Lines changed: 2 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// @flow
2+
import type { CollaborationRole, Item, SharedLink } from '@box/unified-share-modal';
3+
24
import type {
35
Access,
46
BoxItemClassification,
@@ -153,123 +155,6 @@ export type ConvertCollabOptions = {
153155
ownerEmail: ?string,
154156
};
155157

156-
// ContentSharingV2 types
157-
interface Enterprise {
158-
name?: string;
159-
}
160-
161-
export interface User {
162-
id: string;
163-
enterprise: Enterprise;
164-
}
165-
166-
export interface SharedLink {
167-
/**
168-
* The access level of the shared link.
169-
*/
170-
access?: AccessLevelType;
171-
/**
172-
* The available access levels for the shared link. The allowed levels are dependent on the Enterprise settings.
173-
*/
174-
accessLevels?: (AccessLevel | AccessLevelType)[];
175-
/**
176-
* The expiration timestamp of the shared link to indicate when the item will be unshared.
177-
*/
178-
expiresAt?: number;
179-
/**
180-
* The permission level of the shared link.
181-
*/
182-
permission?: PermissionLevelType;
183-
/**
184-
* The available permission levels for the shared link. The allowed levels are dependent on the Item and Enterprise settings.
185-
*/
186-
permissionLevels?: (PermissionLevel | PermissionLevelType)[];
187-
/**
188-
* The configuration options and permissions for managing the shared link settings.
189-
*/
190-
settings?: SharedLinkSettings;
191-
/**
192-
* The URL that can be used to access the shared item.
193-
*/
194-
url: string;
195-
/**
196-
* The static domain portion of the shared link. Used with `vanityName` to preview the custom URL.
197-
*/
198-
vanityDomain?: string;
199-
/**
200-
* The custom name of the shared link. Used with `vanityDomain` to preview the custom URL.
201-
*/
202-
vanityName?: string;
203-
}
204-
205-
export interface CollaborationRole {
206-
/**
207-
* The description for the role. Supported roles have default descriptions.
208-
*/
209-
description?: string;
210-
/**
211-
* The ID of the role. The value must be one of the supported roles within the Enterprise.
212-
*
213-
* If the value does not match a supported role, the role is treated as a custom collaboration role.
214-
*/
215-
id: InvitationRole | string;
216-
/**
217-
* When `true`, the role will be the default selected collaboration role.
218-
*/
219-
isDefault?: boolean;
220-
/**
221-
* When `true`, the role will be disabled when selecting a collaboration role.
222-
*/
223-
isDisabled?: boolean;
224-
/**
225-
* The label for the role. Supported roles have default labels.
226-
*/
227-
label?: string;
228-
}
229-
230-
export interface Classification {
231-
colorId: number;
232-
definition: string;
233-
name: string;
234-
restrictions?: string;
235-
}
236-
237-
export interface Item {
238-
/**
239-
* The classification of the item.
240-
*/
241-
classification?: Classification;
242-
/**
243-
* The ID of the item.
244-
*/
245-
id: string;
246-
/**
247-
* The name of the item.
248-
*/
249-
name: string;
250-
/**
251-
* The permissions that the current user has for the item.
252-
*/
253-
permissions?: {
254-
/**
255-
* When `true`, the user can invite collaborators on the item.
256-
*/
257-
canInviteCollaborator?: boolean,
258-
/**
259-
* When `true`, the user can change the access level of the shared link.
260-
*/
261-
canSetShareAccess?: boolean,
262-
/**
263-
* When `true`, the user can create a shared link for the item.
264-
*/
265-
canShare?: boolean,
266-
};
267-
/**
268-
* The type of the item.
269-
*/
270-
type: ItemType;
271-
}
272-
273158
export interface ItemData {
274159
collaborationRoles: CollaborationRole[];
275160
item: Item;

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ describe('convertItemResponse', () => {
3333
},
3434
type: 'file',
3535
},
36-
sharedLink: {
37-
canInvite: true,
38-
},
3936
});
4037
});
4138

@@ -76,7 +73,6 @@ describe('convertItemResponse', () => {
7673
isPasswordAvailable: true,
7774
isPasswordEnabled: true,
7875
},
79-
canInvite: true,
8076
url: 'https://example.com/shared-link',
8177
vanityDomain: 'https://example.com/vanity-url',
8278
vanityName: 'vanity-name',

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ACCESS_COLLAB, INVITEE_ROLE_EDITOR, PERMISSION_CAN_DOWNLOAD } from '../
22
import { getAllowedAccessLevels, getAllowedPermissionLevels } from '../utils';
33
import { API_TO_USM_CLASSIFICATION_COLORS_MAP } from '../utils/constants';
44

5-
import type { ContentSharingItemAPIResponse, ItemData, SharedLink } from '../types';
5+
import type { ContentSharingItemAPIResponse, ItemData } from '../types';
66

77
export const convertItemResponse = (itemAPIData: ContentSharingItemAPIResponse): ItemData => {
88
const {
@@ -37,9 +37,7 @@ export const convertItemResponse = (itemAPIData: ContentSharingItemAPIResponse):
3737

3838
const isEditAllowed = allowed_invitee_roles.indexOf(INVITEE_ROLE_EDITOR) !== -1;
3939

40-
// The "canInvite" property is necessary even if the item does not have a shared link,
41-
// because it allows users to invite individual collaborators.
42-
let sharedLink: SharedLink = { canInvite: !!canInvite };
40+
let sharedLink;
4341
if (shared_link) {
4442
const {
4543
access,
@@ -72,7 +70,6 @@ export const convertItemResponse = (itemAPIData: ContentSharingItemAPIResponse):
7270
isPasswordAvailable,
7371
isPasswordEnabled,
7472
},
75-
canInvite: !!canInvite,
7673
url,
7774
vanityDomain: vanityUrl,
7875
vanityName: vanityName || '',

0 commit comments

Comments
 (0)