Rename and pass just required data
This commit is contained in:
parent
ea1d893ab8
commit
5fe2a1d33e
|
@ -118,14 +118,17 @@
|
|||
if ($values.url) {
|
||||
data.append("url", $values.url.trim())
|
||||
}
|
||||
data.append("useTemplate", template != null)
|
||||
if (template) {
|
||||
data.append("templateName", template.name)
|
||||
data.append("templateKey", template.key)
|
||||
data.append("templateFile", $values.file)
|
||||
|
||||
if (template?.fromFile) {
|
||||
data.append("useTemplate", true)
|
||||
data.append("fileToImport", $values.file)
|
||||
if ($values.encryptionPassword?.trim()) {
|
||||
data.append("encryptionPassword", $values.encryptionPassword.trim())
|
||||
}
|
||||
} else if (template) {
|
||||
data.append("useTemplate", true)
|
||||
data.append("templateName", template.name)
|
||||
data.append("templateKey", template.key)
|
||||
}
|
||||
|
||||
// Create App
|
||||
|
|
|
@ -250,9 +250,9 @@ async function performAppCreate(ctx: UserCtx<CreateAppRequest, App>) {
|
|||
useTemplate,
|
||||
key: templateKey,
|
||||
}
|
||||
if (ctx.request.files && ctx.request.files.templateFile) {
|
||||
if (ctx.request.files && ctx.request.files.fileToImport) {
|
||||
instanceConfig.file = {
|
||||
...(ctx.request.files.templateFile as any),
|
||||
...(ctx.request.files.fileToImport as any),
|
||||
password: encryptionPassword,
|
||||
}
|
||||
} else if (typeof ctx.request.body.file?.path === "string") {
|
||||
|
|
|
@ -151,7 +151,7 @@ describe("/applications", () => {
|
|||
const app = await config.api.application.create({
|
||||
name: utils.newid(),
|
||||
useTemplate: "true",
|
||||
templateFile: "src/api/routes/tests/data/export.txt",
|
||||
fileToImport: "src/api/routes/tests/data/export.txt",
|
||||
})
|
||||
expect(app._id).toBeDefined()
|
||||
expect(events.app.created).toHaveBeenCalledTimes(1)
|
||||
|
@ -171,7 +171,7 @@ describe("/applications", () => {
|
|||
const app = await config.api.application.create({
|
||||
name: utils.newid(),
|
||||
useTemplate: "true",
|
||||
templateFile: "src/api/routes/tests/data/old-app.txt",
|
||||
fileToImport: "src/api/routes/tests/data/old-app.txt",
|
||||
})
|
||||
expect(app._id).toBeDefined()
|
||||
expect(app.navigation).toBeDefined()
|
||||
|
|
|
@ -17,8 +17,8 @@ export class ApplicationAPI extends TestAPI {
|
|||
app: CreateAppRequest,
|
||||
expectations?: Expectations
|
||||
): Promise<App> => {
|
||||
const files = app.templateFile ? { templateFile: app.templateFile } : {}
|
||||
delete app.templateFile
|
||||
const files = app.fileToImport ? { fileToImport: app.fileToImport } : {}
|
||||
delete app.fileToImport
|
||||
return await this._post<App>("/api/applications", {
|
||||
fields: app,
|
||||
files,
|
||||
|
|
|
@ -7,7 +7,7 @@ export interface CreateAppRequest {
|
|||
useTemplate?: string
|
||||
templateName?: string
|
||||
templateKey?: string
|
||||
templateFile?: string
|
||||
fileToImport?: string
|
||||
encryptionPassword?: string
|
||||
file?: { path: string }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue