Skip to content

Commit b023a3c

Browse files
refactor: LEAP-1772: Remove FF_OPTIC_2 feature flag and associated logic (#7211)
Co-authored-by: robot-ci-heartex <robot-ci-heartex@users.noreply.github.com>
1 parent ac5783e commit b023a3c

File tree

8 files changed

+50
-75
lines changed

8 files changed

+50
-75
lines changed

label_studio/core/feature_flags/stale_feature_flags.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
STALE_FEATURE_FLAGS = {
22
'fflag_feat_all_dia_13_structured_data_support_short': False,
33
'fflag_feat_front_optic_66_lazy_chart_evaluation_19092023_short': False,
4-
'fflag_feat_optic_2_ensure_draft_saved_short': True,
54
'fflag_fix_front_lsdv_4600_lead_time_27072023_short': False,
65
'fflag_fix_front_lsdv_4988_dynamic_no_label_120523_short': True,
76
'fflag_fix_back_lsdv_4648_annotator_filter_29052023_short': True,

web/apps/labelstudio/src/app/App.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { RoutesProvider } from "../providers/RoutesProvider";
1414
import { DRAFT_GUARD_KEY, DraftGuard, draftGuardCallback } from "../components/DraftGuard/DraftGuard";
1515
import { AsyncPage } from "./AsyncPage/AsyncPage";
1616
import ErrorBoundary from "./ErrorBoundary";
17-
import { FF_OPTIC_2, FF_UNSAVED_CHANGES, FF_PRODUCT_TOUR, isFF } from "../utils/feature-flags";
17+
import { FF_UNSAVED_CHANGES, FF_PRODUCT_TOUR, isFF } from "../utils/feature-flags";
1818
import { TourProvider } from "@humansignal/core";
1919
import { ToastProvider, ToastViewport } from "@humansignal/ui";
2020
import { QueryClient } from "@tanstack/react-query";
@@ -49,7 +49,7 @@ const browserHistory = createBrowserHistory({
4949
callback(result);
5050
isFF(FF_UNSAVED_CHANGES) && window.postMessage({ source: "label-studio", payload: UNBLOCK_HISTORY_MESSAGE });
5151
};
52-
if (isFF(FF_OPTIC_2) && message === DRAFT_GUARD_KEY) {
52+
if (message === DRAFT_GUARD_KEY) {
5353
draftGuardCallback.current = callbackWrapper;
5454
} else if (isFF(FF_UNSAVED_CHANGES) && message === LEAVE_BLOCKER_KEY) {
5555
leaveBlockerCallback.current = callbackWrapper;

web/apps/labelstudio/src/components/DraftGuard/DraftGuard.jsx

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { useContext, useEffect } from "react";
22
import { useHistory } from "react-router-dom";
33
import { ToastContext } from "@humansignal/ui";
4-
import { FF_OPTIC_2, isFF } from "../../utils/feature-flags";
54

65
export const DRAFT_GUARD_KEY = "DRAFT_GUARD";
76

@@ -14,49 +13,47 @@ export const DraftGuard = () => {
1413
const history = useHistory();
1514

1615
useEffect(() => {
17-
if (isFF(FF_OPTIC_2)) {
18-
const unblock = () => {
19-
draftGuardCallback.current?.(true);
20-
draftGuardCallback.current = null;
21-
};
22-
23-
/**
24-
* The version of Router History that is in use does not currently support
25-
* the `block` method fully. This is a workaround to allow us to block navigation
26-
* when there are unsaved changes. The draftGuardCallback allows the unblock callback to be captured from the
27-
* history callback `getUserConfirmation` that is triggered by returning a string message from history.block, allowing the user to
28-
* confirm they want to leave the page. Here we send through a constant message
29-
* to signify that we aren't looking for user confirmation but to utilize this to enable navigation blocking based on
30-
* unsuccessful draft saves.
31-
*/
32-
const unsubscribe = history.block(() => {
33-
const selected = window.Htx?.annotationStore?.selected;
34-
const submissionInProgress = !!selected?.submissionStarted;
35-
const hasChanges = !!selected?.history.undoIdx && !submissionInProgress;
36-
37-
if (hasChanges) {
38-
selected.saveDraftImmediatelyWithResults()?.then((res) => {
39-
const status = res?.$meta?.status;
40-
41-
if (status === 200 || status === 201) {
42-
toast.show({ message: "Draft saved successfully", type: "info" });
43-
unblock();
44-
} else if (status !== undefined) {
45-
toast.show({ message: "There was an error saving your draft", type: "error" });
46-
} else {
47-
unblock();
48-
}
49-
});
50-
51-
return DRAFT_GUARD_KEY;
52-
}
53-
});
54-
55-
return () => {
56-
unblock();
57-
unsubscribe();
58-
};
59-
}
16+
const unblock = () => {
17+
draftGuardCallback.current?.(true);
18+
draftGuardCallback.current = null;
19+
};
20+
21+
/**
22+
* The version of Router History that is in use does not currently support
23+
* the `block` method fully. This is a workaround to allow us to block navigation
24+
* when there are unsaved changes. The draftGuardCallback allows the unblock callback to be captured from the
25+
* history callback `getUserConfirmation` that is triggered by returning a string message from history.block, allowing the user to
26+
* confirm they want to leave the page. Here we send through a constant message
27+
* to signify that we aren't looking for user confirmation but to utilize this to enable navigation blocking based on
28+
* unsuccessful draft saves.
29+
*/
30+
const unsubscribe = history.block(() => {
31+
const selected = window.Htx?.annotationStore?.selected;
32+
const submissionInProgress = !!selected?.submissionStarted;
33+
const hasChanges = !!selected?.history.undoIdx && !submissionInProgress;
34+
35+
if (hasChanges) {
36+
selected.saveDraftImmediatelyWithResults()?.then((res) => {
37+
const status = res?.$meta?.status;
38+
39+
if (status === 200 || status === 201) {
40+
toast.show({ message: "Draft saved successfully", type: "info" });
41+
unblock();
42+
} else if (status !== undefined) {
43+
toast.show({ message: "There was an error saving your draft", type: "error" });
44+
} else {
45+
unblock();
46+
}
47+
});
48+
49+
return DRAFT_GUARD_KEY;
50+
}
51+
});
52+
53+
return () => {
54+
unblock();
55+
unsubscribe();
56+
};
6057
}, []);
6158

6259
return <></>;

web/apps/labelstudio/src/pages/DataManager/DataManager.jsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ import { modal } from "../../components/Modal/Modal";
77
import { Space } from "../../components/Space/Space";
88
import { useAPI } from "../../providers/ApiProvider";
99
import { useProject } from "../../providers/ProjectProvider";
10-
import { useContextProps, useFixedLocation, useParams } from "../../providers/RoutesProvider";
11-
import { addAction, addCrumb, deleteAction, deleteCrumb } from "../../services/breadrumbs";
10+
import { useContextProps, useParams } from "../../providers/RoutesProvider";
11+
import { addCrumb, deleteCrumb } from "../../services/breadrumbs";
1212
import { Block, Elem } from "../../utils/bem";
1313
import { isDefined } from "../../utils/helpers";
1414
import { ImportModal } from "../CreateProject/Import/ImportModal";
1515
import { ExportPage } from "../ExportPage/ExportPage";
1616
import { APIConfig } from "./api-config";
1717
import { ToastContext, ToastType } from "@humansignal/ui";
18-
import { FF_OPTIC_2, isFF } from "../../utils/feature-flags";
1918

2019
import "./DataManager.scss";
2120

@@ -236,7 +235,6 @@ DataManagerPage.pages = {
236235
ImportModal,
237236
};
238237
DataManagerPage.context = ({ dmRef }) => {
239-
const location = useFixedLocation();
240238
const { project } = useProject();
241239
const [mode, setMode] = useState(dmRef?.mode ?? "explorer");
242240

@@ -246,19 +244,10 @@ DataManagerPage.context = ({ dmRef }) => {
246244

247245
const updateCrumbs = (currentMode) => {
248246
const isExplorer = currentMode === "explorer";
249-
const dmPath = location.pathname.replace(DataManagerPage.path, "");
250247

251248
if (isExplorer) {
252-
deleteAction(dmPath);
253249
deleteCrumb("dm-crumb");
254250
} else {
255-
if (!isFF(FF_OPTIC_2)) {
256-
addAction(dmPath, (e) => {
257-
e.preventDefault();
258-
e.stopPropagation();
259-
dmRef?.store?.closeLabeling?.();
260-
});
261-
}
262251
addCrumb({
263252
key: "dm-crumb",
264253
title: "Labeling",

web/libs/core/src/lib/utils/feature-flags.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ export const FF_DEV_1682 = "ff_front_dev_1682_model_version_dropdown_070622_shor
1313
export const FF_LSDV_4711 = "fflag_fix_all_lsdv_4711_cors_errors_accessing_task_data_short";
1414
// Enables "Enterprise Awareness" features
1515
export const FF_LSDV_E_297 = "fflag_feat_front_lsdv_e_297_increase_oss_to_enterprise_adoption_short";
16-
/**
17-
* Improve load time performance of Dashboard Members page
18-
*/
19-
export const FF_OPTIC_2 = "fflag_feat_optic_2_ensure_draft_saved_short";
2016

2117
/**
2218
* Prompter workflow

web/libs/datamanager/src/components/MainView/DataView/Table.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useCallback, useMemo } from "react";
44
import { FaQuestionCircle } from "react-icons/fa";
55
import { useShortcut } from "../../../sdk/hotkeys";
66
import { Block, Elem } from "../../../utils/bem";
7-
import { FF_DEV_2536, FF_LOPS_86, FF_OPTIC_2, isFF } from "../../../utils/feature-flags";
7+
import { FF_DEV_2536, FF_LOPS_86, isFF } from "../../../utils/feature-flags";
88
import * as CellViews from "../../CellViews";
99
import { Icon } from "../../Common/Icon/Icon";
1010
import { ImportButton } from "../../Common/SDKButtons";
@@ -120,7 +120,7 @@ export const DataView = injector(
120120
} else if (e.metaKey || e.ctrlKey) {
121121
window.open(`./?task=${itemID}`, "_blank");
122122
} else {
123-
if (isFF(FF_OPTIC_2)) store._sdk.lsf?.saveDraft();
123+
store._sdk.lsf?.saveDraft();
124124
getRoot(view).startLabeling(item);
125125
}
126126
},

web/libs/datamanager/src/sdk/lsf-sdk.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
FF_DEV_2887,
1919
FF_DEV_3034,
2020
FF_LSDV_4620_3_ML,
21-
FF_OPTIC_2,
2221
FF_REGION_VISIBILITY_FROM_URL,
2322
isFF,
2423
} from "../utils/feature-flags";
@@ -881,7 +880,7 @@ export class LSFWrapper {
881880
if (window.APP_SETTINGS.read_only_quick_view_enabled && !this.labelStream) {
882881
prevAnnotation?.setEditable(false);
883882
}
884-
if (isFF(FF_OPTIC_2) && !!nextAnnotation?.history?.undoIdx) {
883+
if (nextAnnotation?.history?.undoIdx) {
885884
this.saveDraft(nextAnnotation).then(() => {
886885
this.datamanager.invoke("onSelectAnnotation", prevAnnotation, nextAnnotation, options, this);
887886
});
@@ -891,11 +890,11 @@ export class LSFWrapper {
891890
};
892891

893892
onNextTask = async (nextTaskId, nextAnnotationId) => {
894-
if (isFF(FF_OPTIC_2)) this.saveDraft();
893+
this.saveDraft();
895894
this.loadTask(nextTaskId, nextAnnotationId, true);
896895
};
897896
onPrevTask = async (prevTaskId, prevAnnotationId) => {
898-
if (isFF(FF_OPTIC_2)) this.saveDraft();
897+
this.saveDraft();
899898
this.loadTask(prevTaskId, prevAnnotationId, true);
900899
};
901900
async submitCurrentAnnotation(eventName, submit, includeId = false, loadNext = true) {

web/libs/datamanager/src/utils/feature-flags.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ export const FF_LSDV_4620_3_ML = "fflag_fix_front_lsdv_4620_memory_leaks_100723_
4242
*/
4343
export const FF_LSDV_4711 = "fflag_fix_all_lsdv_4711_cors_errors_accessing_task_data_short";
4444

45-
/**
46-
* Save draft on leave annotation editor
47-
*/
48-
export const FF_OPTIC_2 = "fflag_feat_optic_2_ensure_draft_saved_short";
49-
5045
/**
5146
* Adding the ability to toggle dataset storage editability.
5247
*/

0 commit comments

Comments
 (0)