Skip to content

Commit 24b6f2a

Browse files
frano-mFran McDade
andauthored
feat: add drs_uri for to the files tab (#3646) (#3661)
Co-authored-by: Fran McDade <[email protected]>
1 parent 18196cd commit 24b6f2a

File tree

6 files changed

+58
-5
lines changed

6 files changed

+58
-5
lines changed

explorer/app/apis/azul/anvil-cmg/common/entities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export interface FileEntity {
9090
data_modality: string[];
9191
date_created: string;
9292
document_id: string;
93+
drs_uri: string;
9394
file_format: string;
9495
file_id: string;
9596
file_name: string;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { CopyToClipboard as DXCopyToClipboard } from "@clevercanary/data-explorer-ui/lib/components/common/CopyToClipboard/copyToClipboard";
2+
import styled from "@emotion/styled";
3+
4+
export const Cell = styled("span")`
5+
overflow: hidden;
6+
text-overflow: ellipsis;
7+
white-space: nowrap;
8+
`;
9+
10+
export const CopyToClipboard = styled(DXCopyToClipboard)`
11+
bottom: 2px;
12+
margin-left: 4px;
13+
position: relative;
14+
`;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Cell, CopyToClipboard } from "./copyCell.styles";
2+
3+
interface CopyCellProps {
4+
value: string;
5+
}
6+
7+
export const CopyCell = ({ value }: CopyCellProps): JSX.Element => {
8+
return (
9+
<>
10+
<Cell>{value}</Cell>
11+
<CopyToClipboard copyStr={value} />
12+
</>
13+
);
14+
};

explorer/app/components/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,4 @@ export { FileLocationDownload } from "./Detail/components/GeneratedMatricesTable
7272
export { FileNameCell } from "./Detail/components/GeneratedMatricesTables/components/FileNameCell/fileNameCell";
7373
export { GeneratedMatricesTables } from "./Detail/components/GeneratedMatricesTables/generatedMatricesTables";
7474
export { ConsentCodesCell } from "./Index/components/ConsentCodesCell/consentCodesCell";
75+
export { CopyCell } from "./Index/components/CopyCell/copyCell";

explorer/app/viewModelBuilders/azul/anvil-cmg/common/viewModelBuilders.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,19 @@ export const buildDocumentId = (
375375
};
376376
};
377377

378+
/**
379+
* Build props for DRS URI CopyCell component from the given files response.
380+
* @param filesResponse - Response model return from index/files API endpoint.
381+
* @returns model to be used as props for the CopyCell component.
382+
*/
383+
export const buildDRSURI = (
384+
filesResponse: FilesResponse
385+
): React.ComponentProps<typeof C.CopyCell> => {
386+
return {
387+
value: processEntityValue(filesResponse.files, "drs_uri"),
388+
};
389+
};
390+
378391
/**
379392
* Build props for ExportCurrentQuery component.
380393
* @param _ - Unused.

explorer/site-config/anvil-cmg/dev/index/filesEntityConfig.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const filesEntityConfig: EntityConfig<FilesResponse> = {
4949
} as ComponentConfig<typeof C.Cell>,
5050
header: ANVIL_CMG_CATEGORY_LABEL.FILE_FILE_NAME,
5151
id: ANVIL_CMG_CATEGORY_KEY.FILE_FILE_NAME,
52-
width: { max: "1fr", min: "120px" },
52+
width: { max: "1fr", min: "240px" },
5353
},
5454
{
5555
componentConfig: {
@@ -58,7 +58,7 @@ export const filesEntityConfig: EntityConfig<FilesResponse> = {
5858
} as ComponentConfig<typeof C.Cell>,
5959
header: ANVIL_CMG_CATEGORY_LABEL.FILE_FILE_FORMAT, // "Format"
6060
id: ANVIL_CMG_CATEGORY_KEY.FILE_FILE_FORMAT,
61-
width: { max: "1fr", min: "120px" },
61+
width: { max: "auto", min: "120px" },
6262
},
6363
{
6464
componentConfig: {
@@ -67,6 +67,16 @@ export const filesEntityConfig: EntityConfig<FilesResponse> = {
6767
} as ComponentConfig<typeof C.Cell>,
6868
header: ANVIL_CMG_CATEGORY_LABEL.FILE_FILE_SIZE,
6969
id: ANVIL_CMG_CATEGORY_KEY.FILE_FILE_SIZE,
70+
width: { max: "auto", min: "120px" },
71+
},
72+
{
73+
componentConfig: {
74+
component: C.CopyCell,
75+
viewBuilder: V.buildDRSURI,
76+
} as ComponentConfig<typeof C.CopyCell>,
77+
disableSorting: true,
78+
header: "DRS URI",
79+
id: "drs_uri",
7080
width: { max: "1fr", min: "120px" },
7181
},
7282
{
@@ -76,7 +86,7 @@ export const filesEntityConfig: EntityConfig<FilesResponse> = {
7686
} as ComponentConfig<typeof C.NTagCell>,
7787
header: ANVIL_CMG_CATEGORY_LABEL.ACTIVITY_DATA_MODALITY,
7888
id: ANVIL_CMG_CATEGORY_KEY.ACTIVITY_DATA_MODALITY,
79-
width: { max: "1fr", min: "240px" },
89+
width: { max: "1fr", min: "140px" },
8090
},
8191
{
8292
componentConfig: {
@@ -85,7 +95,7 @@ export const filesEntityConfig: EntityConfig<FilesResponse> = {
8595
} as ComponentConfig<typeof C.NTagCell>,
8696
header: ANVIL_CMG_CATEGORY_LABEL.DONOR_ORGANISM_TYPE,
8797
id: ANVIL_CMG_CATEGORY_KEY.DONOR_ORGANISM_TYPE,
88-
width: { max: "1fr", min: "200px" },
98+
width: { max: "1fr", min: "140px" },
8999
},
90100
{
91101
columnVisible: false,
@@ -124,7 +134,7 @@ export const filesEntityConfig: EntityConfig<FilesResponse> = {
124134
} as ComponentConfig<typeof C.NTagCell>,
125135
header: ANVIL_CMG_CATEGORY_LABEL.DATASET_TITLE,
126136
id: ANVIL_CMG_CATEGORY_KEY.DATASET_TITLE,
127-
width: { max: "2fr", min: "240px" },
137+
width: { max: "1fr", min: "240px" },
128138
},
129139
],
130140
defaultSort: {

0 commit comments

Comments
 (0)