Skip to content

Commit

Permalink
chore: fix linter checks
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanttV committed May 2, 2024
1 parent 46a3289 commit bcb619a
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 75 deletions.
14 changes: 7 additions & 7 deletions src/containers/TurnitinDisplay/components/HyperlinkCell.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Hyperlink } from '@edx/paragon';
import { Hyperlink } from '@openedx/paragon';
import { useIntl } from '@edx/frontend-platform/i18n';
import messages from './messages';

export const HyperlinkCell = ({ value }) => {
const intl = useIntl();
return (
<Hyperlink destination={value} target="_blank">
{intl.formatMessage(messages.buttonViewerURLTitle)}
</Hyperlink>
)
}
return (
<Hyperlink destination={value} target="_blank">
{intl.formatMessage(messages.buttonViewerURLTitle)}
</Hyperlink>
);
};
HyperlinkCell.propTypes = {
value: PropTypes.string.isRequired,
};
Expand Down
2 changes: 1 addition & 1 deletion src/containers/TurnitinDisplay/components/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const messages = defineMessages({
id: 'ora-grading.TurnitinDisplay.NoSimilarityReports',
defaultMessage: 'No Turnitin Similarity Reports to show',
description: 'Message to display when there are no Turnitin Similarity Reports to show',
},
},
viewerURLExpired: {
id: 'ora-grading.TurnitinDisplay.ViewerURLExpired',
defaultMessage: 'The Similarity Report URLs have a very short lifespan (less than 1 minute) after which it will no longer be valid. Once a user has been redirected to this URL, they will be given a session that will last for 1 hour. When expired, please refresh the page to get a new URL.',
Expand Down
132 changes: 69 additions & 63 deletions src/containers/TurnitinDisplay/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,96 @@ import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';

import { Card, Collapsible, Icon, DataTable, Alert } from '@openedx/paragon';

Check failure on line 5 in src/containers/TurnitinDisplay/index.jsx

View workflow job for this annotation

GitHub Actions / tests

Expected a line break after this opening brace

Check failure on line 5 in src/containers/TurnitinDisplay/index.jsx

View workflow job for this annotation

GitHub Actions / tests

Expected a line break before this closing brace
import {
Card, Collapsible, Icon, DataTable, Alert,
} from '@edx/paragon';
import { ArrowDropDown, ArrowDropUp, WarningFilled } from '@edx/paragon/icons';
ArrowDropDown,
ArrowDropUp,
WarningFilled,
} from '@openedx/paragon/icons';
import messages from './components/messages';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';

Check failure on line 12 in src/containers/TurnitinDisplay/index.jsx

View workflow job for this annotation

GitHub Actions / tests

`@edx/frontend-platform/i18n` import should occur before import of `./components/messages`

import FileNameCell from './components/FileNameCell';
import HyperlinkCell from './components/HyperlinkCell';
import { selectors } from 'data/redux';

Check failure on line 16 in src/containers/TurnitinDisplay/index.jsx

View workflow job for this annotation

GitHub Actions / tests

`data/redux` import should occur before import of `./components/messages`


/**
* <TurnitinDisplay />
*/
export const TurnitinDisplay = ({ viewers, intl }) => {
const [isWarningOpen, setIsWarningOpen] = useState(true);
return <Card className="submission-files p-3">
{viewers.length ? (
<>
<Collapsible.Advanced defaultOpen>
<Collapsible.Trigger className="submission-files-title">
<h3>{intl.formatMessage(messages.similarityReportsTitle)}</h3>
<Collapsible.Visible whenClosed>
<Icon src={ArrowDropDown} />
</Collapsible.Visible>
<Collapsible.Visible whenOpen>
<Icon src={ArrowDropUp} />
</Collapsible.Visible>
</Collapsible.Trigger>
<Collapsible.Body className="submission-files-body">
<Alert
variant="warning"
dismissible
icon={WarningFilled}
show={isWarningOpen}
onClose={() => setIsWarningOpen(false)}
>
<Alert.Heading as="h4">{intl.formatMessage(messages.viewerURLExpiredTitle)}</Alert.Heading>
<p className="small mb-0">{intl.formatMessage(messages.viewerURLExpired)}</p>
</Alert>
<div className="submission-files-table">
<DataTable
columns={[
{
Header: intl.formatMessage(messages.fileNameTableHeader),
accessor: "file_name",
Cell: FileNameCell,
},
{
Header: intl.formatMessage(messages.URLTableHeader),
accessor: "url",
Cell: HyperlinkCell,
},
]}
data={viewers}
itemCount={viewers.length}
return (
<Card className="submission-files p-3">
{viewers.length ? (
<>
<Collapsible.Advanced defaultOpen>
<Collapsible.Trigger className="submission-files-title">
<h3>{intl.formatMessage(messages.similarityReportsTitle)}</h3>
<Collapsible.Visible whenClosed>
<Icon src={ArrowDropDown} />
</Collapsible.Visible>
<Collapsible.Visible whenOpen>
<Icon src={ArrowDropUp} />
</Collapsible.Visible>
</Collapsible.Trigger>
<Collapsible.Body className="submission-files-body">
<Alert
variant="warning"
dismissible
icon={WarningFilled}
show={isWarningOpen}
onClose={() => setIsWarningOpen(false)}
>
<DataTable.Table />
</DataTable>
</div>
</Collapsible.Body>
</Collapsible.Advanced>
<Card.Footer>
</Card.Footer>
</>
) : (
<div className="submission-files-empty">
<WarningFilled />
<p>{intl.formatMessage(messages.noSimilarityReports)}</p>
</div>
)}
</Card>
<Alert.Heading as="h4">
{intl.formatMessage(messages.viewerURLExpiredTitle)}
</Alert.Heading>
<p className="small mb-0">
{intl.formatMessage(messages.viewerURLExpired)}
</p>
</Alert>
<div className="submission-files-table">
<DataTable
columns={[
{
Header: intl.formatMessage(messages.fileNameTableHeader),
accessor: 'file_name',
Cell: FileNameCell,
},
{
Header: intl.formatMessage(messages.URLTableHeader),
accessor: 'url',
Cell: HyperlinkCell,
},
]}
data={viewers}
itemCount={viewers.length}
>
<DataTable.Table />
</DataTable>
</div>
</Collapsible.Body>
</Collapsible.Advanced>
<Card.Footer></Card.Footer>

Check failure on line 74 in src/containers/TurnitinDisplay/index.jsx

View workflow job for this annotation

GitHub Actions / tests

Empty components are self-closing
</>
) : (
<div className="submission-files-empty">
<WarningFilled />
<p>{intl.formatMessage(messages.noSimilarityReports)}</p>
</div>
)}
</Card>
);
};


TurnitinDisplay.defaultProps = {
viewers: [],
};


TurnitinDisplay.propTypes = {
viewers: PropTypes.arrayOf(
PropTypes.shape({
viewer_url: PropTypes.string.isRequired,
}),
})

Check failure on line 94 in src/containers/TurnitinDisplay/index.jsx

View workflow job for this annotation

GitHub Actions / tests

Missing trailing comma
),
// injected
intl: intlShape.isRequired,
Expand All @@ -99,4 +103,6 @@ export const mapStateToProps = (state) => ({

export const mapDispatchToProps = {};

export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(TurnitinDisplay));
export default injectIntl(
connect(mapStateToProps, mapDispatchToProps)(TurnitinDisplay)

Check failure on line 107 in src/containers/TurnitinDisplay/index.jsx

View workflow job for this annotation

GitHub Actions / tests

Missing trailing comma
);
5 changes: 3 additions & 2 deletions src/data/redux/thunkActions/grading.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,16 @@ export const loadSubmission = () => (dispatch, getState) => {
export const loadTurnitinViewers = () => (dispatch, getState) => {
const submissionUUID = selectors.grading.selected.submissionUUID(getState());
dispatch(requests.fetchTurnitinViewers({
submissionUUID, courseId: selectors.app.courseId(getState()),
submissionUUID,
courseId: selectors.app.courseId(getState()),
onSuccess: (response) => {
dispatch(actions.grading.loadTurnitinViewers(response));
},
onFailure: (error) => {
if (error.response.status === ErrorStatuses.notFound) {
dispatch(actions.grading.loadTurnitinViewers([]));
}
}
},
}));
};

Expand Down
2 changes: 1 addition & 1 deletion src/data/redux/thunkActions/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const fetchTurnitinViewers = ({ submissionUUID, courseId, ...rest }) => (
promise: api.fetchTurnitinViewers(submissionUUID, courseId),
...rest,
}));
}
};

/**
* Tracked setLock api method. tracked to the `setLock` request key.
Expand Down
2 changes: 1 addition & 1 deletion src/data/services/lms/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const fetchSubmission = (submissionUUID) => get(
* }
*/
const fetchTurnitinViewers = (submissionUUID, courseId) => get(
stringifyUrl(`${urls.fetchTurnitinViewersUrl()}/${courseId}/api/v1/viewer-url/${submissionUUID}/`)
stringifyUrl(`${urls.fetchTurnitinViewersUrl()}/${courseId}/api/v1/viewer-url/${submissionUUID}/`),
).then(response => response.data);

/**
Expand Down

0 comments on commit bcb619a

Please sign in to comment.