Skip to content

Commit ecd34ed

Browse files
authored
Remove .rli file filter for licenses (#5255)
1 parent e0984a7 commit ecd34ed

File tree

3 files changed

+10
-73
lines changed

3 files changed

+10
-73
lines changed

e2e/playwright/regression/shared/license.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Page, Expect } from '@playwright/test';
33
import { updateCustomer } from './api';
44

55
export const uploadLicense = async (page: Page, expect: Expect, licenseFile: string = "license.yaml") => {
6-
await page.setInputFiles('input[type="file"][accept="application/x-yaml,.yaml,.yml,.rli"]', `${process.env.TEST_PATH}/${licenseFile}`);
6+
await page.setInputFiles('input[type="file"][accept="application/x-yaml,.yaml,.yml"]', `${process.env.TEST_PATH}/${licenseFile}`);
77
await page.getByRole('button', { name: 'Upload license' }).click();
88
await expect(page.locator('#app')).toContainText('Installing your license');
99
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Page, Expect } from '@playwright/test';
22

33
export const uploadLicense = async (page: Page, expect: Expect, licenseFile = "license.yaml") => {
4-
await page.setInputFiles('input[type="file"][accept="application/x-yaml,.yaml,.yml,.rli"]', `${process.env.TEST_PATH}/${licenseFile}`);
4+
await page.setInputFiles('input[type="file"][accept="application/x-yaml,.yaml,.yml"]', `${process.env.TEST_PATH}/${licenseFile}`);
55
await page.getByRole('button', { name: 'Upload license' }).click();
66
await expect(page.locator('#app')).toContainText('Installing your license');
77
};

web/src/components/UploadLicenseFile.tsx

Lines changed: 8 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -138,77 +138,14 @@ const UploadLicenseFile = (props: Props) => {
138138
}
139139
}, [props.appsListLength, props.isEmbeddedCluster]);
140140

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-
174141
const uploadLicenseFile = async () => {
175142
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);
212149

213150
setState({
214151
fileUploading: true,
@@ -223,7 +160,7 @@ const UploadLicenseFile = (props: Props) => {
223160
},
224161
credentials: "include",
225162
body: JSON.stringify({
226-
licenseData: isRliFile ? licenseText : serializedLicense,
163+
licenseData: serializedLicense,
227164
}),
228165
})
229166
.then(async (result) => {
@@ -543,7 +480,7 @@ const UploadLicenseFile = (props: Props) => {
543480
) : (
544481
<Dropzone
545482
className="Dropzone-wrapper"
546-
accept={["application/x-yaml", ".yaml", ".yml", ".rli"]}
483+
accept={["application/x-yaml", ".yaml", ".yml"]}
547484
onDropAccepted={onDrop}
548485
multiple={false}
549486
>

0 commit comments

Comments
 (0)