Skip to content
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

EES-4510 release type modal on release page #4306

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import PrintThisPage from '@admin/components/PrintThisPage';
import RouteLeavingGuard from '@admin/components/RouteLeavingGuard';
import { useConfig } from '@admin/contexts/ConfigContext';
import { useEditingContext } from '@admin/contexts/EditingContext';
import BasicReleaseSummary from '@admin/pages/release/content/components/BasicReleaseSummary';
import RelatedPagesSection from '@admin/pages/release/content/components/RelatedPagesSection';
import ReleaseHelpAndSupportSection from '@common/modules/release/components/ReleaseHelpAndSupportSection';
import ReleaseBlock from '@admin/pages/release/content/components/ReleaseBlock';
import ReleaseContentAccordion from '@admin/pages/release/content/components/ReleaseContentAccordion';
import ReleaseEditableBlock from '@admin/pages/release/content/components/ReleaseEditableBlock';
import ReleaseHeadlines from '@admin/pages/release/content/components/ReleaseHeadlines';
import ReleaseHelpAndSupportSection from '@admin/pages/release/content/components/ReleaseHelpAndSupportSection';
import ReleaseNotesSection from '@admin/pages/release/content/components/ReleaseNotesSection';
import { useReleaseContentState } from '@admin/pages/release/content/contexts/ReleaseContentContext';
import useReleaseContentActions from '@admin/pages/release/content/contexts/useReleaseContentActions';
import { getReleaseApprovalStatusLabel } from '@admin/pages/release/utils/releaseSummaryUtil';
import { ReleaseRouteParams } from '@admin/routes/releaseRoutes';
import {
preReleaseAccessListRoute,
Expand All @@ -25,10 +26,12 @@ import ButtonText from '@common/components/ButtonText';
import Details from '@common/components/Details';
import PageSearchForm from '@common/components/PageSearchForm';
import RelatedAside from '@common/components/RelatedAside';
import ScrollableContainer from '@common/components/ScrollableContainer';
import Tag from '@common/components/Tag';
import ReleaseSummarySection from '@common/modules/release/components/ReleaseSummarySection';
import ReleaseDataAndFiles from '@common/modules/release/components/ReleaseDataAndFiles';
import React, { useCallback, useMemo } from 'react';
import { generatePath, useLocation } from 'react-router';
import ScrollableContainer from '@common/components/ScrollableContainer';

interface MethodologyLink {
key: string;
Expand Down Expand Up @@ -127,7 +130,26 @@ const ReleaseContent = () => {

<div className="govuk-grid-row">
<div className="govuk-grid-column-two-thirds">
<BasicReleaseSummary release={release} />
<ReleaseSummarySection
isEditing={editingMode === 'edit'}
lastUpdated={release.updates[0]?.on}
release={release}
releaseDate={release.published ?? release.publishScheduled}
renderReleaseNotes={<ReleaseNotesSection release={release} />}
renderStatusTags={
<Tag className="govuk-!-margin-right-3 govuk-!-margin-bottom-3">
{getReleaseApprovalStatusLabel(release.approvalStatus)}
</Tag>
}
renderSubscribeLink={
<a
className="govuk-!-display-none-print govuk-!-font-weight-bold"
href="#"
>
Sign up for email alerts
</a>
}
/>

<div id="releaseSummary">
{release.summarySection && (
Expand Down Expand Up @@ -411,7 +433,23 @@ const ReleaseContent = () => {

<ReleaseContentAccordion release={release} sectionName="Contents" />

<ReleaseHelpAndSupportSection release={release} />
<ReleaseHelpAndSupportSection
release={release}
renderExternalMethodologyLink={externalMethodology => (
<Link to={externalMethodology.url}>{externalMethodology.title}</Link>
)}
renderMethodologyLink={methodology => {
<>
{editingMode === 'edit' ? (
<a>{`${methodology.title}`}</a>
) : (
<Link to={`/methodology/${methodology.id}/summary`}>
{methodology.title}
</Link>
)}
</>;
}}
/>
<PrintThisPage />
</>
);
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import Button from '@common/components/Button';
import ButtonText from '@common/components/ButtonText';
import InfoIcon from '@common/components/InfoIcon';
import Modal from '@common/components/Modal';
import { GlossaryEntry } from '@common/services/types/glossary';
import styles from '@common/components/GlossaryEntryButton.module.scss';
import sanitizeHtml from '@common/utils/sanitizeHtml';
import parseHtmlString from 'html-react-parser';
import React, { ReactNode, useState } from 'react';
Expand Down Expand Up @@ -40,15 +38,11 @@ export default function GlossaryEntryButton({

{glossaryEntry && (
<Modal
showClose
title={glossaryEntry.title}
onExit={() => setGlossaryEntry(undefined)}
>
{/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}
<div className={styles.content} tabIndex={0}>
{parseHtmlString(sanitizeHtml(glossaryEntry.body))}
</div>

<Button onClick={() => setGlossaryEntry(undefined)}>Close</Button>
{parseHtmlString(sanitizeHtml(glossaryEntry.body))}
</Modal>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
background: #fff;
cursor: initial;
margin: 0 govuk-spacing(2);
max-height: 98vh;
max-width: map-get($govuk-breakpoints, 'desktop');
min-width: 30vh;
overflow-y: auto;
padding: govuk-spacing(6);

@include govuk-media-query($from: tablet) {
Expand Down
18 changes: 16 additions & 2 deletions src/explore-education-statistics-common/src/components/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ import styles from '@common/components/Modal.module.scss';
import classNames from 'classnames';
import React, { ReactNode, useEffect } from 'react';
import BaseModal from 'react-modal';
import Button from './Button';

export interface ModalProps {
children: ReactNode;
className?: string;
closeOnOutsideClick?: boolean;
closeOnEsc?: boolean;
closeText?: string;
fullScreen?: boolean;
hideTitle?: boolean;
open?: boolean;
showClose?: boolean;
title: string;
underlayClass?: string;
onOpen?: () => void;
Expand All @@ -22,13 +25,15 @@ const Modal = ({
className,
closeOnOutsideClick = true,
closeOnEsc = true,
closeText = 'Close',
fullScreen = false,
hideTitle = false,
open = true,
onOpen,
onExit,
showClose = false,
title,
underlayClass,
onOpen,
onExit,
}: ModalProps) => {
const appElement =
typeof document !== 'undefined'
Expand Down Expand Up @@ -74,6 +79,15 @@ const Modal = ({
{title}
</h2>
{children}

{showClose && (
<Button
className="govuk-button govuk-!-margin-bottom-0"
onClick={onExit}
>
{closeText}
</Button>
)}
</BaseModal>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Modal from './Modal';
interface Props {
children?: ReactNode;
className?: string;
cancelText?: string;
closeText?: string;
confirmText?: string;
open?: boolean;
onConfirm(): void;
Expand All @@ -23,7 +23,7 @@ const ModalConfirm = ({
children,
className,
confirmText = 'Confirm',
cancelText = 'Cancel',
closeText = 'Cancel',
open,
onConfirm,
onExit,
Expand Down Expand Up @@ -70,7 +70,7 @@ const ModalConfirm = ({
onClick={handleAction(onCancel)}
disabled={isDisabled}
>
{cancelText}
{closeText}
</Button>
)}
<Button onClick={handleAction(onConfirm)} disabled={isDisabled}>
Expand Down
Loading