Bin
2025-12-16 9e0b2ba2c317b1a86212f24cbae3195ad1f3dbfa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { observer } from "mobx-react";
 
import { IconViewAll, IconPlus } from "@humansignal/icons";
import { Button } from "@humansignal/ui";
import { ff } from "@humansignal/core";
import { cn } from "../../utils/bem";
import { isSelfServe } from "../../utils/billing";
import { FF_BULK_ANNOTATION, FF_DEV_3873, isFF } from "../../utils/feature-flags";
import { AnnotationsCarousel } from "../AnnotationsCarousel/AnnotationsCarousel";
import { DynamicPreannotationsToggle } from "../AnnotationTab/DynamicPreannotationsToggle";
import { Actions } from "./Actions";
import { Annotations } from "./Annotations";
import { Controls } from "./Controls";
import { CurrentTask } from "./CurrentTask";
 
import "./TopBar.scss";
 
export const TopBar = observer(({ store }) => {
  const annotationStore = store.annotationStore;
  const entity = annotationStore?.selected;
  const isPrediction = entity?.type === "prediction";
 
  const isViewAll = annotationStore?.viewingAll === true;
  const isBulkMode = isFF(FF_BULK_ANNOTATION) && !isSelfServe() && store.hasInterface("annotation:bulk");
 
  if (isFF(FF_DEV_3873) && isBulkMode) return null;
 
  return store ? (
    <div
      className={cn("topbar")
        .mod({ newLabelingUI: isFF(FF_DEV_3873) })
        .toClassName()}
    >
      {isFF(FF_DEV_3873) ? (
        <div className={cn("topbar").elem("group").toClassName()}>
          <CurrentTask store={store} />
          {store.hasInterface("annotations:view-all") && (
            <Button
              className={"topbar__button"}
              type={isViewAll ? undefined : "string"}
              aria-label="Compare all annotations"
              onClick={annotationStore.toggleViewingAllAnnotations}
              variant={isViewAll ? "primary" : "neutral"}
              look={isViewAll ? "filled" : "string"}
              tooltip="Compare all annotations"
              size="small"
            >
              <IconViewAll />
            </Button>
          )}
          {store.hasInterface("annotations:add-new") && (
            <Button
              className={"topbar__button"}
              type={isViewAll ? undefined : "text"}
              aria-label="Create an annotation"
              variant="neutral"
              size="small"
              look="string"
              tooltip="创建新标注"
              onClick={(event) => {
                event.preventDefault();
                const created = store.annotationStore.createAnnotation();
 
                store.annotationStore.selectAnnotation(created.id, { exitViewAll: true });
              }}
            >
              <IconPlus />
            </Button>
          )}
          {(!isViewAll || ff.isActive(ff.FF_SUMMARY)) && (
            <AnnotationsCarousel
              store={store}
              annotationStore={store.annotationStore}
              commentStore={store.commentStore}
            />
          )}
        </div>
      ) : (
        <>
          <div className={cn("topbar").elem("group").toClassName()}>
            {!isBulkMode && <CurrentTask store={store} />}
            {!isViewAll && !isBulkMode && (
              <Annotations store={store} annotationStore={store.annotationStore} commentStore={store.commentStore} />
            )}
            <Actions store={store} />
          </div>
          <div className={cn("topbar").elem("group").toClassName()}>
            {!isViewAll && (
              <div className={cn("topbar").elem("section").toClassName()}>
                <DynamicPreannotationsToggle />
              </div>
            )}
            {!isViewAll && store.hasInterface("controls") && (store.hasInterface("review") || !isPrediction) && (
              <div
                className={cn("topbar").elem("section").mod({ flat: true }).toClassName()}
                style={{ width: 320, boxSizing: "border-box" }}
              >
                <Controls annotation={entity} />
              </div>
            )}
          </div>
        </>
      )}
    </div>
  ) : null;
});