Skip to content

Commit

Permalink
MMT-3492: Fixing 'data' structure
Browse files Browse the repository at this point in the history
  • Loading branch information
mandyparson committed Jan 23, 2024
1 parent 9f15d69 commit 4a3f8db
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 86 deletions.
64 changes: 42 additions & 22 deletions static/src/js/components/DraftList/DraftList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,48 @@ const DraftList = ({ draftType }) => {
const draftLink = `/drafts/${`${paramDraftType}`}/${conceptId}`

return (
[
<Link key={`${conceptId}/col1`} to={draftLink}>
{name || '<Blank Name>'}
</Link>,
<span key={`${conceptId}/col2`}>
{longName || '<Untitled Record>'}
</span>,
<span key={`${conceptId}/col3`}>
{new Date(revisionDate).toISOString().split('T')[0]}
</span>,
<div key={`${conceptId}/col4`} className="d-flex">
<Button
className="d-flex"
Icon={FaFileDownload}
onClick={() => handleDownloadClick(conceptId)}
variant="secondary"
size="sm"
>
Download JSON
</Button>
</div>
]
{
key: `${conceptId}`,
cells:
[
{
value:
(
<Link to={draftLink}>
{name || '<Blank Name>'}
</Link>
)
},
{
value:
(
longName || '<Untitled Record>'
)
},
{
value:
(
new Date(revisionDate).toISOString().split('T')[0]
)
},
{
value:
(
<div className="d-flex">
<Button
className="d-flex"
Icon={FaFileDownload}
onClick={() => handleDownloadClick(conceptId)}
variant="secondary"
size="sm"
>
Download JSON
</Button>
</div>
)
}
]
}
)
})
)
Expand Down
10 changes: 10 additions & 0 deletions static/src/js/components/Pagination/Pagination.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react'

const Pagination = () => {
console.log('rendered')

Check failure on line 4 in static/src/js/components/Pagination/Pagination.jsx

View workflow job for this annotation

GitHub Actions / eslint (lts/hydrogen)

Unexpected tab character

Check failure on line 4 in static/src/js/components/Pagination/Pagination.jsx

View workflow job for this annotation

GitHub Actions / eslint (lts/hydrogen)

Expected indentation of 2 spaces but found 1 tab
return (

Check failure on line 5 in static/src/js/components/Pagination/Pagination.jsx

View workflow job for this annotation

GitHub Actions / eslint (lts/hydrogen)

Expected blank line before this statement
<h1>Pagination</h1>
)
}

export default Pagination
18 changes: 10 additions & 8 deletions static/src/js/components/Table/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import BootstrapTable from 'react-bootstrap/Table'
import Placeholder from 'react-bootstrap/Placeholder'

import For from '../For/For'
import stringifyCircularJSON from '../../utils/stringifyCircularJSON'

/**
* Table
Expand Down Expand Up @@ -54,17 +53,17 @@ const Table = ({
)
} else if (data.length > 0) {
const rowData = data.map((row) => {
const rowKey = stringifyCircularJSON(row)

const { cells, key } = row
const rowKey = key
return (

Check failure on line 58 in static/src/js/components/Table/Table.jsx

View workflow job for this annotation

GitHub Actions / eslint (lts/hydrogen)

Expected blank line before this statement
<tr key={`${rowKey}`}>
{
row.map((cell, index) => {
const cellKey = stringifyCircularJSON(cell)

cells.map((cell, index) => {
const cellKey = `${rowKey}_${headers[index]}`
const { value } = cell
return (

Check failure on line 64 in static/src/js/components/Table/Table.jsx

View workflow job for this annotation

GitHub Actions / eslint (lts/hydrogen)

Expected blank line before this statement
<td key={cellKey} className={classNames[index] || 'col-auto'}>
{cell}
{value}
</td>
)
})
Expand Down Expand Up @@ -102,7 +101,10 @@ Table.propTypes = {
headers: PropTypes.arrayOf(PropTypes.string).isRequired,
classNames: PropTypes.arrayOf(PropTypes.string),
loading: PropTypes.bool,
data: PropTypes.node.isRequired,
data: PropTypes.arrayOf(PropTypes.shape({
key: PropTypes.string,
cells: PropTypes.arrayOf(PropTypes.shape({}))
})).isRequired,
error: PropTypes.string
}

Expand Down
39 changes: 23 additions & 16 deletions static/src/js/components/Table/__tests__/Table.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,29 @@ const setup = (overrideProps = {}) => {
],
loading: false,
data: [
[
<span key="BEAM-001/col2">
Row 1 Cell 1
</span>,
<span key="BEAM-001/col2">
Row 1 Cell 2
</span>
],
[
<span key="BEAM-001/col2">
Row 2 Cell 1
</span>,
<span key="BEAM-001/col2">
Row 2 Cell 2
</span>
]
{
key: 'conceptId001',
cells: [
{
value: ('Row 1 Cell 1')
},
{
value: ('Row 1 Cell 2')
}
]
},
{
key: 'conceptId002',
cells: [
{
value: ('Row 2 Cell 1')
},
{
value: ('Row 2 Cell 2')
}
]
}

],
...overrideProps
}
Expand Down
18 changes: 0 additions & 18 deletions static/src/js/utils/__tests__/stringifyCircularJSON.test.js

This file was deleted.

22 changes: 0 additions & 22 deletions static/src/js/utils/stringifyCircularJSON.js

This file was deleted.

0 comments on commit 4a3f8db

Please sign in to comment.