Skip to content
This repository was archived by the owner on Feb 14, 2025. It is now read-only.

fix: remove deprecated feedback link #493

Merged
merged 1 commit into from
Jul 10, 2024
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
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();
});
});
});
Loading