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

fix: LEAP-872: LEAP-935: Auto-Annotation fixes #5714

Merged
merged 19 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions web/dist/apps/labelstudio/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"message": "Merge branch 'develop' into 'fb-leap-930/copy-changes'",
"commit": "b7c11f044475893039f1e3c7daf093b273fa4d3c",
"date": "2024-04-18T16:23:40.000Z",
"branch": "fb-leap-930/copy-changes"
"message": "Merge branch 'develop' into 'fb-ml-release-blocker'",
"commit": "ca5ca9fde589a0d7fe849630cbb78703bb2cdc43",
"date": "2024-04-18T16:44:49.000Z",
"branch": "fb-ml-release-blocker"
}
8 changes: 4 additions & 4 deletions web/dist/libs/datamanager/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"message": "Merge branch 'develop' into 'fb-leap-930/copy-changes'",
"commit": "b7c11f044475893039f1e3c7daf093b273fa4d3c",
"date": "2024-04-18T16:23:40.000Z",
"branch": "fb-leap-930/copy-changes"
"message": "Merge branch 'develop' into 'fb-ml-release-blocker'",
"commit": "ca5ca9fde589a0d7fe849630cbb78703bb2cdc43",
"date": "2024-04-18T16:44:49.000Z",
"branch": "fb-ml-release-blocker"
}
4 changes: 2 additions & 2 deletions 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.

8 changes: 4 additions & 4 deletions web/dist/libs/editor/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"message": "Merge branch 'develop' into 'fb-leap-930/copy-changes'",
"commit": "b7c11f044475893039f1e3c7daf093b273fa4d3c",
"date": "2024-04-18T16:23:40.000Z",
"branch": "fb-leap-930/copy-changes"
"message": "Merge branch 'develop' into 'fb-ml-release-blocker'",
"commit": "ca5ca9fde589a0d7fe849630cbb78703bb2cdc43",
"date": "2024-04-18T16:44:49.000Z",
"branch": "fb-ml-release-blocker"
}
64 changes: 64 additions & 0 deletions web/libs/editor/src/components/AnnotationTab/AutoAcceptToggle.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { inject, observer } from 'mobx-react';

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

import './AutoAcceptToggle.styl';

// we need to inject all of them to trigger rerender on changes to suggestions
const injector = inject(({ store }) => {
const annotation = store.annotationStore?.selected;
const suggestions = annotation?.suggestions;

return {
store,
annotation,
suggestions,
};
});

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)

This file was deleted.

This file was deleted.

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
4 changes: 0 additions & 4 deletions web/libs/editor/src/components/App/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import { isDefined, sortAnnotations } from '../../utils/utilities';
*/
import { Annotation } from './Annotation';
import { AnnotationTab } from '../AnnotationTab/AnnotationTab';
import { DynamicPreannotationsControl } from '../AnnotationTab/DynamicPreannotationsControl';
import { BottomBar } from '../BottomBar/BottomBar';
import Debug from '../Debug';
import Grid from './Grid';
Expand Down Expand Up @@ -148,9 +147,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.jsx
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 @@ -1342,7 +1342,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
Loading