@@ -11,8 +11,8 @@ class ReactFilestack extends Component {
11
11
customClass : 'filestack-react' ,
12
12
} ,
13
13
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 ) ,
16
16
clientOptions : { } ,
17
17
file : null ,
18
18
source : null ,
@@ -21,7 +21,7 @@ class ReactFilestack extends Component {
21
21
22
22
static propTypes = {
23
23
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' ] ) ,
25
25
componentDisplayMode : PropTypes . objectOf ( PropTypes . any ) ,
26
26
actionOptions : PropTypes . objectOf ( PropTypes . any ) ,
27
27
onSuccess : PropTypes . func ,
@@ -38,13 +38,7 @@ class ReactFilestack extends Component {
38
38
39
39
constructor ( props ) {
40
40
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 ;
48
42
const defaultComponentDisplayMode = {
49
43
type : 'button' ,
50
44
customText : 'Pick file' ,
@@ -60,27 +54,17 @@ class ReactFilestack extends Component {
60
54
this . onFail = this . onFail . bind ( this ) ;
61
55
}
62
56
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 ;
70
60
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 ) ;
74
62
}
75
63
}
76
64
77
65
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 ;
84
68
if ( action === 'pick' ) {
85
69
picker . close ( ) ;
86
70
}
@@ -94,9 +78,7 @@ class ReactFilestack extends Component {
94
78
event . stopPropagation ( ) ;
95
79
event . preventDefault ( ) ;
96
80
97
- this . completeAction ( )
98
- . then ( this . onFinished )
99
- . catch ( this . onFail ) ;
81
+ this . completeAction ( ) . then ( this . onFinished ) . catch ( this . onFail ) ;
100
82
} ;
101
83
102
84
/**
@@ -127,10 +109,7 @@ class ReactFilestack extends Component {
127
109
* Complete executing of provided action
128
110
*/
129
111
completeAction = ( ) => {
130
- const {
131
- client,
132
- picker,
133
- } = this . state ;
112
+ const { client, picker } = this . state ;
134
113
const {
135
114
actionOptions,
136
115
action,
@@ -140,50 +119,54 @@ class ReactFilestack extends Component {
140
119
} = this . props ;
141
120
142
121
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 ( ) ;
159
150
}
160
151
} ;
161
152
162
- render ( ) {
163
- const {
164
- customRender : CustomRender ,
165
- } = this . props ;
153
+ render ( ) {
154
+ const { customRender : CustomRender } = this . props ;
166
155
const {
167
156
componentDisplayModeMerged : { type, customText, customClass } ,
168
157
} = this . state ;
169
158
if ( CustomRender ) {
170
- return (
171
- < CustomRender onPick = { this . onClickPick } />
172
- ) ;
159
+ return < CustomRender onPick = { this . onClickPick } /> ;
173
160
} else if ( type === 'immediate' ) {
174
- return ( null ) ;
161
+ return null ;
175
162
} else {
176
163
const tagMap = {
177
164
button : 'button' ,
178
165
link : 'a' ,
179
166
} ;
180
167
const Tag = tagMap [ type ] ;
181
168
return (
182
- < Tag
183
- name = "filestack"
184
- onClick = { this . onClickPick }
185
- className = { customClass }
186
- >
169
+ < Tag name = "filestack" onClick = { this . onClickPick } className = { customClass } >
187
170
{ customText }
188
171
</ Tag >
189
172
) ;
0 commit comments