Skip to content

Commit c221dd8

Browse files
ladeirarodolfodannyrb
authored andcommitted
feat: 🎸 Load local file or folder using native dialog (#870)
Created to specialized dropzone elements to take care of loading local file/folder from dialog Closes: 847
1 parent a8c3d1b commit c221dd8

2 files changed

Lines changed: 45 additions & 7 deletions

File tree

platform/viewer/src/connectedComponents/ViewerLocalFileData.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@
1313
.drag-drop-instructions h4 {
1414
color: var(--text-secondary-color);
1515
}
16+
17+
.link-dialog {
18+
color: var(--active-color);
19+
cursor: pointer;
20+
}

platform/viewer/src/connectedComponents/ViewerLocalFileData.js

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,44 @@ import { withTranslation } from 'react-i18next';
1212
const { OHIFStudyMetadata } = metadata;
1313
const { studyMetadataManager, updateMetaDataManager } = utils;
1414

15+
const dropZoneLinkDialog = (onDrop, i18n, dir) => {
16+
return (
17+
<Dropzone onDrop={onDrop} noDrag>
18+
{({ getRootProps, getInputProps }) => (
19+
<span {...getRootProps()} className="link-dialog">
20+
{dir ? (
21+
<span>
22+
{i18n('Load folders')}
23+
<input
24+
{...getInputProps()}
25+
webkitdirectory="true"
26+
mozdirectory="true"
27+
/>
28+
</span>
29+
) : (
30+
<span>
31+
{i18n('Load files')}
32+
<input {...getInputProps()} />
33+
</span>
34+
)}
35+
</span>
36+
)}
37+
</Dropzone>
38+
);
39+
};
40+
41+
const linksDialogMessage = (onDrop, i18n) => {
42+
return (
43+
<>
44+
{i18n('Or click to ')}
45+
{dropZoneLinkDialog(onDrop, i18n)}
46+
{i18n(' or ')}
47+
{dropZoneLinkDialog(onDrop, i18n, true)}
48+
{i18n(' from dialog')}
49+
</>
50+
);
51+
};
52+
1553
class ViewerLocalFileData extends Component {
1654
static propTypes = {
1755
studies: PropTypes.array,
@@ -73,7 +111,7 @@ class ViewerLocalFileData extends Component {
73111
}
74112

75113
return (
76-
<Dropzone onDrop={onDrop}>
114+
<Dropzone onDrop={onDrop} noClick>
77115
{({ getRootProps, getInputProps }) => (
78116
<div {...getRootProps()} style={{ width: '100%', height: '100%' }}>
79117
{this.state.studies ? (
@@ -96,15 +134,10 @@ class ViewerLocalFileData extends Component {
96134
'Drag and Drop DICOM files here to load them in the Viewer'
97135
)}
98136
</h3>
99-
<h4>
100-
{this.props.t(
101-
"Or click to load the browser's file selector"
102-
)}
103-
</h4>
137+
<h4>{linksDialogMessage(onDrop, this.props.t)}</h4>
104138
</>
105139
)}
106140
</div>
107-
<input {...getInputProps()} style={{ display: 'none' }} />
108141
</div>
109142
)}
110143
</div>

0 commit comments

Comments
 (0)