Skip to content

Commit 90a901b

Browse files
luarmryyassi-heartex
authored andcommitted
refactor: LEAP-1314: Remove Stale Feature Flag - fflag_feat_front_dev… (HumanSignal#6732)
Co-authored-by: yyassi-heartex <[email protected]>
1 parent c41e893 commit 90a901b

File tree

3 files changed

+117
-148
lines changed

3 files changed

+117
-148
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
@@ -33,7 +33,6 @@
3333
'fflag_fix_front_dev_3666_max_usages_on_region_creation_171122_short': True,
3434
'fflag_fix_front_dev_3617_taxonomy_memory_leaks_fix': True,
3535
'fflag_fix_front_dev_3350_restrict_drawing_area_short': True,
36-
'fflag_feat_front_dev_2984_dm_draggable_columns_short': True,
3736
'fflag_feat_front_dev_2461_audio_paragraphs_seek_chunk_position_short': True,
3837
'ff_front_dev_2432_auto_save_polygon_draft_210622_short': True,
3938
'ff_front_dev_2575_projects_list_performance_280622_short': True,

web/libs/datamanager/src/components/Common/Table/TableHead/TableHead.jsx

Lines changed: 117 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ import { TableCell, TableCellContent } from "../TableCell/TableCell";
1313
import { TableContext, TableElem } from "../TableContext";
1414
import { getStyle } from "../utils";
1515
import "./TableHead.scss";
16-
import { FF_DEV_2984, FF_DEV_3873, isFF } from "../../../../utils/feature-flags";
16+
import { FF_DEV_3873, isFF } from "../../../../utils/feature-flags";
1717
import { getRoot } from "mobx-state-tree";
1818

1919
const { Block, Elem } = BemWithSpecifiContext();
2020

21-
const is2984FF = isFF(FF_DEV_2984);
22-
2321
const DropdownWrapper = observer(({ column, cellViews, children, onChange }) => {
2422
const types = ViewColumnType._types
2523
.map((t) => t.value)
@@ -165,157 +163,132 @@ export const TableHead = observer(
165163
ref,
166164
) => {
167165
const { columns, headerRenderers, cellViews } = React.useContext(TableContext);
166+
const states = useLocalStore(() => ({
167+
orderedColumns: {},
168+
setOrderedColumns(updatedColumns) {
169+
states.orderedColumns = { ...updatedColumns };
170+
},
171+
getOrderedColumns() {
172+
return toJS(states.orderedColumns) ?? {};
173+
},
174+
isDragging: false,
175+
setIsDragging(isDragging) {
176+
states.isDragging = isDragging;
177+
},
178+
getIsDragging() {
179+
return toJS(states.isDragging);
180+
},
181+
initialDragPos: false,
182+
setInitialDragPos(initPos) {
183+
states.initialDragPos = initPos;
184+
},
185+
getInitialDragPos() {
186+
return toJS(states.initialDragPos);
187+
},
188+
draggedCol: null,
189+
setDraggedCol(draggedCol) {
190+
states.draggedCol = draggedCol;
191+
},
192+
getDraggedCol() {
193+
return toJS(states.draggedCol);
194+
},
195+
}));
196+
const colRefs = useRef({});
197+
const getUpdatedColOrder = useCallback(
198+
(cols) => {
199+
const orderedColumns = {};
168200

169-
if (is2984FF) {
170-
const states = useLocalStore(() => ({
171-
orderedColumns: {},
172-
setOrderedColumns(updatedColumns) {
173-
states.orderedColumns = { ...updatedColumns };
174-
},
175-
getOrderedColumns() {
176-
return toJS(states.orderedColumns) ?? {};
177-
},
178-
isDragging: false,
179-
setIsDragging(isDragging) {
180-
states.isDragging = isDragging;
181-
},
182-
getIsDragging() {
183-
return toJS(states.isDragging);
184-
},
185-
initialDragPos: false,
186-
setInitialDragPos(initPos) {
187-
states.initialDragPos = initPos;
188-
},
189-
getInitialDragPos() {
190-
return toJS(states.initialDragPos);
191-
},
192-
draggedCol: null,
193-
setDraggedCol(draggedCol) {
194-
states.draggedCol = draggedCol;
195-
},
196-
getDraggedCol() {
197-
return toJS(states.draggedCol);
198-
},
199-
}));
200-
const colRefs = useRef({});
201-
const getUpdatedColOrder = useCallback(
202-
(cols) => {
203-
const orderedColumns = {};
204-
205-
(cols ?? columns).forEach((col, colIndex) => {
206-
orderedColumns[col.id] = colIndex;
207-
});
208-
return orderedColumns;
209-
},
210-
[columns],
211-
);
201+
(cols ?? columns).forEach((col, colIndex) => {
202+
orderedColumns[col.id] = colIndex;
203+
});
204+
return orderedColumns;
205+
},
206+
[columns],
207+
);
212208

213-
useEffect(() => {
214-
ref.current?.addEventListener("mousedown", (event) => {
215-
const className = event.target.className;
209+
useEffect(() => {
210+
ref.current?.addEventListener("mousedown", (event) => {
211+
const className = event.target.className;
216212

217-
// This element could be an SVG element where className is an object, not a string.
218-
if (className?.includes?.("handle")) {
219-
event.preventDefault();
220-
}
221-
});
222-
}, []);
213+
// This element could be an SVG element where className is an object, not a string.
214+
if (className?.includes?.("handle")) {
215+
event.preventDefault();
216+
}
217+
});
218+
}, []);
223219

224-
return (
225-
<Block
226-
name="table-head"
227-
ref={ref}
228-
style={{
229-
...style,
230-
height: isFF(FF_DEV_3873) && 42,
231-
}}
232-
mod={{ droppable: true }}
233-
mix="horizontal-shadow"
234-
onDragOver={useCallback(
235-
(e) => {
236-
const draggedCol = states.getDraggedCol();
220+
return (
221+
<Block
222+
name="table-head"
223+
ref={ref}
224+
style={{
225+
...style,
226+
height: isFF(FF_DEV_3873) && 42,
227+
}}
228+
mod={{ droppable: true }}
229+
mix="horizontal-shadow"
230+
onDragOver={useCallback(
231+
(e) => {
232+
const draggedCol = states.getDraggedCol();
237233

238-
colRefs.current[draggedCol].style.setProperty("--scale", "0");
239-
e.stopPropagation();
240-
},
241-
[states],
242-
)}
243-
>
244-
{columns.map((col) => {
245-
return (
246-
<Elem
247-
name="draggable"
248-
draggable={true}
249-
ref={(ele) => (colRefs.current[col.id] = ele)}
250-
key={col.id}
251-
onDragStart={(e) => {
252-
e.dataTransfer.effectAllowed = "none";
253-
const ele = colRefs.current[col.id];
234+
colRefs.current[draggedCol].style.setProperty("--scale", "0");
235+
e.stopPropagation();
236+
},
237+
[states],
238+
)}
239+
>
240+
{columns.map((col) => {
241+
return (
242+
<Elem
243+
name="draggable"
244+
draggable={true}
245+
ref={(ele) => (colRefs.current[col.id] = ele)}
246+
key={col.id}
247+
onDragStart={(e) => {
248+
e.dataTransfer.effectAllowed = "none";
249+
const ele = colRefs.current[col.id];
254250

255-
states.setInitialDragPos({
256-
x: ele.offsetLeft,
257-
y: ele.offsetTop,
258-
});
259-
states.setDraggedCol(col.id);
260-
}}
261-
onDragEnd={(e) => {
262-
e.stopPropagation();
263-
const draggedCol = states.getDraggedCol();
264-
const curColumns = columns.filter((curCol) => curCol.id !== draggedCol);
265-
const newIndex = curColumns.findIndex((curCol) => {
266-
const colRefrence = colRefs.current[curCol.id];
267-
const mousePos = e.clientX + (ref?.current?.parentElement?.parentElement.scrollLeft ?? 0);
268-
const isGreaterThanPos = mousePos < colRefrence.offsetLeft + colRefrence.clientWidth / 2;
251+
states.setInitialDragPos({
252+
x: ele.offsetLeft,
253+
y: ele.offsetTop,
254+
});
255+
states.setDraggedCol(col.id);
256+
}}
257+
onDragEnd={(e) => {
258+
e.stopPropagation();
259+
const draggedCol = states.getDraggedCol();
260+
const curColumns = columns.filter((curCol) => curCol.id !== draggedCol);
261+
const newIndex = curColumns.findIndex((curCol) => {
262+
const colRefrence = colRefs.current[curCol.id];
263+
const mousePos = e.clientX + (ref?.current?.parentElement?.parentElement.scrollLeft ?? 0);
264+
const isGreaterThanPos = mousePos < colRefrence.offsetLeft + colRefrence.clientWidth / 2;
269265

270-
return isGreaterThanPos;
271-
});
266+
return isGreaterThanPos;
267+
});
272268

273-
colRefs.current[draggedCol].style.setProperty("--scale", "");
269+
colRefs.current[draggedCol].style.setProperty("--scale", "");
274270

275-
states.setDraggedCol(null);
276-
curColumns.splice(newIndex, 0, col);
277-
const updatedColOrder = getUpdatedColOrder(curColumns);
271+
states.setDraggedCol(null);
272+
curColumns.splice(newIndex, 0, col);
273+
const updatedColOrder = getUpdatedColOrder(curColumns);
278274

279-
onDragEnd?.(updatedColOrder);
280-
}}
281-
>
282-
<ColumnRenderer
283-
column={col}
284-
mod={{ draggable: true }}
285-
headerRenderers={headerRenderers}
286-
cellViews={cellViews}
287-
columnHeaderExtra={columnHeaderExtra}
288-
sortingEnabled={sortingEnabled}
289-
stopInteractions={stopInteractions}
290-
decoration={decoration}
291-
onTypeChange={onTypeChange}
292-
onResize={onResize}
293-
onReset={onReset}
294-
/>
295-
</Elem>
296-
);
297-
})}
298-
<Elem name="extra">{extra}</Elem>
299-
</Block>
300-
);
301-
}
302-
return (
303-
<Block name="table-head" ref={ref} style={style} mix="horizontal-shadow">
304-
{columns.map((col) => {
305-
return (
306-
<ColumnRenderer
307-
key={col.id}
308-
column={col}
309-
headerRenderers={headerRenderers}
310-
cellViews={cellViews}
311-
columnHeaderExtra={columnHeaderExtra}
312-
sortingEnabled={sortingEnabled}
313-
stopInteractions={stopInteractions}
314-
decoration={decoration}
315-
onTypeChange={onTypeChange}
316-
onResize={onResize}
317-
onReset={onReset}
318-
/>
275+
onDragEnd?.(updatedColOrder);
276+
}}
277+
>
278+
<ColumnRenderer
279+
column={col}
280+
mod={{ draggable: true }}
281+
headerRenderers={headerRenderers}
282+
cellViews={cellViews}
283+
columnHeaderExtra={columnHeaderExtra}
284+
sortingEnabled={sortingEnabled}
285+
stopInteractions={stopInteractions}
286+
decoration={decoration}
287+
onTypeChange={onTypeChange}
288+
onResize={onResize}
289+
onReset={onReset}
290+
/>
291+
</Elem>
319292
);
320293
})}
321294
<Elem name="extra">{extra}</Elem>

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ export const FF_DEV_2715 = "ff_front_dev_2715_audio_3_280722_short";
2121
// Comments for annotation editor
2222
export const FF_DEV_2887 = "fflag-feat-dev-2887-comments-ui-editor-short";
2323

24-
// toggles the ability to drag columns on the datamanager table
25-
export const FF_DEV_2984 = "fflag_feat_front_dev_2984_dm_draggable_columns_short";
26-
2724
export const FF_DEV_3034 = "fflag-feat-dev-3034-comments-with-drafts-short";
2825

2926
export const FF_DEV_3873 = "fflag_feat_front_dev_3873_labeling_ui_improvements_short";

0 commit comments

Comments
 (0)