-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Implementing text when saving scopes (#14215)
- Loading branch information
Showing
6 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
...ngsModal/components/Tabs/Maskinporten/ScopeListContainer/SaveStatus/SaveStatus.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.savingContainer { | ||
display: flex; | ||
align-items: center; | ||
gap: var(--fds-spacing-1); | ||
margin-top: var(--fds-spacing-4); | ||
} | ||
|
||
.savedIcon { | ||
font-size: var(--fds-sizing-8); | ||
color: var(--fds-semantic-text-neutral-subtle); | ||
} |
32 changes: 32 additions & 0 deletions
32
...tingsModal/components/Tabs/Maskinporten/ScopeListContainer/SaveStatus/SaveStatus.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { SaveStatus } from './SaveStatus'; | ||
import { textMock } from '@studio/testing/mocks/i18nMock'; | ||
|
||
describe('SaveStatus', () => { | ||
it('should display a spinner while pending', () => { | ||
render(<SaveStatus isPending isSaved={false} />); | ||
|
||
expect( | ||
screen.getByText(textMock('settings_modal.maskinporten_tab_save_scopes_pending')), | ||
).toBeInTheDocument(); | ||
|
||
expect( | ||
screen.getByTitle(textMock('settings_modal.maskinporten_tab_save_scopes_pending_spinner')), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render saved status with checkmark icon', () => { | ||
render(<SaveStatus isPending={false} isSaved />); | ||
|
||
expect( | ||
screen.getByText(textMock('settings_modal.maskinporten_tab_save_scopes_complete')), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render nothing when neither pending nor saved', () => { | ||
const { container } = render(<SaveStatus isPending={false} isSaved={false} />); | ||
|
||
expect(container).toBeEmptyDOMElement(); | ||
}); | ||
}); |
50 changes: 50 additions & 0 deletions
50
...n/SettingsModal/components/Tabs/Maskinporten/ScopeListContainer/SaveStatus/SaveStatus.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React, { type ReactElement } from 'react'; | ||
import classes from './SaveStatus.module.css'; | ||
import { StudioParagraph, StudioSpinner } from '@studio/components'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { CheckmarkIcon } from '@studio/icons'; | ||
|
||
type SaveStatusProps = { | ||
isPending: boolean; | ||
isSaved: boolean; | ||
}; | ||
|
||
export const SaveStatus = ({ isPending, isSaved }: SaveStatusProps): ReactElement => { | ||
const { t } = useTranslation(); | ||
|
||
if (isPending) { | ||
return ( | ||
<SaveStatusContent | ||
text={t('settings_modal.maskinporten_tab_save_scopes_pending')} | ||
isPending | ||
/> | ||
); | ||
} | ||
if (isSaved) { | ||
return <SaveStatusContent text={t('settings_modal.maskinporten_tab_save_scopes_complete')} />; | ||
} | ||
return null; | ||
}; | ||
|
||
type SaveStatusContentProps = { | ||
text: string; | ||
isPending?: boolean; | ||
}; | ||
|
||
const SaveStatusContent = ({ text, isPending = false }: SaveStatusContentProps): ReactElement => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<div className={classes.savingContainer}> | ||
<StudioParagraph size='sm'>{text}</StudioParagraph> | ||
{isPending ? ( | ||
<StudioSpinner | ||
spinnerTitle={t('settings_modal.maskinporten_tab_save_scopes_pending_spinner')} | ||
size='sm' | ||
/> | ||
) : ( | ||
<CheckmarkIcon className={classes.savedIcon} /> | ||
)} | ||
</div> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
...lButton/SettingsModal/components/Tabs/Maskinporten/ScopeListContainer/SaveStatus/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { SaveStatus } from './SaveStatus'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters