/
vshmidt
/
label-studio
Обзор
Документация
Войти
/
vshmidt
/
label-studio
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
web/libs/editor/src/components/AnnotationTab/AutoAcceptToggle.jsx
69 строк
3 KB
Raul Martin
feat: Migrate SCSS to plain CSS with PostCSS, replace Stylelint with Biome (#9584)
12 мар 2026, 20:57
Не верифицирован
12 мар 2026, 20:57
3f31128
Код
Авторство
О чём код?
import { inject, observer } from "mobx-react"; import { IconCheck, IconCross } from "@humansignal/icons"; import { Button, Toggle } from "@humansignal/ui"; import { Space } from "../../common/Space/Space"; import { cn } from "../../utils/bem"; import "./AutoAcceptToggle.prefix.css"; // 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 ( <div className={cn("auto-accept").toClassName()}> {withSuggestions && ( <div className={cn("auto-accept").elem("wrapper").mod({ loading }).toClassName()}> <Space spread> {suggestions.size > 0 ? ( <Space size="small"> <div className={cn("auto-accept").elem("info").toClassName()}> {suggestions.size} suggestion{suggestions.size > 0 && "s"} </div> <Button className={cn("auto-accept").elem("action").mod({ type: "reject" }).toClassName()} onClick={() => annotation.rejectAllSuggestions()} data-testid="bottombar-reject-suggestions-button" > <IconCross /> </Button> <Button className={cn("auto-accept").elem("action").mod({ type: "accept" }).toClassName()} onClick={() => annotation.acceptAllSuggestions()} data-testid="bottombar-accept-suggestions-button" > <IconCheck /> </Button> </Space> ) : ( <Toggle checked={store.autoAcceptSuggestions} onChange={(e) => store.setAutoAcceptSuggestions(e.target.checked)} label="Auto-Accept Suggestions" data-testid="bottombar-auto-accept-toggle" /> )} </Space> </div> )} {loading && <div className={cn("auto-accept").elem("spinner").toClassName()} />} </div> ); }), );