Spaces:
Configuration error
Configuration error
File size: 3,399 Bytes
a7060a0 | 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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | import { observer } from "mobx-react";
import { Button } from "@humansignal/ui";
import {
FullscreenExitOutlined,
FullscreenOutlined,
RedoOutlined,
RollbackOutlined,
SettingOutlined,
UndoOutlined,
} from "@ant-design/icons";
import styles from "./Panel.module.css";
import Hint from "../Hint/Hint";
/**
* Panel component with buttons:
* Undo
* Redo
* Reset
* Show Instructions
* Settings
*/
export default observer(({ store }) => {
const annotation = store.annotationStore.selected;
const { history } = annotation;
const classname = [styles.block, styles.block__controls, store.annotationStore.viewingAll ? styles.hidden : ""]
.filter(Boolean)
.join(" ");
const panelClassName = cn("panel").toClassName();
return (
<div className={`${styles.container} ${panelClassName}`}>
<div className={classname}>
<Button
look="string"
leading={<UndoOutlined />}
disabled={!history?.canUndo}
onClick={(ev) => {
annotation?.undo();
ev.preventDefault();
}}
>
Undo
{store.settings.enableHotkeys && store.settings.enableTooltips && <Hint>[ Ctrl+z ]</Hint>}
</Button>
<Button
look="string"
disabled={!history?.canRedo}
leading={<RedoOutlined />}
onClick={(ev) => {
annotation?.redo();
ev.preventDefault();
}}
>
Redo
</Button>
<Button
type="ghost"
disabled={!history?.canUndo}
icon={<RollbackOutlined />}
onClick={() => {
history && history.reset();
}}
>
Reset
</Button>
{store.setPrelabeling && (
<Button
variant="neutral"
style={{ display: "none" }}
onClick={() => {
store.resetPrelabeling();
}}
>
Reset Prelabeling
</Button>
)}
{store.hasInterface("debug") && (
<span>
{history.undoIdx} / {history.history.length}
{history.isFrozen && " (frozen)"}
</span>
)}
</div>
<div className={[styles.block, styles.common].join(" ")}>
{store.description && store.showingDescription && (
<Button
variant="neutral"
onClick={() => {
store.toggleDescription();
}}
>
Hide Instructions
</Button>
)}
{store.description && !store.showingDescription && (
<Button
variant="neutral"
onClick={() => {
store.toggleDescription();
}}
>
Instructions
</Button>
)}
<Button
variant="neutral"
leading={<SettingOutlined />}
onClick={(ev) => {
store.toggleSettings();
ev.preventDefault();
return false;
}}
/>
<Button
className="lsf-fs"
variant="neutral"
leading={store.settings.fullscreen ? <FullscreenExitOutlined /> : <FullscreenOutlined />}
onClick={(ev) => {
store.settings.toggleFullscreen();
ev.preventDefault();
return false;
}}
/>
</div>
</div>
);
});
|