Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: LEAP-859: Fix data manager breaking on displaying specific data #5692

Merged
merged 8 commits into from
Apr 11, 2024
Merged
8 changes: 4 additions & 4 deletions web/dist/apps/labelstudio/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"message": "Merge branch 'develop' into 'fb-HUMSIG-37-visuals'",
"commit": "309851f803a1995c36b11f416f80cff709b6be2f",
"date": "2024-04-04T16:34:09.000Z",
"branch": "fb-HUMSIG-37-visuals"
"message": "Update web/libs/datamanager/src/components/CellViews/index.js",
"commit": "8553ac21be3cf2f6546938902868db11ecbea92a",
"date": "2024-04-09T15:06:54.000Z",
"branch": "fb-leap-859/colimn-special-characters"
}
2 changes: 1 addition & 1 deletion web/dist/libs/datamanager/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/dist/libs/datamanager/main.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions web/dist/libs/datamanager/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"message": "Merge branch 'develop' into 'fb-HUMSIG-37-visuals'",
"commit": "309851f803a1995c36b11f416f80cff709b6be2f",
"date": "2024-04-04T16:34:09.000Z",
"branch": "fb-HUMSIG-37-visuals"
"message": "Update web/libs/datamanager/src/components/CellViews/index.js",
"commit": "8553ac21be3cf2f6546938902868db11ecbea92a",
"date": "2024-04-09T15:06:54.000Z",
"branch": "fb-leap-859/colimn-special-characters"
}
8 changes: 4 additions & 4 deletions web/dist/libs/editor/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"message": "Merge branch 'develop' into 'fb-HUMSIG-37-visuals'",
"commit": "309851f803a1995c36b11f416f80cff709b6be2f",
"date": "2024-04-04T16:34:09.000Z",
"branch": "fb-HUMSIG-37-visuals"
"message": "Update web/libs/datamanager/src/components/CellViews/index.js",
"commit": "8553ac21be3cf2f6546938902868db11ecbea92a",
"date": "2024-04-09T15:06:54.000Z",
"branch": "fb-leap-859/colimn-special-characters"
}
8 changes: 8 additions & 0 deletions web/libs/datamanager/src/components/CellViews/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { toStudlyCaps } from "strman";

export { Agreement } from './Agreement/Agreement';
export {
Annotators,
Expand All @@ -15,3 +17,9 @@ export { StringCell as Text } from "./StringCell";
export { VideoCell as Video } from "./VideoCell";
export { ProjectCell as Project } from './ProjectCell';

export function normalizeCellAlias(alias) {
// remove trailing separators to make `toStudlyCaps` safe
const safeAlias = alias.replace(/[-_\s]+$/g, '');

return toStudlyCaps(safeAlias);
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { observer } from "mobx-react";
import React from "react";
import { toStudlyCaps } from 'strman';
import { Block } from "../../../../utils/bem";
import { FF_LOPS_E_3, isFF } from "../../../../utils/feature-flags";
import { normalizeCellAlias } from "../../../CellViews";
import { SkeletonLoader } from "../../SkeletonLoader";
import { TableContext, TableElem } from "../TableContext";
import { getProperty, getStyle } from "../utils";
import "./TableRow.styl";
import { SkeletonLoader } from "../../SkeletonLoader";
import { FF_LOPS_E_3, isFF } from "../../../../utils/feature-flags";

const CellRenderer = observer(
({ col: colInput, data, decoration, cellViews }) => {
Expand All @@ -24,7 +24,7 @@ const CellRenderer = observer(


const valuePath = id.split(":")[1] ?? id;
const altType = toStudlyCaps(valuePath);
const altType = normalizeCellAlias(valuePath);
const value = getProperty(data, valuePath);

const Renderer = cellViews[altType] ?? cellViews[col.original.currentType] ?? cellViews.String;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { observer } from "mobx-react";
import React from "react";
import { toStudlyCaps } from 'strman';
import { Block } from "../../../../utils/bem";
import { TableContext, TableElem } from "../TableContext";
import { getProperty, getStyle } from "../utils";
import { FF_LOPS_E_3, isFF } from "../../../../utils/feature-flags";
import { normalizeCellAlias } from "../../../CellViews";
import { SkeletonLoader } from "../../SkeletonLoader";
import "./TableRow.styl";
import { FF_LOPS_E_3, isFF } from "../../../../utils/feature-flags";
import { TableContext, TableElem } from "../TableContext";
import { getProperty, getStyle } from "../utils";

const CellRenderer = observer(
({ col: colInput, data, decoration, cellViews }) => {
Expand All @@ -24,7 +24,7 @@ const CellRenderer = observer(


const valuePath = id.split(":")[1] ?? id;
const altType = toStudlyCaps(valuePath);
const altType = normalizeCellAlias(valuePath);
const value = getProperty(data, valuePath);

const Renderer = cellViews[altType] ?? cellViews[col.original.currentType] ?? cellViews.String;
Expand Down
17 changes: 14 additions & 3 deletions web/libs/datamanager/src/stores/Tabs/tab_column.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { getRoot, getSnapshot, types } from "mobx-state-tree";
import React from "react";
import { toStudlyCaps } from "strman";
import { CommentCheck, CommentRed, LsAnnotation, LsBanSquare, LsSparkSquare, LsStarSquare, LsThumbsDown, LsThumbsUp } from "../../assets/icons";
import {
CommentCheck,
CommentRed,
LsAnnotation,
LsBanSquare,
LsSparkSquare,
LsStarSquare,
LsThumbsDown,
LsThumbsUp
} from "../../assets/icons";
import * as CellViews from "../../components/CellViews";
import { normalizeCellAlias } from "../../components/CellViews";
import { all } from "../../utils/utils";
import { StringOrNumberID } from "../types";

Expand Down Expand Up @@ -214,7 +223,9 @@ export const TabColumn = types
},

get filterable() {
return ((CellViews[self.type] ?? CellViews[toStudlyCaps(self.alias)])?.filterable) !== false;
const cellView = CellViews[self.type] ?? CellViews[normalizeCellAlias(self.alias)];

return cellView?.filterable !== false;
},
}))
.actions((self) => ({
Expand Down
12 changes: 4 additions & 8 deletions web/libs/datamanager/src/stores/Tabs/tab_filter.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { flow, getParent, getRoot, types } from "mobx-state-tree";
import { toStudlyCaps } from "strman";
import * as Filters from "../../components/Filters/types";
import * as CellViews from "../../components/CellViews";
import { normalizeCellAlias } from "../../components/CellViews";
import * as Filters from "../../components/Filters/types";
import { allowedFilterOperations } from "../../components/Filters/types/Utility";
import { debounce } from "../../utils/debounce";
import { isBlank, isDefined } from "../../utils/utils";
import {
FilterValueRange,
FilterValueType,
TabFilterType
} from "./tab_filter_type";
import { FilterValueRange, FilterValueType, TabFilterType } from "./tab_filter_type";

const operatorNames = Array.from(
new Set(
Expand Down Expand Up @@ -99,7 +95,7 @@ export const TabFilter = types
get cellView() {
const col = self.filter.field;

return CellViews[col.type] ?? CellViews[toStudlyCaps(col.alias)];
return CellViews[col.type] ?? CellViews[normalizeCellAlias(col.alias)];
},
}))
.volatile(() => ({
Expand Down