Skip to content

Commit

Permalink
PORTALS-2750: add special renderer for Dataset Collection datasetSize…
Browse files Browse the repository at this point in the history
…InBytes
  • Loading branch information
jay-hodgson committed Jul 25, 2023
1 parent 501457d commit c94e0f0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ export const datasetCardConfiguration: CardConfiguration = {
title: 'title',
description: 'description',
secondaryLabels: [
// 'assay',
'doi',
'datasetSizeInBytes',
'diseaseFocus',
'fundingAgency',
'datasetItemCount',
'dataType',
'series',
'yearProcessed',
'datasetSizeInBytes',
],
},
titleLinkConfig: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { isEmpty } from 'lodash-es'
import React from 'react'
import { SynapseConstants } from '../../utils'
import { isTableEntity } from '../../utils/functions/EntityTypeUtils'
import {
isDatasetCollection,
isTableEntity,
} from '../../utils/functions/EntityTypeUtils'
import { PRODUCTION_ENDPOINT_CONFIG } from '../../utils/functions/getEndpoint'
import {
DOI_REGEX,
Expand Down Expand Up @@ -40,6 +43,7 @@ import { FileHandleLink } from '../widgets/FileHandleLink'
import { ImageFileHandle } from '../widgets/ImageFileHandle'
import { QueryVisualizationContextType } from '../QueryVisualizationWrapper'
import { IconOptions } from '../Icon/Icon'
import { calculateFriendlyFileSize } from '../../utils/functions/calculateFriendlyFileSize'

export type KeyToAlias = {
key: string
Expand Down Expand Up @@ -688,8 +692,15 @@ export default class GenericCard extends React.Component<
let value: any = data[schema[columnName]]
let columnDisplayName
if (value) {
// SWC-6115: special rendering of the version column (for Views)
if (isView && columnName === 'currentVersion') {
// PORTALS-2750: special rendering of the datasetSizeInBytes (for Dataset Collections)
if (
isDatasetCollection(table as Entity) &&
columnName === 'datasetSizeInBytes'
) {
columnDisplayName = 'Size'
value = calculateFriendlyFileSize(parseInt(value))
} // SWC-6115: special rendering of the version column (for Views)
else if (isView && columnName === 'currentVersion') {
const synapseId = data[schema.id]
const version = value
value = VersionLabel({ synapseId, version })
Expand Down

0 comments on commit c94e0f0

Please sign in to comment.