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