From e5ad8698c37f41a283bdf7c79f9c0424a8cbccc9 Mon Sep 17 00:00:00 2001 From: Philipp Otto Date: Tue, 22 Jun 2021 17:29:07 +0200 Subject: [PATCH 1/3] fix undefined access on not-existing segmentation layer --- .../view/layouting/default_layout_configs.js | 2 +- .../javascripts/oxalis/view/node_context_menu.js | 4 +--- .../oxalis/view/right-menu/meshes_view.js | 16 ++++++++++------ .../oxalis/view/right-menu/meshes_view_helper.js | 5 ++++- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/frontend/javascripts/oxalis/view/layouting/default_layout_configs.js b/frontend/javascripts/oxalis/view/layouting/default_layout_configs.js index 3d7703660fa..2dd9e86cfaa 100644 --- a/frontend/javascripts/oxalis/view/layouting/default_layout_configs.js +++ b/frontend/javascripts/oxalis/view/layouting/default_layout_configs.js @@ -8,6 +8,7 @@ // @flow import _ from "lodash"; +import type { ExtractReturn } from "libs/type_helpers"; import { getIsInIframe } from "libs/utils"; import { navbarHeight } from "navbar"; import Constants, { @@ -298,7 +299,6 @@ export const resetDefaultLayouts = () => { getDefaultLayouts.cache.clear(); }; -type ExtractReturn = $Call<(() => T) => T, Fn>; type Layout = $Keys>; export const getCurrentDefaultLayoutConfig = () => { diff --git a/frontend/javascripts/oxalis/view/node_context_menu.js b/frontend/javascripts/oxalis/view/node_context_menu.js index 57d73afc40b..b8d049385e6 100644 --- a/frontend/javascripts/oxalis/view/node_context_menu.js +++ b/frontend/javascripts/oxalis/view/node_context_menu.js @@ -200,9 +200,7 @@ function NoNodeContextMenuOptions({ }: NoNodeContextMenuProps) { useEffect(() => { (async () => { - if (segmentationLayer) { - await maybeFetchMeshFiles(segmentationLayer, dataset, false); - } + await maybeFetchMeshFiles(segmentationLayer, dataset, false); })(); }, []); diff --git a/frontend/javascripts/oxalis/view/right-menu/meshes_view.js b/frontend/javascripts/oxalis/view/right-menu/meshes_view.js index 1e807ff01e3..197d2c82231 100644 --- a/frontend/javascripts/oxalis/view/right-menu/meshes_view.js +++ b/frontend/javascripts/oxalis/view/right-menu/meshes_view.js @@ -59,7 +59,7 @@ export const stlIsosurfaceConstants = { // This file defines the component MeshesView. -const mapStateToProps = (state: OxalisState) => ({ +const mapStateToProps = (state: OxalisState): * => ({ meshes: state.tracing != null ? state.tracing.meshes : [], isImporting: state.uiInformation.isImportingMesh, isosurfaces: state.isosurfaces, @@ -75,7 +75,7 @@ const mapStateToProps = (state: OxalisState) => ({ currentMeshFile: state.currentMeshFile, }); -const mapDispatchToProps = (dispatch: Dispatch<*>) => ({ +const mapDispatchToProps = (dispatch: Dispatch<*>): * => ({ updateRemoteMeshMetadata(id: string, meshMetaData: $Shape) { dispatch(updateRemoteMeshMetaDataAction(id, meshMetaData)); }, @@ -121,8 +121,9 @@ const mapDispatchToProps = (dispatch: Dispatch<*>) => ({ }); type DispatchProps = ExtractReturn; +type StateProps = ExtractReturn; -type Props = {| ...DispatchProps |}; +type Props = {| ...DispatchProps, ...StateProps |}; type State = { hoveredListItem: ?number }; @@ -257,6 +258,9 @@ class MeshesView extends React.Component { Toast.info("No cell found at centered position"); return; } + if (!this.props.currentMeshFile || !this.props.segmentationLayer) { + return; + } await loadMeshFromFile( id, pos, @@ -295,12 +299,12 @@ class MeshesView extends React.Component { ); const getLoadPrecomputedMeshButton = () => { - const hasCurrenMeshFile = this.props.currentMeshFile; + const hasCurrentMeshFile = this.props.currentMeshFile; return ( { overlay={getMeshFilesDropdown()} buttonsRender={([leftButton, rightButton]) => [ React.cloneElement(leftButton, { - disabled: !hasCurrenMeshFile, + disabled: !hasCurrentMeshFile, style: { borderRightStyle: "dashed" }, }), React.cloneElement(rightButton, { style: { borderLeftStyle: "dashed" } }), diff --git a/frontend/javascripts/oxalis/view/right-menu/meshes_view_helper.js b/frontend/javascripts/oxalis/view/right-menu/meshes_view_helper.js index 02cebf064ad..8f0e74e73c6 100644 --- a/frontend/javascripts/oxalis/view/right-menu/meshes_view_helper.js +++ b/frontend/javascripts/oxalis/view/right-menu/meshes_view_helper.js @@ -24,10 +24,13 @@ import processTaskWithPool from "libs/task_pool"; const PARALLEL_MESH_LOADING_COUNT = 6; export async function maybeFetchMeshFiles( - segmentationLayer: APIDataLayer, + segmentationLayer: ?APIDataLayer, dataset: APIDataset, mustRequest: boolean, ): Promise { + if (!segmentationLayer) { + return; + } const files = Store.getState().availableMeshFiles; // only send new get request, if it hasn't happened before (files in store are null) From 640a2aa2c20fca254335b04991c08d79ab57f391 Mon Sep 17 00:00:00 2001 From: Philipp Otto Date: Tue, 22 Jun 2021 17:36:59 +0200 Subject: [PATCH 2/3] update changelog --- CHANGELOG.unreleased.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 370f142ae8d..21e701be005 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -18,6 +18,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released ### Fixed - Fixed a bug where dataset uploads of zips with just one file inside failed. [#5534](https://github.com/scalableminds/webknossos/pull/5534) +- Fixed a benign error message when a dataset without a segmenatation layer was opened in view mode or with a skeleton-only annotation. [#5583](https://github.com/scalableminds/webknossos/pull/5583) ### Removed - From c030dc72d0fbabc056385f7ebc1c30f85d8af891 Mon Sep 17 00:00:00 2001 From: Philipp Otto Date: Thu, 24 Jun 2021 09:10:43 +0200 Subject: [PATCH 3/3] Update CHANGELOG.unreleased.md Co-authored-by: Daniel --- CHANGELOG.unreleased.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 21e701be005..6e6fe42d2c0 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -18,7 +18,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released ### Fixed - Fixed a bug where dataset uploads of zips with just one file inside failed. [#5534](https://github.com/scalableminds/webknossos/pull/5534) -- Fixed a benign error message when a dataset without a segmenatation layer was opened in view mode or with a skeleton-only annotation. [#5583](https://github.com/scalableminds/webknossos/pull/5583) +- Fixed a benign error message when a dataset without a segmentation layer was opened in view mode or with a skeleton-only annotation. [#5583](https://github.com/scalableminds/webknossos/pull/5583) ### Removed -