-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Align the main headings on the data model page #13786
base: main
Are you sure you want to change the base?
Changes from 8 commits
fc539da
21258a0
a4917a2
ac7fd59
98e99b6
54d7553
1b2dc95
8687736
97f9054
6353e90
e30ff38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,11 +21,11 @@ export const NodePanel = ({ schemaPointer }: NodePanelProps) => { | |
|
||
return ( | ||
<> | ||
<div className={classes.top}> | ||
{!isDataModelRoot && <BackButton />} | ||
<HeadingRow schemaPointer={schemaPointer} /> | ||
<HeadingRow schemaPointer={schemaPointer} /> | ||
{!isDataModelRoot && <BackButton />} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Jeg er usikker på om vi burde plassere |
||
<div className={classes.content}> | ||
{isNodeValidParent(node) && <SchemaTree schemaPointer={schemaPointer} />} | ||
</div> | ||
{isNodeValidParent(node) && <SchemaTree schemaPointer={schemaPointer} />} | ||
</> | ||
); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,19 @@ const renderSchemaInspector = (uiSchemaMap: UiSchemaNodes, selectedItem?: UiSche | |
describe('SchemaInspector', () => { | ||
afterEach(jest.clearAllMocks); | ||
|
||
it('Saves data model when entering text in textboxes', async () => { | ||
it('displays a message when no node is selected', () => { | ||
renderSchemaInspector(mockUiSchema); | ||
|
||
const noSelectionHeader = screen.getByRole('heading', { | ||
name: textMock('schema_editor.properties'), | ||
}); | ||
const noSelectionParagraph = screen.getByText(textMock('schema_editor.no_item_selected')); | ||
|
||
expect(noSelectionHeader).toBeInTheDocument(); | ||
expect(noSelectionParagraph).toBeInTheDocument(); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fin test! Synes bare variablenavnet |
||
|
||
it('saves data model when entering text in textboxes', async () => { | ||
renderSchemaInspector(mockUiSchema, getMockSchemaByPath('#/$defs/Kommentar2000Restriksjon')); | ||
const tablist = screen.getByRole('tablist'); | ||
expect(tablist).toBeDefined(); | ||
|
@@ -59,13 +71,13 @@ describe('SchemaInspector', () => { | |
expect(saveDataModel).toHaveBeenCalled(); | ||
}); | ||
|
||
test('renders no item if nothing is selected', () => { | ||
it('renders no item if nothing is selected', () => { | ||
renderSchemaInspector(mockUiSchema); | ||
const textboxes = screen.queryAllByRole('textbox'); | ||
expect(textboxes).toHaveLength(0); | ||
}); | ||
|
||
it('Saves data model correctly when changing restriction value', async () => { | ||
it('saves data model correctly when changing restriction value', async () => { | ||
const schemaPointer = '#/$defs/Kommentar2000Restriksjon'; | ||
|
||
renderSchemaInspector(mockUiSchema, getMockSchemaByPath(schemaPointer)); | ||
|
@@ -93,7 +105,7 @@ describe('SchemaInspector', () => { | |
expect(updatedNode.restrictions.minLength).toEqual(parseInt(minLength)); | ||
}); | ||
|
||
test('Adds new object field when pressing the enter key', async () => { | ||
it('adds new object field when pressing the enter key', async () => { | ||
const parentNodePointer = '#/properties/test'; | ||
const childNodePointer = '#/properties/test/properties/abc'; | ||
const rootNode: FieldNode = { | ||
|
@@ -125,7 +137,7 @@ describe('SchemaInspector', () => { | |
}); | ||
}); | ||
|
||
test('Adds new valid value field when pressing the enter key', async () => { | ||
it('adds new valid value field when pressing the enter key', async () => { | ||
const itemPointer = '#/properties/test'; | ||
const enumValue = 'valid value'; | ||
const rootNode: FieldNode = { | ||
|
@@ -155,7 +167,7 @@ describe('SchemaInspector', () => { | |
expect(saveDataModel).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('Does not display the fields tab when the selected item is a combination', async () => { | ||
it('does not display the fields tab when the selected item is a combination', async () => { | ||
const itemPointer = '#/properties/testcombination'; | ||
const rootNode: FieldNode = { | ||
...rootNodeMock, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,49 @@ | ||
import type { ReactElement } from 'react'; | ||
import React from 'react'; | ||
import { Alert, Tabs } from '@digdir/designsystemet-react'; | ||
import type { UiSchemaNode } from '@altinn/schema-model'; | ||
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 { StudioCenter, StudioHeading, StudioParagraph } from '@studio/components'; | ||
|
||
export const SchemaInspector = () => { | ||
export const SchemaInspector = (): ReactElement => { | ||
const { t } = useTranslation(); | ||
const { selectedUniquePointer } = useSchemaEditorAppContext(); | ||
const savableModel = useSavableSchemaModel(); | ||
const selectedItem: UiSchemaNode = selectedUniquePointer | ||
? savableModel.getNodeByUniquePointer(selectedUniquePointer) | ||
: undefined; | ||
const shouldDisplayFieldsTab = selectedItem && isField(selectedItem) && isObject(selectedItem); | ||
|
||
if (!selectedUniquePointer) { | ||
if (!selectedItem) { | ||
return ( | ||
<div> | ||
<p className={classes.noItem}>{t('schema_editor.no_item_selected')}</p> | ||
<Divider /> | ||
</div> | ||
<> | ||
<div className={classes.noSelectionHeadingContainer}> | ||
<StudioHeading level={2} size='2xs'> | ||
{t('schema_editor.properties')} | ||
</StudioHeading> | ||
</div> | ||
<StudioCenter> | ||
<StudioParagraph size='sm'>{t('schema_editor.no_item_selected')}</StudioParagraph> | ||
</StudioCenter> | ||
</> | ||
); | ||
} | ||
|
||
const selectedItem: UiSchemaNode = savableModel.getNodeByUniquePointer(selectedUniquePointer); | ||
const shouldDisplayFieldsTab = isField(selectedItem) && isObject(selectedItem); | ||
|
||
return ( | ||
<Tabs defaultValue={t('schema_editor.properties')} className={classes.root}> | ||
<Tabs defaultValue={t('schema_editor.properties')}> | ||
<Tabs.List> | ||
<Tabs.Tab value={t('schema_editor.properties')}>{t('schema_editor.properties')}</Tabs.Tab> | ||
<Tabs.Tab value={t('schema_editor.fields')}>{t('schema_editor.fields')}</Tabs.Tab> | ||
<Tabs.Tab value={t('schema_editor.properties')} className={classes.tabHeader}> | ||
{t('schema_editor.properties')} | ||
</Tabs.Tab> | ||
<Tabs.Tab value={t('schema_editor.fields')} className={classes.tabHeader}> | ||
{t('schema_editor.fields')} | ||
</Tabs.Tab> | ||
</Tabs.List> | ||
<Tabs.Content value={t('schema_editor.properties')}> | ||
<ItemPropertiesTab selectedItem={selectedItem} /> | ||
|
@@ -41,7 +53,9 @@ export const SchemaInspector = () => { | |
<ItemFieldsTab selectedItem={selectedItem} /> | ||
</Tabs.Content> | ||
) : ( | ||
<Alert severity='info'>{t('app_data_modelling.fields_information')}</Alert> | ||
<Tabs.Content value={t('schema_editor.fields')}> | ||
<Alert severity='info'>{t('app_data_modelling.fields_information')}</Alert> | ||
</Tabs.Content> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fint at du fikk plassert denne i en |
||
)} | ||
</Tabs> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,20 @@ | ||
.root { | ||
box-sizing: border-box; | ||
padding: 24px 24px; | ||
min-height: 100%; | ||
background: rgba(224, 224, 224, 0.3); | ||
border-right: 1px solid var(--fds-semantic-border-neutral-subtle); | ||
} | ||
|
||
.types { | ||
.headingContainer { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: stretch; | ||
gap: 8px; | ||
} | ||
|
||
.addRow { | ||
display: grid; | ||
grid-template-columns: repeat(3, 1fr); | ||
justify-content: space-between; | ||
align-items: center; | ||
height: var(--subtoolbar-height); | ||
padding-inline: var(--fds-spacing-6); | ||
border-bottom: 1px solid var(--fds-semantic-border-neutral-subtle); | ||
} | ||
|
||
.addRowText { | ||
grid-column: 1 / 3; | ||
font-size: 18px; | ||
.addTypeButton { | ||
color: var(--fds-semantic-surface-neutral-inverted); | ||
} | ||
|
||
.addRowButton { | ||
grid-column: 3; | ||
margin-left: auto; | ||
margin-right: 0; | ||
color: #000000; | ||
} | ||
|
||
.noItem { | ||
font-weight: 500; | ||
margin: 18px; | ||
.typesList { | ||
display: flex; | ||
flex-direction: column; | ||
padding-block: var(--fds-spacing-5); | ||
padding-inline: var(--fds-spacing-6); | ||
gap: var(--fds-spacing-3); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disse egenskapene er her for å skape en likhet mellom rotelementet og underelementene når de er valgt (se bilder). Hva skjer når du tar dette bort?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oi, det var ikke meningen. Bra du fanget det opp!
Ser at dette må være tilstede:
Mens det virker som om dette ikke har noen funksjon:
Bør være greit å ta vekk, eller?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jeg tror faktisk de to linjene også må være der. Når det står
border-color: transparent
, er det ofte for å hindre at ting flytter på seg når konturen blir borte eller dukker opp. Her skjer det når brukeren bytter mellom valgt / ikke valgt.Eventuelt kunne vi valgt en helt annen fremgangsmåte her, f.eks. med
background
medlinear-gradient
eller medbox-shadow
. Da kan vi unngå denne litt uheldige effekten av å brukeborder
: