-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Austenem/CAT-934 Update metadata sections (#3568)
* update combineMetadata param * add changelog * append hubmap IDs to duplicate sample categories * use metadata from provenance table * fix tab widths * update labels * separate entity sorting * add tests, move to utils file * clean up * update changelog * remove extra utils functions * lift helper function
- Loading branch information
Showing
13 changed files
with
350 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
- Switch to using metadata table with tabs component in the Sample and Donor pages. | ||
- In the metadata sections of Dataset, Sample, and Donor pages, add tabs for any entities in the Provenance section with metadata. | ||
- Update the metadata table component to show unique labels for each tab and to be scrollable when many tabs are present. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 0 additions & 79 deletions
79
context/app/static/js/components/detailPage/MetadataSection/MetadataTable.spec.ts
This file was deleted.
Oops, something went wrong.
145 changes: 145 additions & 0 deletions
145
context/app/static/js/components/detailPage/MetadataSection/utils.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
import { DonorIcon } from 'js/shared-styles/icons'; | ||
import { buildTableData, sortEntities, TableEntity } from './utils'; | ||
|
||
/** | ||
* ============================================================================= | ||
* buildTableData | ||
* ============================================================================= | ||
*/ | ||
|
||
test('should look up field descriptions', () => { | ||
expect( | ||
buildTableData( | ||
{ | ||
assay_type: 'FAKE-seq', | ||
}, | ||
{ | ||
assay_type: 'The specific type of assay being executed.', | ||
}, | ||
), | ||
).toEqual([ | ||
{ | ||
description: 'The specific type of assay being executed.', | ||
key: 'assay_type', | ||
value: 'FAKE-seq', | ||
}, | ||
]); | ||
}); | ||
|
||
test('should remove nested objects, but concat nested lists', () => { | ||
expect( | ||
buildTableData( | ||
{ | ||
object: { foo: 'bar' }, | ||
list: ['foo', 'bar'], | ||
}, | ||
{}, | ||
), | ||
).toEqual([ | ||
{ | ||
description: undefined, | ||
key: 'list', | ||
value: 'foo, bar', | ||
}, | ||
]); | ||
}); | ||
|
||
test('should remove keys that are not metadata', () => { | ||
expect( | ||
buildTableData( | ||
{ | ||
contributors_path: '/local/path', | ||
antibodies_path: '/local/path', | ||
version: '42', | ||
}, | ||
{}, | ||
), | ||
).toEqual([]); | ||
}); | ||
|
||
/** | ||
* ============================================================================= | ||
* sortEntities | ||
* ============================================================================= | ||
*/ | ||
|
||
const baseEntity = { | ||
icon: DonorIcon, | ||
tableRows: [], | ||
}; | ||
|
||
const current: TableEntity = { | ||
...baseEntity, | ||
uuid: 'current', | ||
label: 'Current', | ||
entity_type: 'Dataset', | ||
hubmap_id: 'current', | ||
}; | ||
|
||
const donor: TableEntity = { | ||
...baseEntity, | ||
uuid: 'donor', | ||
label: 'Donor', | ||
entity_type: 'Donor', | ||
hubmap_id: 'donor', | ||
}; | ||
|
||
const uniqueSample1: TableEntity = { | ||
...baseEntity, | ||
uuid: 'sample1', | ||
label: 'Unique Category', | ||
entity_type: 'Sample', | ||
hubmap_id: 'sample1', | ||
}; | ||
|
||
const duplicateSample2: TableEntity = { | ||
...baseEntity, | ||
uuid: 'sample2', | ||
label: 'Duplicate Category (sample2)', | ||
entity_type: 'Sample', | ||
hubmap_id: 'sample2', | ||
}; | ||
|
||
const duplicateSample3: TableEntity = { | ||
...baseEntity, | ||
uuid: 'sample3', | ||
label: 'Duplicate Category (sample3)', | ||
entity_type: 'Sample', | ||
hubmap_id: 'sample3', | ||
}; | ||
|
||
test('should sort by current -> donor -> samples without IDs in their label -> samples with IDs in their label', () => { | ||
expect( | ||
sortEntities({ | ||
tableEntities: [duplicateSample2, duplicateSample3, donor, current, uniqueSample1], | ||
uuid: 'current', | ||
}), | ||
).toEqual([current, donor, uniqueSample1, duplicateSample2, duplicateSample3]); | ||
}); | ||
|
||
test('should sort by current -> samples without IDs in their label -> samples with IDs in their label when donor is absent', () => { | ||
expect( | ||
sortEntities({ | ||
tableEntities: [duplicateSample2, current, uniqueSample1, duplicateSample3], | ||
uuid: 'current', | ||
}), | ||
).toEqual([current, uniqueSample1, duplicateSample2, duplicateSample3]); | ||
}); | ||
|
||
test('should sort by donor -> samples without IDs -> samples with IDs when current is absent', () => { | ||
expect( | ||
sortEntities({ | ||
tableEntities: [duplicateSample3, duplicateSample2, donor, uniqueSample1], | ||
uuid: 'current', | ||
}), | ||
).toEqual([donor, uniqueSample1, duplicateSample2, duplicateSample3]); | ||
}); | ||
|
||
test('should return only the current entity if no other entities are present', () => { | ||
expect( | ||
sortEntities({ | ||
tableEntities: [current], | ||
uuid: 'current', | ||
}), | ||
).toEqual([current]); | ||
}); |
Oops, something went wrong.