Skip to content

Commit

Permalink
Mmt 3492: Creating a resuable table Component (#1114)
Browse files Browse the repository at this point in the history
* MMT-3492: Saving progress on table component

* MMT-3492: Adjusting RenderRows

* MMT-3492: Finish writing tests

* MMT-3492: Addressing PR Comments

* MMT-3492: Fixing 'data' structure

* MMT-3492: eslint error fixes

* MMT-3492: reverting changes to ManagePage

* MMT-3492: Fixing shortName and title

* MMT-3492: Editing table and ManagePage

* MMT-3492: Trying to get tests to run on github

* MMT-3492: Addressing comments

* MMT-3492: Changing all conceptTypes to ummMetadata

* MMT-3492: lint
  • Loading branch information
mandyparson authored Feb 2, 2024
1 parent c5087ad commit 18d0d12
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 48 deletions.
11 changes: 6 additions & 5 deletions static/src/js/components/DraftList/DraftList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ const DraftList = ({ draftType }) => {
// Building a Table using Data in items
const data = (items.map((item) => {
const {
conceptId, revisionDate, previewMetadata: {
name, longName, shortName, title
}
conceptId, revisionDate, ummMetadata
} = item
const {
ShortName, EntryTitle, Name, LongName
} = ummMetadata || {}

const draftLink = `/drafts/${`${paramDraftType}`}/${conceptId}`

Expand All @@ -72,14 +73,14 @@ const DraftList = ({ draftType }) => {
value:
(
<Link to={draftLink}>
{name || shortName || '<Blank Name>'}
{Name || ShortName || '<Blank Name>'}
</Link>
)
},
{
value:
(
longName || title || '<Untitled Record>'
LongName || EntryTitle || '<Untitled Record>'
)
},
{
Expand Down
13 changes: 9 additions & 4 deletions static/src/js/components/DraftList/__tests__/DraftList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,19 @@ describe('DraftList', () => {
{
conceptId: 'TD1200000092-MMT_2',
revisionDate: '2023-12-08T17:56:09.385Z',
ummMetadata: {
Name: 'Tool TD1200000092 short name',
LongName: 'Tool TD1200000092 long name'
},
previewMetadata: {
name: 'Tool TD1200000092 short name',
longName: 'Tool TD1200000092 long name',
__typename: 'Tool'
},
__typename: 'Draft'
},
{
conceptId: 'TD1200000093-MMT_2',
revisionDate: '2023-11-08T17:56:09.385Z',
ummMetadata: {},
previewMetadata: {
__typename: 'Tool'
},
Expand All @@ -115,9 +118,11 @@ describe('DraftList', () => {
{
conceptId: 'TD1200000094-MMT_2',
revisionDate: '2023-10-08T17:56:09.385Z',
ummMetadata: {
Name: 'Tool TD1200000094 short name',
LongName: 'Tool TD1200000094 long name'
},
previewMetadata: {
name: 'Tool TD1200000094 short name',
longName: 'Tool TD1200000094 long name',
__typename: 'Tool'
},
__typename: 'Draft'
Expand Down
7 changes: 1 addition & 6 deletions static/src/js/operations/queries/getCollectionDrafts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ export const GET_COLLECTION_DRAFTS = gql`
items {
conceptId
revisionDate
previewMetadata {
... on Collection {
shortName
title
}
}
ummMetadata
}
}
}
Expand Down
1 change: 1 addition & 0 deletions static/src/js/operations/queries/getServiceDrafts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const GET_SERVICE_DRAFTS = gql`
items {
conceptId
revisionDate
ummMetadata
previewMetadata {
... on Service {
name
Expand Down
1 change: 1 addition & 0 deletions static/src/js/operations/queries/getToolDrafts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const GET_TOOL_DRAFTS = gql`
items {
conceptId
revisionDate
ummMetadata
previewMetadata {
... on Tool {
name
Expand Down
1 change: 1 addition & 0 deletions static/src/js/operations/queries/getVariableDrafts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const GET_VARIABLE_DRAFTS = gql`
items {
conceptId
revisionDate
ummMetadata
previewMetadata {
... on Variable {
name
Expand Down
48 changes: 24 additions & 24 deletions static/src/js/pages/ManagePage/ManagePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import './ManagePage.scss'

/**
* Renders a `ManagePage` component
*
* @component
* @example <caption>Renders a `ManagePage` component</caption>
* return (
Expand Down Expand Up @@ -120,30 +119,31 @@ const ManagePage = () => {
{
({
conceptId,
previewMetadata: {
longName,
name,
shortName,
title
},
ummMetadata,
revisionDate
}) => (
<ListGroup.Item key={conceptId} action className="mb-0">
<Link
className="text-decoration-none text-primary"
to={`/drafts/${type}/${conceptId}`}
>
<div>
<span className="text-black d-block d-xl-inline">{new Date(revisionDate).toLocaleString('en-US', { hour12: false })}</span>
<span className="d-none d-xl-inline"> | </span>
<span>{name || shortName || '<Blank Name>'}</span>
</div>
<div>
<span className="text-secondary">{longName || title || '<Untitled Record>'}</span>
</div>
</Link>
</ListGroup.Item>
)
}) => {
const {
ShortName, EntryTitle, Name, LongName
} = ummMetadata || {}

return (
<ListGroup.Item key={conceptId} action className="mb-0">
<Link
className="text-decoration-none text-primary"
to={`/drafts/${type}/${conceptId}`}
>
<div>
<span className="text-black d-block d-xl-inline">{new Date(revisionDate).toLocaleString('en-US', { hour12: false })}</span>
<span className="d-none d-xl-inline"> | </span>
<span>{Name || ShortName || '<Blank Name>'}</span>
</div>
<div>
<span className="text-secondary">{LongName || EntryTitle || '<Untitled Record>'}</span>
</div>
</Link>
</ListGroup.Item>
)
}
}
</For>
)
Expand Down
24 changes: 15 additions & 9 deletions static/src/js/pages/ManagePage/__tests__/ManagePage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,23 @@ const setup = (overrideMocks) => {
{
conceptId: 'TD1000000000-TESTPROV',
revisionDate: '2023-11-30 00:00:00',
ummMetadata: {
Name: 'Tool Draft 1 Name',
LongName: 'Tool Draft 1 Long Name'
},
previewMetadata: {
__typename: 'Tool',
name: 'Tool Draft 1 Name',
longName: 'Tool Draft 1 Long Name'
__typename: 'Tool'
}
},
{
conceptId: 'TD1000000001-TESTPROV',
revisionDate: '2023-11-30 00:00:00',
ummMetadata: {
Name: 'Tool Draft 2 Name',
LongName: 'Tool Draft 2 Long Name'
},
previewMetadata: {
__typename: 'Tool',
name: 'Tool Draft 2 Name',
longName: 'Tool Draft 2 Long Name'
__typename: 'Tool'
}
}
]
Expand Down Expand Up @@ -198,10 +202,12 @@ describe('ManagePage component', () => {
{
conceptId: 'TD1000000000-TESTPROV',
revisionDate: '2023-11-30 00:00:00',
ummMetadata: {
Name: null,
LongName: null
},
previewMetadata: {
__typename: 'Tool',
name: null,
longName: null
__typename: 'Tool'
}
}
]
Expand Down

0 comments on commit 18d0d12

Please sign in to comment.