Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit 3a122f3

Browse files
juliosgarbibmartel
andauthored
fix: LSDV-4766: Toggle selected region visibility with hotkeys (#1338)
* fix: LSDV-4766: Toggle selected region visibility with hotkeys * fix ESLint problem * set back the toggle hidden button * make cypress tests sync for now while debuggin parallel problem with ffmpeg * testing parallel cypress with explicit binary location set * using patched version to fix parallel runner * using patched version to fix parallel runner * forgot to commit lock * moving back to original --------- Co-authored-by: Brandon Martel <[email protected]>
1 parent f44a935 commit 3a122f3

File tree

5 files changed

+128
-5
lines changed

5 files changed

+128
-5
lines changed

src/components/SidePanels/DetailsPanel/RegionItem.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ const RegionAction: FC<any> = observer(({
133133
<RegionActionButton
134134
icon={region.hidden ? <IconEyeClosed/> : <IconEyeOpened/>}
135135
onClick={region.toggleHidden}
136-
hotkey="region:visibility"
137136
/>
138137
<RegionActionButton
139138
danger

src/components/SidePanels/OutlinerPanel/ViewControls.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ export const ViewControls: FC<ViewControlsProps> = ({
7474
}
7575
}, []);
7676

77-
console.log('regions?.regions', regions?.regions);
78-
7977
return (
8078
<Block name="view-controls" mod={{ collapsed: context.locked }}>
8179
<Grouping

src/stores/Annotation/Annotation.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,12 @@ export const Annotation = types
367367
self.regionStore.clearSelection();
368368
},
369369

370+
hideSelectedRegions() {
371+
self.selectedRegions.forEach(region => {
372+
region.toggleHidden();
373+
});
374+
},
375+
370376
deleteSelectedRegions() {
371377
self.selectedRegions.forEach(region => {
372378
region.deleteRegion();

src/stores/AppStore.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,8 @@ export default types
381381
hotkeys.addNamed('region:visibility', function() {
382382
const c = self.annotationStore.selected;
383383

384-
if (c && c.highlightedNode && !c.relationMode) {
385-
c.highlightedNode.toggleHidden();
384+
if (c && !c.relationMode) {
385+
c.hideSelectedRegions();
386386
}
387387
});
388388

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import { ImageView, LabelStudio, Sidebar } from '@heartexlabs/ls-test/helpers/LSF';
2+
3+
const config = `
4+
<View>
5+
<Image name="img" value="$image"></Image>
6+
<RectangleLabels name="tag" toName="img">
7+
<Label value="Planet"></Label>
8+
<Label value="Moonwalker" background="blue"></Label>
9+
<Label value="Moonwalker 1" background="red"></Label>
10+
<Label value="Moonwalker 2" background="pink"></Label>
11+
<Label value="Moonwalker 3" background="yellow"></Label>
12+
</RectangleLabels>
13+
</View>
14+
`;
15+
16+
const image = 'https://htx-misc.s3.amazonaws.com/opensource/label-studio/examples/images/nick-owuor-astro-nic-visuals-wDifg5xc9Z4-unsplash.jpg';
17+
18+
const task = {
19+
id: 1,
20+
annotations: [{ id: 1001, result: [
21+
{
22+
id: 'Dx_aB91ISN',
23+
source: '$image',
24+
from_name: 'tag',
25+
to_name: 'img',
26+
type: 'rectanglelabels',
27+
origin: 'manual',
28+
value: {
29+
height: 10.458911419423693,
30+
rotation: 0,
31+
width: 12.4,
32+
x: 50.8,
33+
y: 5.869797225186766,
34+
rectanglelabels: ['Moonwalker'],
35+
},
36+
},
37+
{
38+
id: 'Dx_aB91INs',
39+
source: '$image',
40+
from_name: 'tag',
41+
to_name: 'img',
42+
type: 'rectanglelabels',
43+
origin: 'manual',
44+
value: {
45+
height: 10.458911419423693,
46+
rotation: 0,
47+
width: 12.4,
48+
x: 150.8,
49+
y: 15.866,
50+
rectanglelabels: ['Moonwalker 2'],
51+
},
52+
},
53+
{
54+
id: 'Dx_aB91ANs',
55+
source: '$image',
56+
from_name: 'tag',
57+
to_name: 'img',
58+
type: 'rectanglelabels',
59+
origin: 'manual',
60+
value: {
61+
height: 10.458911419423693,
62+
rotation: 0,
63+
width: 12.4,
64+
x: 150.8,
65+
y: 45.866,
66+
rectanglelabels: ['Moonwalker 3'],
67+
},
68+
},
69+
{
70+
id: 'Dx_aB19ISN',
71+
source: '$image',
72+
from_name: 'tag',
73+
to_name: 'img',
74+
type: 'rectanglelabels',
75+
origin: 'manual',
76+
value: {
77+
height: 10.458911419423693,
78+
rotation: 0,
79+
width: 12.4,
80+
x: 250.8,
81+
y: 15.866,
82+
rectanglelabels: ['Planet'],
83+
},
84+
},
85+
] }],
86+
predictions: [],
87+
data: { image },
88+
};
89+
90+
describe('Image Regions scenario', () => {
91+
it('should check that regions is hidden', () => {
92+
LabelStudio.init({
93+
config,
94+
task,
95+
});
96+
97+
ImageView.waitForImage();
98+
Sidebar.hasRegions(4);
99+
100+
const regions = Sidebar.regions;
101+
let hiddenRegions = 0;
102+
103+
regions.each(($el, index) => {
104+
if (index % 2)
105+
cy.get($el[0]).click({ multiple:true, ctrlKey: true });
106+
});
107+
108+
cy.get('body')
109+
.focus()
110+
.trigger('keydown', { altKey: true, keyCode: 72 });
111+
112+
regions.each(($el) => {
113+
if ($el.parent().hasClass('lsf-tree__node_hidden')) {
114+
hiddenRegions++;
115+
}
116+
}).then(() => {
117+
expect(hiddenRegions).to.be.eq(2);
118+
});
119+
});
120+
});

0 commit comments

Comments
 (0)