Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
bchu1 committed Jan 30, 2025
1 parent 27dd1e2 commit a5c013b
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { useI18n } from 'app/hooks/useI18n'
import { useSelectedAnnotationShape } from 'app/state/annotation'

export function AnnotationConfidenceTable() {
const { activeAnnotation: annotation } = useSelectedAnnotationShape()
const { selectedAnnotationShape } = useSelectedAnnotationShape()
const { t } = useI18n()

if (!annotation) {
if (!selectedAnnotationShape) {
return null
}

const isGroundTruth = annotation.ground_truth_status
const isGroundTruth = selectedAnnotationShape.annotation?.groundTruthStatus

return (
<AccordionMetadataTable
Expand All @@ -26,7 +26,7 @@ export function AnnotationConfidenceTable() {
values: [
isGroundTruth
? t('notApplicable')
: annotation.ground_truth_used ?? '--',
: selectedAnnotationShape.annotation?.groundTruthUsed ?? '--',
],
className: 'text-sds-color-primitive-gray-500',
},
Expand All @@ -35,7 +35,7 @@ export function AnnotationConfidenceTable() {
values: [
isGroundTruth
? t('notApplicable')
: annotation.confidence_precision ?? '--',
: selectedAnnotationShape.annotation?.confidenceRecall ?? '--',
],
className: 'text-sds-color-primitive-gray-500',
},
Expand All @@ -44,7 +44,7 @@ export function AnnotationConfidenceTable() {
values: [
isGroundTruth
? t('notApplicable')
: annotation.confidence_recall ?? '--',
: selectedAnnotationShape.annotation?.confidenceRecall ?? '--',
],
className: 'text-sds-color-primitive-gray-500',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ import { IdPrefix } from 'app/constants/idPrefixes'
import { MetadataDrawerId } from 'app/hooks/useMetadataDrawer'
import { i18n } from 'app/i18n'
import { useSelectedAnnotationShape } from 'app/state/annotation'
import { getAnnotationTitle } from 'app/utils/annotation'

import { AnnotationConfidenceTable } from './AnnotationConfidenceTable'
import { AnnotationObjectTable } from './AnnotationObjectTable/AnnotationObjectTable'
import { AnnotationOverviewTable } from './AnnotationOveriewTable'

export function AnnotationDrawer() {
const { activeAnnotation, setActiveAnnotation } = useSelectedAnnotationShape()
const { selectedAnnotationShape, setSelectedAnnotationShape } =
useSelectedAnnotationShape()

return (
<MetadataDrawer
disabled={!activeAnnotation}
disabled={!selectedAnnotationShape}
drawerId={MetadataDrawerId.Annotation}
label={i18n.annotationDetails}
title={getAnnotationTitle(activeAnnotation)}
title={`${selectedAnnotationShape?.id} - ${selectedAnnotationShape?.annotation?.objectName}`}
idInfo={{
label: 'annotationId',
text: `${IdPrefix.Annotation}-${activeAnnotation?.id}`,
text: `${IdPrefix.Annotation}-${selectedAnnotationShape?.annotation?.id}`,
}}
onClose={() => setActiveAnnotation(null)}
onClose={() => setSelectedAnnotationShape(null)}
>
<AnnotationOverviewTable />
<AnnotationObjectTable />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,54 @@
import { AccordionMetadataTable } from 'app/components/AccordionMetadataTable'
import { shapeTypeToI18nKey } from 'app/constants/objectShapeTypes'
import { SHAPE_TYPE_TO_I18N_KEY } from 'app/constants/objectShapeTypes'
import { useI18n } from 'app/hooks/useI18n'
import { useSelectedAnnotationShape } from 'app/state/annotation'
import { ObjectShapeType } from 'app/types/shapeTypes'
import { getTableData } from 'app/utils/table'

import { ObjectIdLink } from './components/ObjectIdLink'

export function AnnotationObjectTable() {
const { t } = useI18n()
const { activeAnnotation: annotation } = useSelectedAnnotationShape()
const { selectedAnnotationShape } = useSelectedAnnotationShape()

if (!annotation) {
if (!selectedAnnotationShape) {
return null
}

const annotationObject = getTableData(
{
label: t('objectName'),
values: [annotation.object_name],
values: [selectedAnnotationShape.annotation?.objectName ?? '--'],
},
{
label: t('objectId'),
renderValue: () => {
return <ObjectIdLink id={annotation.object_id} />
return (
<ObjectIdLink
id={selectedAnnotationShape.annotation?.objectId ?? ''}
/>
)
},
values: [],
},
{
label: t('objectCount'),
values: [String(annotation.object_count)],
values: [String(selectedAnnotationShape.annotation?.objectCount)],
},
{
label: t('objectShapeType'),
values: [t(shapeTypeToI18nKey[annotation.shape_type as ObjectShapeType])],
values: [
selectedAnnotationShape.shapeType != null
? t(SHAPE_TYPE_TO_I18N_KEY[selectedAnnotationShape.shapeType])
: '--',
],
},
{
label: t('objectState'),
values: [annotation.object_state ?? '--'],
values: [selectedAnnotationShape.annotation?.objectState ?? '--'],
},
{
label: t('objectDescription'),
values: [annotation.object_description ?? '--'],
values: [selectedAnnotationShape.annotation?.objectDescription ?? '--'],
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ import { IdPrefix } from 'app/constants/idPrefixes'
import { useI18n } from 'app/hooks/useI18n'
import { useRunById } from 'app/hooks/useRunById'
import { useSelectedAnnotationShape } from 'app/state/annotation'
import { useFeatureFlag } from 'app/utils/featureFlags'

import { I18n } from '../I18n'
import { Tooltip } from '../Tooltip'

export function AnnotationOverviewTable() {
const { selectedAnnotationShape } = useSelectedAnnotationShape()
const { t } = useI18n()
const isDepositionsEnabled = useFeatureFlag('depositions')

const methodLinks = useMemo(
() =>
Expand Down Expand Up @@ -75,8 +73,7 @@ export function AnnotationOverviewTable() {
],
},

...(isDepositionsEnabled &&
selectedAnnotationShape.annotation?.deposition
...(selectedAnnotationShape.annotation?.deposition
? [
{
label: t('depositionName'),
Expand All @@ -101,16 +98,24 @@ export function AnnotationOverviewTable() {

{
label: t('depositionDate'),
values: [selectedAnnotationShape.annotation?.depositionDate ?? '--'],
values: [
selectedAnnotationShape.annotation?.depositionDate.split('T')[0] ??
'--',
],
},
{
label: t('releaseDate'),
values: [selectedAnnotationShape.annotation?.releaseDate ?? '--'],
values: [
selectedAnnotationShape.annotation?.releaseDate.split('T')[0] ??
'--',
],
},
{
label: t('lastModifiedDate'),
values: [
selectedAnnotationShape.annotation?.lastModifiedDate ?? '--',
selectedAnnotationShape.annotation?.lastModifiedDate.split(
'T',
)[0] ?? '--',
],
},
{
Expand Down Expand Up @@ -140,45 +145,42 @@ export function AnnotationOverviewTable() {
},
{
label: t('annotationMethod'),
values: [selectedAnnotationShape.annotation?.annotationMethod],
values: [
selectedAnnotationShape.annotation?.annotationMethod ?? '--',
],
},
{
label: t('annotationSoftware'),
values: [
selectedAnnotationShape.annotation?.annotationSoftware ?? '--',
],
},

...(isDepositionsEnabled
? [
{
label: t('methodLinks'),
// No value required for this field, render only links component
values: [''],
renderValue: () =>
methodLinks.length > 0 ? (
<ul>
{methodLinks.map((link) => (
<li key={`${link.url}_${link.i18nLabel}_${link.title}`}>
<MethodLink
{...link}
className="text-sds-header-s leading-sds-header-s whitespace-nowrap overflow-hidden text-ellipsis"
linkProps={{
className:
'text-sds-color-primitive-blue-400 overflow-hidden text-ellipsis',
}}
/>
</li>
))}
</ul>
) : (
<p className="text-sds-body-s leading-sds-body-s text-sds-color-primitive-gray-500">
{t('notSubmitted')}
</p>
),
},
]
: []),
{
label: t('methodLinks'),
// No value required for this field, render only links component
values: [''],
renderValue: () =>
methodLinks.length > 0 ? (
<ul>
{methodLinks.map((link) => (
<li key={`${link.url}_${link.i18nLabel}_${link.title}`}>
<MethodLink
{...link}
className="text-sds-header-s leading-sds-header-s whitespace-nowrap overflow-hidden text-ellipsis"
linkProps={{
className:
'text-sds-color-primitive-blue-400 overflow-hidden text-ellipsis',
}}
/>
</li>
))}
</ul>
) : (
<p className="text-sds-body-s leading-sds-body-s text-sds-color-primitive-gray-500">
{t('notSubmitted')}
</p>
),
},
]}
/>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export function AnnotationTable() {
{t('annotationId')}: {IdPrefix.Annotation}-
</span>
<span data-testid={TestIds.AnnotationId}>
{annotationShape.id}
{annotationShape.annotation?.id}
</span>
</p>

Expand Down Expand Up @@ -240,7 +240,7 @@ export function AnnotationTable() {
cell: ({ getValue }) => (
<TableCell width={AnnotationTableWidths.depositionDate}>
<div className="line-clamp-2 text-ellipsis capitalize">
{getValue()}
{getValue().split('T')[0]}
</div>
</TableCell>
),
Expand Down
13 changes: 13 additions & 0 deletions frontend/packages/data-portal/app/constants/objectShapeTypes.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import { Annotation_File_Shape_Type_Enum } from 'app/__generated_v2__/graphql'
import { I18nKeys } from 'app/types/i18n'
import { ObjectShapeType } from 'app/types/shapeTypes'

type ShapeTypeToI18nKeyMap = { [key in ObjectShapeType]: I18nKeys }

/** @deprecated */
export const shapeTypeToI18nKey = {
InstanceSegmentation: 'instanceSegmentation',
OrientedPoint: 'orientedPoint',
Point: 'point',
SegmentationMask: 'segmentationMask',
} as const satisfies ShapeTypeToI18nKeyMap

export const SHAPE_TYPE_TO_I18N_KEY: Record<
Annotation_File_Shape_Type_Enum,
I18nKeys
> = {
InstanceSegmentation: 'instanceSegmentation',
OrientedPoint: 'orientedPoint',
Point: 'point',
SegmentationMask: 'segmentationMask',
Mesh: 'mesh',
}
11 changes: 0 additions & 11 deletions frontend/packages/data-portal/app/utils/annotation.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@
"limitOneValuePerField": "Limit one value per field",
"manual": "Manual",
"meetsAll": "Meets all",
"mesh": "Mesh",
"meshes": "Meshes",
"metadata": "Metadata",
"methodCount": "Method {{ value }}",
Expand Down

0 comments on commit a5c013b

Please sign in to comment.