-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Migrate annotations table to V2 data (#1433)
* rebase * rebase
- Loading branch information
Showing
29 changed files
with
430 additions
and
347 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
57 changes: 20 additions & 37 deletions
57
frontend/packages/data-portal/app/components/Download/ConfigureAnnotationDownloadContent.tsx
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 |
---|---|---|
@@ -1,51 +1,34 @@ | ||
import { useMemo } from 'react' | ||
import { DeepPartial } from 'utility-types' | ||
|
||
import { AnnotationFileEdge } from 'app/__generated_v2__/graphql' | ||
import { useDownloadModalContext } from 'app/context/DownloadModal.context' | ||
import { useDownloadModalQueryParamState } from 'app/hooks/useDownloadModalQueryParamState' | ||
import { useRunById } from 'app/hooks/useRunById' | ||
|
||
import { AnnotationAlignmentCallout } from './AnnotationAlignmentCallout' | ||
import { FileFormatDropdown } from './FileFormatDropdown' | ||
|
||
export function ConfigureAnnotationDownloadContent() { | ||
const { objectShapeType, fileFormat } = useDownloadModalQueryParamState() | ||
const { annotationToDownload, allTomograms } = useDownloadModalContext() | ||
|
||
const fileFormats = useMemo<string[]>( | ||
() => | ||
annotationToDownload?.files | ||
.filter((annotation) => annotation.shape_type === objectShapeType) | ||
.map((annotation) => annotation.format) ?? [], | ||
[annotationToDownload?.files, objectShapeType], | ||
) | ||
|
||
const { annotationShapes } = useRunById() | ||
|
||
const isMatchingFormat = (file: DeepPartial<AnnotationFileEdge>) => | ||
file?.node?.format === fileFormat | ||
|
||
const alignmentId = | ||
annotationShapes | ||
.find( | ||
(shape) => | ||
shape.annotation?.id === annotationToDownload?.id && | ||
shape.shapeType === objectShapeType && | ||
shape.annotationFiles.edges.some(isMatchingFormat), | ||
) | ||
?.annotationFiles.edges.find(isMatchingFormat)?.node.alignmentId ?? 0 | ||
const { fileFormat } = useDownloadModalQueryParamState() | ||
const { annotationShapeToDownload, allTomograms } = useDownloadModalContext() | ||
|
||
const fileFormats = | ||
annotationShapeToDownload?.annotationFiles.edges.map( | ||
(file) => file.node.format, | ||
) ?? [] | ||
const annotationFileAlignmentId = | ||
annotationShapeToDownload?.annotationFiles.edges.find( | ||
(file) => file.node.format === fileFormat, | ||
)?.node.alignmentId ?? undefined | ||
|
||
return ( | ||
<> | ||
<FileFormatDropdown className="pt-sds-l" fileFormats={fileFormats} /> | ||
<AnnotationAlignmentCallout | ||
alignmentId={alignmentId} | ||
initialState="open" | ||
misalignedTomograms={(allTomograms ?? []).filter( | ||
(tomogram) => tomogram.alignment?.id !== alignmentId, | ||
)} | ||
/> | ||
{annotationFileAlignmentId !== undefined && ( | ||
<AnnotationAlignmentCallout | ||
alignmentId={annotationFileAlignmentId} | ||
initialState="open" | ||
misalignedTomograms={(allTomograms ?? []).filter( | ||
(tomogram) => tomogram.alignment?.id !== annotationFileAlignmentId, | ||
)} | ||
/> | ||
)} | ||
</> | ||
) | ||
} |
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
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
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
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
10 changes: 5 additions & 5 deletions
10
frontend/packages/data-portal/app/components/Filters/AnnotationObjectShapeTypeFilter.tsx
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
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
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
Oops, something went wrong.