diff --git a/app/portainer/components/forms/stack-redeploy-git-form/stack-redeploy-git-form.html b/app/portainer/components/forms/stack-redeploy-git-form/stack-redeploy-git-form.html
index 170b7dd05..e4c883c76 100644
--- a/app/portainer/components/forms/stack-redeploy-git-form/stack-redeploy-git-form.html
+++ b/app/portainer/components/forms/stack-redeploy-git-form/stack-redeploy-git-form.html
@@ -65,13 +65,12 @@
-
+ >
diff --git a/app/portainer/react/components/index.ts b/app/portainer/react/components/index.ts
index 7f1262010..20f75c796 100644
--- a/app/portainer/react/components/index.ts
+++ b/app/portainer/react/components/index.ts
@@ -14,6 +14,7 @@ import { withControlledInput } from '@/react-tools/withControlledInput';
import {
EnvironmentVariablesFieldset,
EnvironmentVariablesPanel,
+ StackEnvironmentVariablesPanel,
envVarValidation,
} from '@@/form-components/EnvironmentVariablesFieldset';
import { Icon } from '@@/Icon';
@@ -263,3 +264,13 @@ withFormValidation(
['explanation', 'showHelpMessage', 'isFoldable'],
envVarValidation
);
+
+withFormValidation(
+ ngModule,
+ withUIRouter(
+ withControlledInput(StackEnvironmentVariablesPanel, { values: 'onChange' })
+ ),
+ 'stackEnvironmentVariablesPanel',
+ ['showHelpMessage', 'isFoldable'],
+ envVarValidation
+);
diff --git a/app/portainer/views/stacks/create/createstack.html b/app/portainer/views/stacks/create/createstack.html
index ffd860c44..85bf271dc 100644
--- a/app/portainer/views/stacks/create/createstack.html
+++ b/app/portainer/views/stacks/create/createstack.html
@@ -152,12 +152,7 @@
-
-
+
diff --git a/app/portainer/views/stacks/edit/stack.html b/app/portainer/views/stacks/edit/stack.html
index 0ebc3401f..2cdf107d3 100644
--- a/app/portainer/views/stacks/edit/stack.html
+++ b/app/portainer/views/stacks/edit/stack.html
@@ -169,13 +169,12 @@
-
+ >
diff --git a/app/react/components/form-components/EnvironmentVariablesFieldset/EnvironmentVariablesPanel.tsx b/app/react/components/form-components/EnvironmentVariablesFieldset/EnvironmentVariablesPanel.tsx
index 5f090f33f..74d8ba25b 100644
--- a/app/react/components/form-components/EnvironmentVariablesFieldset/EnvironmentVariablesPanel.tsx
+++ b/app/react/components/form-components/EnvironmentVariablesFieldset/EnvironmentVariablesPanel.tsx
@@ -1,4 +1,4 @@
-import { ComponentProps } from 'react';
+import React, { ComponentProps } from 'react';
import { FormSection } from '@@/form-components/FormSection';
import { TextTip } from '@@/Tip/TextTip';
@@ -14,16 +14,19 @@ export function EnvironmentVariablesPanel({
showHelpMessage,
errors,
isFoldable = false,
+ alertMessage,
}: {
- explanation?: string;
+ explanation?: React.ReactNode;
showHelpMessage?: boolean;
isFoldable?: boolean;
+ alertMessage?: React.ReactNode;
} & FieldsetProps) {
return (
{!!explanation && (
@@ -32,6 +35,8 @@ export function EnvironmentVariablesPanel({
)}
+ {alertMessage}
+
;
+
+export function StackEnvironmentVariablesPanel({
+ onChange,
+ values,
+ errors,
+ isFoldable = false,
+ showHelpMessage,
+}: {
+ isFoldable?: boolean;
+ showHelpMessage?: boolean;
+} & FieldsetProps) {
+ return (
+
+ You may use{' '}
+
+ environment variables in your compose file
+
+ . The environment variable values set below will be used as
+ substitutions in the compose file. Note that you may also reference a
+ stack.env file in your compose file. A stack.env file contains the
+ environment variables and their values (e.g. TAG=v1.5).
+
+ }
+ onChange={onChange}
+ values={values}
+ errors={errors}
+ isFoldable={isFoldable}
+ showHelpMessage={showHelpMessage}
+ alertMessage={
+
+
+
+
+ stack.env file operation
+
+
+ When deploying via Repository , the stack.env
+ file must already reside in the Git repo.
+
+
+ When deploying via Web editor ,{' '}
+ Upload or{' '}
+ Custom template deployment , the stack.env file
+ is auto created from what you set below.
+
+
+
+
+ }
+ />
+ );
+}
diff --git a/app/react/components/form-components/EnvironmentVariablesFieldset/index.ts b/app/react/components/form-components/EnvironmentVariablesFieldset/index.ts
index 03d1f4c59..3e2e0e201 100644
--- a/app/react/components/form-components/EnvironmentVariablesFieldset/index.ts
+++ b/app/react/components/form-components/EnvironmentVariablesFieldset/index.ts
@@ -4,5 +4,6 @@ export {
} from './EnvironmentVariablesFieldset';
export { EnvironmentVariablesPanel } from './EnvironmentVariablesPanel';
+export { StackEnvironmentVariablesPanel } from './StackEnvironmentVariablesPanel';
export { type Values as EnvVarValues } from './types';
diff --git a/app/react/components/form-components/FormSection/FormSection.tsx b/app/react/components/form-components/FormSection/FormSection.tsx
index ec09cdcea..38f7f56f7 100644
--- a/app/react/components/form-components/FormSection/FormSection.tsx
+++ b/app/react/components/form-components/FormSection/FormSection.tsx
@@ -11,6 +11,7 @@ interface Props {
isFoldable?: boolean;
defaultFolded?: boolean;
titleClassName?: string;
+ className?: string;
}
export function FormSection({
@@ -20,11 +21,12 @@ export function FormSection({
isFoldable = false,
defaultFolded = isFoldable,
titleClassName,
+ className,
}: PropsWithChildren) {
const [isExpanded, setIsExpanded] = useState(!defaultFolded);
return (
- <>
+
{isExpanded && children}
- >
+
);
}