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

View File

@ -2,6 +2,7 @@ import { Form, useFormikContext } from 'formik';
import { applySetStateAction } from '@/react-tools/apply-set-state-action';
import { EnvironmentType } from '@/react/portainer/environments/types';
import { isBE } from '@/react/portainer/feature-flags/feature-flags.service';
import { EnvironmentVariablesPanel } from '@@/form-components/EnvironmentVariablesFieldset';
import { FormActions } from '@@/form-components/FormActions';
@ -92,47 +93,53 @@ export function InnerForm({
/>
)}
{values.method !== 'repository' && (
<WebhookSwitch
onChange={(value) => setFieldValue('enableWebhook', value)}
value={values.enableWebhook}
/>
{isBE && (
<>
{values.method !== 'repository' && (
<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
data-cy="edgeStackCreate-createStackButton"
submitLabel="Deploy the stack"