@@ -138,77 +138,14 @@ const UploadLicenseFile = (props: Props) => {
138
138
}
139
139
} , [ props . appsListLength , props . isEmbeddedCluster ] ) ;
140
140
141
- const exchangeRliFileForLicense = async ( content : string ) => {
142
- return new Promise ( ( resolve , reject ) => {
143
- const payload = {
144
- licenseData : content ,
145
- } ;
146
-
147
- fetch ( `${ process . env . API_ENDPOINT } /license/platform` , {
148
- method : "POST" ,
149
- headers : {
150
- "Content-Type" : "application/json" ,
151
- Accept : "application/json" ,
152
- } ,
153
- credentials : "include" ,
154
- body : JSON . stringify ( payload ) ,
155
- } )
156
- . then ( async ( res ) => {
157
- if ( ! res . ok ) {
158
- reject (
159
- res . status === 401
160
- ? "Invalid license. Please try again"
161
- : "There was an error uploading your license. Please try again"
162
- ) ;
163
- return ;
164
- }
165
- resolve ( ( await res . json ( ) ) . licenseData ) ;
166
- } )
167
- . catch ( ( err ) => {
168
- console . log ( err ) ;
169
- reject ( "There was an error uploading your license. Please try again" ) ;
170
- } ) ;
171
- } ) ;
172
- } ;
173
-
174
141
const uploadLicenseFile = async ( ) => {
175
142
const { onUploadSuccess } = props ;
176
- const { licenseFile, licenseFileContent, hasMultiApp } = state ;
177
- const isRliFile =
178
- licenseFile ?. name . substr ( licenseFile . name . lastIndexOf ( "." ) ) === ".rli" ;
179
- let licenseText ;
180
-
181
- let serializedLicense ;
182
- if ( isRliFile ) {
183
- try {
184
- const base64String = btoa (
185
- // TODO: this is probably a bug
186
- // https://stackoverflow.com/questions/67057689/typscript-type-uint8array-is-missing-the-following-properties-from-type-numb
187
- // @ts -ignore
188
- String . fromCharCode . apply ( null , new Uint8Array ( licenseFileContent ) )
189
- ) ;
190
- licenseText = await exchangeRliFileForLicense ( base64String ) ;
191
- } catch ( err ) {
192
- if ( err instanceof Error ) {
193
- setState ( {
194
- fileUploading : false ,
195
- errorMessage : err . message ,
196
- } ) ;
197
- return ;
198
- }
199
- setState ( {
200
- fileUploading : false ,
201
- errorMessage :
202
- "Something went wrong while uploading your license. Please try again" ,
203
- } ) ;
204
- }
205
- } else {
206
- licenseText =
207
- hasMultiApp && licenseFileContent && state . selectedAppToInstall ?. value
208
- ? licenseFileContent [ state . selectedAppToInstall . value ]
209
- : licenseFileContent ;
210
- serializedLicense = yaml . dump ( licenseText ) ;
211
- }
143
+ const { licenseFileContent, hasMultiApp } = state ;
144
+ const licenseText =
145
+ hasMultiApp && licenseFileContent && state . selectedAppToInstall ?. value
146
+ ? licenseFileContent [ state . selectedAppToInstall . value ]
147
+ : licenseFileContent ;
148
+ const serializedLicense = yaml . dump ( licenseText ) ;
212
149
213
150
setState ( {
214
151
fileUploading : true ,
@@ -223,7 +160,7 @@ const UploadLicenseFile = (props: Props) => {
223
160
} ,
224
161
credentials : "include" ,
225
162
body : JSON . stringify ( {
226
- licenseData : isRliFile ? licenseText : serializedLicense ,
163
+ licenseData : serializedLicense ,
227
164
} ) ,
228
165
} )
229
166
. then ( async ( result ) => {
@@ -543,7 +480,7 @@ const UploadLicenseFile = (props: Props) => {
543
480
) : (
544
481
< Dropzone
545
482
className = "Dropzone-wrapper"
546
- accept = { [ "application/x-yaml" , ".yaml" , ".yml" , ".rli" ] }
483
+ accept = { [ "application/x-yaml" , ".yaml" , ".yml" ] }
547
484
onDropAccepted = { onDrop }
548
485
multiple = { false }
549
486
>
0 commit comments