diff --git a/.storybook/decorators.tsx b/.storybook/decorators.tsx index 7d807ed0..da0a0bd7 100644 --- a/.storybook/decorators.tsx +++ b/.storybook/decorators.tsx @@ -12,7 +12,6 @@ import { DEFAULT_FILE_TYPES, DEFAULT_PREFILL_ATTRIBUTES, DEFAULT_PREFILL_PLUGINS, - DEFAULT_PRODUCTS, DEFAULT_REGISTRATION_ATTRIBUTES, DEFAULT_VALIDATOR_PLUGINS, sleep, @@ -101,7 +100,6 @@ export const BuilderContextDecorator: Decorator = (Story, context) => { getDocumentTypes: async () => context?.args?.documentTypes || defaultdocumentTypes, getConfidentialityLevels: async () => CONFIDENTIALITY_LEVELS, getAuthPlugins: async () => DEFAULT_AUTH_PLUGINS, - getProducts: async () => DEFAULT_PRODUCTS, }} > diff --git a/i18n/messages/en.json b/i18n/messages/en.json index 2af642ab..1d1a24ed 100644 --- a/i18n/messages/en.json +++ b/i18n/messages/en.json @@ -604,11 +604,6 @@ "description": "File component 'fileMaxSize' validation error", "originalDefault": "Specify a positive, non-zero file size without decimals, e.g. 10MB." }, - "QXsAuR": { - "defaultMessage": "Product to fetch prices for", - "description": "Tooltip for 'product' builder field", - "originalDefault": "Product to fetch prices for" - }, "Qjl92W": { "defaultMessage": "Preview", "description": "Component preview card title", @@ -1439,11 +1434,6 @@ "description": "Tooltip for 'hideHeader' builder field", "originalDefault": "Do not display the configured label and top line as the header in the fieldset." }, - "uuKVtO": { - "defaultMessage": "Product", - "description": "Label for 'product' builder field", - "originalDefault": "Product" - }, "vRVMpe": { "defaultMessage": "Value", "description": "Translations: property column header", diff --git a/i18n/messages/nl.json b/i18n/messages/nl.json index 2824c045..506be98f 100644 --- a/i18n/messages/nl.json +++ b/i18n/messages/nl.json @@ -613,11 +613,6 @@ "description": "File component 'fileMaxSize' validation error", "originalDefault": "Specify a positive, non-zero file size without decimals, e.g. 10MB." }, - "QXsAuR": { - "defaultMessage": "Product waarvoor prijzen worden opgehaald", - "description": "Tooltip for 'product' builder field", - "originalDefault": "Product to fetch prices for" - }, "Qjl92W": { "defaultMessage": "Voorbeeld", "description": "Component preview card title", @@ -1459,12 +1454,6 @@ "description": "Tooltip for 'hideHeader' builder field", "originalDefault": "Do not display the configured label and top line as the header in the fieldset." }, - "uuKVtO": { - "defaultMessage": "Product", - "description": "Label for 'product' builder field", - "isTranslated": true, - "originalDefault": "Product" - }, "vRVMpe": { "defaultMessage": "(Standaard)tekst", "description": "Translations: property column header", diff --git a/package-lock.json b/package-lock.json index 6c299f5a..969a6301 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,7 +39,7 @@ "@formatjs/cli": "^6.1.1", "@formatjs/ts-transformer": "^3.12.0", "@fortawesome/fontawesome-free": "^6.4.0", - "@open-formulieren/types": "^0.31.0", + "@open-formulieren/types": "^0.32.0", "@storybook/addon-actions": "^8.3.5", "@storybook/addon-essentials": "^8.3.5", "@storybook/addon-interactions": "^8.3.5", @@ -5087,9 +5087,9 @@ } }, "node_modules/@open-formulieren/types": { - "version": "0.31.0", - "resolved": "https://registry.npmjs.org/@open-formulieren/types/-/types-0.31.0.tgz", - "integrity": "sha512-ahdTHgSACvHvrQPwXh/1bkq7+8J9m4b8m1UdvaVirP8cMJwfvUJ1hdgMuOhwPoYJUlQ/tVrrL9rRl0cQ/bC79Q==", + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@open-formulieren/types/-/types-0.32.0.tgz", + "integrity": "sha512-Zio0HV99RqfYjVVx7TTdV+SxShwmc7j57cHXCZGGgpY6VicpOwISD6Wg93SEbYuQoFuRUAtjKE1JZ91dR+5TLg==", "dev": true }, "node_modules/@pkgjs/parseargs": { @@ -24606,9 +24606,9 @@ } }, "@open-formulieren/types": { - "version": "0.31.0", - "resolved": "https://registry.npmjs.org/@open-formulieren/types/-/types-0.31.0.tgz", - "integrity": "sha512-ahdTHgSACvHvrQPwXh/1bkq7+8J9m4b8m1UdvaVirP8cMJwfvUJ1hdgMuOhwPoYJUlQ/tVrrL9rRl0cQ/bC79Q==", + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@open-formulieren/types/-/types-0.32.0.tgz", + "integrity": "sha512-Zio0HV99RqfYjVVx7TTdV+SxShwmc7j57cHXCZGGgpY6VicpOwISD6Wg93SEbYuQoFuRUAtjKE1JZ91dR+5TLg==", "dev": true }, "@pkgjs/parseargs": { diff --git a/package.json b/package.json index 751e5c1b..f2a8fd01 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@formatjs/cli": "^6.1.1", "@formatjs/ts-transformer": "^3.12.0", "@fortawesome/fontawesome-free": "^6.4.0", - "@open-formulieren/types": "^0.31.0", + "@open-formulieren/types": "^0.32.0", "@storybook/addon-actions": "^8.3.5", "@storybook/addon-essentials": "^8.3.5", "@storybook/addon-interactions": "^8.3.5", diff --git a/src/components/ComponentConfiguration.stories.tsx b/src/components/ComponentConfiguration.stories.tsx index 5d87405f..7f3184e0 100644 --- a/src/components/ComponentConfiguration.stories.tsx +++ b/src/components/ComponentConfiguration.stories.tsx @@ -13,7 +13,6 @@ import { DEFAULT_COLORS, DEFAULT_DOCUMENT_TYPES, DEFAULT_FILE_TYPES, - DEFAULT_PRODUCTS, } from '@/tests/sharedUtils'; import {AnyComponentSchema} from '@/types'; @@ -114,7 +113,6 @@ const Template: StoryFn = ({ getDocumentTypes={async () => DEFAULT_DOCUMENT_TYPES} getConfidentialityLevels={async () => CONFIDENTIALITY_LEVELS} getAuthPlugins={async () => DEFAULT_AUTH_PLUGINS} - getProducts={async () => DEFAULT_PRODUCTS} component={component} isNew={isNew} builderInfo={builderInfo} @@ -2300,7 +2298,6 @@ export const ProductPrice: Story = { type: 'productPrice', key: 'productPrice', label: 'A productPrice field', - product: '123', }, builderInfo: { @@ -2317,9 +2314,6 @@ export const ProductPrice: Story = { const preview = within(canvas.getByTestId('componentPreview')); await expect(canvas.getByLabelText('Label')).toHaveValue('A productPrice field'); - await waitFor(async () => { - await expect(canvas.getByLabelText('Property Name')).toHaveValue('aProductPriceField'); - }); await expect(canvas.getByLabelText('Description')).toHaveValue(''); await expect(canvas.getByLabelText('Tooltip')).toHaveValue(''); await expect(canvas.getByLabelText('Show in summary')).toBeChecked(); @@ -2332,26 +2326,9 @@ export const ProductPrice: Story = { await userEvent.type(canvas.getByLabelText('Label'), 'Updated preview label'); await expect(await preview.findByText('Updated preview label')).toBeVisible(); - // Ensure that the manually entered key is kept instead of derived from the label, - // even when key/label components are not mounted. - const keyInput = canvas.getByLabelText('Property Name'); - // fireEvent is deliberate, as userEvent.clear + userEvent.type briefly makes the field - // not have any value, which triggers the generate-key-from-label behaviour. - fireEvent.change(keyInput, {target: {value: 'customKey'}}); await userEvent.click(canvas.getByRole('tab', {name: 'Basic'})); await userEvent.clear(canvas.getByLabelText('Label')); await userEvent.type(canvas.getByLabelText('Label'), 'Other label', {delay: 50}); - await expect(canvas.getByLabelText('Property Name')).toHaveDisplayValue('customKey'); - - await step('Change Product', async () => { - canvas.getByLabelText('Product').focus(); - await userEvent.keyboard('[ArrowDown]'); - await waitFor(async () => { - const product1 = canvas.getByText('product 1'); - await expect(product1).toBeVisible(); - await userEvent.click(product1); - }); - }); await step('Submit form', async () => { await userEvent.click(canvas.getByRole('button', {name: 'Save'})); diff --git a/src/components/ComponentConfiguration.tsx b/src/components/ComponentConfiguration.tsx index ab03bfbd..eca05a25 100644 --- a/src/components/ComponentConfiguration.tsx +++ b/src/components/ComponentConfiguration.tsx @@ -44,7 +44,6 @@ const ComponentConfiguration: React.FC = ({ getDocumentTypes, getConfidentialityLevels, getAuthPlugins, - getProducts, isNew, component, builderInfo, @@ -72,7 +71,6 @@ const ComponentConfiguration: React.FC = ({ getDocumentTypes, getConfidentialityLevels, getAuthPlugins, - getProducts, }} > Promise>; getConfidentialityLevels: () => Promise; getAuthPlugins: () => Promise; - getProducts: () => Promise; } const BuilderContext = React.createContext({ @@ -66,7 +65,6 @@ const BuilderContext = React.createContext({ getDocumentTypes: async () => [], getConfidentialityLevels: async () => [], getAuthPlugins: async () => [], - getProducts: async () => [], }); BuilderContext.displayName = 'BuilderContext'; diff --git a/src/registry/productPrice/edit.tsx b/src/registry/productPrice/edit.tsx index 6f3d6bdf..a9269144 100644 --- a/src/registry/productPrice/edit.tsx +++ b/src/registry/productPrice/edit.tsx @@ -1,7 +1,5 @@ import {ProductPriceComponentSchema} from '@open-formulieren/types'; -import {useContext} from 'react'; -import {FormattedMessage, useIntl} from 'react-intl'; -import useAsync from 'react-use/esm/useAsync'; +import {useIntl} from 'react-intl'; import { BuilderTabs, @@ -9,7 +7,6 @@ import { Description, Hidden, IsSensitiveData, - Key, Label, PresentationConfig, Registration, @@ -17,11 +14,9 @@ import { Tooltip, Translations, Validate, - useDeriveComponentKey, } from '@/components/builder'; import {LABELS} from '@/components/builder/messages'; -import {Select, TabList, TabPanel, Tabs} from '@/components/formio'; -import {BuilderContext} from '@/context'; +import {TabList, TabPanel, Tabs} from '@/components/formio'; import {useErrorChecker} from '@/utils/errors'; import {EditFormDefinition} from '../types'; @@ -31,7 +26,6 @@ import {EditFormDefinition} from '../types'; */ const EditForm: EditFormDefinition = () => { const intl = useIntl(); - const [isKeyManuallySetRef, generatedKey] = useDeriveComponentKey(); const {hasAnyError} = useErrorChecker(); Validate.useManageValidatorsTranslations(['required']); @@ -42,7 +36,6 @@ const EditForm: EditFormDefinition = () => { = () => { 'showInPDF', 'hidden', 'clearOnHide', - 'isSensitiveData', - 'product' + 'isSensitiveData' )} /> @@ -63,14 +55,12 @@ const EditForm: EditFormDefinition = () => { {/* Basic tab */} {/* Advanced tab */} @@ -107,7 +97,7 @@ const EditForm: EditFormDefinition = () => { EditForm.defaultValues = { // basic tab label: '', - key: '', + key: 'priceOption', description: '', tooltip: '', showInSummary: true, @@ -116,7 +106,6 @@ EditForm.defaultValues = { hidden: false, clearOnHide: true, isSensitiveData: false, - product: '', // Advanced tab conditional: { show: undefined, @@ -134,32 +123,4 @@ EditForm.defaultValues = { }, }; -const Product: React.FC = () => { - const {getProducts} = useContext(BuilderContext); - const {value: options, loading, error} = useAsync(async () => await getProducts(), []); - if (error) { - throw error; - } - - const intl = useIntl(); - const tooltip = intl.formatMessage({ - description: "Tooltip for 'product' builder field", - defaultMessage: 'Product to fetch prices for', - }); - return ( -