Skip to content

Commit

Permalink
♻️ [#4608] Ensure that plugin dropdown is part of core form
Browse files Browse the repository at this point in the history
This way, plugin-specific configuration forms cannot accidentally make
it impossible to change the plugin type again when a mistake is made,
and it reduces the code repetition.
  • Loading branch information
sergei-maertens committed Oct 8, 2024
1 parent 9f11639 commit 8095b9d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {get} from 'utils/fetch';

import AttributeField from './AttributeField';
import IdentifierRoleField from './IdentifierRoleField';
import PluginField from './PluginField';
import {ErrorsType} from './types';

// Load the possible prefill attributes
Expand Down Expand Up @@ -52,18 +51,6 @@ const DefaultFields = ({errors}) => {

return (
<Fieldset>
<FormRow>
<Field
name="plugin"
label={
<FormattedMessage description="Variable prefill plugin label" defaultMessage="Plugin" />
}
errors={errors.plugin}
>
<PluginField />
</Field>
</FormRow>

<FormRow>
<Field
name="attribute"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {FAIcon} from 'components/admin/icons';
import ErrorBoundary from 'components/errors/ErrorBoundary';
import {get} from 'utils/fetch';

import PluginField from './PluginField';
import {ErrorsType} from './types';

const PLUGIN_ID = 'objects_api';
Expand Down Expand Up @@ -90,21 +89,6 @@ const ObjectsAPIFields = ({errors}) => {
return (
<>
<Fieldset>
<FormRow>
<Field
name="plugin"
label={
<FormattedMessage
description="Variable prefill plugin label"
defaultMessage="Plugin"
/>
}
errors={errors.plugin}
>
<PluginField />
</Field>
</FormRow>

<ObjectsAPIGroup
apiGroupChoices={apiGroups}
onChangeCheck={() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import {Formik} from 'formik';
import PropTypes from 'prop-types';
import {FormattedMessage} from 'react-intl';

import {SubmitAction} from 'components/admin/forms/ActionButton';
import Field from 'components/admin/forms/Field';
import Fieldset from 'components/admin/forms/Fieldset';
import FormRow from 'components/admin/forms/FormRow';
import SubmitRow from 'components/admin/forms/SubmitRow';

import DefaultFields from './DefaultFields';
import ObjectsAPIFields from './ObjectsAPIFields';
import PluginField from './PluginField';

const PLUGIN_COMPONENT_MAPPING = {
objects_api: ObjectsAPIFields,
Expand Down Expand Up @@ -46,6 +51,23 @@ const PrefillConfigurationForm = ({
PLUGIN_COMPONENT_MAPPING[values.plugin] ?? PLUGIN_COMPONENT_MAPPING.default;
return (
<>
<Fieldset extraClassName="module--spaceless">
<FormRow>
<Field
name="plugin"
label={
<FormattedMessage
description="Variable prefill plugin label"
defaultMessage="Plugin"
/>
}
errors={errors.plugin}
>
<PluginField />
</Field>
</FormRow>
</Fieldset>

<PluginFormComponent errors={errors} />

<SubmitRow>
Expand Down
4 changes: 4 additions & 0 deletions src/openforms/scss/admin/_admin_theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ div.breadcrumbs {
}
}

.module.module--spaceless {
margin-block-end: 0;
}

/* Important is used because Django templates include their own style, after ours */
#changelist-filter {
a:focus,
Expand Down

0 comments on commit 8095b9d

Please sign in to comment.