Skip to content

Commit e7f0fd0

Browse files
committed
chore: ui implement for self assessment
chore: delete file
1 parent 03f1b2f commit e7f0fd0

34 files changed

+468
-67
lines changed

src/components/FileUpload/ActionCell.jsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,35 @@
1-
import React from 'react';
1+
import React, { useCallback } from 'react';
22
import { IconButton, Icon } from '@edx/paragon';
33

44
import { useIntl } from '@edx/frontend-platform/i18n';
55
import { Delete, Preview } from '@edx/paragon/icons';
66

77
import messages from './messages';
88

9-
const ActionCell = () => {
9+
const ActionCell = ({
10+
onDeletedFile,
11+
disabled,
12+
row,
13+
}) => {
1014
const { formatMessage } = useIntl();
15+
const deleteFile = useCallback(async () => {
16+
console.log('deleteFile', row.index);
17+
await onDeletedFile(row.index);
18+
}, []);
1119
return (
1220
<>
1321
<IconButton
1422
src={Delete}
1523
alt={formatMessage(messages.deleteButtonAltText)}
1624
iconAs={Icon}
25+
onClick={deleteFile}
26+
disabled={disabled}
1727
/>
1828
<IconButton
1929
src={Preview}
2030
alt={formatMessage(messages.previewButtonAltText)}
2131
iconAs={Icon}
32+
disabled={disabled}
2233
/>
2334
</>
2435
);

src/components/FileUpload/__snapshots__/ActionCell.test.jsx.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ exports[`<ActionCell /> renders 1`] = `
55
<IconButton
66
alt="Delete"
77
iconAs="Icon"
8+
onClick={[Function]}
89
src={[Function]}
910
/>
1011
<IconButton

src/components/FileUpload/__snapshots__/index.test.jsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ exports[`<FileUpload /> renders default 1`] = `
2525
"accessor": "fileSize",
2626
},
2727
Object {
28-
"Cell": "ActionCell",
28+
"Cell": [Function],
2929
"Header": "Actions",
3030
"accessor": "actions",
3131
},
@@ -106,7 +106,7 @@ exports[`<FileUpload /> renders read only 1`] = `
106106
"accessor": "fileSize",
107107
},
108108
Object {
109-
"Cell": "ActionCell",
109+
"Cell": [Function],
110110
"Header": "Actions",
111111
"accessor": "actions",
112112
},

src/components/FileUpload/index.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import messages from './messages';
1414

1515
import './styles.scss';
1616

17-
const FileUpload = ({ isReadOnly, uploadedFiles, onFileUploaded }) => {
17+
const FileUpload = ({ isReadOnly, uploadedFiles, onFileUploaded, onDeletedFile }) => {
1818
const { formatMessage } = useIntl();
1919

2020
const {
@@ -55,7 +55,7 @@ const FileUpload = ({ isReadOnly, uploadedFiles, onFileUploaded }) => {
5555
{
5656
Header: formatMessage(messages.fileActionsTitle),
5757
accessor: 'actions',
58-
Cell: ActionCell,
58+
Cell: (props) => <ActionCell {...props} onDeletedFile={onDeletedFile} disabled={isReadOnly} />,
5959
},
6060
]}
6161
/>
@@ -81,6 +81,7 @@ const FileUpload = ({ isReadOnly, uploadedFiles, onFileUploaded }) => {
8181
FileUpload.defaultProps = {
8282
isReadOnly: false,
8383
uploadedFiles: [],
84+
onFileUploaded: () => { },
8485
};
8586
FileUpload.propTypes = {
8687
isReadOnly: PropTypes.bool,
@@ -91,7 +92,7 @@ FileUpload.propTypes = {
9192
fileSize: PropTypes.number,
9293
}),
9394
),
94-
onFileUploaded: PropTypes.func.isRequired,
95+
onFileUploaded: PropTypes.func,
9596
};
9697

9798
export default FileUpload;

src/components/FileUpload/index.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ describe('<FileUpload />', () => {
2626
},
2727
],
2828
onFileUploaded: jest.fn(),
29+
onDeletedFile: jest.fn().mockName('onDeletedFile'),
2930
};
3031

3132
const mockHooks = (overrides) => {

src/components/InfoPopover/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const InfoPopover = ({ onClick, children }) => {
2222
return (
2323
<OverlayTrigger
2424
trigger="focus"
25-
placement="right-end"
25+
placement="bottom"
2626
flip
2727
overlay={(
2828
<Popover id="info-popover" className="overlay-help-popover">

src/components/Rubric/CriterionContainer/RadioCriterion.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const RadioCriterion = ({ isGrading, criterion }) => {
4242
RadioCriterion.propTypes = {
4343
isGrading: PropTypes.bool.isRequired,
4444
criterion: PropTypes.shape({
45-
optionsValue: PropTypes.string.isRequired,
45+
optionsValue: PropTypes.string,
4646
optionsIsInvalid: PropTypes.bool.isRequired,
4747
optionsOnChange: PropTypes.func.isRequired,
4848
name: PropTypes.string.isRequired,

src/components/TextResponse/index.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import RichTextEditor from 'components/TextResponse/RichTextEditor';
66

77
import './index.scss';
88

9-
const TextResponse = ({ submissionConfig, value, onChange }) => {
9+
const TextResponse = ({ submissionConfig, value, onChange, isReadOnly }) => {
1010
const { textResponseConfig } = submissionConfig;
1111
const { optional, enabled } = textResponseConfig;
1212
const props = {
1313
optional,
14-
disabled: !enabled,
14+
disabled: !enabled || isReadOnly,
1515
value,
1616
onChange,
1717
};
@@ -34,7 +34,7 @@ TextResponse.propTypes = {
3434
}),
3535
}).isRequired,
3636
value: PropTypes.string.isRequired,
37-
onChange: PropTypes.func.isRequired,
37+
onChange: PropTypes.func,
3838
};
3939

4040
export default TextResponse;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
@import "@edx/paragon/scss/core/core.scss";
2+
13
.textarea-response {
24
min-height: 200px;
35
max-height: 300px;
46
overflow-y: scroll;
7+
}
8+
9+
.tox-tinymce--disabled {
10+
background-color: $input-disabled-bg;
11+
// Override Firefox's unusual default opacity; see https://github.com/twbs/bootstrap/pull/11526.
12+
opacity: 1;
513
}

src/components/TextResponse/index.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ describe('<TextResponse />', () => {
1515
},
1616
value: 'value',
1717
onChange: jest.fn().mockName('onChange'),
18+
isReadOnly: false,
1819
};
1920

2021
it('render Text Editor ', () => {

0 commit comments

Comments
 (0)