Skip to content

Commit

Permalink
fix: remove deprecated feedback link (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinAoki authored Jul 10, 2024
1 parent a22a260 commit 9bce0a3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,6 @@ exports[`EditorFooter render snapshot: default args (disableSave: false, saveFai
className="shadow-sm"
>
<ActionRow>
<ActionRow.Spacer />
<Button
aria-label="Discard changes and return to learning context"
onClick={[MockFunction args.onCancel]}
variant="tertiary"
>
<FormattedMessage
defaultMessage="Cancel"
description="Label for cancel button"
id="authoring.editorfooter.cancelButton.label"
/>
</Button>
<Button
aria-label="Save changes and return to learning context"
disabled={false}
onClick={[MockFunction args.onSave]}
>
<FormattedMessage
defaultMessage="Save"
description="Label for Save button"
id="authoring.editorfooter.savebutton.label"
/>
</Button>
</ActionRow>
</ModalDialog.Footer>
</div>
`;

exports[`EditorFooter render snapshot: dont show feedback link 1`] = `
<div
className="editor-footer fixed-bottom"
>
<ModalDialog.Footer
className="shadow-sm"
>
<ActionRow>
<ActionRow.Spacer />
<Button
aria-label="Discard changes and return to learning context"
onClick={[MockFunction args.onCancel]}
Expand Down Expand Up @@ -80,7 +43,6 @@ exports[`EditorFooter render snapshot: save disabled. Show button spinner 1`] =
className="shadow-sm"
>
<ActionRow>
<ActionRow.Spacer />
<Button
aria-label="Discard changes and return to learning context"
onClick={[MockFunction args.onCancel]}
Expand Down Expand Up @@ -124,49 +86,6 @@ exports[`EditorFooter render snapshot: save failed. Show error message 1`] = `
className="shadow-sm"
>
<ActionRow>
<ActionRow.Spacer />
<Button
aria-label="Discard changes and return to learning context"
onClick={[MockFunction args.onCancel]}
variant="tertiary"
>
<FormattedMessage
defaultMessage="Cancel"
description="Label for cancel button"
id="authoring.editorfooter.cancelButton.label"
/>
</Button>
<Button
aria-label="Save changes and return to learning context"
disabled={false}
onClick={[MockFunction args.onSave]}
>
<FormattedMessage
defaultMessage="Save"
description="Label for Save button"
id="authoring.editorfooter.savebutton.label"
/>
</Button>
</ActionRow>
</ModalDialog.Footer>
</div>
`;

exports[`EditorFooter render snapshot: show feedback link 1`] = `
<div
className="editor-footer fixed-bottom"
>
<ModalDialog.Footer
className="shadow-sm"
>
<ActionRow>
<Hyperlink
destination="https://docs.google.com/forms/d/e/1FAIpQLSdmtO5at9WWHLcWLrOgk1oMz97gYYYrUq4cvH8Vzd-WQwM0Cg/viewform?usp=sharing"
target="_blank"
>
Share Feedback
</Hyperlink>
<ActionRow.Spacer />
<Button
aria-label="Discard changes and return to learning context"
onClick={[MockFunction args.onCancel]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { useSelector } from 'react-redux';
import PropTypes from 'prop-types';

import {
Expand All @@ -8,11 +7,8 @@ import {
Button,
ModalDialog,
Toast,
Hyperlink,
} from '@openedx/paragon';
import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { selectors } from '../../../../data/redux';
import { blockTypes } from '../../../../data/constants/app';

import messages from './messages';

Expand All @@ -24,50 +20,36 @@ export const EditorFooter = ({
saveFailed,
// injected
intl,
}) => {
const blockType = useSelector(selectors.app.blockType);
}) => (
<div className="editor-footer fixed-bottom">
{saveFailed && (
<Toast show onClose={clearSaveFailed}>
<FormattedMessage {...messages.contentSaveFailed} />
</Toast>
)}
<ModalDialog.Footer className="shadow-sm">
<ActionRow>
<Button
aria-label={intl.formatMessage(messages.cancelButtonAriaLabel)}
variant="tertiary"
onClick={onCancel}
>
<FormattedMessage {...messages.cancelButtonLabel} />
</Button>
<Button
aria-label={intl.formatMessage(messages.saveButtonAriaLabel)}
onClick={onSave}
disabled={disableSave}
>
{disableSave
? <Spinner animation="border" className="mr-3" />
: <FormattedMessage {...messages.saveButtonLabel} />}
</Button>
</ActionRow>
</ModalDialog.Footer>
</div>
);

return (
<div className="editor-footer fixed-bottom">
{saveFailed && (
<Toast show onClose={clearSaveFailed}>
<FormattedMessage {...messages.contentSaveFailed} />
</Toast>
)}

<ModalDialog.Footer className="shadow-sm">
<ActionRow>
{
// TODO: Remove this code when the problem Editor Beta is complete.
blockType === blockTypes.problem
&& (
<Hyperlink destination="https://docs.google.com/forms/d/e/1FAIpQLSdmtO5at9WWHLcWLrOgk1oMz97gYYYrUq4cvH8Vzd-WQwM0Cg/viewform?usp=sharing" target="_blank">
Share Feedback
</Hyperlink>
)
}
<ActionRow.Spacer />
<Button
aria-label={intl.formatMessage(messages.cancelButtonAriaLabel)}
variant="tertiary"
onClick={onCancel}
>
<FormattedMessage {...messages.cancelButtonLabel} />
</Button>
<Button
aria-label={intl.formatMessage(messages.saveButtonAriaLabel)}
onClick={onSave}
disabled={disableSave}
>
{disableSave
? <Spinner animation="border" className="mr-3" />
: <FormattedMessage {...messages.saveButtonLabel} />}
</Button>
</ActionRow>
</ModalDialog.Footer>
</div>
);
};
EditorFooter.propTypes = {
clearSaveFailed: PropTypes.func.isRequired,
disableSave: PropTypes.bool.isRequired,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import React from 'react';
import { shallow } from '@edx/react-unit-test-utils';

import { useSelector } from 'react-redux';
import { formatMessage } from '../../../../../testUtils';
import { EditorFooter } from '.';

jest.mock('../../hooks', () => ({
nullMethod: jest.fn().mockName('hooks.nullMethod'),
}));

jest.mock('react-redux', () => ({
useSelector: jest.fn(),
}));

describe('EditorFooter', () => {
const props = {
intl: { formatMessage },
Expand All @@ -25,20 +20,13 @@ describe('EditorFooter', () => {
test('snapshot: default args (disableSave: false, saveFailed: false)', () => {
expect(shallow(<EditorFooter {...props} />).snapshot).toMatchSnapshot();
});

test('snapshot: save disabled. Show button spinner', () => {
expect(shallow(<EditorFooter {...props} disableSave />).snapshot).toMatchSnapshot();
});

test('snapshot: save failed. Show error message', () => {
expect(shallow(<EditorFooter {...props} saveFailed />).snapshot).toMatchSnapshot();
});

test('snapshot: show feedback link', () => {
useSelector.mockReturnValueOnce('problem');
expect(shallow(<EditorFooter {...props} />).snapshot).toMatchSnapshot();
});
test('snapshot: dont show feedback link', () => {
useSelector.mockReturnValueOnce('not a Problem');
expect(shallow(<EditorFooter {...props} />).snapshot).toMatchSnapshot();
});
});
});

0 comments on commit 9bce0a3

Please sign in to comment.