Skip to content

Commit

Permalink
♻️ [open-formulieren/open-forms#180] Make the abortion button an actu…
Browse files Browse the repository at this point in the history
…al button
  • Loading branch information
SilviaAmAm committed Jan 17, 2024
1 parent 8300e5a commit e6bbcc6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
23 changes: 9 additions & 14 deletions src/components/AbortionButton/AbortionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {FormattedMessage, useIntl} from 'react-intl';

import {AnalyticsToolsConfigContext} from 'Context';
import {OFButton} from 'components/Button';
import {Toolbar, ToolbarList} from 'components/Toolbar';
import {buildGovMetricUrl} from 'components/analytics/utils';
import useFormContext from 'hooks/useFormContext';

Expand All @@ -31,13 +30,13 @@ const AbortionButton = ({isAuthenticated, onDestroySession}) => {

await onDestroySession();

Check warning on line 31 in src/components/AbortionButton/AbortionButton.js

View check run for this annotation

Codecov / codecov/patch

src/components/AbortionButton/AbortionButton.js#L31

Added line #L31 was not covered by tests

const govmetricUrl = buildGovMetricUrl(
analyticsToolsConfig.govmetricSourceId,
form.slug,
analyticsToolsConfig.govmetricSecureGuid
);

if (analyticsToolsConfig.enableGovmetricAnalytics) {
const govmetricUrl = buildGovMetricUrl(

Check warning on line 34 in src/components/AbortionButton/AbortionButton.js

View check run for this annotation

Codecov / codecov/patch

src/components/AbortionButton/AbortionButton.js#L34

Added line #L34 was not covered by tests
analyticsToolsConfig.govmetricSourceId,
form.slug,
analyticsToolsConfig.govmetricSecureGuid
);

window.open(govmetricUrl);

Check warning on line 40 in src/components/AbortionButton/AbortionButton.js

View check run for this annotation

Codecov / codecov/patch

src/components/AbortionButton/AbortionButton.js#L40

Added line #L40 was not covered by tests
}
};
Expand All @@ -54,13 +53,9 @@ const AbortionButton = ({isAuthenticated, onDestroySession}) => {
if (!isAuthenticated && !analyticsToolsConfig.enableGovmetricAnalytics) return null;

return (
<Toolbar modifiers={['bottom', 'reverse']}>
<ToolbarList>
<OFButton appearance="primary-action-button" hint="danger" name="abort" onClick={callback}>
{message}
</OFButton>
</ToolbarList>
</Toolbar>
<OFButton appearance="primary-action-button" hint="danger" name="abort" onClick={callback}>
{message}
</OFButton>
);
};

Expand Down
13 changes: 9 additions & 4 deletions src/components/FormStep/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import ButtonsToolbar from 'components/ButtonsToolbar';
import Card, {CardTitle} from 'components/Card';
import FormStepDebug from 'components/FormStepDebug';
import Loader from 'components/Loader';
import {Toolbar, ToolbarList} from 'components/Toolbar';
import FormStepSaveModal from 'components/modals/FormStepSaveModal';
import {
eventTriggeredBySubmitButton,
Expand Down Expand Up @@ -878,10 +879,14 @@ const FormStep = ({
onNavigatePrevPage={onPrevPage}
previousPage={getPreviousPageHref()}
/>
<AbortionButton
isAuthenticated={submission.isAuthenticated}
onDestroySession={onDestroySession}
/>
<Toolbar modifiers={['bottom', 'reverse']}>
<ToolbarList>
<AbortionButton
isAuthenticated={submission.isAuthenticated}
onDestroySession={onDestroySession}
/>
</ToolbarList>
</Toolbar>
</form>
</>
) : null}
Expand Down
10 changes: 9 additions & 1 deletion src/components/Summary/GenericSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import FormStepSummary from 'components/FormStepSummary';
import Loader from 'components/Loader';
import Price from 'components/Price';
import SummaryConfirmation from 'components/SummaryConfirmation';
import {Toolbar, ToolbarList} from 'components/Toolbar';
import {SUBMISSION_ALLOWED} from 'components/constants';

const GenericSummary = ({
Expand Down Expand Up @@ -60,7 +61,14 @@ const GenericSummary = ({
prevPage={prevPage}
onPrevPage={onPrevPage}
/>
<AbortionButton isAuthenticated={isAuthenticated} onDestroySession={onDestroySession} />
<Toolbar modifiers={['bottom', 'reverse']}>
<ToolbarList>
<AbortionButton
isAuthenticated={isAuthenticated}
onDestroySession={onDestroySession}
/>
</ToolbarList>
</Toolbar>
</Wrapper>
</Formik>
</Card>
Expand Down
4 changes: 2 additions & 2 deletions src/components/analytics/GovMetricSnippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ const GovMetricSnippet = () => {
const form = useFormContext();
const intl = useIntl();

if (!analyticsToolsConfig.enableGovmetricAnalytics) return null;

const govmetricUrl = buildGovMetricUrl(
analyticsToolsConfig.govmetricSourceId,
form.slug,
analyticsToolsConfig.govmetricSecureGuid
);

if (!analyticsToolsConfig.enableGovmetricAnalytics) return null;

return (
<Toolbar modifiers={['bottom', 'reverse']}>
<ToolbarList>
Expand Down

0 comments on commit e6bbcc6

Please sign in to comment.