-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #729 from open-formulieren/feature/4320-cosign-imp…
…rovements Cosign improvements
- Loading branch information
Showing
23 changed files
with
438 additions
and
151 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import CosignDone from './CosignDone'; | ||
|
||
export default { | ||
title: 'Views / Co-sign done', | ||
title: 'Views / Cosign / Done', | ||
component: CosignDone, | ||
args: { | ||
reportDownloadUrl: '#', | ||
}, | ||
}; | ||
|
||
export const CoSignDone = { | ||
name: 'Co-sign done', | ||
name: 'CosignDone', | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import {FormattedMessage} from 'react-intl'; | ||
|
||
import Body from 'components/Body'; | ||
import Card from 'components/Card'; | ||
import {LiteralsProvider} from 'components/Literal'; | ||
import LoginOptions from 'components/LoginOptions'; | ||
import MaintenanceMode from 'components/MaintenanceMode'; | ||
import { | ||
AuthenticationErrors, | ||
useDetectAuthErrorMessages, | ||
} from 'components/auth/AuthenticationErrors'; | ||
import AuthenticationOutage, { | ||
useDetectAuthenticationOutage, | ||
} from 'components/auth/AuthenticationOutage'; | ||
import {UnprocessableEntity} from 'errors'; | ||
import {IsFormDesigner} from 'headers'; | ||
import useFormContext from 'hooks/useFormContext'; | ||
|
||
const CosignStart = () => { | ||
const form = useFormContext(); | ||
|
||
const outagePluginId = useDetectAuthenticationOutage(); | ||
const authErrors = useDetectAuthErrorMessages(); | ||
|
||
if (!form.active) { | ||
throw new UnprocessableEntity('Unprocessable Entity', 422, 'Form not active', 'form-inactive'); | ||
} | ||
|
||
const userIsFormDesigner = IsFormDesigner.getValue(); | ||
if (!userIsFormDesigner && form.maintenanceMode) { | ||
return <MaintenanceMode title={form.name} />; | ||
} | ||
|
||
if (outagePluginId) { | ||
const loginOption = form.cosignLoginOptions.find( | ||
option => option.identifier === outagePluginId | ||
); | ||
if (!loginOption) throw new Error('Unknown login plugin identifier'); | ||
return ( | ||
<Card | ||
title={ | ||
<FormattedMessage | ||
description="Form start outage title" | ||
defaultMessage="Problem - {formName}" | ||
values={{formName: form.name}} | ||
/> | ||
} | ||
> | ||
<AuthenticationOutage loginOption={loginOption} /> | ||
</Card> | ||
); | ||
} | ||
|
||
return ( | ||
<LiteralsProvider literals={form.literals}> | ||
<Card title={form.name}> | ||
{userIsFormDesigner && form.maintenanceMode && <MaintenanceMode asToast />} | ||
|
||
{!!authErrors ? <AuthenticationErrors parameters={authErrors} /> : null} | ||
|
||
<Body> | ||
<FormattedMessage | ||
description="Cosign start explanation message" | ||
defaultMessage={`Did you receive an email with a request to cosign? | ||
Start the cosigning by logging in.`} | ||
/> | ||
</Body> | ||
|
||
<LoginOptions | ||
// hide the normal login options, and only display the cosign login options | ||
form={{...form, loginOptions: []}} | ||
// dummy - we don't actually start a new submission, but the next URL is baked | ||
// into the login URLs. | ||
onFormStart={() => {}} | ||
isolateCosignOptions={false} | ||
/> | ||
</Card> | ||
</LiteralsProvider> | ||
); | ||
}; | ||
|
||
export default CosignStart; |
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,51 @@ | ||
import {withRouter} from 'storybook-addon-remix-react-router'; | ||
|
||
import {buildForm} from 'api-mocks'; | ||
import {withForm} from 'story-utils/decorators'; | ||
|
||
import CosignStart from './CosignStart'; | ||
|
||
export default { | ||
title: 'Views / Cosign / Start', | ||
component: CosignStart, | ||
decorators: [withForm, withRouter], | ||
parameters: { | ||
formContext: { | ||
form: buildForm({ | ||
loginRequired: true, | ||
loginOptions: [ | ||
{ | ||
identifier: 'digid', | ||
label: 'DigiD', | ||
url: '#', | ||
logo: { | ||
title: 'DigiD simulatie', | ||
imageSrc: './digid.png', | ||
href: 'https://www.digid.nl/', | ||
appearance: 'dark', | ||
}, | ||
isForGemachtigde: false, | ||
}, | ||
], | ||
cosignLoginOptions: [ | ||
{ | ||
identifier: 'digid', | ||
label: 'DigiD', | ||
url: 'http://localhost:8000/auth/digid/?next=http://localhost:8000/cosign&code=123', | ||
logo: { | ||
title: 'DigiD simulatie', | ||
imageSrc: './digid.png', | ||
href: 'https://www.digid.nl/', | ||
appearance: 'dark', | ||
}, | ||
isForGemachtigde: false, | ||
}, | ||
], | ||
}), | ||
}, | ||
}, | ||
}; | ||
|
||
export const Default = { | ||
name: 'CosignStart', | ||
}; |
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
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
Oops, something went wrong.