Skip to content

Commit

Permalink
fix: LEAP-872: LEAP-935: Auto-Annotation fixes (#5715)
Browse files Browse the repository at this point in the history
LEAP-872: Move the Auto-Accept checkbox to the bottom bar
LEAP-935: Fix Reject All button not working

Mirroring #5714

---------

Co-authored-by: Michael Malyuk <[email protected]>
Co-authored-by: robot-ci-heartex <[email protected]>
Co-authored-by: hlomzik <[email protected]>
  • Loading branch information
4 people authored Apr 16, 2024
1 parent 224b72e commit 91e2618
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 59 deletions.
2 changes: 1 addition & 1 deletion web/dist/libs/editor/main.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/dist/libs/editor/main.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/dist/libs/editor/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/dist/libs/editor/main.js.map

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions web/libs/editor/src/components/AnnotationTab/AutoAcceptToggle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { inject, observer } from 'mobx-react';

import { Block, Elem } from '../../utils/bem';
import { Button } from '../../common/Button/Button';
import { IconCheck, IconCross } from '../../assets/icons';
import { Space } from '../../common/Space/Space';
import Toggle from '../../common/Toggle/Toggle';

import './AutoAcceptToggle.styl';

const injector = inject(({ store }) => {
const annotation = store.annotationStore?.selected;
const suggestions = annotation?.suggestions;

return {
store,
annotation,
suggestions,
interfaces: Array.from(store?.interfaces),
};
});

export const AutoAcceptToggle = injector(observer(({
store,
annotation,
suggestions,
}) => {
if (!store.autoAnnotation) return null;

const withSuggestions = annotation.hasSuggestionsSupport && !store.forceAutoAcceptSuggestions;
const loading = store.awaitingSuggestions;

return (
<Block name="auto-accept">
{withSuggestions && (
<Elem name="wrapper" mod={{ loading }}>
<Space spread>
{suggestions.size > 0 ? (
<Space size="small">
<Elem name="info">
{suggestions.size} suggestion{suggestions.size > 0 && 's'}
</Elem>
<Elem name="action" tag={Button} mod={{ type: 'reject' }} onClick={() => annotation.rejectAllSuggestions()}>
<IconCross/>
</Elem>
<Elem name="action" tag={Button} mod={{ type: 'accept' }} onClick={() => annotation.acceptAllSuggestions()}>
<IconCheck/>
</Elem>
</Space>
) : (
<Toggle
checked={store.autoAcceptSuggestions}
onChange={(e) => store.setAutoAcceptSuggestions(e.target.checked)}
label="Auto-Accept Suggestions"
style={{ color: '#7F64FF' }}
/>
)}
</Space>
</Elem>
)}
{loading && <Elem name="spinner" />}
</Block>
);
}));
55 changes: 55 additions & 0 deletions web/libs/editor/src/components/AnnotationTab/AutoAcceptToggle.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
.auto-accept
height 44px
display flex
align-items center
box-sizing border-box
background-color #fff
margin-left: 16px;

&__wrapper
width 100%

&_loading
// toggle will not be disabled, because it's usable even when loading
opacity: 0.5;

&__info
font-size: 16px;

&__action
padding 0
margin 0
margin 2px
width 28px
height 28px
display flex
align-items center
justify-content center
border-radius 100%
color rgba(#000, 0.6)
background-color rgba(#000, 0.1)

&_type
&_accept svg
width 15px
height 10px

&_reject svg
width 12.5px
height 12.5px

&__spinner
width 16px
height 16px
border-radius 100%;
box-sizing border-box
border 2px solid #FFD666
border-right-color transparent
animation waiting-spin 1s linear infinite

@keyframes waiting-spin
0%
transform rotate(0deg)

100%
transform rotate(360deg)
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
import { inject, observer } from 'mobx-react';
import { useEffect } from 'react';
import { IconCheck, IconCross } from '../../assets/icons';
import { Button } from '../../common/Button/Button';
import { Space } from '../../common/Space/Space';
import Toggle from '../../common/Toggle/Toggle';
import ToolsManager from '../../tools/Manager';
import { Block, Elem } from '../../utils/bem';
import './DynamicPreannotationsToggle.styl';

const injector = inject(({ store }) => {
const annotation = store.annotationStore?.selected;
const suggestions = annotation?.suggestions;

return {
store,
annotation,
suggestions,
interfaces: Array.from(store?.interfaces),
};
});

export const DynamicPreannotationsToggle = injector(observer(({
store,
annotation,
suggestions,
}) => {
export const DynamicPreannotationsToggle = inject('store')(observer(({ store }) => {
const enabled = store.hasInterface('auto-annotation') && !store.forceAutoAnnotation;

useEffect(() => {
Expand All @@ -49,16 +32,6 @@ export const DynamicPreannotationsToggle = injector(observer(({
label="Auto-Annotation"
style={{ color: '#7F64FF' }}
/>
{suggestions.size > 0 && (
<Space size="small">
<Elem name="action" tag={Button} mod={{ type: 'reject' }} onClick={() => annotation.rejectAllSuggestions()}>
<IconCross/>
</Elem>
<Elem name="action" tag={Button} mod={{ type: 'accept' }} onClick={() => annotation.acceptAllSuggestions()}>
<IconCheck/>
</Elem>
</Space>
)}
</Space>
</Elem>
</Block>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,3 @@

&__wrapper
width 100%

&__action
padding 0
margin 0
margin 2px
width 28px
height 28px
display flex
align-items center
justify-content center
border-radius 100%
color rgba(#000, 0.6)
background-color rgba(#000, 0.1)

&_type
&_accept svg
width 15px
height 10px

&_reject svg
width 12.5px
height 12.5px
3 changes: 0 additions & 3 deletions web/libs/editor/src/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ class App extends Component {
{this.renderRelations(as.selected)}
</Elem>
{(!isFF(FF_DEV_3873)) && getRoot(as).hasInterface('infobar') && this._renderInfobar(as)}
{as.selected.hasSuggestionsSupport && (
<DynamicPreannotationsControl />
)}
</Block>
);
}
Expand Down
3 changes: 2 additions & 1 deletion web/libs/editor/src/components/BottomBar/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Button } from '../../common/Button/Button';
import { Elem } from '../../utils/bem';
import { EditingHistory } from './HistoryActions';
import { DynamicPreannotationsToggle } from '../AnnotationTab/DynamicPreannotationsToggle';
import { AutoAcceptToggle } from '../AnnotationTab/AutoAcceptToggle';
import { GroundTruth } from '../CurrentEntity/GroundTruth';
import { Tooltip } from '../../common/Tooltip/Tooltip';

Expand Down Expand Up @@ -49,9 +50,9 @@ export const Actions = ({ store }) => {
{store.hasInterface('ground-truth') && <GroundTruth entity={entity}/>}

{!isViewAll && (

<Elem name="section">
<DynamicPreannotationsToggle />
<AutoAcceptToggle />
</Elem>
)}
</Elem>
Expand Down
2 changes: 1 addition & 1 deletion web/libs/editor/src/stores/Annotation/Annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ export const Annotation = types
},

rejectAllSuggestions() {
Array.from(self.suggestions.keys).forEach((id) => {
Array.from(self.suggestions.keys()).forEach((id) => {
self.suggestions.delete(id);
});
self.deleteAllDynamicregions(isFF(FF_DEV_1284));
Expand Down

0 comments on commit 91e2618

Please sign in to comment.