Skip to content

Commit 08c958f

Browse files
committed
feat: add footer and fix styles
1 parent 14b8cb4 commit 08c958f

4 files changed

Lines changed: 39 additions & 8 deletions

File tree

src/library-authoring/component-comparison/CompareChangesWidget.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const CompareChangesWidget = ({
5151
<Card className={classNames('flex-1 min-w-0', { 'border-0': !sideBySide })}>
5252
<Card.Body
5353
className="p-4 bg-white overflow-auto"
54-
style={{ height: '70vh' }}
54+
style={{ height: '60vh' }}
5555
>
5656
{sideBySide && (
5757
<h3 className="w-100 text-center mb-4">
@@ -68,9 +68,9 @@ const CompareChangesWidget = ({
6868
<LibraryBlock
6969
usageKey={oldUsageKey || usageKey}
7070
version={oldVersion}
71-
minHeight="50vh"
71+
minHeight="45vh"
7272
showTitle={showTitle}
73-
addHeight={40}
73+
addHeight={70}
7474
/>
7575
</IframeProvider>
7676
</div>
@@ -82,7 +82,7 @@ const CompareChangesWidget = ({
8282
<Card className={classNames('flex-1 min-w-0', { 'border-0': !sideBySide })}>
8383
<Card.Body
8484
className="p-4 bg-white overflow-auto"
85-
style={{ height: '70vh' }}
85+
style={{ height: '60vh' }}
8686
>
8787
{sideBySide && (
8888
<h3 className="w-100 text-center mb-4">
@@ -94,8 +94,8 @@ const CompareChangesWidget = ({
9494
usageKey={usageKey}
9595
version={newVersion}
9696
showTitle={showNewTitle || showTitle}
97-
minHeight="50vh"
98-
addHeight={40}
97+
minHeight="45vh"
98+
addHeight={70}
9999
/>
100100
</IframeProvider>
101101
</Card.Body>

src/library-authoring/generic/history-log/HistoryCompareChangesModal.test.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { userEvent } from '@testing-library/user-event';
12
import { render, screen, initializeMocks } from '@src/testUtils';
23

34
import HistoryCompareChangesModal from './HistoryCompareChangesModal';
@@ -43,6 +44,26 @@ describe('<HistoryCompareChangesModal />', () => {
4344
expect(await screen.findByTestId('compare-changes-widget')).toHaveAttribute('data-new-version', 'published');
4445
expect(await screen.findByTestId('compare-changes-widget')).toHaveAttribute('data-side-by-side', 'true');
4546
expect(await screen.findByTestId('compare-changes-widget')).toHaveAttribute('data-show-title', 'true');
47+
expect(screen.getByRole('button', { name: 'Done' })).toBeInTheDocument();
48+
});
49+
50+
it('closes modal when clicking done button', async () => {
51+
const onClose = jest.fn();
52+
const user = userEvent.setup();
53+
54+
render(
55+
<HistoryCompareChangesModal
56+
isOpen
57+
onClose={onClose}
58+
usageKey="lb:org:lib:type:id"
59+
oldTitle="Electron Arcs"
60+
oldVersion={3}
61+
newVersion="published"
62+
/>,
63+
);
64+
65+
await user.click(screen.getByRole('button', { name: 'Done' }));
66+
expect(onClose).toHaveBeenCalledTimes(1);
4667
});
4768

4869
it('renders nothing for container usage keys', () => {

src/library-authoring/generic/history-log/HistoryCompareChangesModal.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Icon, ModalDialog, Stack } from '@openedx/paragon';
1+
import { Button, Icon, ModalDialog, Stack } from '@openedx/paragon';
22
import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n';
33

44
import CompareChangesWidget from '@src/library-authoring/component-comparison/CompareChangesWidget';
@@ -49,7 +49,7 @@ const HistoryCompareChangesModal = ({
4949
>
5050
<ModalDialog.Header>
5151
<ModalDialog.Title>
52-
<Stack direction='horizontal'>
52+
<Stack direction='horizontal' gap={2}>
5353
<FormattedMessage
5454
{...messages.previewChangesTitle}
5555
values={{
@@ -74,6 +74,11 @@ const HistoryCompareChangesModal = ({
7474
showTitle
7575
/>
7676
</ModalDialog.Body>
77+
<ModalDialog.Footer>
78+
<Button onClick={onClose}>
79+
{intl.formatMessage(messages.doneButton)}
80+
</Button>
81+
</ModalDialog.Footer>
7782
</ModalDialog>
7883
);
7984
};

src/library-authoring/generic/history-log/messages.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ const messages = defineMessages({
7171
defaultMessage: 'Show this version',
7272
description: 'Action to open the version comparison modal for a history entry.',
7373
},
74+
doneButton: {
75+
id: 'course-authoring.library-authoring.history.done-button',
76+
defaultMessage: 'Done',
77+
description: 'Button label to close preview changes modal.',
78+
},
7479
});
7580

7681
export default messages;

0 commit comments

Comments
 (0)