Skip to content

Commit 2367d66

Browse files
committed
update comments to separate remove and add into another ticket
1 parent b30a645 commit 2367d66

File tree

2 files changed

+90
-80
lines changed

2 files changed

+90
-80
lines changed

src/components/FilesTable/FilesTable.jsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ const FilesTable = ({addClass, files, handleDeleteFile}) => {
1717
<th>Uploaded By</th>
1818
<th>Size</th>
1919
<th>Created At</th>
20-
<th> </th>
20+
{/* TODO(summer-cook):
21+
- comment this back in once posting attachments/messages is working/during the work for this ticket: https://github.com/scientist-softserv/webstore-component-library/issues/152*/}
22+
{/* <th> </th> */}
2123
</tr>
2224
</thead>
2325
<tbody>
@@ -29,14 +31,16 @@ const FilesTable = ({addClass, files, handleDeleteFile}) => {
2931
<td>{uploadedBy}</td>
3032
<td>{contentLength}</td>
3133
<td>{createdAt}</td>
32-
<td>
33-
{/* TODO: add an X icon here instead of close button, make sure the handleDeleteFile is working */}
34+
{/* TODO(summer-cook):
35+
- comment this back in (see above comment)
36+
- add an X icon here instead of remove text, make sure the handleDeleteFile is working */}
37+
{/* <td>
3438
<Button
3539
primary
3640
onClick={handleDeleteFile}>
3741
Remove
3842
</Button>
39-
</td>
43+
</td> */}
4044
</tr>
4145
)
4246
})}

src/compounds/ActionsGroup/actions/ViewFiles.jsx

Lines changed: 82 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
import React, { useState, useRef } from 'react'
22
import PropTypes from 'prop-types'
33
import {
4-
Button,
5-
CloseButton,
6-
Form,
7-
InputGroup,
8-
ListGroup,
4+
// Button,
5+
// CloseButton,
6+
// Form,
7+
// InputGroup,
8+
// ListGroup,
99
Offcanvas,
1010
Tab,
1111
Tabs } from 'react-bootstrap'
12-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
12+
// import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
1313
import FilesTable from '../../../components/FilesTable/FilesTable'
14-
import { apiV2CompatibleStrings, convertToBase64 } from '../../../resources/utilityFunctions'
14+
// import { apiV2CompatibleStrings, convertToBase64 } from '../../../resources/utilityFunctions'
1515

1616
const ViewFiles = ({ initialFiles, handleClose, show }) => {
17-
const fileRef = useRef(null)
18-
const [files, setFiles] = useState([])
17+
// TODO(summercook):
18+
// - comment back in the following 2 lines & above imports once posting messages/attachments is working
19+
// const fileRef = useRef(null)
20+
// const [files, setFiles] = useState([])
1921
const documentTabs = [
2022
{
2123
eventKey: 'files',
@@ -35,84 +37,88 @@ const ViewFiles = ({ initialFiles, handleClose, show }) => {
3537
},
3638
]
3739

38-
// TODO(summercook): update this method once posting messages is working- may need to use the handleSendingMessagesOrFiles to post
39-
// need to check if we should just a different endpoint to post attachments
40-
const handleSubmit = (event) => {
41-
event.preventDefault()
42-
onSubmit({ files: apiV2CompatibleStrings(files) })
43-
}
40+
// TODO(summercook):
41+
// - comment back in the following 3 methods once posting messages/attachments is working
42+
// may need to use the handleSendingMessagesOrFiles to post
43+
// const handleSubmit = (event) => {
44+
// event.preventDefault()
45+
// onSubmit({ files: apiV2CompatibleStrings(files) })
46+
// }
4447

45-
const handleAddFile = async (event) => {
46-
event.preventDefault()
47-
try {
48-
// "event.target.files" returns a FileList, which looks like an array but does not respond to array methods
49-
// except "length". we are using the spread syntax to set "files" to be an iterable array
50-
const fileArray = [...event.target.files]
51-
const newBase64Files = await Promise.all(convertToBase64(fileArray))
52-
const newFiles = fileArray.map((file, index) => ({ [file.name]: newBase64Files[index] }))
48+
// const handleAddFile = async (event) => {
49+
// event.preventDefault()
50+
// try {
51+
// // "event.target.files" returns a FileList, which looks like an array but does not respond to array methods
52+
// // except "length". we are using the spread syntax to set "files" to be an iterable array
53+
// const fileArray = [...event.target.files]
54+
// const newBase64Files = await Promise.all(convertToBase64(fileArray))
55+
// const newFiles = fileArray.map((file, index) => ({ [file.name]: newBase64Files[index] }))
5356

54-
setFiles([...files, ...newFiles])
55-
fileRef.current.value = ''
56-
} catch (error) {
57-
throw new Error(error)
58-
}
59-
}
57+
// setFiles([...files, ...newFiles])
58+
// fileRef.current.value = ''
59+
// } catch (error) {
60+
// throw new Error(error)
61+
// }
62+
// }
6063

61-
const handleDeleteFile = (file) => {
62-
const remainingFiles = files.filter((obj) => obj !== file)
63-
setFiles(remainingFiles)
64-
}
64+
// const handleDeleteFile = (file) => {
65+
// const remainingFiles = files.filter((obj) => obj !== file)
66+
// setFiles(remainingFiles)
67+
// }
6568

6669
return (
6770
<Offcanvas show={show} onHide={handleClose} placement='end' scroll='true'>
6871
<Offcanvas.Header className='d-flex border-bottom px-3 py-2 bg-light' closeButton>
6972
<Offcanvas.Title>Documents</Offcanvas.Title>
7073
</Offcanvas.Header>
7174
<Offcanvas.Body className='border rounded p-2 m-3'>
72-
<Form>
73-
<h6 className='mt-3'>Upload Additional Documents</h6>
74-
<InputGroup controlId='attachments' className='mb-3'>
75-
<Form.Control
76-
multiple
77-
type='file'
78-
onChange={handleAddFile}
79-
ref={fileRef}
80-
/>
81-
<Button
82-
variant='outline-primary'
83-
onClick={handleSubmit}
84-
type='submit'
85-
>
86-
<FontAwesomeIcon icon='fa-upload' />
87-
</Button>
88-
</InputGroup>
89-
</Form>
90-
<ListGroup variant='flush'>
91-
{files.map((file) => {
92-
const fileName = Object.keys(file)[0]
75+
{/* TODO(summercook): see above comment */}
76+
{/* <Form>
77+
<h6 className='mt-3'>Upload Additional Documents</h6>
78+
<InputGroup controlId='attachments' className='mb-3'>
79+
<Form.Control
80+
multiple
81+
type='file'
82+
onChange={handleAddFile}
83+
ref={fileRef}
84+
/>
85+
<Button
86+
variant='outline-primary'
87+
onClick={handleSubmit}
88+
type='submit'
89+
>
90+
<FontAwesomeIcon icon='fa-upload' />
91+
</Button>
92+
</InputGroup>
93+
</Form>
94+
<ListGroup variant='flush'>
95+
{files.map((file) => {
96+
const fileName = Object.keys(file)[0]
9397
94-
return (
95-
<ListGroup.Item key={fileName} className='d-flex align-items-center'>
96-
<span>{fileName}</span>
97-
<CloseButton onClick={() => handleDeleteFile(file)} className='ms-auto' />
98-
</ListGroup.Item>
99-
)
100-
})}
101-
</ListGroup>
102-
<Tabs defaultActiveKey="files" id="document-tabs">
103-
{documentTabs && documentTabs.map(tab => {
104-
const { eventKey, title, status } = tab
105-
let filteredFiles = initialFiles.filter(f => (status === f.status) || (status === 'Other File' && f.status === null))
106-
return (
107-
<Tab eventKey={eventKey} title={title} className='p-2'>
108-
<FilesTable
109-
files={filteredFiles}
110-
status={status}
111-
handleDeleteFile={handleDeleteFile}/>
112-
</Tab>
113-
)
114-
})}
115-
</Tabs>
98+
return (
99+
<ListGroup.Item key={fileName} className='d-flex align-items-center'>
100+
<span>{fileName}</span>
101+
<CloseButton onClick={() => handleDeleteFile(file)} className='ms-auto' />
102+
</ListGroup.Item>
103+
)
104+
})}
105+
</ListGroup> */}
106+
<Tabs defaultActiveKey="files" id="document-tabs">
107+
{documentTabs && documentTabs.map(tab => {
108+
const { eventKey, title, status } = tab
109+
let filteredFiles = initialFiles.filter(f => (status === f.status) || (status === 'Other File' && f.status === null))
110+
return (
111+
<Tab eventKey={eventKey} title={title} className='p-2'>
112+
<FilesTable
113+
files={filteredFiles}
114+
status={status}
115+
// TODO(summercook): see above comment
116+
// handleDeleteFile={handleDeleteFile}
117+
/>
118+
</Tab>
119+
)
120+
})}
121+
</Tabs>
116122
</Offcanvas.Body>
117123
</Offcanvas>
118124
)

0 commit comments

Comments
 (0)