diff --git a/web/libs/editor/src/core/Tree.tsx b/web/libs/editor/src/core/Tree.tsx index bb8bf3897f88..c24b3c44bcc0 100644 --- a/web/libs/editor/src/core/Tree.tsx +++ b/web/libs/editor/src/core/Tree.tsx @@ -221,7 +221,8 @@ function renderItem(ref: IAnyStateTreeNode, annotation: IAnnotation, includeKey if (isFF(FF_DEV_3391)) { if (!annotation) return null; - el = annotation.ids.get(cleanUpId(ref.id ?? ref.name)); + // The part `|| el` is a hack to allow it to work with Image regions. For some reason, it uses this function for rendering + el = annotation.ids.get(cleanUpId(ref.id ?? ref.name)) || el; } if (!el) { diff --git a/web/libs/editor/src/core/feature-flags/flags.json b/web/libs/editor/src/core/feature-flags/flags.json index f81f3ccea2e6..d077246c29d6 100644 --- a/web/libs/editor/src/core/feature-flags/flags.json +++ b/web/libs/editor/src/core/feature-flags/flags.json @@ -1,7 +1,6 @@ { "ff_front_DEV_1713_audio_ui_150222_short": false, "ff_front_dev_2715_audio_3_280722_short": true, - "fflag_fix_front_dev_3391_interactive_view_all": false, "fflag_feat_front_dev_3873_labeling_ui_improvements_short": true, "fflag_fix_front_lsdv_4620_memory_leaks_100723_short": false } diff --git a/web/libs/editor/src/mixins/Tool.js b/web/libs/editor/src/mixins/Tool.js index eeda4704c7fe..5298160aaf66 100644 --- a/web/libs/editor/src/mixins/Tool.js +++ b/web/libs/editor/src/mixins/Tool.js @@ -1,5 +1,7 @@ +import { ff } from "@humansignal/core"; import { getEnv, getRoot, types } from "mobx-state-tree"; import { cloneNode } from "../core/Helpers"; +import { FF_DEV_3391 } from "../utils/feature-flags"; import { AnnotationMixin } from "./AnnotationMixin"; const ToolMixin = types @@ -10,6 +12,13 @@ const ToolMixin = types }) .views((self) => ({ get obj() { + if (ff.isActive(FF_DEV_3391)) { + // It's a temporal solution (see root description) + const root = self.manager?.root; + if (root?.annotationStore.selected) { + return root.annotationStore.selected.names.get(self.manager?.name); + } + } return self.manager?.obj ?? getEnv(self).object; }, @@ -18,6 +27,16 @@ const ToolMixin = types }, get control() { + if (ff.isActive(FF_DEV_3391)) { + // It's a temporal solution (see root description) + const control = getEnv(self).control; + const { name } = control; + const root = self.manager?.root; + if (root?.annotationStore.selected) { + return root.annotationStore.selected.names.get(name); + } + return control; + } return getEnv(self).control; }, diff --git a/web/libs/editor/src/mixins/ToolManagerMixin.js b/web/libs/editor/src/mixins/ToolManagerMixin.js index 660232e90c93..c9025ff5d004 100644 --- a/web/libs/editor/src/mixins/ToolManagerMixin.js +++ b/web/libs/editor/src/mixins/ToolManagerMixin.js @@ -1,10 +1,15 @@ +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 }; diff --git a/web/libs/editor/src/stores/Annotation/Annotation.js b/web/libs/editor/src/stores/Annotation/Annotation.js index 3e0253b2d603..4365a2d06eff 100644 --- a/web/libs/editor/src/stores/Annotation/Annotation.js +++ b/web/libs/editor/src/stores/Annotation/Annotation.js @@ -174,8 +174,10 @@ const _Annotation = types const updateIds = (item) => { const children = item.children?.map(updateIds); + const imageEntities = item.imageEntities?.map(updateIds); if (children) item = { ...item, children }; + if (imageEntities) item = { ...item, imageEntities }; if (item.id) item = { ...item, id: `${item.name ?? item.id}@${sn.id}` }; // @todo fallback for tags with name as id: // if (item.name) item = { ...item, name: item.name + "@" + sn.id }; diff --git a/web/libs/editor/src/tags/object/Image/Image.js b/web/libs/editor/src/tags/object/Image/Image.js index ad76b0f33288..f202ca28c7ce 100644 --- a/web/libs/editor/src/tags/object/Image/Image.js +++ b/web/libs/editor/src/tags/object/Image/Image.js @@ -1,3 +1,4 @@ +import { ff } from "@humansignal/core"; import { inject } from "mobx-react"; import { destroy, getRoot, getType, types } from "mobx-state-tree"; @@ -16,6 +17,7 @@ import ToolsManager from "../../../tools/Manager"; import { parseValue } from "../../../utils/data"; import { FF_DEV_3377, + FF_DEV_3391, FF_DEV_3793, FF_LSDV_4583, FF_LSDV_4583_6, @@ -567,7 +569,9 @@ const Model = types }; }, })) - + .volatile((self) => ({ + manager: null, + })) // actions for the tools .actions((self) => { const manager = ToolsManager.getInstance({ name: self.name }); @@ -577,18 +581,19 @@ const Model = types if (!self.store.task) return; const parsedValue = self.multiImage ? self.parsedValueList : self.parsedValue; + const idPostfix = self.annotation ? `@${self.annotation.id}` : ""; if (Array.isArray(parsedValue)) { parsedValue.forEach((src, index) => { self.imageEntities.push({ - id: `${self.name}#${index}`, + id: `${self.name}#${index}${idPostfix}`, src, index, }); }); } else { self.imageEntities.push({ - id: `${self.name}#0`, + id: `${self.name}#0${idPostfix}`, src: parsedValue, index: 0, }); @@ -598,6 +603,9 @@ const Model = types } function afterAttach() { + if (ff.isActive(FF_DEV_3391) && !self.annotation) { + return; + } if (self.selectioncontrol) manager.addTool("MoveTool", Tools.Selection.create({}, env)); if (self.zoomcontrol) manager.addTool("ZoomPanTool", Tools.Zoom.create({}, env)); diff --git a/web/libs/editor/src/tools/Manager.js b/web/libs/editor/src/tools/Manager.js index 77c479a74284..5dfbc0b0f5ee 100644 --- a/web/libs/editor/src/tools/Manager.js +++ b/web/libs/editor/src/tools/Manager.js @@ -42,6 +42,19 @@ class ToolsManager { get preservedTool() { return window.localStorage.getItem(`selected-tool:${this.name}`); } + /** + There are some problems with working with ToolManager with interactive view all flag switched on. + For now, tool manager is hidden in view_all, + so it allows us to use root and selected annotation + while we are looking for the object or the control from the tool. + At the same time, we can use `annotation_id` + as an additional key to be able to get the right annotation in that view_all mode. + But in that case, + there will be a problem with the inconsistent state of tool manager for 2 different annotations in the context of the same task. + */ + get root() { + return root; + } get obj() { return root.annotationStore.names.get(this.name);