-
Notifications
You must be signed in to change notification settings - Fork 346
Expand file tree
/
Copy pathtypes.js
More file actions
192 lines (164 loc) · 5.67 KB
/
types.js
File metadata and controls
192 lines (164 loc) · 5.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
// @flow
import type { CollaborationRole, Collaborator, DateValue, Item, SharedLink } from '@box/unified-share-modal';
import API from '../../api';
import type { RequestOptions } from '../../common/types/api';
import type {
Access,
BoxItemClassification,
BoxItemPermission,
Collaboration,
GroupMini,
ItemType,
NewCollaboration,
SharedLink as APISharedLink,
UserMini,
} from '../../common/types/core';
import type {
accessLevelsDisabledReasonType,
contactType,
InviteCollaboratorsRequest,
item,
sharedLinkType as USMSharedLinkType,
} from '../../features/unified-share-modal/flowTypes';
// "SLS" denotes values that are used in the Shared Link Settings modal
type ContentSharingEnterpriseDataType = {
enterpriseName?: string,
serverURL?: string, // SLS
};
export type ContentSharingUserDataType = {
id: string,
userEnterpriseData: ContentSharingEnterpriseDataType,
};
// This type is used when an item does not have a shared link.
type SharedLinkNotCreatedType = {
accessLevel?: string,
canChangeExpiration?: boolean,
canInvite: boolean,
expirationTimestamp?: ?number,
isDownloadAvailable?: boolean,
};
// This is the full shared link type, which extends the internal USM shared link with
// data necessary for instantiating the Shared Link Settings modal.
type SharedLinkCreatedType = USMSharedLinkType &
SharedLinkNotCreatedType & {
canChangeDownload: boolean, // SLS
canChangeExpiration: boolean, // SLS
canChangePassword: boolean, // SLS
canChangeVanityName: boolean, // SLS
directLink: string, // SLS
isDirectLinkAvailable: boolean, // SLS
isDownloadAvailable: boolean, // SLS
isDownloadEnabled: boolean, // SLS
isPasswordAvailable: boolean, // SLS
isPasswordEnabled: boolean, // SLS
vanityName: string,
};
export type ContentSharingSharedLinkType = ContentSharingEnterpriseDataType &
(SharedLinkNotCreatedType | SharedLinkCreatedType);
export type ContentSharingItemDataType = {
item: item,
sharedLink: ContentSharingSharedLinkType,
};
export type ContentSharingItemAPIResponse = {
allowed_invitee_roles: Array<string>,
allowed_shared_link_access_levels?: Array<string>,
allowed_shared_link_access_levels_disabled_reasons?: accessLevelsDisabledReasonType,
classification: ?BoxItemClassification,
description: string,
etag: string,
extension: string,
id: string,
name: string,
owned_by: {
id: string,
login: string,
},
permissions: BoxItemPermission,
shared_link?: APISharedLink,
shared_link_features: {
download_url: boolean,
password: boolean,
vanity_name: boolean,
},
shared_link_permission_options?: Array<'can_preview' | 'can_download' | 'can_edit'>,
type: ItemType,
};
export type ContentSharingHooksOptions = {
currentUserId?: string,
handleError?: Function,
handleRemoveSharedLinkError?: Function,
handleRemoveSharedLinkSuccess?: Function,
handleSuccess?: Function,
handleUpdateSharedLinkError?: Function,
handleUpdateSharedLinkSuccess?: Function,
isContentSharingV2Enabled?: boolean,
setIsLoading?: Function,
transformAccess?: Function,
transformGroups?: Function,
transformItem?: Function,
transformPermissions?: Function,
transformResponse?: Function,
transformSettings?: Function,
transformUsers?: Function,
};
export type SharedLinkSettingsOptions = {
expirationTimestamp: number,
isDownloadEnabled: boolean,
isExpirationEnabled: boolean,
isPasswordEnabled: boolean,
password: string,
vanityName: string,
};
export type ContentSharingCollaborationsRequest = {
groups: Array<$Shape<NewCollaboration>>,
users: Array<$Shape<NewCollaboration>>,
};
export type UseInvitesOptions = ContentSharingHooksOptions & {
collaborators?: Array<Collaborator>,
transformRequest: InviteCollaboratorsRequest => ContentSharingCollaborationsRequest,
};
export type SharedLinkUpdateLevelFnType = () => (level: string) => Promise<void>;
export type SharedLinkUpdateSettingsFnType = () => ($Shape<APISharedLink>) => Promise<void>;
export type GetContactsFnType = () => (filterTerm: string) => Promise<Array<contactType | GroupMini | UserMini>> | null;
export type ContactByEmailObject = { [string]: contactType | UserMini | [] };
export type GetContactsByEmailFnType = () => (filterTerm: {
[emails: string]: string,
}) => Promise<ContactByEmailObject | Array<UserMini>> | null;
export type GetContactByEmailFnType = () => (email: string) => Promise<ContactByEmailObject | Array<UserMini>> | null;
export type SendInvitesFnType = () => InviteCollaboratorsRequest => Promise<null | Array<Function>>;
export type ConnectToItemShareFnType = ({
access?: Access,
errorFn?: Function,
requestOptions?: RequestOptions,
successFn?: Function,
}) => Function;
export type AvatarURLMap = { [number | string]: ?string };
export type ConvertCollabOptions = {
avatarURLMap?: ?AvatarURLMap,
collab: Collaboration,
isCurrentUserOwner: boolean,
ownerEmail: ?string,
};
export interface ItemData {
collaborationRoles: CollaborationRole[];
item: Item;
sharedLink: SharedLink;
}
export interface BaseFetchProps {
api: API;
itemID: string;
}
export interface FetchItemProps extends BaseFetchProps {
itemType: ItemType;
}
export interface FetchCollaboratorsProps extends BaseFetchProps {
collaborators: Collaboration[];
}
export interface SharedLinkSettings {
expiration: ?DateValue;
isDownloadEnabled: boolean;
isExpirationEnabled: boolean;
isPasswordEnabled: boolean;
password: string;
vanityName: string;
}