fix(app/edge-stack): hide non-working BE fields from CE (#205)

Co-authored-by: LP B <xAt0mZ@users.noreply.github.com>
release/2.25
Yajith Dayarathna 2024-12-05 07:00:40 +13:00 committed by GitHub
parent c5accd0f16
commit 3c3dc547b2
2 changed files with 64 additions and 54 deletions

View File

@ -4,6 +4,7 @@ import { GitForm } from '@/react/portainer/gitops/GitForm';
import { baseEdgeStackWebhookUrl } from '@/portainer/helpers/webhookHelper'; import { baseEdgeStackWebhookUrl } from '@/portainer/helpers/webhookHelper';
import { RelativePathFieldset } from '@/react/portainer/gitops/RelativePathFieldset/RelativePathFieldset'; import { RelativePathFieldset } from '@/react/portainer/gitops/RelativePathFieldset/RelativePathFieldset';
import { applySetStateAction } from '@/react-tools/apply-set-state-action'; import { applySetStateAction } from '@/react-tools/apply-set-state-action';
import { isBE } from '@/react/portainer/feature-flags/feature-flags.service';
import { BoxSelector } from '@@/BoxSelector'; import { BoxSelector } from '@@/BoxSelector';
import { FormSection } from '@@/form-components/FormSection'; import { FormSection } from '@@/form-components/FormSection';
@ -124,21 +125,23 @@ export function DockerComposeForm({
webhookId={webhookId} webhookId={webhookId}
/> />
<FormSection title="Advanced configurations"> {isBE && (
<RelativePathFieldset <FormSection title="Advanced configurations">
values={values.relativePath} <RelativePathFieldset
gitModel={values.git} values={values.relativePath}
onChange={(relativePath) => gitModel={values.git}
setValues((values) => ({ onChange={(relativePath) =>
...values, setValues((values) => ({
relativePath: { ...values,
...values.relativePath, relativePath: {
...relativePath, ...values.relativePath,
}, ...relativePath,
})) },
} }))
/> }
</FormSection> />
</FormSection>
)}
</> </>
)} )}
</> </>

View File

@ -2,6 +2,7 @@ import { Form, useFormikContext } from 'formik';
import { applySetStateAction } from '@/react-tools/apply-set-state-action'; import { applySetStateAction } from '@/react-tools/apply-set-state-action';
import { EnvironmentType } from '@/react/portainer/environments/types'; import { EnvironmentType } from '@/react/portainer/environments/types';
import { isBE } from '@/react/portainer/feature-flags/feature-flags.service';
import { EnvironmentVariablesPanel } from '@@/form-components/EnvironmentVariablesFieldset'; import { EnvironmentVariablesPanel } from '@@/form-components/EnvironmentVariablesFieldset';
import { FormActions } from '@@/form-components/FormActions'; import { FormActions } from '@@/form-components/FormActions';
@ -92,47 +93,53 @@ export function InnerForm({
/> />
)} )}
{values.method !== 'repository' && ( {isBE && (
<WebhookSwitch <>
onChange={(value) => setFieldValue('enableWebhook', value)} {values.method !== 'repository' && (
value={values.enableWebhook} <WebhookSwitch
/> onChange={(value) => setFieldValue('enableWebhook', value)}
value={values.enableWebhook}
/>
)}
{values.deploymentType === DeploymentType.Compose && (
<EnvironmentVariablesPanel
values={values.envVars}
onChange={(value) => setFieldValue('envVars', value)}
/>
)}
<PrivateRegistryFieldsetWrapper
onChange={(value) => setFieldValue('privateRegistryId', value)}
value={values.privateRegistryId}
values={{ fileContent: values.fileContent, file: values.file }}
error={errors.privateRegistryId}
onFieldError={(message) =>
setFieldError('privateRegistryId', message)
}
isGit={values.method === 'repository'}
/>
{values.deploymentType === DeploymentType.Compose && (
<DeploymentOptions values={values} setFieldValue={setFieldValue} />
)}
<StaggerFieldset
isEdit={false}
values={values.staggerConfig}
onChange={(newStaggerValues) =>
setValues((values) => ({
...values,
staggerConfig: {
...values.staggerConfig,
...newStaggerValues,
},
}))
}
/>
</>
)} )}
{values.deploymentType === DeploymentType.Compose && (
<EnvironmentVariablesPanel
values={values.envVars}
onChange={(value) => setFieldValue('envVars', value)}
/>
)}
<PrivateRegistryFieldsetWrapper
onChange={(value) => setFieldValue('privateRegistryId', value)}
value={values.privateRegistryId}
values={{ fileContent: values.fileContent, file: values.file }}
error={errors.privateRegistryId}
onFieldError={(message) => setFieldError('privateRegistryId', message)}
isGit={values.method === 'repository'}
/>
{values.deploymentType === DeploymentType.Compose && (
<DeploymentOptions values={values} setFieldValue={setFieldValue} />
)}
<StaggerFieldset
isEdit={false}
values={values.staggerConfig}
onChange={(newStaggerValues) =>
setValues((values) => ({
...values,
staggerConfig: {
...values.staggerConfig,
...newStaggerValues,
},
}))
}
/>
<FormActions <FormActions
data-cy="edgeStackCreate-createStackButton" data-cy="edgeStackCreate-createStackButton"
submitLabel="Deploy the stack" submitLabel="Deploy the stack"