Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
79b3438
add button to select all trees that match a search
knollengewaechs Oct 14, 2024
e71449d
add function for segments and improve icon
knollengewaechs Oct 16, 2024
7fcca34
remove console log
knollengewaechs Oct 17, 2024
27e841e
Merge branch 'master' into select-all-matching-trees
knollengewaechs Oct 17, 2024
a9ad926
add ts-expect-error tag again
knollengewaechs Oct 17, 2024
526fcc9
Merge branch 'master' into select-all-matching-trees
knollengewaechs Oct 17, 2024
fa56c82
Merge branch 'master' into select-all-matching-trees
knollengewaechs Oct 18, 2024
84301eb
focus first search result and only allow select all matches for leaves
knollengewaechs Oct 18, 2024
9d48473
fix select segment group as search result
knollengewaechs Oct 18, 2024
46c40d9
Merge branch 'master' into select-all-matching-trees
knollengewaechs Oct 21, 2024
c5c32aa
expand parent groups and fix mixed tree and tree group selection
knollengewaechs Oct 21, 2024
b7f484a
changelog
knollengewaechs Oct 21, 2024
304a63a
merge master
knollengewaechs Oct 21, 2024
3c89ebe
lint
knollengewaechs Oct 21, 2024
9d829da
address review
knollengewaechs Oct 24, 2024
0f7c1b7
Merge branch 'master' into select-all-matching-trees
knollengewaechs Oct 24, 2024
a64028b
add placeholder and disable field if all matches all selected
knollengewaechs Oct 25, 2024
13b01f4
Merge branch 'master' into select-all-matching-trees
knollengewaechs Oct 28, 2024
52ef6b4
fix case where group is selected
knollengewaechs Oct 28, 2024
dacdfc3
Merge branch 'master' into select-all-matching-trees
MichaelBuessemeyer Oct 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import Shortcut from "libs/shortcut_component";
import DomVisibilityObserver from "oxalis/view/components/dom_visibility_observer";
import { mod } from "libs/utils";

const PRIMARY_COLOR = "var(--ant-color-primary)";
Copy link
Contributor

Choose a reason for hiding this comment

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

Uh nice 🎉, this made me come up with the following possible refactoring: #8150

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I LOVE THE IDEA, THANK YOU 🙌


type Props<S> = {
data: S[];
searchKey: keyof S | ((item: S) => string);
Expand All @@ -21,6 +23,7 @@ type State = {
isVisible: boolean;
searchQuery: string;
currentPosition: number | null | undefined;
areAllMatchesSelected: boolean;
};

export default class AdvancedSearchPopover<
Expand All @@ -30,6 +33,7 @@ export default class AdvancedSearchPopover<
isVisible: false,
searchQuery: "",
currentPosition: null,
areAllMatchesSelected: false,
};

getAvailableOptions = memoizeOne(
Expand Down Expand Up @@ -70,6 +74,7 @@ export default class AdvancedSearchPopover<
currentPosition = mod(currentPosition + offset, numberOfAvailableOptions);
this.setState({
currentPosition,
areAllMatchesSelected: false,
});
this.props.onSelect(availableOptions[currentPosition]);
};
Expand Down Expand Up @@ -102,7 +107,7 @@ export default class AdvancedSearchPopover<

render() {
const { data, searchKey, provideShortcut, children, targetId } = this.props;
const { searchQuery, isVisible } = this.state;
const { searchQuery, isVisible, areAllMatchesSelected } = this.state;
let { currentPosition } = this.state;
const availableOptions = this.getAvailableOptions(data, searchQuery, searchKey);
const numberOfAvailableOptions = availableOptions.length;
Expand All @@ -120,6 +125,7 @@ export default class AdvancedSearchPopover<
color: "red",
}
: {};
const selectAllMatchesButtonColor = areAllMatchesSelected ? PRIMARY_COLOR : undefined;
return (
<React.Fragment>
{provideShortcut ? (
Expand Down Expand Up @@ -175,9 +181,16 @@ export default class AdvancedSearchPopover<
this.setState({
searchQuery: evt.target.value,
currentPosition: null,
areAllMatchesSelected: false,
})
}
addonAfter={`${currentPosition + 1}/${numberOfAvailableOptions}`}
addonAfter={
<div style={{ minWidth: 25 }}>
{!areAllMatchesSelected
? `${currentPosition + 1}/${numberOfAvailableOptions}`
: ""}
</div>
}
ref={this.autoFocus}
autoFocus
/>
Expand Down Expand Up @@ -207,10 +220,16 @@ export default class AdvancedSearchPopover<
<ButtonComponent
style={{
width: 40,
color: selectAllMatchesButtonColor,
borderColor: selectAllMatchesButtonColor,
}}
onClick={
this.props.onSelectAllMatches != null
? () => this.props.onSelectAllMatches!(availableOptionsToSelectAllMatches)
? () => {
this.props.onSelectAllMatches!(availableOptionsToSelectAllMatches);
if (!areAllMatchesSelected)
this.setState({ areAllMatchesSelected: true });
}
: undefined
}
disabled={isSelectAllMatchesDisabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ import { SegmentStatisticsModal } from "./segment_statistics_modal";
import type { ItemType } from "antd/lib/menu/interface";
import { InputWithUpdateOnBlur } from "oxalis/view/components/input_with_update_on_blur";

const SCROLL_DELAY_MS = 50;

const { confirm } = Modal;
const { Option } = Select;
// Interval in ms to check for running mesh file computation jobs for this dataset
Expand Down Expand Up @@ -1613,7 +1615,7 @@ class SegmentsView extends React.Component<Props, State> {
// As parent groups might still need to expand, we need to wait for this to finish.
setTimeout(() => {
if (this.tree.current) this.tree.current.scrollTo({ key: selectedElement.key });
}, 50);
}, SCROLL_DELAY_MS);
const isASegment = "color" in selectedElement;
if (isASegment) {
this.onSelectSegment(selectedElement);
Expand Down Expand Up @@ -1642,7 +1644,9 @@ class SegmentsView extends React.Component<Props, State> {
this.props.visibleSegmentationLayer.name,
),
);
this.tree.current?.scrollTo({ key: allMatches[0].key });
setTimeout(() => {
this.tree.current?.scrollTo({ key: allMatches[0].key });
}, SCROLL_DELAY_MS);
};

getSegmentStatisticsModal = (groupId: number) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,14 @@ function TreeHierarchyView(props: Props) {
const checkedKeys = deepFlatFilter(UITreeData, (node) => node.isChecked).map((node) => node.key);

// selectedKeys is mainly used for highlighting, i.e. blueish background color
let selectedKeys = props.selectedTreeIds.map((treeId) => getNodeKey(GroupTypeEnum.TREE, treeId));
const selectedKeys = props.activeGroupId
? [getNodeKey(GroupTypeEnum.GROUP, props.activeGroupId)]
: props.selectedTreeIds.map((treeId) => getNodeKey(GroupTypeEnum.TREE, treeId));

if (props.activeGroupId) selectedKeys = [getNodeKey(GroupTypeEnum.GROUP, props.activeGroupId)];

treeRef.current?.scrollTo({ key: selectedKeys[0], align: "auto" });
useEffect(
() => treeRef.current?.scrollTo({ key: selectedKeys[0], align: "auto" }),
[selectedKeys[0]],
);

return (
<>
Expand Down