-
Notifications
You must be signed in to change notification settings - Fork 75
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
feat: 14732 set up a new navigation page #14804
base: main
Are you sure you want to change the base?
Changes from all commits
e1cf07d
6c093c3
45871c8
1b39358
17179ad
1891db7
c778934
4bee2ff
3153a54
76768c0
ba2b0d9
3ed96e5
243a7c2
fb490dd
1c11d90
f38acd5
ca1aa89
b2c67be
7a8f54e
2c9c4ea
d38c8ca
ac40bbc
5ab9fad
a21e41d
f09fae7
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 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -12,9 +12,12 @@ import { useAppVersionQuery } from 'app-shared/hooks/queries'; | |||||||||
import React from 'react'; | ||||||||||
import { usePreviewContext } from '../contexts/PreviewContext'; | ||||||||||
import { useLayoutContext } from '../contexts/LayoutContext'; | ||||||||||
import { StudioPageSpinner } from '@studio/components'; | ||||||||||
import { StudioPageSpinner, useLocalStorage } from '@studio/components'; | ||||||||||
import { useTranslation } from 'react-i18next'; | ||||||||||
import { AppContentLibrary } from 'app-development/features/appContentLibrary'; | ||||||||||
import { FormDesignerNavigation } from '@altinn/ux-editor/containers/FormDesignNavigation'; | ||||||||||
import { FeatureFlag, shouldDisplayFeature } from 'app-shared/utils/featureToggleUtils'; | ||||||||||
import { useAppConfigQuery } from 'app-development/hooks/queries'; | ||||||||||
|
||||||||||
interface IRouteProps { | ||||||||||
headerTextKey?: string; | ||||||||||
|
@@ -39,28 +42,44 @@ const latestFrontendVersion = '4'; | |||||||||
const isLatestFrontendVersion = (version: AppVersion): boolean => | ||||||||||
version?.frontendVersion?.startsWith(latestFrontendVersion); | ||||||||||
|
||||||||||
const UiEditor = () => { | ||||||||||
export const UiEditor = () => { | ||||||||||
const { org, app } = useStudioEnvironmentParams(); | ||||||||||
const { t } = useTranslation(); | ||||||||||
const { data: version, isPending: fetchingVersionIsPending } = useAppVersionQuery(org, app); | ||||||||||
const { shouldReloadPreview, previewHasLoaded } = usePreviewContext(); | ||||||||||
const { setSelectedLayoutSetName } = useLayoutContext(); | ||||||||||
const [selectedFormLayoutSetName] = useLocalStorage<string>('layoutSet/' + app); | ||||||||||
const isTaskNavigationEnabled = shouldDisplayFeature(FeatureFlag.TaskNavigation); | ||||||||||
|
||||||||||
const { data: appConfigData } = useAppConfigQuery(org, app, { | ||||||||||
hideDefaultError: true, | ||||||||||
}); | ||||||||||
|
||||||||||
if (fetchingVersionIsPending) { | ||||||||||
return <StudioPageSpinner spinnerTitle={t('ux_editor.loading_page')} />; | ||||||||||
} | ||||||||||
|
||||||||||
if (!version) return null; | ||||||||||
|
||||||||||
return isLatestFrontendVersion(version) ? ( | ||||||||||
<UiEditorLatest | ||||||||||
shouldReloadPreview={shouldReloadPreview} | ||||||||||
previewHasLoaded={previewHasLoaded} | ||||||||||
onLayoutSetNameChange={(layoutSetName) => setSelectedLayoutSetName(layoutSetName)} | ||||||||||
/> | ||||||||||
) : ( | ||||||||||
<UiEditorV3 /> | ||||||||||
); | ||||||||||
const renderUiEditorContent = () => { | ||||||||||
if (isTaskNavigationEnabled && !selectedFormLayoutSetName && appConfigData) { | ||||||||||
return <FormDesignerNavigation appConfig={appConfigData.serviceName} />; | ||||||||||
Comment on lines
+65
to
+66
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.
Suggested change
|
||||||||||
} | ||||||||||
|
||||||||||
const handleLayoutSetNameChange = (layoutSetName: string) => { | ||||||||||
setSelectedLayoutSetName(layoutSetName); | ||||||||||
}; | ||||||||||
|
||||||||||
return ( | ||||||||||
<UiEditorLatest | ||||||||||
shouldReloadPreview={shouldReloadPreview} | ||||||||||
previewHasLoaded={previewHasLoaded} | ||||||||||
onLayoutSetNameChange={handleLayoutSetNameChange} | ||||||||||
/> | ||||||||||
); | ||||||||||
}; | ||||||||||
|
||||||||||
return isLatestFrontendVersion(version) ? renderUiEditorContent() : <UiEditorV3 />; | ||||||||||
}; | ||||||||||
|
||||||||||
export const routerRoutes: RouterRoute[] = [ | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
.wrapper { | ||
background-color: #e6eff8; | ||
} | ||
|
||
.container { | ||
margin: auto; | ||
padding: var(--fds-spacing-6); | ||
position: relative; | ||
} | ||
|
||
.header { | ||
font-size: var(--fds-sizing-6); | ||
} | ||
|
||
.panel { | ||
background-color: white; | ||
border-radius: var(--fds-border_radius-medium); | ||
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.05); | ||
padding: var(--fds-spacing-10); | ||
position: relative; | ||
} | ||
|
||
.content { | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--fds-spacing-10); | ||
} | ||
|
||
.footer { | ||
border-top: 2px solid #efefef; | ||
margin-top: var(--fds-spacing-10); | ||
padding-top: var(--fds-spacing-8); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
import { screen } from '@testing-library/react'; | ||
import { FormDesignerNavigation, type FormDesignerNavigationProps } from './FormDesignerNavigation'; | ||
import { renderWithProviders } from 'app-development/test/mocks'; | ||
import { textMock } from '@studio/testing/mocks/i18nMock'; | ||
|
||
const defaultProps = { | ||
appConfig: 'test', | ||
}; | ||
|
||
describe('FormDesignerNavigation', () => { | ||
it('renders the component with heading text test', () => { | ||
render({ appConfig: 'test' }); | ||
expect(screen.getByText('test')).toBeInTheDocument(); | ||
}); | ||
it('renders the contact link', () => { | ||
render(); | ||
expect(screen.getByRole('link', { name: textMock('general.contact') })).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
const render = (props: Partial<FormDesignerNavigationProps> = {}) => | ||
renderWithProviders()(<FormDesignerNavigation {...defaultProps} {...props} />); |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,26 @@ | ||||||||||
import { Link } from '@digdir/designsystemet-react'; | ||||||||||
import React from 'react'; | ||||||||||
import classes from './FormDesignerNavigation.module.css'; | ||||||||||
import { useTranslation } from 'react-i18next'; | ||||||||||
|
||||||||||
export type FormDesignerNavigationProps = { | ||||||||||
appConfig: string; | ||||||||||
}; | ||||||||||
Comment on lines
+6
to
+8
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.
Suggested change
|
||||||||||
|
||||||||||
export const FormDesignerNavigation = ({ appConfig }: FormDesignerNavigationProps) => { | ||||||||||
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.
Suggested change
|
||||||||||
const { t } = useTranslation(); | ||||||||||
return ( | ||||||||||
<div className={classes.wrapper}> | ||||||||||
<main className={classes.container}> | ||||||||||
<div className={classes.panel}> | ||||||||||
<div className={classes.content}> | ||||||||||
<div className={classes.header}>{appConfig}</div> | ||||||||||
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.
Suggested change
|
||||||||||
</div> | ||||||||||
JamalAlabdullah marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
<footer className={classes.footer}> | ||||||||||
<Link href='/contact'>{t('general.contact')}</Link> | ||||||||||
</footer> | ||||||||||
</div> | ||||||||||
</main> | ||||||||||
</div> | ||||||||||
); | ||||||||||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { FormDesignerNavigation } from './FormDesignerNavigation'; |
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.
I’d suggest moving this code into
FormDesignerNavigation
, as it’s only used byFormDesignerNavigation
and should not block the whole page from loading since it’s only used to show theappName
.