File tree Expand file tree Collapse file tree 2 files changed +43
-3
lines changed Expand file tree Collapse file tree 2 files changed +43
-3
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,7 @@ interface FileUploadProps {
101
101
dropzone_handler ?: DropzoneComponentHandlers ;
102
102
close_button_onclick ?: ( event ) => void ;
103
103
show_header : boolean ;
104
+ config ?: object ; // All supported dropzone.js config options
104
105
}
105
106
106
107
export const FileUpload : React . FC < FileUploadProps > = ( props ) => {
@@ -140,7 +141,10 @@ export const FileUpload: React.FC<FileUploadProps> = (props) => {
140
141
{ props . show_header ? < Header /> : undefined }
141
142
< div style = { DROPSTYLE } >
142
143
< DropzoneComponent
143
- config = { { postUrl : postUrl ( props . project_id , props . current_path ) } }
144
+ config = { {
145
+ postUrl : postUrl ( props . project_id , props . current_path ) ,
146
+ ...props . config ,
147
+ } }
144
148
eventHandlers = { props . dropzone_handler }
145
149
djsConfig = { {
146
150
previewTemplate : ReactDOMServer . renderToStaticMarkup (
@@ -475,3 +479,29 @@ const DropzonePreview: React.FC<DropzonePreviewProps> = ({ project_id }) => {
475
479
</ div >
476
480
) ;
477
481
} ;
482
+
483
+ export function UploadLink ( {
484
+ project_id,
485
+ path,
486
+ onUpload,
487
+ style,
488
+ } : {
489
+ project_id : string ;
490
+ path : string ;
491
+ onUpload ?: Function ;
492
+ style ?;
493
+ } ) {
494
+ return (
495
+ < FileUploadWrapper
496
+ project_id = { project_id }
497
+ dest_path = { path }
498
+ event_handlers = { { complete : onUpload } }
499
+ config = { { clickable : ".cocalc-upload-link" } }
500
+ style = { { display : "inline" } }
501
+ >
502
+ < a style = { style } className = "cocalc-upload-link" >
503
+ Upload
504
+ </ a >
505
+ </ FileUploadWrapper >
506
+ ) ;
507
+ }
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ import {
24
24
Tip ,
25
25
} from "@cocalc/frontend/components" ;
26
26
import FakeProgress from "@cocalc/frontend/components/fake-progress" ;
27
- import { FileUpload } from "@cocalc/frontend/file-upload" ;
27
+ import { FileUpload , UploadLink } from "@cocalc/frontend/file-upload" ;
28
28
import { special_filenames_with_no_extension } from "@cocalc/frontend/project-file" ;
29
29
import { ProjectMap } from "@cocalc/frontend/todo-types" ;
30
30
import { filename_extension , is_only_downloadable } from "@cocalc/util/misc" ;
@@ -265,7 +265,17 @@ export default function NewFilePage(props: Props) {
265
265
< SettingBox
266
266
show_header
267
267
icon = { "plus-circle" }
268
- title = { < > Create or Upload New File or Folder</ > }
268
+ title = {
269
+ < >
270
+ Create or{ " " }
271
+ < UploadLink
272
+ project_id = { project_id }
273
+ path = { current_path }
274
+ onUpload = { ( ) => getActions ( ) . fetch_directory_listing ( ) }
275
+ /> { " " }
276
+ New File or Folder
277
+ </ >
278
+ }
269
279
subtitle = {
270
280
< div >
271
281
< PathNavigator
You can’t perform that action at this time.
0 commit comments