From f15be1d92adc64508e9c6923acc9b101893cd00a Mon Sep 17 00:00:00 2001 From: cmeng Date: Mon, 18 Mar 2024 09:36:04 +1300 Subject: [PATCH] fix(stack): prepopulate when creating template from stack EE-6853 (#11379) --- app/docker/__module.js | 2 +- .../custom-templates/CreateView/useInitialValues.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/docker/__module.js b/app/docker/__module.js index f553d3955..21cfc5149 100644 --- a/app/docker/__module.js +++ b/app/docker/__module.js @@ -125,7 +125,7 @@ angular.module('portainer.docker', ['portainer.app', reactModule]).config([ const customTemplatesNew = { name: 'docker.templates.custom.new', - url: '/new?appTemplateId&type', + url: '/new?fileContent&appTemplateId&type', views: { 'content@': { diff --git a/app/react/portainer/templates/custom-templates/CreateView/useInitialValues.ts b/app/react/portainer/templates/custom-templates/CreateView/useInitialValues.ts index 72856b6df..615c0e828 100644 --- a/app/react/portainer/templates/custom-templates/CreateView/useInitialValues.ts +++ b/app/react/portainer/templates/custom-templates/CreateView/useInitialValues.ts @@ -23,6 +23,10 @@ export function useInitialValues({ const { appTemplateId, type = defaultType } = useAppTemplateParams(); + const { + params: { fileContent = '' }, + } = useCurrentStateAndParams(); + const fileContentQuery = useFetchTemplateFile(appTemplateId); if (fileContentQuery.isLoading) { return undefined; @@ -30,7 +34,7 @@ export function useInitialValues({ return { Title: '', - FileContent: fileContentQuery.data ?? '', + FileContent: (fileContentQuery.data ?? '') || fileContent, Type: type, Platform: Platform.LINUX, File: undefined,