-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VV - Implement Classifier Annotation Model (#6568)
* Create Volumetric Annotation
- Loading branch information
Showing
17 changed files
with
170 additions
and
61 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
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
3 changes: 3 additions & 0 deletions
3
...nents/Classifier/components/SubjectViewer/components/VolumetricViewer/README.md
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 @@ | ||
# Volumetric Viewer | ||
|
||
Implementation of the `lib-subject-viewers/VolumetricViewer` component. |
9 changes: 9 additions & 0 deletions
9
.../Classifier/components/SubjectViewer/components/VolumetricViewer/VolumetricMockSubject.js
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,9 @@ | ||
export const VolumetricSubjectMock = { | ||
id: 'mockSubject', | ||
locations: [ | ||
{ | ||
'application/json': 'https://zooniverse.org/subject.json' | ||
}, | ||
], | ||
subjectJSON: 'GRnI+hnIr5bIr5Z9r5Z9+uHIr5bIr5Z9r5Z9ZJZ9ZEv6r5Z9r5Z9ZJZ9ZEt9ZEsyGZZ9GRl9ZEt9ZEsyGUsyGQ==' | ||
} |
19 changes: 19 additions & 0 deletions
19
.../Classifier/components/SubjectViewer/components/VolumetricViewer/VolumetricViewer.spec.js
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,19 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import { expect } from 'chai' | ||
import asyncStates from '@zooniverse/async-states' | ||
import VolumetricViewerWrapper from './VolumetricViewerWrapper' | ||
|
||
describe('Component > VolumetricViewer', function () { | ||
it('should render the Volumetric Viewer asynchronously', async function () { | ||
render(<VolumetricViewerWrapper | ||
subjectQueueState={asyncStates.success} | ||
subjectReadyState={asyncStates.success} | ||
subject={{ | ||
id: 'mock-id', | ||
subjectJSON: 'mock-subject-json' | ||
}} | ||
/>) | ||
expect(screen.getByText('Suspense boundary')).to.exist() | ||
expect(await screen.findByTestId('subject-viewer-volumetric')).to.exist() | ||
}) | ||
}) |
17 changes: 17 additions & 0 deletions
17
...assifier/components/SubjectViewer/components/VolumetricViewer/VolumetricViewer.stories.js
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,17 @@ | ||
import asyncStates from '@zooniverse/async-states' | ||
import { VolumetricViewerWrapper } from './VolumetricViewerWrapper' | ||
import { VolumetricSubjectMock } from './VolumetricMockSubject' | ||
|
||
export default { | ||
title: 'Subject Viewers / VolumetricViewer', | ||
component: VolumetricViewerWrapper | ||
} | ||
|
||
export function Default() { | ||
return ( | ||
<VolumetricViewerWrapper | ||
loadingState={asyncStates.success} | ||
subject={VolumetricSubjectMock} | ||
/> | ||
) | ||
} |
35 changes: 35 additions & 0 deletions
35
...lassifier/components/SubjectViewer/components/VolumetricViewer/VolumetricViewerWrapper.js
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,35 @@ | ||
import asyncStates from '@zooniverse/async-states' | ||
import { lazy, Suspense } from 'react' | ||
import { MobXProviderContext } from 'mobx-react' | ||
import { useContext } from 'react' | ||
|
||
const VolumetricViewer = lazy(() => import('@zooniverse/subject-viewers/VolumetricViewer')) | ||
const DEFAULT_HANDLER = () => {} | ||
|
||
function VolumetricViewerWrapper({ | ||
loadingState = asyncStates.initialized, | ||
onError = DEFAULT_HANDLER, | ||
onReady = DEFAULT_HANDLER, | ||
subject, | ||
}) { | ||
const stores = useContext(MobXProviderContext) | ||
const addAnnotation = stores?.classifierStore?.classifications?.addAnnotation ?? DEFAULT_HANDLER | ||
const activeStepTasks = stores?.classifierStore?.workflowSteps?.activeStepTasks ?? [] | ||
|
||
function onAnnotationUpdate(annotations) { | ||
if (activeStepTasks[0]) | ||
addAnnotation(activeStepTasks[0], annotations) | ||
} | ||
|
||
return <Suspense fallback={<p>Suspense boundary</p>}> | ||
<VolumetricViewer | ||
loadingState={loadingState} | ||
onAnnotation={onAnnotationUpdate} | ||
onError={onError} | ||
onReady={onReady} | ||
subject={subject} | ||
/> | ||
</Suspense> | ||
} | ||
|
||
export default VolumetricViewerWrapper |
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
14 changes: 13 additions & 1 deletion
14
...s/lib-classifier/src/plugins/tasks/experimental/volumetric/models/VolumetricAnnotation.js
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
Oops, something went wrong.