-
Notifications
You must be signed in to change notification settings - Fork 317
/
Copy pathshareAccessCellRenderer.js
45 lines (40 loc) · 1.33 KB
/
shareAccessCellRenderer.js
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
/**
* @flow
* @file Function to render the share access table cell
* @author Box
*/
import * as React from 'react';
import getProp from 'lodash/get';
import ShareAccessSelect from '../common/share-access-select';
import isRowSelectable from './cellRendererHelper';
import LoadingIndicator from '../../components/loading-indicator';
import type { BoxItem } from '../../common/types/core';
export default (
onChange: Function,
canSetShareAccess: boolean,
selectableType: string,
extensionsWhitelist: string[],
hasHitSelectionLimit: boolean,
) => ({ rowData }: { rowData: BoxItem }) => {
const itemCanSetShareAccess = getProp(rowData, 'permissions.can_set_share_access', false);
if (
!canSetShareAccess ||
!itemCanSetShareAccess ||
!isRowSelectable(selectableType, extensionsWhitelist, hasHitSelectionLimit, rowData) ||
!rowData.selected
) {
return <span />;
}
const { allowed_shared_link_access_levels } = rowData;
const isLoading = !allowed_shared_link_access_levels;
return isLoading ? (
<LoadingIndicator className="bcp-share-access-loading" />
) : (
<ShareAccessSelect
canSetShareAccess={canSetShareAccess}
className="bcp-shared-access-select"
item={rowData}
onChange={onChange}
/>
);
};