From b06f2be81c168f5944ad08ccd36f98d6fc4ab9ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marti=CC=81n?= Date: Mon, 23 Dec 2024 18:07:52 +0100 Subject: [PATCH] Add variants to link to media --- .../legacy/lib/models/common/widgets/Link/Form.jsx | 8 ++++---- .../lib/models/common/widgets/LinkToMedia/Form.jsx | 12 +++++++++--- .../lib/models/common/widgets/LinkToMedia/index.ts | 1 - 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/slice-machine/src/legacy/lib/models/common/widgets/Link/Form.jsx b/packages/slice-machine/src/legacy/lib/models/common/widgets/Link/Form.jsx index 78b60d552..6e727a742 100644 --- a/packages/slice-machine/src/legacy/lib/models/common/widgets/Link/Form.jsx +++ b/packages/slice-machine/src/legacy/lib/models/common/widgets/Link/Form.jsx @@ -15,7 +15,7 @@ import { CheckBox } from "@/legacy/lib/forms/fields"; import { DisplayTextCheckbox, RepeatableCheckbox, - Variants, + Variants as VariantsForm, } from "./components"; const FormFields = { @@ -82,7 +82,7 @@ const Form = (props) => { // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment setFieldValue={setFieldValue} /> - + ); @@ -91,7 +91,7 @@ const Form = (props) => { export { FormFields }; export default Form; -function VariantsWrapper({ variants, setFieldValue }) { +export function Variants({ variants, setFieldValue }) { const fieldKey = "config.variants"; const onVariantsChange = (newVariants) => @@ -102,7 +102,7 @@ function VariantsWrapper({ variants, setFieldValue }) { const error = meta.error?.find((err) => err); return ( - { // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const { - config: { allowText }, + config: { allowText, variants }, } = formValues; return ( - <> + {Object.entries(FormFields).map(([key, field]) => ( @@ -40,7 +45,8 @@ const Form = (props) => { setFieldValue={setFieldValue} /> - + + ); }; diff --git a/packages/slice-machine/src/legacy/lib/models/common/widgets/LinkToMedia/index.ts b/packages/slice-machine/src/legacy/lib/models/common/widgets/LinkToMedia/index.ts index 2a5ea315c..90146c140 100644 --- a/packages/slice-machine/src/legacy/lib/models/common/widgets/LinkToMedia/index.ts +++ b/packages/slice-machine/src/legacy/lib/models/common/widgets/LinkToMedia/index.ts @@ -41,7 +41,6 @@ export const LinkToMediaWidget: Widget = { placeholder: "", select: "media", allowText: true, - repeat: false, }, }), TYPE_NAME: "Link",