-
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.
- Create Volumetric Annotation
- Loading branch information
Showing
17 changed files
with
183 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 correct number of thumbnnails', 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} | ||
/> | ||
) | ||
} |
48 changes: 48 additions & 0 deletions
48
...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,48 @@ | ||
import asyncStates from '@zooniverse/async-states' | ||
import { lazy, Suspense } from 'react' | ||
import { withStores } from '@helpers' | ||
|
||
const VolumetricViewer = lazy(() => import('@zooniverse/subject-viewers/VolumetricViewer')) | ||
const DEFAULT_HANDLER = () => {} | ||
|
||
function storeMapper(classifierStore) { | ||
const { | ||
classifications: { addAnnotation }, | ||
workflowSteps: { activeStepTasks }, | ||
} = classifierStore | ||
|
||
const activeTask = (activeStepTasks && activeStepTasks.length > 0) | ||
? activeStepTasks[0] | ||
: null; | ||
|
||
return { | ||
activeTask, | ||
addAnnotation, | ||
} | ||
} | ||
|
||
function VolumetricViewerWrapper({ | ||
activeTask, | ||
addAnnotation = DEFAULT_HANDLER, | ||
loadingState = asyncStates.initialized, | ||
onError = DEFAULT_HANDLER, | ||
onReady = DEFAULT_HANDLER, | ||
subject, | ||
}) { | ||
function onAnnotationUpdate(annotations) { | ||
addAnnotation(activeTask, annotations) | ||
} | ||
|
||
return <Suspense fallback={<p>Suspense boundary</p>}> | ||
<VolumetricViewer | ||
loadingState={loadingState} | ||
onAnnotation={onAnnotationUpdate} | ||
onError={onError} | ||
onReady={onReady} | ||
subject={subject} | ||
/> | ||
</Suspense> | ||
} | ||
|
||
export default withStores(VolumetricViewerWrapper, storeMapper) | ||
export { 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.