From c9d1e52028c1e8b50d3350bd31479128cc12102d Mon Sep 17 00:00:00 2001 From: William Thorenfeldt <48119543+wrt95@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:33:32 +0100 Subject: [PATCH 1/2] chore: Replace divider component (#13960) --- .../components/Tabs/AboutTab/AboutTab.tsx | 2 -- .../AboutTab/InputFields/InputFields.module.css | 1 + .../components/Resources/Resources.module.css | 10 +++++++--- .../dashboard/components/Resources/Resources.tsx | 8 +++++--- .../src/style/studio-variables.css | 2 ++ .../NoItemSelectedMessage.module.css | 7 +++++++ .../NoItemSelectedMessage.tsx | 13 +++++++++++++ .../src/components/NoItemSelectedMessage/index.ts | 1 + .../SchemaInspector/CustomProperties.module.css | 5 ++--- .../SchemaInspector/CustomProperties.tsx | 1 - .../SchemaInspector/ItemDataComponent.module.css | 5 +++++ .../SchemaInspector/ItemDataComponent.tsx | 9 +-------- .../ArrayRestrictions/ArrayRestrictions.tsx | 7 +++---- .../EnumList/EnumField/EnumField.tsx | 3 ++- .../ItemRestrictions/EnumList/EnumList.module.css | 4 ++++ .../ItemRestrictions/EnumList/EnumList.tsx | 2 ++ .../ItemRestrictions/ItemRestrictions.tsx | 6 +----- .../ItemWrapper/ItemWrapper.module.css | 7 +++++++ .../ItemRestrictions/ItemWrapper/ItemWrapper.tsx | 8 ++++++++ .../ItemRestrictions/ItemWrapper/index.ts | 1 + .../NumberRestrictions/NumberRestrictions.tsx | 7 +++---- .../ObjectRestrictions/ObjectRestrictions.tsx | 7 +++---- .../RestrictionField/RestrictionField.tsx | 1 + .../StringRestrictions.module.css | 4 +++- .../StringRestrictions/StringRestrictions.tsx | 10 +++++----- .../SchemaInspector/SchemaInspector.module.css | 7 +++++-- .../components/SchemaInspector/SchemaInspector.tsx | 9 ++------- .../TypesInspector/TypesInspector.module.css | 5 ----- .../components/TypesInspector/TypesInspector.tsx | 11 ++--------- .../shared/src/primitives/Divider.module.css | 13 ------------- .../packages/shared/src/primitives/Divider.tsx | 14 -------------- frontend/packages/shared/src/primitives/index.ts | 1 - .../components/Properties/Calculations.module.css | 4 ++++ .../src/components/Properties/Calculations.tsx | 4 +--- .../Properties/ConditionalRendering.module.css | 9 +++++++++ .../components/Properties/ConditionalRendering.tsx | 7 ++----- .../SimpleExpression/SimpleExpression.tsx | 2 -- .../SubExpressionContent.module.css | 1 + 38 files changed, 113 insertions(+), 105 deletions(-) create mode 100644 frontend/packages/schema-editor/src/components/NoItemSelectedMessage/NoItemSelectedMessage.module.css create mode 100644 frontend/packages/schema-editor/src/components/NoItemSelectedMessage/NoItemSelectedMessage.tsx create mode 100644 frontend/packages/schema-editor/src/components/NoItemSelectedMessage/index.ts create mode 100644 frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ItemWrapper/ItemWrapper.module.css create mode 100644 frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ItemWrapper/ItemWrapper.tsx create mode 100644 frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ItemWrapper/index.ts delete mode 100644 frontend/packages/shared/src/primitives/Divider.module.css delete mode 100644 frontend/packages/shared/src/primitives/Divider.tsx delete mode 100644 frontend/packages/shared/src/primitives/index.ts diff --git a/frontend/app-development/layout/PageHeader/SubHeader/SettingsModalButton/SettingsModal/components/Tabs/AboutTab/AboutTab.tsx b/frontend/app-development/layout/PageHeader/SubHeader/SettingsModalButton/SettingsModal/components/Tabs/AboutTab/AboutTab.tsx index 54177b08d52..53f73ee6130 100644 --- a/frontend/app-development/layout/PageHeader/SubHeader/SettingsModalButton/SettingsModal/components/Tabs/AboutTab/AboutTab.tsx +++ b/frontend/app-development/layout/PageHeader/SubHeader/SettingsModalButton/SettingsModal/components/Tabs/AboutTab/AboutTab.tsx @@ -3,7 +3,6 @@ import { useTranslation } from 'react-i18next'; import { TabHeader } from '../../TabHeader'; import type { AppConfig } from 'app-shared/types/AppConfig'; import { ErrorMessage } from '@digdir/designsystemet-react'; -import { Divider } from 'app-shared/primitives'; import { getRepositoryType } from 'app-shared/utils/repository'; import { useAppConfigMutation } from 'app-development/hooks/mutations'; import { useAppConfigQuery } from 'app-development/hooks/queries'; @@ -70,7 +69,6 @@ export const AboutTab = (): React.ReactElement => { return ( <> - -

{t('dashboard.resources')}

- + + {t('dashboard.resources')} +
{resources.map((resource, index) => ( { + const { t } = useTranslation(); + return ( + + {t('schema_editor.no_item_selected')} + + ); +}; diff --git a/frontend/packages/schema-editor/src/components/NoItemSelectedMessage/index.ts b/frontend/packages/schema-editor/src/components/NoItemSelectedMessage/index.ts new file mode 100644 index 00000000000..0968e02dab5 --- /dev/null +++ b/frontend/packages/schema-editor/src/components/NoItemSelectedMessage/index.ts @@ -0,0 +1 @@ +export { NoItemSelectedMessage } from './NoItemSelectedMessage'; diff --git a/frontend/packages/schema-editor/src/components/SchemaInspector/CustomProperties.module.css b/frontend/packages/schema-editor/src/components/SchemaInspector/CustomProperties.module.css index 6e04fce0886..68951e99eb5 100644 --- a/frontend/packages/schema-editor/src/components/SchemaInspector/CustomProperties.module.css +++ b/frontend/packages/schema-editor/src/components/SchemaInspector/CustomProperties.module.css @@ -1,6 +1,8 @@ .root { display: flex; flex-direction: column; + border-top: var(--studio-border-divider); + padding-top: var(--fds-spacing-5); } .listItem { @@ -36,9 +38,6 @@ align-items: center; } -.deleteButton { -} - .unknownFormatValue { display: inline-flex; gap: 0.5rem; diff --git a/frontend/packages/schema-editor/src/components/SchemaInspector/CustomProperties.tsx b/frontend/packages/schema-editor/src/components/SchemaInspector/CustomProperties.tsx index 34511ae572f..5b145b7863b 100644 --- a/frontend/packages/schema-editor/src/components/SchemaInspector/CustomProperties.tsx +++ b/frontend/packages/schema-editor/src/components/SchemaInspector/CustomProperties.tsx @@ -92,7 +92,6 @@ export const CustomProperties = ({ path }: CustomPropertiesProps) => { {renderInput(key)} } onClick={() => deleteCustomProperty(key)} title={t('general.delete')} diff --git a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemDataComponent.module.css b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemDataComponent.module.css index abc1cc0c37a..6d1042f4653 100644 --- a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemDataComponent.module.css +++ b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemDataComponent.module.css @@ -4,6 +4,11 @@ gap: 2rem; } +.fieldSet { + border-top: var(--studio-border-divider); + padding-top: var(--fds-spacing-8); +} + .fieldSet > div { display: flex; flex-direction: column; diff --git a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemDataComponent.tsx b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemDataComponent.tsx index fe2f68f874c..e5306d7cb66 100644 --- a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemDataComponent.tsx +++ b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemDataComponent.tsx @@ -26,7 +26,6 @@ import { changeNameInPointer, } from '@altinn/schema-model'; import { makeDomFriendlyID } from '../../utils/ui-schema-utils'; -import { Divider } from 'app-shared/primitives'; import { useTranslation } from 'react-i18next'; import { CustomProperties } from '@altinn/schema-editor/components/SchemaInspector/CustomProperties'; import { NameField } from './NameField'; @@ -174,15 +173,9 @@ export function ItemDataComponent({ schemaNode }: IItemDataComponentProps) { )} - - - )} - {hasCustomProps && ( - <> - - )} + {hasCustomProps && }
- +
- + ); } diff --git a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/EnumList/EnumField/EnumField.tsx b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/EnumList/EnumField/EnumField.tsx index ab8b51e4be1..e90539f6a62 100644 --- a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/EnumList/EnumField/EnumField.tsx +++ b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/EnumList/EnumField/EnumField.tsx @@ -53,6 +53,7 @@ export const EnumField = ({ onChange={handleChange} onKeyDown={onKeyDown} error={!isValid} + size='sm' /> onDelete()} color='danger' variant='tertiary' - size='medium' + size='sm' />
); diff --git a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/EnumList/EnumList.module.css b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/EnumList/EnumList.module.css index e69de29bb2d..e670d81185a 100644 --- a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/EnumList/EnumList.module.css +++ b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/EnumList/EnumList.module.css @@ -0,0 +1,4 @@ +.enumListFieldsset { + border-top: var(--studio-border-divider); + padding-top: var(--fds-spacing-5); +} diff --git a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/EnumList/EnumList.tsx b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/EnumList/EnumList.tsx index ae27c271845..d07353b1c56 100644 --- a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/EnumList/EnumList.tsx +++ b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/EnumList/EnumList.tsx @@ -55,6 +55,8 @@ export const EnumList = ({ schemaNode }: EnumListProps): JSX.Element => {
{duplicateValues !== null && ( {t('schema_editor.enum_error_duplicate')} diff --git a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ItemRestrictions.tsx b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ItemRestrictions.tsx index c9bd586a50c..c764c338f0a 100644 --- a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ItemRestrictions.tsx +++ b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ItemRestrictions.tsx @@ -17,7 +17,6 @@ import { ObjectRestrictions } from './ObjectRestrictions'; import { StringRestrictions } from './StringRestrictions'; import classes from './ItemRestrictions.module.css'; import { Switch } from '@digdir/designsystemet-react'; -import { Divider } from 'app-shared/primitives'; import { useTranslation } from 'react-i18next'; import type { KeyValuePairs } from 'app-shared/types/KeyValuePairs'; import { useSchemaEditorAppContext } from '@altinn/schema-editor/hooks/useSchemaEditorAppContext'; @@ -82,10 +81,7 @@ export const ItemRestrictions = ({ schemaNode }: ItemRestrictionsProps) => { {isArray && } {isField(schemaNode) && [FieldType.String, FieldType.Integer, FieldType.Number].includes(schemaNode.fieldType) && ( - <> - - - + )} ); diff --git a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ItemWrapper/ItemWrapper.module.css b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ItemWrapper/ItemWrapper.module.css new file mode 100644 index 00000000000..f462c7a1b51 --- /dev/null +++ b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ItemWrapper/ItemWrapper.module.css @@ -0,0 +1,7 @@ +.itemWrapper { + border-top: var(--studio-border-divider); + padding-top: var(--fds-spacing-5); + display: flex; + flex-direction: column; + gap: var(--fds-spacing-8); +} diff --git a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ItemWrapper/ItemWrapper.tsx b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ItemWrapper/ItemWrapper.tsx new file mode 100644 index 00000000000..dc497489d65 --- /dev/null +++ b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ItemWrapper/ItemWrapper.tsx @@ -0,0 +1,8 @@ +import React, { type HTMLAttributes, type ReactElement } from 'react'; +import classes from './ItemWrapper.module.css'; + +type ItemWrapperProps = HTMLAttributes; + +export const ItemWrapper = ({ children }: ItemWrapperProps): ReactElement => ( +
{children}
+); diff --git a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ItemWrapper/index.ts b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ItemWrapper/index.ts new file mode 100644 index 00000000000..0b41e2f2fb1 --- /dev/null +++ b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ItemWrapper/index.ts @@ -0,0 +1 @@ +export { ItemWrapper } from './ItemWrapper'; diff --git a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/NumberRestrictions/NumberRestrictions.tsx b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/NumberRestrictions/NumberRestrictions.tsx index 077e4d6a413..66df851639b 100644 --- a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/NumberRestrictions/NumberRestrictions.tsx +++ b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/NumberRestrictions/NumberRestrictions.tsx @@ -3,7 +3,6 @@ import React, { useReducer } from 'react'; import type { RestrictionItemProps } from '../ItemRestrictions'; import type { KeyValuePairs } from 'app-shared/types/KeyValuePairs'; import { IntRestrictionKey } from '@altinn/schema-model'; -import { Divider } from 'app-shared/primitives'; import { useTranslation } from 'react-i18next'; import classes from './NumberRestrictions.module.css'; import { ErrorMessage, Switch, Label } from '@digdir/designsystemet-react'; @@ -18,6 +17,7 @@ import { import { NumberRestrictionsError } from '@altinn/schema-editor/types'; import { valueExists } from '@altinn/schema-editor/utils/value'; import { StudioTextfield } from '@studio/components'; +import { ItemWrapper } from '../ItemWrapper'; export interface NumberRestrictionsProps extends RestrictionItemProps { isInteger: boolean; @@ -83,8 +83,7 @@ export function NumberRestrictions({ }; return ( - <> - +
@@ -152,6 +151,6 @@ export function NumberRestrictions({ />
- +
); } diff --git a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ObjectRestrictions/ObjectRestrictions.tsx b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ObjectRestrictions/ObjectRestrictions.tsx index da193f367d7..0d9ad638458 100644 --- a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ObjectRestrictions/ObjectRestrictions.tsx +++ b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/ObjectRestrictions/ObjectRestrictions.tsx @@ -2,8 +2,8 @@ import React from 'react'; import type { RestrictionItemProps } from '../ItemRestrictions'; import { ObjRestrictionKey } from '@altinn/schema-model'; import { RestrictionField } from '../RestrictionField'; -import { Divider } from 'app-shared/primitives'; import { useTranslation } from 'react-i18next'; +import { ItemWrapper } from '../ItemWrapper'; export function ObjectRestrictions({ restrictions, @@ -13,8 +13,7 @@ export function ObjectRestrictions({ const { t } = useTranslation(); const defaults = Object.values(ObjRestrictionKey); return defaults?.length ? ( - <> - + {defaults.map((key) => ( ))} - + ) : null; } diff --git a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/RestrictionField/RestrictionField.tsx b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/RestrictionField/RestrictionField.tsx index 8475976e193..86fbb77f5c3 100644 --- a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/RestrictionField/RestrictionField.tsx +++ b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/RestrictionField/RestrictionField.tsx @@ -39,6 +39,7 @@ export const RestrictionField = ({ onChange={handleChange} readOnly={readOnly} value={value ?? ''} + size='sm' />
); diff --git a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/StringRestrictions/StringRestrictions.module.css b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/StringRestrictions/StringRestrictions.module.css index a66227eecfc..14c57060db3 100644 --- a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/StringRestrictions/StringRestrictions.module.css +++ b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/StringRestrictions/StringRestrictions.module.css @@ -11,8 +11,10 @@ .lengthFields { display: flex; flex-direction: row; - gap: 2rem; + gap: var(--fds-spacing-8); justify-content: space-between; + border-bottom: var(--studio-border-divider); + padding-bottom: var(--fds-spacing-8); } .lengthField { diff --git a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/StringRestrictions/StringRestrictions.tsx b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/StringRestrictions/StringRestrictions.tsx index 4114e08d966..9a9fece18f1 100644 --- a/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/StringRestrictions/StringRestrictions.tsx +++ b/frontend/packages/schema-editor/src/components/SchemaInspector/ItemRestrictions/StringRestrictions/StringRestrictions.tsx @@ -6,7 +6,6 @@ import classes from './StringRestrictions.module.css'; import { Fieldset, Label, Switch, Textfield } from '@digdir/designsystemet-react'; import type { KeyValuePairs } from 'app-shared/types/KeyValuePairs'; import { StringFormat, StrRestrictionKey } from '@altinn/schema-model'; -import { Divider } from 'app-shared/primitives'; import { makeDomFriendlyID } from '../../../../utils/ui-schema-utils'; import type { StringRestrictionsReducerAction } from './StringRestrictionsReducer'; import { @@ -15,6 +14,7 @@ import { } from './StringRestrictionsReducer'; import { useTranslation } from 'react-i18next'; import { StudioNativeSelect, StudioTextfield } from '@studio/components'; +import { ItemWrapper } from '../ItemWrapper'; export function StringRestrictions({ onChangeRestrictionValue, @@ -73,8 +73,7 @@ export function StringRestrictions({ const formatMaxLangKey = `format_date_before_${formatState.latestIsInclusive ? 'incl' : 'excl'}`; return ( - <> - +
-
- + ); } diff --git a/frontend/packages/schema-editor/src/components/SchemaInspector/SchemaInspector.module.css b/frontend/packages/schema-editor/src/components/SchemaInspector/SchemaInspector.module.css index 2ea6be75947..f764b2607a8 100644 --- a/frontend/packages/schema-editor/src/components/SchemaInspector/SchemaInspector.module.css +++ b/frontend/packages/schema-editor/src/components/SchemaInspector/SchemaInspector.module.css @@ -5,6 +5,9 @@ } .noItem { - font-weight: 500; - margin: 18px; + margin: 0; + border-bottom: var(--studio-border-divider); + width: 100%; + padding-block: var(--fds-spacing-5); + text-align: center; } diff --git a/frontend/packages/schema-editor/src/components/SchemaInspector/SchemaInspector.tsx b/frontend/packages/schema-editor/src/components/SchemaInspector/SchemaInspector.tsx index 9480c520805..67f95f091ce 100644 --- a/frontend/packages/schema-editor/src/components/SchemaInspector/SchemaInspector.tsx +++ b/frontend/packages/schema-editor/src/components/SchemaInspector/SchemaInspector.tsx @@ -5,10 +5,10 @@ import { isField, isObject } from '@altinn/schema-model'; import { ItemPropertiesTab } from './ItemPropertiesTab'; import { ItemFieldsTab } from './ItemFieldsTab'; import classes from './SchemaInspector.module.css'; -import { Divider } from 'app-shared/primitives'; import { useTranslation } from 'react-i18next'; import { useSchemaEditorAppContext } from '../../hooks/useSchemaEditorAppContext'; import { useSavableSchemaModel } from '../../hooks/useSavableSchemaModel'; +import { NoItemSelectedMessage } from '../NoItemSelectedMessage'; export const SchemaInspector = () => { const { t } = useTranslation(); @@ -16,12 +16,7 @@ export const SchemaInspector = () => { const savableModel = useSavableSchemaModel(); if (!selectedUniquePointer) { - return ( -
-

{t('schema_editor.no_item_selected')}

- -
- ); + return ; } const selectedItem: UiSchemaNode = savableModel.getNodeByUniquePointer(selectedUniquePointer); diff --git a/frontend/packages/schema-editor/src/components/TypesInspector/TypesInspector.module.css b/frontend/packages/schema-editor/src/components/TypesInspector/TypesInspector.module.css index 26856e71376..12fc73e64a9 100644 --- a/frontend/packages/schema-editor/src/components/TypesInspector/TypesInspector.module.css +++ b/frontend/packages/schema-editor/src/components/TypesInspector/TypesInspector.module.css @@ -30,8 +30,3 @@ margin-right: 0; color: #000000; } - -.noItem { - font-weight: 500; - margin: 18px; -} diff --git a/frontend/packages/schema-editor/src/components/TypesInspector/TypesInspector.tsx b/frontend/packages/schema-editor/src/components/TypesInspector/TypesInspector.tsx index 54e6a29226d..c0b4f4c97f2 100644 --- a/frontend/packages/schema-editor/src/components/TypesInspector/TypesInspector.tsx +++ b/frontend/packages/schema-editor/src/components/TypesInspector/TypesInspector.tsx @@ -5,10 +5,10 @@ import { PlusIcon } from '@studio/icons'; import type { UiSchemaNode } from '@altinn/schema-model'; import { SchemaModel } from '@altinn/schema-model'; import classes from './TypesInspector.module.css'; -import { Divider } from 'app-shared/primitives'; import { useTranslation } from 'react-i18next'; import { TypeItem } from './TypeItem'; import { useSchemaEditorAppContext } from '../../hooks/useSchemaEditorAppContext'; +import { NoItemSelectedMessage } from '../NoItemSelectedMessage'; export interface TypesInspectorProps { schemaItems: UiSchemaNode[]; @@ -39,14 +39,7 @@ export const TypesInspector = ({ schemaItems }: TypesInspectorProps) => { }; if (!schemaItems) { - return ( -
-

- {t('schema_editor.no_item_selected')} -

- -
- ); + return ; } return ( diff --git a/frontend/packages/shared/src/primitives/Divider.module.css b/frontend/packages/shared/src/primitives/Divider.module.css deleted file mode 100644 index bc2aab7139b..00000000000 --- a/frontend/packages/shared/src/primitives/Divider.module.css +++ /dev/null @@ -1,13 +0,0 @@ -.root { - border-color: rgba(0, 0, 0, 0.12); - border-style: solid; - border-width: 1px 0 0 0; -} - -.marginless { - margin: 0; -} - -.standalone { - margin: 2rem 0; -} diff --git a/frontend/packages/shared/src/primitives/Divider.tsx b/frontend/packages/shared/src/primitives/Divider.tsx deleted file mode 100644 index 45c24b5b8f5..00000000000 --- a/frontend/packages/shared/src/primitives/Divider.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; -import classes from './Divider.module.css'; -import cn from 'classnames'; - -interface DividerProps { - marginless?: boolean; - className?: string; -} - -export const Divider = ({ marginless, className }: DividerProps) => ( -
-); diff --git a/frontend/packages/shared/src/primitives/index.ts b/frontend/packages/shared/src/primitives/index.ts deleted file mode 100644 index 8ba836ab714..00000000000 --- a/frontend/packages/shared/src/primitives/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { Divider } from './Divider'; diff --git a/frontend/packages/ux-editor-v3/src/components/Properties/Calculations.module.css b/frontend/packages/ux-editor-v3/src/components/Properties/Calculations.module.css index d5d5d62fea3..89014c9713e 100644 --- a/frontend/packages/ux-editor-v3/src/components/Properties/Calculations.module.css +++ b/frontend/packages/ux-editor-v3/src/components/Properties/Calculations.module.css @@ -11,3 +11,7 @@ gap: 1rem; margin-bottom: 1rem; } + +.ruleModalWrapper { + border-bottom: var(--studio-border-divider); +} diff --git a/frontend/packages/ux-editor-v3/src/components/Properties/Calculations.tsx b/frontend/packages/ux-editor-v3/src/components/Properties/Calculations.tsx index 9a00545e584..c90d57ca55d 100644 --- a/frontend/packages/ux-editor-v3/src/components/Properties/Calculations.tsx +++ b/frontend/packages/ux-editor-v3/src/components/Properties/Calculations.tsx @@ -2,7 +2,6 @@ import React from 'react'; import classes from './Calculations.module.css'; import { RuleModal } from '../toolbar/RuleModal'; import { OldDynamicsInfo } from './OldDynamicsInfo'; -import { Divider } from 'app-shared/primitives'; import { useFormItemContext } from '../../containers/FormItemContext'; import { formItemConfigs } from '../../data/formItemConfig'; import { UnknownComponentAlert } from '../UnknownComponentAlert'; @@ -17,10 +16,9 @@ export const Calculations = () => { return (
-
+
-
); diff --git a/frontend/packages/ux-editor-v3/src/components/Properties/ConditionalRendering.module.css b/frontend/packages/ux-editor-v3/src/components/Properties/ConditionalRendering.module.css index f7caa7e6a63..2ac9bbfcd2b 100644 --- a/frontend/packages/ux-editor-v3/src/components/Properties/ConditionalRendering.module.css +++ b/frontend/packages/ux-editor-v3/src/components/Properties/ConditionalRendering.module.css @@ -15,3 +15,12 @@ .dynamicsVersionCheckBox { z-index: 1; } + +.alert { + border-top: var(--studio-border-divider); + padding-block: var(--fds-spacing-8); +} + +.conditionalRenderingWrapper { + border-bottom: var(--studio-border-divider); +} diff --git a/frontend/packages/ux-editor-v3/src/components/Properties/ConditionalRendering.tsx b/frontend/packages/ux-editor-v3/src/components/Properties/ConditionalRendering.tsx index 9b0eb183c21..994e72c8bed 100644 --- a/frontend/packages/ux-editor-v3/src/components/Properties/ConditionalRendering.tsx +++ b/frontend/packages/ux-editor-v3/src/components/Properties/ConditionalRendering.tsx @@ -2,7 +2,6 @@ import React from 'react'; import { Alert } from '@digdir/designsystemet-react'; import classes from './ConditionalRendering.module.css'; import { OldDynamicsInfo } from './OldDynamicsInfo'; -import { Divider } from 'app-shared/primitives'; import { Trans } from 'react-i18next'; import { altinnDocsUrl } from 'app-shared/ext-urls'; import { ConditionalRenderingModal } from '../toolbar/ConditionalRenderingModal'; @@ -10,10 +9,9 @@ import { ConditionalRenderingModal } from '../toolbar/ConditionalRenderingModal' export const ConditionalRendering = () => { return (
-
+
- - + {
-
); diff --git a/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/SimpleExpression.tsx b/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/SimpleExpression.tsx index fdd531240b6..9a2e00c9d45 100644 --- a/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/SimpleExpression.tsx +++ b/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/SimpleExpression.tsx @@ -3,7 +3,6 @@ import type { Expression, SubExpression } from '../../../../../../types/Expressi import { Operator } from '../../../../../../types/Expressions'; import { SubExpressionContent } from './SubExpressionContent'; import { useText } from '../../../../../../hooks'; -import { Divider } from 'app-shared/primitives'; import { ToggleGroup } from '@digdir/designsystemet-react'; export type SimpleExpressionProps = { @@ -25,7 +24,6 @@ export const SimpleExpression = ({ {expression.subExpressions?.map((subExp: SubExpression, index: number) => { return ( - diff --git a/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/SubExpressionContent.module.css b/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/SubExpressionContent.module.css index 80070e79369..4d19e3b525b 100644 --- a/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/SubExpressionContent.module.css +++ b/frontend/packages/ux-editor-v3/src/components/config/Expressions/ExpressionContent/ExpressionEditMode/SimpleExpression/SubExpressionContent.module.css @@ -1,6 +1,7 @@ .subExpressionTop { display: flex; justify-content: space-between; + border-top: var(--studio-border-divider); } .subExpression { From 22337dc64c301327352dd23c0260571b07bd0fd2 Mon Sep 17 00:00:00 2001 From: William Thorenfeldt <48119543+wrt95@users.noreply.github.com> Date: Thu, 7 Nov 2024 15:56:47 +0100 Subject: [PATCH 2/2] refactor: Split ui-editor playwright tests into smaller tests (#14008) --- ...ditor-data-model-binding-and-gitea.spec.ts | 161 +++++++++++------- 1 file changed, 100 insertions(+), 61 deletions(-) diff --git a/frontend/testing/playwright/tests/ui-editor/ui-editor-data-model-binding-and-gitea.spec.ts b/frontend/testing/playwright/tests/ui-editor/ui-editor-data-model-binding-and-gitea.spec.ts index ba23b332d07..82867f39665 100644 --- a/frontend/testing/playwright/tests/ui-editor/ui-editor-data-model-binding-and-gitea.spec.ts +++ b/frontend/testing/playwright/tests/ui-editor/ui-editor-data-model-binding-and-gitea.spec.ts @@ -10,21 +10,21 @@ import { Header } from '../../components/Header'; import { DataModelPage } from '../../pages/DataModelPage'; import { GiteaPage } from '../../pages/GiteaPage'; -const getAppTestName = (app: string) => `bindings-${app}`; +// This line must be there to ensure that the tests do not run in parallell, and +// that the before all call is being executed before we start the tests +test.describe.configure({ mode: 'serial' }); // Before the tests starts, we need to create the data model app test.beforeAll(async ({ testAppName, request, storageState }) => { // Create a new app - const designerApi = new DesignerApi({ app: getAppTestName(testAppName) }); + const designerApi = new DesignerApi({ app: testAppName }); const response = await designerApi.createApp(request, storageState as StorageState); expect(response.ok()).toBeTruthy(); }); test.afterAll(async ({ request, testAppName }) => { const gitea = new Gitea(); - const response = await request.delete( - gitea.getDeleteAppEndpoint({ app: getAppTestName(testAppName) }), - ); + const response = await request.delete(gitea.getDeleteAppEndpoint({ app: testAppName })); expect(response.ok()).toBeTruthy(); }); @@ -41,31 +41,44 @@ const setupAndVerifyUiEditorPage = async ( localStorage.setItem('featureFlags', JSON.stringify(flag)); }, featureFlag); } + + await uiEditorPage.clickOnPageAccordion(pageName); + await uiEditorPage.verifyUiEditorPage(pageName); + return uiEditorPage; }; -test('That it is possible to add a data model binding, and that the files are updated accordingly in Gitea', async ({ +test('That it is possible to drag in a new component, add a title to the newly added component and add a data model binding', async ({ page, testAppName, }): Promise => { - const app = getAppTestName(testAppName); - const header = new Header(page, { app }); - const dataModelPage = new DataModelPage(page, { app }); - const giteaPage = new GiteaPage(page, { app }); - const uiEditorPage = await setupAndVerifyUiEditorPage(page, app); - - const pageName: string = 'Side1'; - await openPageAccordionAndVerifyUpdatedUrl(uiEditorPage, pageName); + const uiEditorPage = await setupAndVerifyUiEditorPage(page, testAppName); await uiEditorPage.verifyThatPageIsEmpty(); - const newInputLabel: string = 'Input Label 1'; await uiEditorPage.dragComponentIntoDroppableList(ComponentType.Input); await uiEditorPage.waitForComponentTreeItemToBeVisibleInDroppableList(ComponentType.Input); - await addNewLabelToTreeItemComponent(uiEditorPage, newInputLabel); + + await uiEditorPage.clickOnComponentTextConfigAccordion(); + await uiEditorPage.clickOnTitleTextButton(); + await uiEditorPage.writeTitleTextInTextarea(newInputLabel); + await uiEditorPage.clickOnSaveNewLabelName(); + await uiEditorPage.waitForTreeItemToGetNewLabel(newInputLabel); + + await uiEditorPage.verifyThatTreeItemByNameIsNotVisibleInDroppableList(ComponentType.Input); + await uiEditorPage.verifyThatTreeItemByNameIsVisibleInDroppableList(newInputLabel); await uiEditorPage.clickOnComponentDataModelBindingConfigAccordion(); await uiEditorPage.clickOnAddDataModelButton(ComponentType.Input); await uiEditorPage.clickOnDataModelFieldBindingCombobox(); +}); + +test('That it is possible to navigate to Gitea and that data model bindings are not present', async ({ + page, + testAppName, +}): Promise => { + const uiEditorPage = await setupAndVerifyUiEditorPage(page, testAppName); + const header = new Header(page, { app: testAppName }); + const giteaPage = new GiteaPage(page, { app: testAppName }); await header.clickOnThreeDotsMenu(); await header.clickOnGoToGiteaRepository(); @@ -75,23 +88,34 @@ test('That it is possible to add a data model binding, and that the files are up await giteaPage.goBackNPages(6); // 5 because of: Gitea -> App -> ui -> layoutsSet -> layouts -> page1.json await uiEditorPage.verifyUiEditorPage(pageName); +}); + +test('That it is possible to navigate to datamodel page and create a new data model', async ({ + page, + testAppName, +}): Promise => { + await setupAndVerifyUiEditorPage(page, testAppName); + const header = new Header(page, { app: testAppName }); + const dataModelPage = new DataModelPage(page, { app: testAppName }); await header.clickOnNavigateToPageInTopMenuHeader('data_model'); await dataModelPage.verifyDataModelPage(); - // Add data model - await dataModelPage.clickOnCreateNewDataModelButton(); const dataModelName: string = 'testDataModel'; - await dataModelPage.typeDataModelName(dataModelName); - await dataModelPage.clickOnCreateModelButton(); - await dataModelPage.waitForDataModelToAppear(dataModelName); - await dataModelPage.clickOnGenerateDataModelButton(); - await dataModelPage.checkThatSuccessAlertIsVisibleOnScreen(); - await dataModelPage.waitForSuccessAlertToDisappear(); + await createNewDataModel(dataModelPage, dataModelName); +}); + +test('That it is possible to navigate back to ui-editor page and add the data model', async ({ + page, + testAppName, +}): Promise => { + const uiEditorPage = await setupAndVerifyUiEditorPage(page, testAppName); + const header = new Header(page, { app: testAppName }); await header.clickOnNavigateToPageInTopMenuHeader('create'); await uiEditorPage.verifyUiEditorPage(); - await openPageAccordionAndVerifyUpdatedUrl(uiEditorPage, pageName); + await uiEditorPage.clickOnPageAccordion(pageName); + await uiEditorPage.verifyUiEditorPage(pageName); await uiEditorPage.clickOnTreeItem(newInputLabel); await uiEditorPage.clickOnComponentDataModelBindingConfigAccordion(); @@ -99,10 +123,18 @@ test('That it is possible to add a data model binding, and that the files are up await uiEditorPage.clickOnDataModelFieldBindingCombobox(); await uiEditorPage.verifyThatThereAreOptionsInTheDataModelFieldList(); - const dataModelBindingName = 'property1'; await uiEditorPage.clickOnDataModelFieldPropertyOption(dataModelBindingName); await uiEditorPage.clickOnSaveDataModel(); await uiEditorPage.waitForDataModelToBeSelected(); +}); + +test('That it is possible to upload the changes to Gitea and view the changes in Gitea', async ({ + page, + testAppName, +}): Promise => { + await setupAndVerifyUiEditorPage(page, testAppName); + const header = new Header(page, { app: testAppName }); + const giteaPage = new GiteaPage(page, { app: testAppName }); await header.clickOnUploadLocalChangesButton(); await header.clickOnValidateChanges(); @@ -117,31 +149,31 @@ test('That it is possible to add a data model binding, and that the files are up ); }); -test('That is possible to select a different data model binding, and that the files are updated accordingly in Gitea', async ({ +test('That it is possible to navigate to data model page and create another data model', async ({ page, testAppName, }): Promise => { - const app = getAppTestName(testAppName); - const header = new Header(page, { app }); - const dataModelPage = new DataModelPage(page, { app }); - const uiEditorPage = await setupAndVerifyUiEditorPage(page, app, ['multipleDataModelsPerTask']); - const pageName: string = 'Side1'; - const giteaPage = new GiteaPage(page, { app }); + await setupAndVerifyUiEditorPage(page, testAppName, ['multipleDataModelsPerTask']); + const header = new Header(page, { app: testAppName }); + const dataModelPage = new DataModelPage(page, { app: testAppName }); await header.clickOnNavigateToPageInTopMenuHeader('data_model'); + await createNewDataModel(dataModelPage, newDataModel); +}); - const newDataModel = 'testDataModel2'; - await dataModelPage.clickOnCreateNewDataModelButton(); - await dataModelPage.typeDataModelName(newDataModel); - await dataModelPage.clickOnCreateModelButton(); - await dataModelPage.waitForDataModelToAppear(newDataModel); - await dataModelPage.clickOnGenerateDataModelButton(); - await dataModelPage.checkThatSuccessAlertIsVisibleOnScreen(); - await dataModelPage.waitForSuccessAlertToDisappear(); +test('That it is possible to navigate back to ui-editor page and add the newly added data model using data model binding combobox', async ({ + page, + testAppName, +}): Promise => { + const uiEditorPage = await setupAndVerifyUiEditorPage(page, testAppName, [ + 'multipleDataModelsPerTask', + ]); + const header = new Header(page, { app: testAppName }); await header.clickOnNavigateToPageInTopMenuHeader('create'); await uiEditorPage.verifyUiEditorPage(); - await openPageAccordionAndVerifyUpdatedUrl(uiEditorPage, pageName); + await uiEditorPage.clickOnPageAccordion(pageName); + await uiEditorPage.verifyUiEditorPage(pageName); await uiEditorPage.dragComponentIntoDroppableList(ComponentType.Input); await uiEditorPage.waitForComponentTreeItemToBeVisibleInDroppableList(ComponentType.Input); @@ -152,6 +184,15 @@ test('That is possible to select a different data model binding, and that the fi await uiEditorPage.clickOnDataModelPropertyOption(newDataModel); await uiEditorPage.clickOnSaveDataModel(); await uiEditorPage.waitForDataModelToBeSelected(); +}); + +test('That it is possible to upload to Gitea and that files are updated correctly', async ({ + page, + testAppName, +}): Promise => { + await setupAndVerifyUiEditorPage(page, testAppName); + const header = new Header(page, { app: testAppName }); + const giteaPage = new GiteaPage(page, { app: testAppName }); await header.clickOnUploadLocalChangesButton(); await header.clickOnValidateChanges(); @@ -166,6 +207,13 @@ test('That is possible to select a different data model binding, and that the fi ); }); +// Shared variables +const pageName: string = 'Side1'; +const newInputLabel: string = 'Input Label 1'; +const dataModelBindingName: string = 'property1'; +const newDataModel: string = 'testDataModel2'; + +// Helper functions const navigateInToLayoutJsonFile = async (giteaPage: GiteaPage, layoutName: string) => { await giteaPage.verifyGiteaPage(); await giteaPage.clickOnAppFilesButton(); @@ -175,24 +223,15 @@ const navigateInToLayoutJsonFile = async (giteaPage: GiteaPage, layoutName: stri await giteaPage.clickOnLayoutJsonFile(layoutName); }; -const addNewLabelToTreeItemComponent = async ( - uiEditorPage: UiEditorPage, - newInputLabel: string, -) => { - await uiEditorPage.clickOnComponentTextConfigAccordion(); - await uiEditorPage.clickOnTitleTextButton(); - await uiEditorPage.writeTitleTextInTextarea(newInputLabel); - await uiEditorPage.clickOnSaveNewLabelName(); - await uiEditorPage.waitForTreeItemToGetNewLabel(newInputLabel); - - await uiEditorPage.verifyThatTreeItemByNameIsNotVisibleInDroppableList(ComponentType.Input); - await uiEditorPage.verifyThatTreeItemByNameIsVisibleInDroppableList(newInputLabel); -}; - -const openPageAccordionAndVerifyUpdatedUrl = async ( - uiEditorPage: UiEditorPage, - pageName: string, +const createNewDataModel = async ( + dataModelPage: DataModelPage, + dataModelName: string, ): Promise => { - await uiEditorPage.clickOnPageAccordion(pageName); - await uiEditorPage.verifyUiEditorPage(pageName); // When clicking the page, the url is updated to include the layout + await dataModelPage.clickOnCreateNewDataModelButton(); + await dataModelPage.typeDataModelName(dataModelName); + await dataModelPage.clickOnCreateModelButton(); + await dataModelPage.waitForDataModelToAppear(dataModelName); + await dataModelPage.clickOnGenerateDataModelButton(); + await dataModelPage.checkThatSuccessAlertIsVisibleOnScreen(); + await dataModelPage.waitForSuccessAlertToDisappear(); };