Skip to content

Commit

Permalink
Chore/update ds to newest (#1125)
Browse files Browse the repository at this point in the history
* update pagination & replace Ingress

* Replace chip.toggle with chip.checkbox and remove chip.group

* add story to test receipt-action-bar

* Refactor spacing in ActionBar.stories.tsx and remove unnecessary prop

* delegation-modal

* Refactor spacing in Dialog.stories.tsx and fix modal onClose

* update changed ds-props

* heading size & overviewPage story update

* add manual spacing

* remove console.log

* Update CSS for users list heading and action bar content headings

* Refactor ChooseOrgPage component and CSS

- Refactor ChooseOrgPage component to use the Heading component from @digdir/designsystemet-react for consistent heading styles.
- Add CSS class ".alertHeading" to apply margin-bottom to alert headings in ChooseOrgPage.

* Refactor ChooseOrgPage component and CSS
Update CSS for users list heading and action bar content headings
Remove console.log
Add manual spacing
Update heading size and overviewPage story
Add ConfirmationPage component and CSS
Update ConfirmationPage component to include alert heading
Update apiDelegationSlice.ts

* fix margins in confirmation-page

* fix margins for users list heading and action bar content headings

* remove story

* Refactor mockServiceWorker.js and ChooseServicePage.module.css
  • Loading branch information
sonwit authored Oct 23, 2024
1 parent 7cc75c8 commit e3b06aa
Show file tree
Hide file tree
Showing 61 changed files with 1,220 additions and 426 deletions.
136 changes: 108 additions & 28 deletions .mock/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,25 @@ export const handlers = [
id: 'LIVLIG DYREBAR TIGER AS',
name: 'LIVLIG DYREBAR TIGER AS',
orgNumber: '313357120',
apiList: [
{
id: 'digdir-maskinportenschemaid-302',
apiName: 'Automation Regression',
owner: 'Digitaliseringsdirektoratet',
description:
'Gir anledning til a teste maskinporten som en del av automatiserte tester_Endret',
scopes: [],
},
],
apiList: [],
},
{
id: 'MAGISK FANTASTISK KATT AS',
name: 'MAGISK FANTASTISK KATT AS',
orgNumber: '123456789',
apiList: [],
},
{
id: 'EVENTYR SKOGEN AS',
name: 'EVENTYR SKOGEN AS',
orgNumber: '987654321',
apiList: [],
},
{
id: 'STORSLATT HAV AS',
name: 'STORSLATT HAV AS',
orgNumber: '112233445',
apiList: [],
},
]);
}),
Expand All @@ -93,24 +102,25 @@ export const handlers = [
id: 'LIVLIG DYREBAR TIGER AS',
name: 'LIVLIG DYREBAR TIGER AS',
orgNumber: '313357120',
apiList: [
{
id: 'digdir-maskinportenschemaid-302',
apiName: 'Automation Regression',
owner: 'Digitaliseringsdirektoratet',
description:
'Gir anledning til a teste maskinporten som en del av automatiserte tester_Endret',
scopes: [],
},
{
id: 'digdir-maskinportenschemaid-302',
apiName: 'Automation Regression 2 ',
owner: 'Digitaliseringsdirektoratet',
description:
'Gir anledning til a teste maskinporten som en del av automatiserte tester_Endret',
scopes: [],
},
],
apiList: [],
},
{
id: 'MAGISK FANTASTISK KATT AS',
name: 'MAGISK FANTASTISK KATT AS',
orgNumber: '123456789',
apiList: [],
},
{
id: 'EVENTYR SKOGEN AS',
name: 'EVENTYR SKOGEN AS',
orgNumber: '987654321',
apiList: [],
},
{
id: 'STORSLATT HAV AS',
name: 'STORSLATT HAV AS',
orgNumber: '112233445',
apiList: [],
},
]);
}),
Expand Down Expand Up @@ -175,6 +185,76 @@ export const handlers = [
]);
},
),
http.post(`${BASE_URL}/accessmanagement/api/v1/singleright/checkdelegationaccesses/:id`, () => {
return HttpResponse.json([
{
rightKey: 'test_resource_local:read',
resource: [
{
id: 'urn:altinn:resource',
value: 'test_resource_local',
},
],
action: 'read',
status: 'Delegable',
details: [
{
code: 'RoleAccess',
description:
'Delegator have access through having one of the following role(s) for the reportee party: urn:altinn:rolecode:dagl. Note: if the user is a Main Administrator (HADM) the user might not have direct access to the role other than for delegation purposes.',
parameters: {
RoleRequirementsMatches: [
{
id: 'urn:altinn:rolecode',
value: 'dagl',
},
],
},
},
],
},
]);
}),
http.get(`${BASE_URL}/accessmanagement/api/v1/lookup/org/:id`, () => {
return HttpResponse.json({
orgNumber: '991825827',
name: 'Digitaliseringsdirektoratet',
});
}),
http.get(`${BASE_URL}/accessmanagement/api/v1/user/reporteelist/:id`, () => {
return HttpResponse.json({
partyUuid: '54f128f7-ca7c-4a57-ad49-3787eb79b506',
name: 'DISKRET NÆR TIGER AS',
organizationNumber: '310202398',
subunits: [
{
partyUuid: '0020c970-ba68-44cd-8440-0894b594f58a',
name: 'DISKRET NÆR TIGER AS',
organizationNumber: '311312294',
subunits: [],
},
],
});
}),
http.get(`${BASE_URL}/accessmanagement/api/v1/user/profile`, () => {
return HttpResponse.json({
userId: 20010996,
userUuid: '167536b5-f8ed-4c5a-8f48-0279507e53ae',
userName: 'GullMedalje',
partyId: 50789533,
party: {
partyId: 50789533,
partyUuid: '167536b5-f8ed-4c5a-8f48-0279507e53ae',
name: 'SITRONGUL MEDALJONG',
},
userType: 1,
profileSettingPreference: {
language: 'nb',
preSelectedPartyId: 0,
doNotPromptForParty: false,
},
});
}),
http.get('*', () => {
return passthrough();
}),
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
},
"dependencies": {
"@cypress/react18": "^2.0.0",
"@digdir/designsystemet-css": "1.0.0-next.34",
"@digdir/designsystemet-react": "1.0.0-next.34",
"@digdir/designsystemet-theme": "1.0.0-next.34",
"@digdir/designsystemet-css": "1.0.0-next.35",
"@digdir/designsystemet-react": "1.0.0-next.35",
"@digdir/designsystemet-theme": "1.0.0-next.35",
"@navikt/aksel-icons": "^7.0.0",
"@reduxjs/toolkit": "^2.2.5",
"@tanstack/react-query": "^5.0.0",
Expand Down
1 change: 0 additions & 1 deletion src/components/ActionBar/ActionBar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const exampleArgs: ActionbarPropsAndCustomArgs = {
<Paragraph
variant='long'
size='sm'
spacing={true}
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
Expand Down
6 changes: 3 additions & 3 deletions src/components/ActionBar/ActionBarContent.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
border-top-right-radius: 0px;
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
background-color: var(#ffffff);
background-color: #fff;
--border-color: var(--a2-color-neutral-border-default);
--header-color: var(--a2-color-neutral-surface-default);
}
Expand Down Expand Up @@ -42,8 +42,8 @@
}

.actionBarContent.neutral {
--border-color: #d2d5d8; /*var(--ds-color-neutral-border-default); */
--header-color: #f4f5f6; /*var(--ds-color-neutral-surface-default); */
--border-color: #d2d5d8;
--header-color: #f4f5f6;
border-top-color: var(--header-color);
}

Expand Down
1 change: 1 addition & 0 deletions src/components/ActionBar/ActionBarHeader.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
display: flex;
flex-direction: column;
justify-content: center;
height: 100%;
}

.title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
border-bottom-width: 1px;
border-bottom-style: var(--borderStyle);
list-style: none;
margin: 0;
}

.dashed {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
display: flex;
margin-left: 10px;
min-height: 40px;
align-items: center;
}

.deleteSection {
Expand All @@ -55,6 +56,11 @@
word-break: break-word;
}

.listItemIcon {
display: flex;
align-items: center;
}

.listItemIcon > * {
margin-right: 10px;
min-width: 24px;
Expand Down
1 change: 0 additions & 1 deletion src/components/Dialog/Dialog.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default {
<Paragraph
variant='long'
size='sm'
spacing={true}
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus orci turpis, vehicula a
dignissim eget, condimentum at diam. Etiam iaculis, purus vel venenatis condimentum,
Expand Down
70 changes: 70 additions & 0 deletions src/components/Paginering/AmPaginering.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';

import { AmPagination } from './AmPaginering';

type AmPaginationPropsAndCustomArgs = React.ComponentProps<typeof AmPagination>;

const paginatedDummyData = Array.from({ length: 105 }, (_, i) => i + 1);

const TestAmPagination = (props: AmPaginationPropsAndCustomArgs) => {
const [currentPage, setCurrentPage] = React.useState(1);
const itemsPerPage = 10;
const totalPages = Math.ceil(paginatedDummyData.length / itemsPerPage);

return (
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '2rem' }}>
<ul>
{paginatedDummyData
.slice((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage)
.map((item) => (
<li key={item}>{`Element: ${item}`}</li>
))}
</ul>
<AmPagination
{...props}
currentPage={currentPage}
setCurrentPage={setCurrentPage}
totalPages={totalPages}
/>
</div>
);
};

export default {
title: 'Components/AmPagination',
component: AmPagination,
} as Meta;

export const Default: StoryObj<AmPaginationPropsAndCustomArgs> = {
args: {
totalPages: 10,
showPages: 5,
currentPage: 1,
hideLabels: false,
size: 'md',
},
argTypes: {
totalPages: { control: { type: 'number' } },
showPages: { control: { type: 'number' } },
size: { control: { type: 'inline-radio', options: ['sm', 'md', 'lg'] } },
currentPage: { control: { type: 'number' } },
hideLabels: { control: { type: 'boolean' } },
},
render: (args) => <AmPagination {...args} />,
};

export const Test: StoryObj<AmPaginationPropsAndCustomArgs> = {
render: (args) => <TestAmPagination {...args} />,
args: {
showPages: 5,
},
argTypes: {
showPages: { control: { type: 'number' } },
totalPages: { disabled: true },
currentPage: { disabled: true },
setCurrentPage: { disabled: true },
hideLabels: { control: { type: 'boolean' } },
size: { control: { type: 'inline-radio', options: ['sm', 'md', 'lg'] } },
},
};
57 changes: 57 additions & 0 deletions src/components/Paginering/AmPaginering.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import type { PaginationProps } from '@digdir/designsystemet-react';
import { Pagination, usePagination } from '@digdir/designsystemet-react';
import * as React from 'react';
import { useTranslation } from 'react-i18next';

export interface AmPaginationProps extends PaginationProps {
totalPages: number;
showPages?: number;
setCurrentPage?: (page: number) => void;
currentPage: number;
hideLabels?: boolean;
}

export const AmPagination = ({
totalPages,
showPages = 5,
currentPage,
setCurrentPage,
hideLabels = false,
size = 'md',
}: AmPaginationProps) => {
const { t } = useTranslation();
const { pages, prevButtonProps, nextButtonProps } = usePagination({
currentPage,
setCurrentPage,
onChange: () => {},
totalPages,
showPages: showPages > totalPages ? totalPages : showPages,
});

return (
<Pagination size={size}>
<Pagination.List>
<Pagination.Item>
<Pagination.Button {...prevButtonProps}>
{!hideLabels && t('common.previous')}
</Pagination.Button>
</Pagination.Item>
{pages.map(({ page, itemKey, buttonProps }) => (
<Pagination.Item key={itemKey}>
<Pagination.Button
{...buttonProps}
aria-label={`${t('common.page')} ${page}`}
>
{page}
</Pagination.Button>
</Pagination.Item>
))}
<Pagination.Item>
<Pagination.Button {...nextButtonProps}>
{!hideLabels && t('common.next')}
</Pagination.Button>
</Pagination.Item>
</Pagination.List>
</Pagination>
);
};
1 change: 1 addition & 0 deletions src/components/Paginering/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { AmPagination } from './AmPaginering';
4 changes: 4 additions & 0 deletions src/components/RestartPrompter/RestartPrompter.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
.spacing {
margin-bottom: 30px;
}

.title {
margin-bottom: 10px;
}
Loading

0 comments on commit e3b06aa

Please sign in to comment.