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

Migrate off paragon modal deprecated component #275

Merged
merged 2 commits into from
Nov 30, 2022
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
244 changes: 186 additions & 58 deletions src/components/GradesView/EditModal/__snapshots__/test.jsx.snap
Original file line number Diff line number Diff line change
@@ -1,17 +1,59 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EditMoal Component snapshots gradeOverrideHistoryError is and empty and open is true modal open and StatusAlert showing 1`] = `
<Modal
body={
exports[`EditModal Component snapshots gradeOverrideHistoryError is and empty and open is true modal open and StatusAlert showing 1`] = `
<ModalDialog
closeLabel="Close"
hasCloseButton={true}
isBlocking={false}
isFullscreenOnMobile={true}
isFullscreenScroll={false}
isOpen={true}
onClose={[MockFunction this.closeAssignmentModal]}
size="xl"
variant="default"
>
<ModalDialogHeader
as="div"
>
<ModalDialogTitle
as="h2"
>
<FormattedMessage
defaultMessage="Edit Grades"
description="Edit Modal title"
id="gradebook.GradesView.EditModal.title"
/>
</ModalDialogTitle>
</ModalDialogHeader>
<ModalDialogBody
as="div"
>
<div>
<ModalHeaders />
<Alert
<ForwardRef
closeLabel="Dismiss"
dismissible={false}
onClose={[Function]}
show={true}
stacked={false}
transition={
Object {
"$$typeof": Symbol(react.forward_ref),
"defaultProps": Object {
"appear": false,
"in": false,
"mountOnEnter": false,
"timeout": 300,
"unmountOnExit": false,
},
"displayName": "Fade",
"render": [Function],
}
}
variant="danger"
>
Weve been trying to contact you regarding...
</Alert>
</ForwardRef>
<OverrideTable />
<div>
<FormattedMessage
Expand All @@ -28,10 +70,48 @@ exports[`EditMoal Component snapshots gradeOverrideHistoryError is and empty and
/>
</div>
</div>
}
buttons={
Array [
<Button
</ModalDialogBody>
<ModalDialogFooter
as="div"
>
<ActionRow
as="div"
isStacked={false}
>
<ForwardRef
as={
Object {
"$$typeof": Symbol(react.forward_ref),
"Deprecated": [Function],
"defaultProps": Object {
"active": false,
"children": undefined,
"className": undefined,
"disabled": false,
"iconAfter": undefined,
"iconBefore": undefined,
"variant": "primary",
},
"propTypes": Object {
"children": [Function],
"className": [Function],
"iconAfter": [Function],
"iconBefore": [Function],
},
"render": [Function],
}
}
variant="tertiary"
>
<FormattedMessage
defaultMessage="Cancel"
description="Edit Modal close button text"
id="gradebook.GradesView.EditModal.closeText"
/>
</ForwardRef>
<ForwardRef
active={false}
disabled={false}
onClick={[MockFunction this.handleAdjustedGradeClick]}
variant="primary"
>
Expand All @@ -40,40 +120,66 @@ exports[`EditMoal Component snapshots gradeOverrideHistoryError is and empty and
description="Edit Modal Save button label"
id="gradebook.GradesView.EditModal.saveGrade"
/>
</Button>,
]
}
closeText={
<FormattedMessage
defaultMessage="Cancel"
description="Edit Modal close button text"
id="gradebook.GradesView.EditModal.closeText"
/>
}
onClose={[MockFunction this.closeAssignmentModal]}
open={true}
title={
<FormattedMessage
defaultMessage="Edit Grades"
description="Edit Modal title"
id="gradebook.GradesView.EditModal.title"
/>
}
/>
</ForwardRef>
</ActionRow>
</ModalDialogFooter>
</ModalDialog>
`;

exports[`EditMoal Component snapshots gradeOverrideHistoryError is empty and open is false modal closed and StatusAlert closed 1`] = `
<Modal
body={
exports[`EditModal Component snapshots gradeOverrideHistoryError is empty and open is false modal closed and StatusAlert closed 1`] = `
<ModalDialog
closeLabel="Close"
hasCloseButton={true}
isBlocking={false}
isFullscreenOnMobile={true}
isFullscreenScroll={false}
isOpen={true}
onClose={[MockFunction this.closeAssignmentModal]}
size="xl"
variant="default"
>
<ModalDialogHeader
as="div"
>
<ModalDialogTitle
as="h2"
>
<FormattedMessage
defaultMessage="Edit Grades"
description="Edit Modal title"
id="gradebook.GradesView.EditModal.title"
/>
</ModalDialogTitle>
</ModalDialogHeader>
<ModalDialogBody
as="div"
>
<div>
<ModalHeaders />
<Alert
<ForwardRef
closeLabel="Dismiss"
dismissible={false}
onClose={[Function]}
show={false}
stacked={false}
transition={
Object {
"$$typeof": Symbol(react.forward_ref),
"defaultProps": Object {
"appear": false,
"in": false,
"mountOnEnter": false,
"timeout": 300,
"unmountOnExit": false,
},
"displayName": "Fade",
"render": [Function],
}
}
variant="danger"
>

</Alert>
</ForwardRef>
<OverrideTable />
<div>
<FormattedMessage
Expand All @@ -90,10 +196,48 @@ exports[`EditMoal Component snapshots gradeOverrideHistoryError is empty and ope
/>
</div>
</div>
}
buttons={
Array [
<Button
</ModalDialogBody>
<ModalDialogFooter
as="div"
>
<ActionRow
as="div"
isStacked={false}
>
<ForwardRef
as={
Object {
"$$typeof": Symbol(react.forward_ref),
"Deprecated": [Function],
"defaultProps": Object {
"active": false,
"children": undefined,
"className": undefined,
"disabled": false,
"iconAfter": undefined,
"iconBefore": undefined,
"variant": "primary",
},
"propTypes": Object {
"children": [Function],
"className": [Function],
"iconAfter": [Function],
"iconBefore": [Function],
},
"render": [Function],
}
}
variant="tertiary"
>
<FormattedMessage
defaultMessage="Cancel"
description="Edit Modal close button text"
id="gradebook.GradesView.EditModal.closeText"
/>
</ForwardRef>
<ForwardRef
active={false}
disabled={false}
onClick={[MockFunction this.handleAdjustedGradeClick]}
variant="primary"
>
Expand All @@ -102,24 +246,8 @@ exports[`EditMoal Component snapshots gradeOverrideHistoryError is empty and ope
description="Edit Modal Save button label"
id="gradebook.GradesView.EditModal.saveGrade"
/>
</Button>,
]
}
closeText={
<FormattedMessage
defaultMessage="Cancel"
description="Edit Modal close button text"
id="gradebook.GradesView.EditModal.closeText"
/>
}
onClose={[MockFunction this.closeAssignmentModal]}
open={false}
title={
<FormattedMessage
defaultMessage="Edit Grades"
description="Edit Modal title"
id="gradebook.GradesView.EditModal.title"
/>
}
/>
</ForwardRef>
</ActionRow>
</ModalDialogFooter>
</ModalDialog>
`;
42 changes: 28 additions & 14 deletions src/components/GradesView/EditModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import { connect } from 'react-redux';

import {
Button,
Modal,
Alert,
ModalDialog,
ActionRow,
} from '@edx/paragon';
import { FormattedMessage } from '@edx/frontend-platform/i18n';

Expand Down Expand Up @@ -46,11 +47,20 @@ export class EditModal extends React.Component {

render() {
return (
<Modal
open={this.props.open}
title={<FormattedMessage {...messages.title} />}
closeText={<FormattedMessage {...messages.closeText} />}
body={(

<ModalDialog
isOpen
onClose={this.closeAssignmentModal}
size="xl"
hasCloseButton
isFullscreenOnMobile
>
<ModalDialog.Header>
<ModalDialog.Title>
<FormattedMessage {...messages.title} />
</ModalDialog.Title>
</ModalDialog.Header>
<ModalDialog.Body>
<div>
<ModalHeaders />
<Alert
Expand All @@ -64,14 +74,18 @@ export class EditModal extends React.Component {
<div><FormattedMessage {...messages.visibility} /></div>
<div><FormattedMessage {...messages.saveVisibility} /></div>
</div>
)}
buttons={[
<Button variant="primary" onClick={this.handleAdjustedGradeClick}>
<FormattedMessage {...messages.saveGrade} />
</Button>,
]}
onClose={this.closeAssignmentModal}
/>
</ModalDialog.Body>
<ModalDialog.Footer>
<ActionRow>
<ModalDialog.CloseButton variant="tertiary">
<FormattedMessage {...messages.closeText} />
</ModalDialog.CloseButton>
<Button variant="primary" onClick={this.handleAdjustedGradeClick}>
<FormattedMessage {...messages.saveGrade} />
</Button>
</ActionRow>
</ModalDialog.Footer>
</ModalDialog>
);
}
}
Expand Down
10 changes: 3 additions & 7 deletions src/components/GradesView/EditModal/test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@ import {
EditModal,
mapDispatchToProps,
mapStateToProps,
} from '.';
}
from '.';

jest.mock('./OverrideTable', () => 'OverrideTable');
jest.mock('./ModalHeaders', () => 'ModalHeaders');
jest.mock('@edx/paragon', () => ({
Button: () => 'Button',
Modal: () => 'Modal',
Alert: () => 'Alert',
}));
jest.mock('data/actions', () => ({
__esModule: true,
default: {
Expand All @@ -44,7 +40,7 @@ jest.mock('data/selectors', () => ({
},
},
}));
describe('EditMoal', () => {
describe('EditModal', () => {
let props;
beforeEach(() => {
props = {
Expand Down