-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
Copy pathToolManagerMixin.js
38 lines (33 loc) · 1.21 KB
/
ToolManagerMixin.js
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
import { ff } from "@humansignal/core";
import { types } from "mobx-state-tree";
import ToolsManager from "../tools/Manager";
import * as Tools from "../tools";
import { FF_DEV_3391 } from "../utils/feature-flags";
export const ToolManagerMixin = types.model().actions((self) => {
return {
afterAttach() {
if (ff.isActive(FF_DEV_3391) && !self.annotation) {
return;
}
const toolNames = self.toolNames ?? [];
const manager = ToolsManager.getInstance({ name: self.toname });
const env = { manager, control: self };
const tools = {};
toolNames.forEach((toolName) => {
if (toolName in Tools) {
const tool = Tools[toolName].create({}, env);
tools[toolName] = tool;
}
});
self.tools = tools;
// copy tools from control tags into object tools manager
// [DOCS] each object tag may have an assigned tools
// manager. This assignment may happen because user asked
// for it through the config, or because the attached
// control tags are complex and require additional UI
// interfaces. Each control tag defines a set of tools it
// supports
manager.addToolsFromControl(self);
},
};
});