fix(stacks): update info text for stack environment variables [EE-6902] (#11551)
parent
09837769d7
commit
b265810b95
|
@ -65,13 +65,12 @@
|
||||||
<relative-path-fieldset value="$ctrl.stack" git-model="$ctrl.stack" is-editing="true" hide-edge-configs="true"></relative-path-fieldset>
|
<relative-path-fieldset value="$ctrl.stack" git-model="$ctrl.stack" is-editing="true" hide-edge-configs="true"></relative-path-fieldset>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<environment-variables-panel
|
<stack-environment-variables-panel
|
||||||
values="$ctrl.formValues.Env"
|
values="$ctrl.formValues.Env"
|
||||||
explanation="'These values will be used as substitutions in the stack file. To reference the .env file in your compose file, use ‘stack.env’.'"
|
|
||||||
on-change="($ctrl.onChangeEnvVar)"
|
on-change="($ctrl.onChangeEnvVar)"
|
||||||
show-help-message="true"
|
show-help-message="true"
|
||||||
is-foldable="true"
|
is-foldable="true"
|
||||||
></environment-variables-panel>
|
></stack-environment-variables-panel>
|
||||||
|
|
||||||
<option-panel ng-if="$ctrl.stack.Type === 1 && $ctrl.endpoint.apiVersion >= 1.27" ng-model="$ctrl.formValues.Option" on-change="($ctrl.onChangeOption)"></option-panel>
|
<option-panel ng-if="$ctrl.stack.Type === 1 && $ctrl.endpoint.apiVersion >= 1.27" ng-model="$ctrl.formValues.Option" on-change="($ctrl.onChangeOption)"></option-panel>
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import { withControlledInput } from '@/react-tools/withControlledInput';
|
||||||
import {
|
import {
|
||||||
EnvironmentVariablesFieldset,
|
EnvironmentVariablesFieldset,
|
||||||
EnvironmentVariablesPanel,
|
EnvironmentVariablesPanel,
|
||||||
|
StackEnvironmentVariablesPanel,
|
||||||
envVarValidation,
|
envVarValidation,
|
||||||
} from '@@/form-components/EnvironmentVariablesFieldset';
|
} from '@@/form-components/EnvironmentVariablesFieldset';
|
||||||
import { Icon } from '@@/Icon';
|
import { Icon } from '@@/Icon';
|
||||||
|
@ -263,3 +264,13 @@ withFormValidation(
|
||||||
['explanation', 'showHelpMessage', 'isFoldable'],
|
['explanation', 'showHelpMessage', 'isFoldable'],
|
||||||
envVarValidation
|
envVarValidation
|
||||||
);
|
);
|
||||||
|
|
||||||
|
withFormValidation(
|
||||||
|
ngModule,
|
||||||
|
withUIRouter(
|
||||||
|
withControlledInput(StackEnvironmentVariablesPanel, { values: 'onChange' })
|
||||||
|
),
|
||||||
|
'stackEnvironmentVariablesPanel',
|
||||||
|
['showHelpMessage', 'isFoldable'],
|
||||||
|
envVarValidation
|
||||||
|
);
|
||||||
|
|
|
@ -153,12 +153,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- environment-variables -->
|
<!-- environment-variables -->
|
||||||
<environment-variables-panel
|
<stack-environment-variables-panel values="formValues.Env" on-change="(handleEnvVarChange)" show-alert="true"> </stack-environment-variables-panel>
|
||||||
values="formValues.Env"
|
|
||||||
explanation="'These values will be used as substitutions in the stack file. To reference the .env file in your compose file, use ‘stack.env’'"
|
|
||||||
on-change="(handleEnvVarChange)"
|
|
||||||
>
|
|
||||||
</environment-variables-panel>
|
|
||||||
<!-- !environment-variables -->
|
<!-- !environment-variables -->
|
||||||
<por-access-control-form form-data="formValues.AccessControlData"></por-access-control-form>
|
<por-access-control-form form-data="formValues.AccessControlData"></por-access-control-form>
|
||||||
<!-- actions -->
|
<!-- actions -->
|
||||||
|
|
|
@ -169,13 +169,12 @@
|
||||||
|
|
||||||
<!-- environment-variables -->
|
<!-- environment-variables -->
|
||||||
<div ng-if="stack">
|
<div ng-if="stack">
|
||||||
<environment-variables-panel
|
<stack-environment-variables-panel
|
||||||
values="formValues.Env"
|
values="formValues.Env"
|
||||||
explanation="'These values will be used as substitutions in the stack file. To reference the .env file in your compose file, use ‘stack.env’.'"
|
|
||||||
on-change="(handleEnvVarChange)"
|
on-change="(handleEnvVarChange)"
|
||||||
show-help-message="true"
|
show-help-message="true"
|
||||||
is-foldable="true"
|
is-foldable="true"
|
||||||
></environment-variables-panel>
|
></stack-environment-variables-panel>
|
||||||
</div>
|
</div>
|
||||||
<!-- !environment-variables -->
|
<!-- !environment-variables -->
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { ComponentProps } from 'react';
|
import React, { ComponentProps } from 'react';
|
||||||
|
|
||||||
import { FormSection } from '@@/form-components/FormSection';
|
import { FormSection } from '@@/form-components/FormSection';
|
||||||
import { TextTip } from '@@/Tip/TextTip';
|
import { TextTip } from '@@/Tip/TextTip';
|
||||||
|
@ -14,16 +14,19 @@ export function EnvironmentVariablesPanel({
|
||||||
showHelpMessage,
|
showHelpMessage,
|
||||||
errors,
|
errors,
|
||||||
isFoldable = false,
|
isFoldable = false,
|
||||||
|
alertMessage,
|
||||||
}: {
|
}: {
|
||||||
explanation?: string;
|
explanation?: React.ReactNode;
|
||||||
showHelpMessage?: boolean;
|
showHelpMessage?: boolean;
|
||||||
isFoldable?: boolean;
|
isFoldable?: boolean;
|
||||||
|
alertMessage?: React.ReactNode;
|
||||||
} & FieldsetProps) {
|
} & FieldsetProps) {
|
||||||
return (
|
return (
|
||||||
<FormSection
|
<FormSection
|
||||||
title="Environment variables"
|
title="Environment variables"
|
||||||
isFoldable={isFoldable}
|
isFoldable={isFoldable}
|
||||||
defaultFolded={isFoldable}
|
defaultFolded={isFoldable}
|
||||||
|
className="flex flex-col w-full"
|
||||||
>
|
>
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
{!!explanation && (
|
{!!explanation && (
|
||||||
|
@ -32,6 +35,8 @@ export function EnvironmentVariablesPanel({
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{alertMessage}
|
||||||
|
|
||||||
<div className="col-sm-12">
|
<div className="col-sm-12">
|
||||||
<EnvironmentVariablesFieldset
|
<EnvironmentVariablesFieldset
|
||||||
values={values}
|
values={values}
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
import { ComponentProps } from 'react';
|
||||||
|
|
||||||
|
import { Alert } from '@@/Alert';
|
||||||
|
import { Link } from '@@/Link';
|
||||||
|
|
||||||
|
import { EnvironmentVariablesFieldset } from './EnvironmentVariablesFieldset';
|
||||||
|
import { EnvironmentVariablesPanel } from './EnvironmentVariablesPanel';
|
||||||
|
|
||||||
|
type FieldsetProps = ComponentProps<typeof EnvironmentVariablesFieldset>;
|
||||||
|
|
||||||
|
export function StackEnvironmentVariablesPanel({
|
||||||
|
onChange,
|
||||||
|
values,
|
||||||
|
errors,
|
||||||
|
isFoldable = false,
|
||||||
|
showHelpMessage,
|
||||||
|
}: {
|
||||||
|
isFoldable?: boolean;
|
||||||
|
showHelpMessage?: boolean;
|
||||||
|
} & FieldsetProps) {
|
||||||
|
return (
|
||||||
|
<EnvironmentVariablesPanel
|
||||||
|
explanation={
|
||||||
|
<div>
|
||||||
|
You may use{' '}
|
||||||
|
<Link
|
||||||
|
to="https://docs.portainer.io/v/2.20/user/docker/stacks/add#environment-variables"
|
||||||
|
target="_blank"
|
||||||
|
data-cy="stack-env-vars-help-link"
|
||||||
|
>
|
||||||
|
environment variables in your compose file
|
||||||
|
</Link>
|
||||||
|
. 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).
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
onChange={onChange}
|
||||||
|
values={values}
|
||||||
|
errors={errors}
|
||||||
|
isFoldable={isFoldable}
|
||||||
|
showHelpMessage={showHelpMessage}
|
||||||
|
alertMessage={
|
||||||
|
<div className="flex p-4">
|
||||||
|
<Alert color="info" className="col-sm-12">
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
<strong>stack.env file operation</strong>
|
||||||
|
</p>
|
||||||
|
<div>
|
||||||
|
When deploying via <strong>Repository</strong>, the stack.env
|
||||||
|
file must already reside in the Git repo.
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
When deploying via <strong>Web editor</strong>,{' '}
|
||||||
|
<strong>Upload</strong> or{' '}
|
||||||
|
<strong>Custom template deployment</strong>, the stack.env file
|
||||||
|
is auto created from what you set below.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Alert>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
|
@ -4,5 +4,6 @@ export {
|
||||||
} from './EnvironmentVariablesFieldset';
|
} from './EnvironmentVariablesFieldset';
|
||||||
|
|
||||||
export { EnvironmentVariablesPanel } from './EnvironmentVariablesPanel';
|
export { EnvironmentVariablesPanel } from './EnvironmentVariablesPanel';
|
||||||
|
export { StackEnvironmentVariablesPanel } from './StackEnvironmentVariablesPanel';
|
||||||
|
|
||||||
export { type Values as EnvVarValues } from './types';
|
export { type Values as EnvVarValues } from './types';
|
||||||
|
|
|
@ -11,6 +11,7 @@ interface Props {
|
||||||
isFoldable?: boolean;
|
isFoldable?: boolean;
|
||||||
defaultFolded?: boolean;
|
defaultFolded?: boolean;
|
||||||
titleClassName?: string;
|
titleClassName?: string;
|
||||||
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function FormSection({
|
export function FormSection({
|
||||||
|
@ -20,11 +21,12 @@ export function FormSection({
|
||||||
isFoldable = false,
|
isFoldable = false,
|
||||||
defaultFolded = isFoldable,
|
defaultFolded = isFoldable,
|
||||||
titleClassName,
|
titleClassName,
|
||||||
|
className,
|
||||||
}: PropsWithChildren<Props>) {
|
}: PropsWithChildren<Props>) {
|
||||||
const [isExpanded, setIsExpanded] = useState(!defaultFolded);
|
const [isExpanded, setIsExpanded] = useState(!defaultFolded);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className={className}>
|
||||||
<FormSectionTitle
|
<FormSectionTitle
|
||||||
htmlFor={isFoldable ? `foldingButton${title}` : ''}
|
htmlFor={isFoldable ? `foldingButton${title}` : ''}
|
||||||
titleSize={titleSize}
|
titleSize={titleSize}
|
||||||
|
@ -52,6 +54,6 @@ export function FormSection({
|
||||||
</FormSectionTitle>
|
</FormSectionTitle>
|
||||||
|
|
||||||
{isExpanded && children}
|
{isExpanded && children}
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue