@@ -11,8 +11,8 @@ class ReactFilestack extends Component {
1111 customClass : 'filestack-react' ,
1212 } ,
1313 actionOptions : { } ,
14- onSuccess : result => console . log ( result ) ,
15- onError : error => console . error ( error ) ,
14+ onSuccess : ( result ) => console . log ( result ) ,
15+ onError : ( error ) => console . error ( error ) ,
1616 clientOptions : { } ,
1717 file : null ,
1818 source : null ,
@@ -21,7 +21,7 @@ class ReactFilestack extends Component {
2121
2222 static propTypes = {
2323 apikey : PropTypes . string . isRequired ,
24- action : PropTypes . oneOf ( [ 'transform' , 'retrieve' , 'metadata' , 'storeUrl' , 'upload' , 'remove' , 'pick' , 'removeMetadata' , 'preview' , 'logout' ] ) ,
24+ action : PropTypes . oneOf ( [ 'transform' , 'retrieve' , 'metadata' , 'storeUrl' , 'upload' , 'multiupload' , ' remove', 'pick' , 'removeMetadata' , 'preview' , 'logout' ] ) ,
2525 componentDisplayMode : PropTypes . objectOf ( PropTypes . any ) ,
2626 actionOptions : PropTypes . objectOf ( PropTypes . any ) ,
2727 onSuccess : PropTypes . func ,
@@ -38,13 +38,7 @@ class ReactFilestack extends Component {
3838
3939 constructor ( props ) {
4040 super ( props ) ;
41- const {
42- apikey,
43- clientOptions,
44- actionOptions,
45- action,
46- componentDisplayMode,
47- } = this . props ;
41+ const { apikey, clientOptions, actionOptions, action, componentDisplayMode } = this . props ;
4842 const defaultComponentDisplayMode = {
4943 type : 'button' ,
5044 customText : 'Pick file' ,
@@ -60,27 +54,17 @@ class ReactFilestack extends Component {
6054 this . onFail = this . onFail . bind ( this ) ;
6155 }
6256
63- componentWillMount ( ) {
64- const {
65- customRender,
66- } = this . props ;
67- const {
68- componentDisplayModeMerged,
69- } = this . state ;
57+ componentWillMount ( ) {
58+ const { customRender } = this . props ;
59+ const { componentDisplayModeMerged } = this . state ;
7060 if ( componentDisplayModeMerged . type === 'immediate' && ! customRender ) {
71- this . completeAction ( )
72- . then ( this . onFinished )
73- . catch ( this . onFail ) ;
61+ this . completeAction ( ) . then ( this . onFinished ) . catch ( this . onFail ) ;
7462 }
7563 }
7664
7765 componentWillUnmount ( ) {
78- const {
79- action,
80- } = this . props ;
81- const {
82- picker,
83- } = this . state ;
66+ const { action } = this . props ;
67+ const { picker } = this . state ;
8468 if ( action === 'pick' ) {
8569 picker . close ( ) ;
8670 }
@@ -94,9 +78,7 @@ class ReactFilestack extends Component {
9478 event . stopPropagation ( ) ;
9579 event . preventDefault ( ) ;
9680
97- this . completeAction ( )
98- . then ( this . onFinished )
99- . catch ( this . onFail ) ;
81+ this . completeAction ( ) . then ( this . onFinished ) . catch ( this . onFail ) ;
10082 } ;
10183
10284 /**
@@ -127,10 +109,7 @@ class ReactFilestack extends Component {
127109 * Complete executing of provided action
128110 */
129111 completeAction = ( ) => {
130- const {
131- client,
132- picker,
133- } = this . state ;
112+ const { client, picker } = this . state ;
134113 const {
135114 actionOptions,
136115 action,
@@ -140,50 +119,54 @@ class ReactFilestack extends Component {
140119 } = this . props ;
141120
142121 switch ( action ) {
143- case 'transform' : return new Promise ( ( resolve , reject ) => {
144- try {
145- resolve ( client . transform ( source , actionOptions ) ) ;
146- } catch ( err ) {
147- reject ( err ) ;
148- }
149- } ) ;
150- case 'retrieve' : return client . retrieve ( source , actionOptions , security ) ;
151- case 'metadata' : return client . metadata ( source , actionOptions , security ) ;
152- case 'storeUrl' : return client . storeURL ( source , actionOptions , security ) ;
153- case 'upload' : return client . upload ( file , actionOptions ) ;
154- case 'remove' : return client . remove ( source , security ) ;
155- case 'removeMetadata' : return client . removeMetadata ( source , security ) ;
156- case 'preview' : return client . preview ( source , actionOptions ) ;
157- case 'logout' : return client . logout ( actionOptions ) ;
158- default : return picker . open ( ) ;
122+ case 'transform' :
123+ return new Promise ( ( resolve , reject ) => {
124+ try {
125+ resolve ( client . transform ( source , actionOptions ) ) ;
126+ } catch ( err ) {
127+ reject ( err ) ;
128+ }
129+ } ) ;
130+ case 'retrieve' :
131+ return client . retrieve ( source , actionOptions , security ) ;
132+ case 'metadata' :
133+ return client . metadata ( source , actionOptions , security ) ;
134+ case 'storeUrl' :
135+ return client . storeURL ( source , actionOptions , security ) ;
136+ case 'upload' :
137+ return client . upload ( file , actionOptions ) ;
138+ case 'multiupload' :
139+ return client . upload ( file , actionOptions ) ;
140+ case 'remove' :
141+ return client . remove ( source , security ) ;
142+ case 'removeMetadata' :
143+ return client . removeMetadata ( source , security ) ;
144+ case 'preview' :
145+ return client . preview ( source , actionOptions ) ;
146+ case 'logout' :
147+ return client . logout ( actionOptions ) ;
148+ default :
149+ return picker . open ( ) ;
159150 }
160151 } ;
161152
162- render ( ) {
163- const {
164- customRender : CustomRender ,
165- } = this . props ;
153+ render ( ) {
154+ const { customRender : CustomRender } = this . props ;
166155 const {
167156 componentDisplayModeMerged : { type, customText, customClass } ,
168157 } = this . state ;
169158 if ( CustomRender ) {
170- return (
171- < CustomRender onPick = { this . onClickPick } />
172- ) ;
159+ return < CustomRender onPick = { this . onClickPick } /> ;
173160 } else if ( type === 'immediate' ) {
174- return ( null ) ;
161+ return null ;
175162 } else {
176163 const tagMap = {
177164 button : 'button' ,
178165 link : 'a' ,
179166 } ;
180167 const Tag = tagMap [ type ] ;
181168 return (
182- < Tag
183- name = "filestack"
184- onClick = { this . onClickPick }
185- className = { customClass }
186- >
169+ < Tag name = "filestack" onClick = { this . onClickPick } className = { customClass } >
187170 { customText }
188171 </ Tag >
189172 ) ;
0 commit comments