Repository navigation
Expand file tree
/
Copy pathApp.js
More file actions
68 lines (66 loc) · 1.97 KB
/
Copy pathApp.js
File metadata and controls
68 lines (66 loc) · 1.97 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
import React, { useCallback, useState } from 'react';
import FileManager, { Permissions } from 'devextreme-react/file-manager';
import RemoteFileSystemProvider from 'devextreme/file_management/remote_provider';
import { Popup } from 'devextreme-react/popup';
const remoteProvider = new RemoteFileSystemProvider({
endpointUrl: 'https://js.devexpress.com/Demos/NetCore/api/file-manager-file-system-images',
});
export default function App() {
const [currentPath, setCurrentPath] = useState('Places');
const [popupVisible, setPopupVisible] = useState(false);
const [imageItemToDisplay, setImageItemToDisplay] = useState({});
const displayImagePopup = useCallback(
(e) => {
setPopupVisible(true);
setImageItemToDisplay({
name: e.file.name,
url: e.file.dataItem.url,
});
},
[setPopupVisible, setImageItemToDisplay],
);
const hideImagePopup = useCallback(() => {
setPopupVisible(false);
}, [setPopupVisible]);
const onCurrentDirectoryChanged = useCallback(
(e) => {
const path = e?.component?.option('currentPath');
path && setCurrentPath(path);
},
[setCurrentPath],
);
return (
<div>
<FileManager
currentPath={currentPath}
fileSystemProvider={remoteProvider}
onSelectedFileOpened={displayImagePopup}
onCurrentDirectoryChanged={onCurrentDirectoryChanged}
>
<Permissions
create={true}
copy={true}
move={true}
delete={true}
rename={true}
upload={true}
download={true}
></Permissions>
</FileManager>
<Popup
maxHeight={600}
hideOnOutsideClick={true}
showCloseButton={true}
title={imageItemToDisplay.name}
visible={popupVisible}
onHiding={hideImagePopup}
className="photo-popup-content"
>
<img
src={imageItemToDisplay.url}
className="photo-popup-image"
/>
</Popup>
</div>
);
}