Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segment group batch actions #7164

Merged
merged 51 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
4e86f6d
start: change group color
dieknolle3333 Jun 20, 2023
b97c9d8
change group color
dieknolle3333 Jun 20, 2023
ea18ffd
[very broken] first implementation to hide/load all meshes of a segme…
dieknolle3333 Jun 20, 2023
98e458f
show/hide all msehes for group
dieknolle3333 Jun 23, 2023
071d0e1
add batch actions: download, show/hide, load meshes for segment group
dieknolle3333 Jun 25, 2023
d2d8861
fix code duplication and lint
dieknolle3333 Jun 26, 2023
e6ed640
add warning if position of segments in unknown
dieknolle3333 Jun 26, 2023
5472e53
push WIP before I leave
dieknolle3333 Jun 27, 2023
0a4c7d2
zip multiple meshes
dieknolle3333 Jun 27, 2023
31c3f87
undo zip.js upgrade
dieknolle3333 Jun 27, 2023
e829f1e
batch actions to set colour and remove and refresh meshes option
dieknolle3333 Jun 27, 2023
0f0f402
Merge branch 'master' into segment-group-batch-actions
dieknolle3333 Jun 27, 2023
c879a10
lint
dieknolle3333 Jun 27, 2023
e0440d3
remove TODOs
dieknolle3333 Jun 27, 2023
8cab227
add chagelog entry
dieknolle3333 Jun 27, 2023
ea8b1c9
refactor code
dieknolle3333 Jun 30, 2023
5944d85
WIP: start refactoring
dieknolle3333 Jun 30, 2023
8781956
WIP: add helper method
dieknolle3333 Jul 2, 2023
e809bca
WIP: address review
dieknolle3333 Jul 3, 2023
ca20df1
WIP: add lost method call
dieknolle3333 Jul 3, 2023
a4b89e2
WIP: trying to improve areSegmentsInGroupVisible
dieknolle3333 Jul 3, 2023
b5a2e99
WIP: fix getDerivedStateFromProps
dieknolle3333 Jul 4, 2023
9db1f1e
veryWIP: trying to fix tests by mocking zipjs
dieknolle3333 Jul 4, 2023
6c7bedd
WIP: trying to fix tests
dieknolle3333 Jul 7, 2023
cc866f5
WIP: fix small typo
dieknolle3333 Jul 7, 2023
c8ca503
fix merge conflicts
dieknolle3333 Jul 7, 2023
180bddb
WIP: trying to fix tests again
dieknolle3333 Jul 10, 2023
b9a11ed
WIP: trying to fix tests again
dieknolle3333 Jul 10, 2023
4939928
WIP: trying to fix tests (I really hope its the last time)
dieknolle3333 Jul 10, 2023
5f872b1
fix comment
dieknolle3333 Jul 10, 2023
ecdf655
change order of menu items
dieknolle3333 Jul 10, 2023
fc65635
Merge branch 'master' into segment-group-batch-actions
dieknolle3333 Jul 10, 2023
f3156ea
WIP: address PR review
dieknolle3333 Jul 11, 2023
1198f1d
WIP: address refactoring
dieknolle3333 Jul 12, 2023
9c1c06f
WIP: change icons
dieknolle3333 Jul 14, 2023
cdf453a
address review and lint
dieknolle3333 Jul 14, 2023
2803c61
merge master
dieknolle3333 Jul 14, 2023
76a09af
fix capitalization
dieknolle3333 Jul 14, 2023
720e052
fix spacing
dieknolle3333 Jul 14, 2023
bb1e286
fx method name
dieknolle3333 Jul 14, 2023
3baa2aa
fix icon spacing
dieknolle3333 Jul 17, 2023
caa361a
Merge branch 'master' into segment-group-batch-actions
dieknolle3333 Jul 17, 2023
a78963f
improve typing
philippotto Jul 17, 2023
bebb08f
Merge branch 'segment-group-batch-actions' of github.com:scalablemind…
philippotto Jul 17, 2023
a4dd2cd
WIP: fix spacing of font awesome icons and fix linting
dieknolle3333 Jul 17, 2023
e3892db
Merge branch 'segment-group-batch-actions' of github.com:scalablemind…
dieknolle3333 Jul 17, 2023
4d35fca
address review
dieknolle3333 Jul 17, 2023
eef4546
remove TODO comment and improve naming
dieknolle3333 Jul 18, 2023
414455e
Merge branch 'master' into segment-group-batch-actions
dieknolle3333 Jul 18, 2023
41034cc
merge master
dieknolle3333 Jul 18, 2023
eddc45e
merge master
dieknolle3333 Jul 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions frontend/javascripts/libs/zipjs_wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ import * as ZipType from "@zip.js/zip.js";

class TransFormStream {}

let mockedWindow = false;

// Mock zip.js and TransformStream during tests
if (!global.window) {
// @ts-expect-error
global.TransformStream = TransFormStream;
mockedWindow = true;
}

const Zip = require("@zip.js/zip.js") as typeof ZipType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import {
SettingOutlined,
ExclamationCircleOutlined,
ArrowRightOutlined,
CloudDownloadOutlined,
DownloadOutlined,
SearchOutlined,
EyeInvisibleOutlined,
EyeOutlined,
DatabaseOutlined,
} from "@ant-design/icons";
import type RcTree from "rc-tree";
import { getJobs, startComputeMeshFileJob } from "admin/admin_rest_api";
Expand Down Expand Up @@ -420,23 +418,23 @@ class SegmentsView extends React.Component<Props, State> {
};
}
if (prevState.prevProps?.isosurfaces !== isosurfaces) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I understand the reason for this code. Can you elaborate please. How can I test this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code makes sure that changing the visibility of a mesh (e.g. by clicking the checkbox) gets noticed by the segments_view as the visibility is part of the isosurface.
This is needed because I toggle the "Hide/Show meshes" option based on the mesh visibility in the group.
You can test it by loading all meshes in a group. Now, the context menu should say "Hide...". If you deselect any mesh's visibility checkbox, the context menu notices and will then read "Show all meshes".
Does that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also see philipps comment for this: #7164 (review)

//if any segment is invisible, set visibility false, so that the first action is to make all meshes visible
// Derive the areSegmentsInGroupVisible state so that we know per group
// if it contains only visible elements. This is used to know whether "Show meshes" or
// "Hide meshes" context item should be shown.
// If any segment is invisible, set the visibility of the group to false, so that the preferred
// action is to make all meshes visible.
const newVisibleMap: { [groupId: number]: boolean } = {};
const segmentGroupsWithRoot = [...segmentGroups, rootGroup];
segmentGroupsWithRoot.forEach((group) => {
let isVisible = true;
const segmentsOfGroup = groupToSegmentsMap[group.groupId];
if (segmentsOfGroup == null) return;
const visibilityOfSegments: number[] = segmentsOfGroup.map((segment) => {
const isSomeSegmentLoadedAndInvisible = segmentsOfGroup.some((segment) => {
const segmentIsosurface = isosurfaces[segment.id];
if (segmentIsosurface == null) return 1; //only care about explicitly invisible (not unloaded) meshes
return isosurfaces[segment.id].isVisible ? 1 : 0;
// Only regard loaded, but invisible meshes
return segmentIsosurface != null && !isosurfaces[segment.id].isVisible;
});
if (_.sum(visibilityOfSegments) < segmentsOfGroup.length) {
//at least one is invisible, so first option is to make every mesh visible
isVisible = false;
}
newVisibleMap[group.groupId] = isVisible;

newVisibleMap[group.groupId] = !isSomeSegmentLoadedAndInvisible;
});
return {
...updateStateObject, //may be null
Expand Down Expand Up @@ -1098,41 +1096,21 @@ class SegmentsView extends React.Component<Props, State> {
Store.dispatch(updateIsosurfaceVisibilityAction(layerName, segment.id, isVisible));
}
});

const newSegmentsInGroupVisible = {
...this.state.areSegmentsInGroupVisible,
[groupId]: isVisible,
};
this.setState({
areSegmentsInGroupVisible: newSegmentsInGroupVisible,
});
};

handleLoadMeshesAdHoc = (groupId: number) => {
this.handlePerSegment(groupId, (segment) => {
if (segment.somePosition == null) return;
this.props.loadAdHocMesh(segment.id, segment.somePosition);
});

const newSegmentsInGroupVisible = {
...this.state.areSegmentsInGroupVisible,
[groupId]: true,
};
this.setState({
areSegmentsInGroupVisible: newSegmentsInGroupVisible,
});
};

getSegmentsWithMissingLocation = (groupId: number): number[] => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd replace Location with Position here to keep it consistent with the somePosition attribute.

const segmentGroup = this.getSegmentsOfGroup(groupId);
if (segmentGroup == null) return [];
let segmentsWithoutPosition: number[] = segmentGroup.reduce(
(segmentsWithoutPositionAcc: number[], segment: Segment) => {
segment.somePosition == null && segmentsWithoutPositionAcc.push(segment.id);
return segmentsWithoutPositionAcc;
},
[],
);
let segmentsWithoutPosition: number[] = segmentGroup
.filter((segment) => segment.somePosition == null)
.map((segment) => segment.id);
return segmentsWithoutPosition.sort();
};

Expand All @@ -1153,14 +1131,6 @@ class SegmentsView extends React.Component<Props, State> {
this.props.currentMeshFile.meshFileName,
);
});

const newSegmentsInGroupVisible = {
...this.state.areSegmentsInGroupVisible,
[groupId]: true,
};
this.setState({
areSegmentsInGroupVisible: newSegmentsInGroupVisible,
});
};

downloadAllMeshesForGroup = (groupId: number) => {
Expand Down Expand Up @@ -1442,8 +1412,7 @@ class SegmentsView extends React.Component<Props, State> {
// does not work properly. See https://github.com/react-component/trigger/issues/106#issuecomment-948532990
// @ts-expect-error ts-migrate(2322) FIXME: Type '{ children: Element; overlay: () => Element;... Remove this comment to see the full error message
autoDestroy
open
/* open={this.state.activeDropdownSegmentOrGroupId === id} */ // explicit visibility handling is required here otherwise the color picker component for "Change Group color" is rendered/positioned incorrectly
open={this.state.activeDropdownSegmentOrGroupId === id} // explicit visibility handling is required here otherwise the color picker component for "Change Group color" is rendered/positioned incorrectly
onOpenChange={(isVisible) =>
this.handleSegmentDropdownMenuVisibility(id, isVisible)
}
Expand Down