Skip to content

Commit 7f1ebd2

Browse files
committed
allow null
1 parent 2cfb042 commit 7f1ebd2

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed

src/components/FilesTable/FilesTable.jsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
// Button,
55
Table,
66
} from 'react-bootstrap'
7+
import { allowNull } from '../../resources/utilityFunctions'
78

89
// TODO(summer-cook):
910
// add back handleDeleteFile to props once posting attachments/messages is working/during the work for this ticket:
@@ -65,7 +66,7 @@ FilesTable.propTypes = {
6566
download: PropTypes.string.isRequired,
6667
fileName: PropTypes.string.isRequired,
6768
href: PropTypes.string.isRequired,
68-
status: PropTypes.string,
69+
status: allowNull(PropTypes.string.isRequired),
6970
uploadedBy: PropTypes.string.isRequired,
7071
uuid: PropTypes.string.isRequired,
7172
}),
@@ -76,9 +77,6 @@ FilesTable.propTypes = {
7677

7778
FilesTable.defaultProps = {
7879
addClass: '',
79-
files: [{
80-
status: null
81-
}]
8280
}
8381

8482
export default FilesTable

src/compounds/ActionsGroup/ActionsGroup.jsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ListGroup } from 'react-bootstrap'
44
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
55
// import SendMessage from './actions/SendMessage'
66
import ViewFiles from './actions/ViewFiles'
7+
import { allowNull } from '../../../resources/utilityFunctions'
78
import './actions-group.scss'
89

910
// TODO: add back handleSendingMessagesOrFiles into the props. see below TODO.
@@ -68,17 +69,11 @@ ActionsGroup.propTypes = {
6869
download: PropTypes.string.isRequired,
6970
fileName: PropTypes.string.isRequired,
7071
href: PropTypes.string.isRequired,
71-
status: PropTypes.string,
72+
status: allowNull(PropTypes.string.isRequired),
7273
uploadedBy: PropTypes.string.isRequired,
7374
uuid: PropTypes.string.isRequired,
7475
}),
7576
).isRequired,
7677
}
7778

78-
ActionsGroup.defaultProps = {
79-
initialFiles: [{
80-
status: null
81-
}]
82-
}
83-
8479
export default ActionsGroup

src/compounds/ActionsGroup/actions/ViewFiles.jsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ import {
1515
// import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
1616
import FilesTable from '../../../components/FilesTable/FilesTable'
1717
// import { apiV2CompatibleStrings, convertToBase64 } from '../../../resources/utilityFunctions'
18+
import { allowNull } from '../../../resources/utilityFunctions'
1819

19-
const ViewFiles = ({ initialFiles, handleClose, show }) => {
20+
const ViewFiles = ({ initialFiles, handleClose }) => {
2021
// TODO(summercook):
2122
// - comment back in the following 2 lines & above imports once posting messages/attachments is working
2223
// const fileRef = useRef(null)
@@ -135,19 +136,12 @@ ViewFiles.propTypes = {
135136
download: PropTypes.string.isRequired,
136137
fileName: PropTypes.string.isRequired,
137138
href: PropTypes.string.isRequired,
138-
status: PropTypes.string,
139+
status: allowNull(PropTypes.string.isRequired),
139140
uploadedBy: PropTypes.string.isRequired,
140141
uuid: PropTypes.string.isRequired,
141142
}),
142143
).isRequired,
143144
handleClose: PropTypes.func.isRequired,
144-
show: PropTypes.bool.isRequired,
145-
}
146-
147-
ViewFiles.defaultProps = {
148-
initialFiles: [{
149-
status: null
150-
}]
151145
}
152146

153147
export default ViewFiles

src/resources/utilityFunctions.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@ export const addDays = (date, days) => {
1515
date.setDate(date.getDate() + days)
1616
return date
1717
}
18+
19+
export const allowNull = (wrappedPropTypes) => {
20+
return (props, propName, ...rest) => {
21+
if (props[propName] === null) return null
22+
return wrappedPropTypes(props, propName, ...rest)
23+
}
24+
}

0 commit comments

Comments
 (0)