|
1 |
| -import React from 'react' |
| 1 | +import { CButton } from '@coreui/react' |
| 2 | +import { faEllipsisV } from '@fortawesome/free-solid-svg-icons' |
| 3 | +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' |
| 4 | +import React, { useState } from 'react' |
2 | 5 | import { useSelector } from 'react-redux'
|
3 | 6 | import { CippPageList } from 'src/components/layout'
|
4 | 7 | import { CellTip } from 'src/components/tables'
|
5 |
| - |
6 |
| -const columns = [ |
7 |
| - { |
8 |
| - name: 'URL', |
9 |
| - selector: (row) => row['URL'], |
10 |
| - sortable: true, |
11 |
| - cell: (row) => CellTip(row['URL']), |
12 |
| - exportSelector: 'URL', |
13 |
| - }, |
14 |
| - { |
15 |
| - name: 'Owner', |
16 |
| - selector: (row) => row['displayName'], |
17 |
| - sortable: true, |
18 |
| - cell: (row) => CellTip(row['displayName']), |
19 |
| - exportSelector: 'displayName', |
20 |
| - maxWidth: '300px', |
21 |
| - }, |
22 |
| - { |
23 |
| - name: 'Last Active', |
24 |
| - selector: (row) => row['LastActive'], |
25 |
| - sortable: true, |
26 |
| - exportSelector: 'LastActive', |
27 |
| - maxWidth: '120px', |
28 |
| - }, |
29 |
| - { |
30 |
| - name: 'File Count (Total)', |
31 |
| - selector: (row) => row['FileCount'], |
32 |
| - sortable: true, |
33 |
| - exportSelector: 'FileCount', |
34 |
| - maxWidth: '120px', |
35 |
| - }, |
36 |
| - { |
37 |
| - name: 'Used (GB)', |
38 |
| - selector: (row) => row['UsedGB'], |
39 |
| - sortable: true, |
40 |
| - exportSelector: 'UsedGB', |
41 |
| - maxWidth: '120px', |
42 |
| - }, |
43 |
| - { |
44 |
| - name: 'Allocated (GB)', |
45 |
| - selector: (row) => row['Allocated'], |
46 |
| - sortable: true, |
47 |
| - exportSelector: 'Allocated', |
48 |
| - maxWidth: '70px', |
49 |
| - }, |
50 |
| - { |
51 |
| - name: 'Root Template', |
52 |
| - selector: (row) => row['Template'], |
53 |
| - sortable: true, |
54 |
| - cell: (row) => CellTip(row['Template']), |
55 |
| - exportSelector: 'Template', |
56 |
| - maxWidth: '200px', |
57 |
| - }, |
58 |
| -] |
| 8 | +import { CippActionsOffcanvas } from 'src/components/utilities' |
59 | 9 |
|
60 | 10 | const SharepointList = () => {
|
61 | 11 | const tenant = useSelector((state) => state.app.currentTenant)
|
| 12 | + const Offcanvas = (row, rowIndex, formatExtraData) => { |
| 13 | + const tenant = useSelector((state) => state.app.currentTenant) |
| 14 | + const [ocVisible, setOCVisible] = useState(false) |
62 | 15 |
|
| 16 | + //console.log(row) |
| 17 | + return ( |
| 18 | + <> |
| 19 | + <CButton size="sm" color="link" onClick={() => setOCVisible(true)}> |
| 20 | + <FontAwesomeIcon icon={faEllipsisV} /> |
| 21 | + </CButton> |
| 22 | + <CippActionsOffcanvas |
| 23 | + title="User Information" |
| 24 | + extendedInfo={[ |
| 25 | + { |
| 26 | + label: 'Site URL', |
| 27 | + value: `${row.URL ?? ' '}`, |
| 28 | + }, |
| 29 | + ]} |
| 30 | + actions={[ |
| 31 | + { |
| 32 | + label: 'Add member', |
| 33 | + color: 'info', |
| 34 | + modal: true, |
| 35 | + modalType: 'POST', |
| 36 | + modalBody: { |
| 37 | + groupId: row.UPN, |
| 38 | + TenantFilter: tenant.defaultDomainName, |
| 39 | + add: true, |
| 40 | + URL: row.URL, |
| 41 | + SharePointType: row.Template, |
| 42 | + }, |
| 43 | + modalUrl: `/api/ExecSetSharePointMember`, |
| 44 | + modalDropdown: { |
| 45 | + url: `/api/listUsers?TenantFilter=${tenant.defaultDomainName}`, |
| 46 | + labelField: 'displayName', |
| 47 | + valueField: 'userPrincipalName', |
| 48 | + }, |
| 49 | + modalMessage: 'Select the User to add as a member.', |
| 50 | + }, |
| 51 | + { |
| 52 | + label: 'Remove member', |
| 53 | + color: 'info', |
| 54 | + modal: true, |
| 55 | + modalType: 'POST', |
| 56 | + modalBody: { |
| 57 | + groupId: row.UPN, |
| 58 | + TenantFilter: tenant.defaultDomainName, |
| 59 | + add: false, |
| 60 | + URL: row.URL, |
| 61 | + SharePointType: row.Template, |
| 62 | + }, |
| 63 | + modalUrl: `/api/ExecSetSharePointMember`, |
| 64 | + modalDropdown: { |
| 65 | + url: `/api/listUsers?TenantFilter=${tenant.defaultDomainName}`, |
| 66 | + labelField: 'displayName', |
| 67 | + valueField: 'userPrincipalName', |
| 68 | + }, |
| 69 | + modalMessage: 'Select the User to remove as a member.', |
| 70 | + }, |
| 71 | + { |
| 72 | + label: 'Add Site Admin', |
| 73 | + color: 'info', |
| 74 | + modal: true, |
| 75 | + modalType: 'POST', |
| 76 | + modalBody: { |
| 77 | + UPN: row.UPN, |
| 78 | + TenantFilter: tenant.defaultDomainName, |
| 79 | + RemovePermission: false, |
| 80 | + URL: row.URL, |
| 81 | + }, |
| 82 | + modalUrl: `/api/ExecSharePointOwner`, |
| 83 | + modalDropdown: { |
| 84 | + url: `/api/listUsers?TenantFilter=${tenant.defaultDomainName}`, |
| 85 | + labelField: 'displayName', |
| 86 | + valueField: 'userPrincipalName', |
| 87 | + }, |
| 88 | + modalMessage: 'Select the User to add to the Site Admins permissions', |
| 89 | + }, |
| 90 | + { |
| 91 | + label: 'Remove Site Admin', |
| 92 | + color: 'info', |
| 93 | + modal: true, |
| 94 | + modalType: 'POST', |
| 95 | + modalBody: { |
| 96 | + UPN: row.UPN, |
| 97 | + TenantFilter: tenant.defaultDomainName, |
| 98 | + RemovePermission: true, |
| 99 | + URL: row.URL, |
| 100 | + }, |
| 101 | + modalUrl: `/api/ExecSharePointOwner`, |
| 102 | + modalDropdown: { |
| 103 | + url: `/api/listUsers?TenantFilter=${tenant.defaultDomainName}`, |
| 104 | + labelField: 'displayName', |
| 105 | + valueField: 'userPrincipalName', |
| 106 | + }, |
| 107 | + modalMessage: 'Select the User to remove from the Site Admins permission', |
| 108 | + }, |
| 109 | + ]} |
| 110 | + placement="end" |
| 111 | + visible={ocVisible} |
| 112 | + id={row.id} |
| 113 | + hideFunction={() => setOCVisible(false)} |
| 114 | + /> |
| 115 | + </> |
| 116 | + ) |
| 117 | + } |
| 118 | + const columns = [ |
| 119 | + { |
| 120 | + name: 'URL', |
| 121 | + selector: (row) => row['URL'], |
| 122 | + sortable: true, |
| 123 | + cell: (row) => CellTip(row['URL']), |
| 124 | + exportSelector: 'URL', |
| 125 | + }, |
| 126 | + { |
| 127 | + name: 'Owner', |
| 128 | + selector: (row) => row['displayName'], |
| 129 | + sortable: true, |
| 130 | + cell: (row) => CellTip(row['displayName']), |
| 131 | + exportSelector: 'displayName', |
| 132 | + maxWidth: '300px', |
| 133 | + }, |
| 134 | + { |
| 135 | + name: 'Last Active', |
| 136 | + selector: (row) => row['LastActive'], |
| 137 | + sortable: true, |
| 138 | + exportSelector: 'LastActive', |
| 139 | + maxWidth: '120px', |
| 140 | + }, |
| 141 | + { |
| 142 | + name: 'File Count (Total)', |
| 143 | + selector: (row) => row['FileCount'], |
| 144 | + sortable: true, |
| 145 | + exportSelector: 'FileCount', |
| 146 | + maxWidth: '120px', |
| 147 | + }, |
| 148 | + { |
| 149 | + name: 'Used (GB)', |
| 150 | + selector: (row) => row['UsedGB'], |
| 151 | + sortable: true, |
| 152 | + exportSelector: 'UsedGB', |
| 153 | + maxWidth: '120px', |
| 154 | + }, |
| 155 | + { |
| 156 | + name: 'Allocated (GB)', |
| 157 | + selector: (row) => row['Allocated'], |
| 158 | + sortable: true, |
| 159 | + exportSelector: 'Allocated', |
| 160 | + maxWidth: '70px', |
| 161 | + }, |
| 162 | + { |
| 163 | + name: 'Root Template', |
| 164 | + selector: (row) => row['Template'], |
| 165 | + sortable: true, |
| 166 | + cell: (row) => CellTip(row['Template']), |
| 167 | + exportSelector: 'Template', |
| 168 | + maxWidth: '200px', |
| 169 | + }, |
| 170 | + { |
| 171 | + name: 'Actions', |
| 172 | + cell: Offcanvas, |
| 173 | + }, |
| 174 | + ] |
63 | 175 | return (
|
64 | 176 | <CippPageList
|
65 | 177 | title="SharePoint List"
|
|
0 commit comments