Skip to content

Commit

Permalink
refactor: LEAP-1310: Remove Stale Feature Flag - fflag_fix_front_dev_…
Browse files Browse the repository at this point in the history
…3666_max_usages_on_region_creation_171122_short
  • Loading branch information
luarmr committed Jan 23, 2025
1 parent c37964e commit 6e6afe6
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 68 deletions.
1 change: 0 additions & 1 deletion label_studio/core/feature_flags/stale_feature_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
'fflag_feat_front_lsdv_4620_richtext_opimization_060423_short': True,
'fflag_feat_front_dev_3873_labeling_ui_improvements_short': True,
'fflag_feat_back_dev_3756_queue_enrollment_min_short': False,
'fflag_fix_front_dev_3666_max_usages_on_region_creation_171122_short': True,
'ff_front_dev_2432_auto_save_polygon_draft_210622_short': True,
'ff_front_1170_outliner_030222_short': True,
'fflag_fix_front_lsdv_4620_memory_leaks_100723_short': False,
Expand Down
9 changes: 2 additions & 7 deletions web/libs/editor/src/mixins/DrawingTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { types } from "mobx-state-tree";
import Utils from "../utils";
import throttle from "lodash.throttle";
import { MIN_SIZE } from "../tools/Base";
import { FF_DEV_3666, FF_DEV_3793, isFF } from "../utils/feature-flags";
import { FF_DEV_3793, isFF } from "../utils/feature-flags";
import { RELATIVE_STAGE_HEIGHT, RELATIVE_STAGE_WIDTH } from "../components/ImageView/Image";

const DrawingTool = types
Expand Down Expand Up @@ -175,12 +175,7 @@ const DrawingTool = types
},

canStartDrawing() {
return (
!self.isIncorrectControl() &&
(!isFF(FF_DEV_3666) || !self.isIncorrectLabel()) &&
self.canStart() &&
!self.annotation.isDrawing
);
return !self.isIncorrectControl() && !self.isIncorrectLabel() && self.canStart() && !self.annotation.isDrawing;
},

startDrawing(x, y) {
Expand Down
9 changes: 1 addition & 8 deletions web/libs/editor/src/mixins/SelectedModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { types } from "mobx-state-tree";

import Tree from "../core/Tree";
import { isDefined } from "../utils/utilities";
import { FF_DEV_3666, isFF } from "../utils/feature-flags";

const SelectedModelMixin = types
.model()
Expand Down Expand Up @@ -82,13 +81,7 @@ const SelectedModelMixin = types
},

checkMaxUsages() {
if (isFF(FF_DEV_3666)) {
return self.tiedChildren.filter((c) => !c.canBeUsed());
}
const list = self.tiedChildren.filter((c) => !c.canBeUsed());

if (list.length) list.forEach((c) => c.setSelected(false));
return list;
return self.tiedChildren.filter((c) => !c.canBeUsed());
},

selectFirstVisible() {
Expand Down
10 changes: 3 additions & 7 deletions web/libs/editor/src/tags/object/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { types } from "mobx-state-tree";
import isMatch from "lodash.ismatch";
import InfoModal from "../../components/Infomodal/Infomodal";
import { AnnotationMixin } from "../../mixins/AnnotationMixin";
import { FF_DEV_3391, FF_DEV_3666, isFF } from "../../utils/feature-flags";
import { FF_DEV_3391, isFF } from "../../utils/feature-flags";
import { BaseTag } from "../TagBase";

const ObjectBase = types
Expand Down Expand Up @@ -73,12 +73,8 @@ const ObjectBase = types
const allStates = self.states() || [];
let exceeded;

if (isFF(FF_DEV_3666)) {
exceeded = allStates.reduce(checkAndCollect, []).filter((e) => e.selected);
exceeded.forEach((e) => e.setSelected(false));
} else {
exceeded = allStates.reduce(checkAndCollect, []);
}
exceeded = allStates.reduce(checkAndCollect, []).filter((e) => e.selected);
exceeded.forEach((e) => e.setSelected(false));

const states = self.activeStates() || [];

Expand Down
12 changes: 2 additions & 10 deletions web/libs/editor/src/tags/object/Image/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import ToolsManager from "../../../tools/Manager";
import { parseValue } from "../../../utils/data";
import {
FF_DEV_3377,
FF_DEV_3666,
FF_DEV_3793,
FF_LSDV_4583,
FF_LSDV_4583_6,
Expand Down Expand Up @@ -1106,15 +1105,8 @@ const Model = types
},

checkLabels() {
let labelStates;

if (isFF(FF_DEV_3666)) {
// there should be at least one available label or none of them should be selected
labelStates = self.activeStates() || [];
} else {
// there is should be at least one state selected for *labels object
labelStates = (self.states() || []).filter((s) => s.type.includes("labels"));
}
// there should be at least one available label or none of them should be selected
const labelStates = self.activeStates() || [];
const selectedStates = self.getAvailableStates();

return selectedStates.length !== 0 || labelStates.length === 0;
Expand Down
6 changes: 3 additions & 3 deletions web/libs/editor/src/tags/object/Paragraphs/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { SyncableMixin } from "../../../mixins/Syncable";
import { ParagraphsRegionModel } from "../../../regions/ParagraphsRegion";
import Utils from "../../../utils";
import { parseValue } from "../../../utils/data";
import { FF_DEV_2669, FF_DEV_2918, FF_DEV_3666, FF_LSDV_E_278, isFF } from "../../../utils/feature-flags";
import { FF_DEV_2669, FF_DEV_2918, FF_LSDV_E_278, isFF } from "../../../utils/feature-flags";
import messages from "../../../utils/messages";
import { clamp, isDefined, isValidObjectURL } from "../../../utils/utilities";
import ObjectBase from "../Base";
Expand Down Expand Up @@ -516,7 +516,7 @@ const ParagraphsLoadingModel = types.model().actions((self) => ({

addRegions(ranges) {
const areas = [];
const states = isFF(FF_DEV_3666) ? self.getAvailableStates() : self.activeStates();
const states = self.getAvailableStates();

if (states.length === 0) return;

Expand All @@ -540,7 +540,7 @@ const ParagraphsLoadingModel = types.model().actions((self) => ({
if (isFF(FF_DEV_2918)) {
return self.addRegions([range])[0];
}
const states = isFF(FF_DEV_3666) ? self.getAvailableStates() : self.activeStates();
const states = self.getAvailableStates();

if (states.length === 0) return;

Expand Down
3 changes: 1 addition & 2 deletions web/libs/editor/src/tools/Brush.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { DrawingTool } from "../mixins/DrawingTool";
import { Tool } from "../components/Toolbar/Tool";
import { Range } from "../common/Range/Range";
import { NodeViews } from "../components/Node/Node";
import { FF_DEV_3666, isFF } from "../utils/feature-flags";

const MIN_SIZE = 1;
const MAX_SIZE = 50;
Expand Down Expand Up @@ -213,7 +212,7 @@ const _Tool = types

self.addPoint(x, y);
} else {
if (isFF(FF_DEV_3666) && !self.canStartDrawing()) return;
if (!self.canStartDrawing()) return;
if (self.tagTypes.stateTypes === self.control.type && !self.control.isSelected) return;
self.annotation.history.freeze();
self.mode = "drawing";
Expand Down
4 changes: 2 additions & 2 deletions web/libs/editor/src/tools/KeyPoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import BaseTool from "./Base";
import ToolMixin from "../mixins/Tool";
import { NodeViews } from "../components/Node/Node";
import { DrawingTool } from "../mixins/DrawingTool";
import { FF_DEV_3666, FF_DEV_3793, isFF } from "../utils/feature-flags";
import { FF_DEV_3793, isFF } from "../utils/feature-flags";

const _Tool = types
.model("KeyPointTool", {
Expand All @@ -29,7 +29,7 @@ const _Tool = types
}))
.actions((self) => ({
clickEv(ev, [x, y]) {
if (isFF(FF_DEV_3666) && !self.canStartDrawing()) return;
if (!self.canStartDrawing()) return;

const c = self.control;

Expand Down
6 changes: 0 additions & 6 deletions web/libs/editor/src/utils/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ export const FF_DEV_3377 = "fflag_fix_front_dev_3377_image_regions_shift_on_resi
// Refactoring to use separate trees for every annotation to allow real annotations in View All
export const FF_DEV_3391 = "fflag_fix_front_dev_3391_interactive_view_all";

/**
* Fixing maxUsages prop of *labels on region creation.
* @link https://app.launchdarkly.com/default/test/features/fflag_fix_front_dev_3666_max_usages_on_region_creation_171122_short
*/
export const FF_DEV_3666 = "fflag_fix_front_dev_3666_max_usages_on_region_creation_171122_short";

/**
* Fixing "Auto Detect" tool undo functionality and bugs with skipNextUndoState.
* @link https://app.launchdarkly.com/default/production/features/fflag_fix_front_dev_1284_auto_detect_undo_281022_short
Expand Down
16 changes: 0 additions & 16 deletions web/libs/editor/tests/e2e/tests/maxUsage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ Data(maxUsageImageToolsDataTable).Scenario(
}

I.amOnPage("/");
LabelStudio.setFeatureFlags({
fflag_fix_front_dev_3666_max_usages_on_region_creation_171122_short: true,
});
LabelStudio.init({
config: createImageToolsConfig({ maxUsage }),
data: {
Expand Down Expand Up @@ -174,9 +171,6 @@ Data(maxUsageImageToolsDataTable).Scenario(
const shape = shapes[shapeName];

I.amOnPage("/");
LabelStudio.setFeatureFlags({
fflag_fix_front_dev_3666_max_usages_on_region_creation_171122_short: true,
});
LabelStudio.init({
config: createImageLabelsConfig({ maxUsage }),
data: {
Expand Down Expand Up @@ -207,7 +201,6 @@ Data(maxUsageDataTable).Scenario(
const { maxUsage } = current;

LabelStudio.setFeatureFlags({
fflag_fix_front_dev_3666_max_usages_on_region_creation_171122_short: true,
ff_front_dev_2715_audio_3_280722_short: true,
});
I.amOnPage("/");
Expand Down Expand Up @@ -248,9 +241,6 @@ Data(maxUsageDataTable).Scenario(
const { maxUsage } = current;

I.amOnPage("/");
LabelStudio.setFeatureFlags({
fflag_fix_front_dev_3666_max_usages_on_region_creation_171122_short: true,
});
LabelStudio.init({
config: `
<View>
Expand Down Expand Up @@ -286,9 +276,6 @@ Data(maxUsageDataTable).Scenario(
const { maxUsage } = current;

I.amOnPage("/");
LabelStudio.setFeatureFlags({
fflag_fix_front_dev_3666_max_usages_on_region_creation_171122_short: true,
});
LabelStudio.init({
config: `
<View>
Expand Down Expand Up @@ -322,9 +309,6 @@ Data(maxUsageDataTable).Scenario(
const { maxUsage } = current;

I.amOnPage("/");
LabelStudio.setFeatureFlags({
fflag_fix_front_dev_3666_max_usages_on_region_creation_171122_short: true,
});
LabelStudio.init({
config: `
<View>
Expand Down
6 changes: 0 additions & 6 deletions web/libs/frontend-test/src/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ export const FF_DEV_3377 = "fflag_fix_front_dev_3377_image_regions_shift_on_resi
// Refactoring to use separate trees for every annotation to allow real annotations in View All
export const FF_DEV_3391 = "fflag_fix_front_dev_3391_interactive_view_all";

/**
* Fixing maxUsages prop of *labels on region creation.
* @link https://app.launchdarkly.com/default/test/features/fflag_fix_front_dev_3666_max_usages_on_region_creation_171122_short
*/
export const FF_DEV_3666 = "fflag_fix_front_dev_3666_max_usages_on_region_creation_171122_short";

// Use only relative coords internally to improve performance and reduce bugs
export const FF_DEV_3793 = "fflag_fix_front_dev_3793_relative_coords_short";

Expand Down

0 comments on commit 6e6afe6

Please sign in to comment.