diff --git a/packages/builder/src/components/start/CreateAppModal.svelte b/packages/builder/src/components/start/CreateAppModal.svelte index b5fed9cdc1..83ed089006 100644 --- a/packages/builder/src/components/start/CreateAppModal.svelte +++ b/packages/builder/src/components/start/CreateAppModal.svelte @@ -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 diff --git a/packages/server/src/api/controllers/application.ts b/packages/server/src/api/controllers/application.ts index 1be301dd9d..fbcf51c1de 100644 --- a/packages/server/src/api/controllers/application.ts +++ b/packages/server/src/api/controllers/application.ts @@ -250,9 +250,9 @@ async function performAppCreate(ctx: UserCtx) { 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") { diff --git a/packages/server/src/api/routes/tests/application.spec.ts b/packages/server/src/api/routes/tests/application.spec.ts index f10f4089bf..b654e577ba 100644 --- a/packages/server/src/api/routes/tests/application.spec.ts +++ b/packages/server/src/api/routes/tests/application.spec.ts @@ -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() diff --git a/packages/server/src/tests/utilities/api/application.ts b/packages/server/src/tests/utilities/api/application.ts index 516af5c973..9dabc8cfe8 100644 --- a/packages/server/src/tests/utilities/api/application.ts +++ b/packages/server/src/tests/utilities/api/application.ts @@ -17,8 +17,8 @@ export class ApplicationAPI extends TestAPI { app: CreateAppRequest, expectations?: Expectations ): Promise => { - const files = app.templateFile ? { templateFile: app.templateFile } : {} - delete app.templateFile + const files = app.fileToImport ? { fileToImport: app.fileToImport } : {} + delete app.fileToImport return await this._post("/api/applications", { fields: app, files, diff --git a/packages/types/src/api/web/application.ts b/packages/types/src/api/web/application.ts index e4a70c7fd4..57422ceabc 100644 --- a/packages/types/src/api/web/application.ts +++ b/packages/types/src/api/web/application.ts @@ -7,7 +7,7 @@ export interface CreateAppRequest { useTemplate?: string templateName?: string templateKey?: string - templateFile?: string + fileToImport?: string encryptionPassword?: string file?: { path: string } }