feat(docker/stacks): fold env vars by default [EE-5575] (#9957)

pull/10183/head
Chaim Lev-Ari 2023-09-07 14:45:59 +01:00 committed by GitHub
parent 6a8ff7c076
commit ae3e612a24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 17 deletions

View File

@ -66,6 +66,7 @@
explanation="'These values will be used as substitutions in the stack file. To reference the .env file in your compose file, use stack.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"
></environment-variables-panel> ></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>

View File

@ -239,6 +239,6 @@ withFormValidation(
ngModule, ngModule,
EnvironmentVariablesPanel, EnvironmentVariablesPanel,
'environmentVariablesPanel', 'environmentVariablesPanel',
['explanation', 'showHelpMessage'], ['explanation', 'showHelpMessage', 'isFoldable'],
envVarValidation envVarValidation
); );

View File

@ -164,9 +164,21 @@
</div> </div>
</div> </div>
<!-- environment-variables -->
<div ng-if="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)"
show-help-message="true"
is-foldable="true"
></environment-variables-panel>
</div>
<!-- !environment-variables -->
<!-- webhook -->
<div ng-if="isAdmin && applicationState.endpoint.type !== 4"> <div ng-if="isAdmin && applicationState.endpoint.type !== 4">
<div class="col-sm-12 form-section-title"> <div class="form-section-title"> Webhooks</div>
Webhooks
<por-switch-field <por-switch-field
name="EnableWebhook" name="EnableWebhook"
checked="formValues.EnableWebhook" checked="formValues.EnableWebhook"
@ -176,18 +188,8 @@
feature-id="'stack-webhook'" feature-id="'stack-webhook'"
></por-switch-field> ></por-switch-field>
</div> </div>
</div> <!-- !webhook -->
<!-- environment-variables -->
<div ng-if="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)"
show-help-message="true"
></environment-variables-panel>
</div>
<!-- !environment-variables -->
<!-- options --> <!-- options -->
<div ng-if="stack.Type === 1 && applicationState.endpoint.apiVersion >= 1.27" authorization="PortainerStackUpdate"> <div ng-if="stack.Type === 1 && applicationState.endpoint.apiVersion >= 1.27" authorization="PortainerStackUpdate">
<div class="col-sm-12 form-section-title"> Options </div> <div class="col-sm-12 form-section-title"> Options </div>

View File

@ -12,15 +12,21 @@ export function EnvironmentVariablesPanel({
values, values,
showHelpMessage, showHelpMessage,
errors, errors,
isFoldable = false,
}: { }: {
explanation?: string; explanation?: string;
values: Value; values: Value;
onChange(value: Value): void; onChange(value: Value): void;
showHelpMessage?: boolean; showHelpMessage?: boolean;
errors?: ArrayError<Value>; errors?: ArrayError<Value>;
isFoldable?: boolean;
}) { }) {
return ( return (
<FormSection title="Environment variables"> <FormSection
title="Environment variables"
isFoldable={isFoldable}
defaultFolded={isFoldable}
>
<div className="form-group"> <div className="form-group">
{!!explanation && ( {!!explanation && (
<div className="col-sm-12 environment-variables-panel--explanation"> <div className="col-sm-12 environment-variables-panel--explanation">

View File

@ -9,6 +9,7 @@ interface Props {
title: ReactNode; title: ReactNode;
titleSize?: 'sm' | 'md' | 'lg'; titleSize?: 'sm' | 'md' | 'lg';
isFoldable?: boolean; isFoldable?: boolean;
defaultFolded?: boolean;
} }
export function FormSection({ export function FormSection({
@ -16,8 +17,9 @@ export function FormSection({
titleSize = 'md', titleSize = 'md',
children, children,
isFoldable = false, isFoldable = false,
defaultFolded = isFoldable,
}: PropsWithChildren<Props>) { }: PropsWithChildren<Props>) {
const [isExpanded, setIsExpanded] = useState(!isFoldable); const [isExpanded, setIsExpanded] = useState(!defaultFolded);
return ( return (
<> <>