Skip to content

Commit cf83b47

Browse files
fix: OPTIC-152: Uploading a text field but only 'true' is showing up not 'false' (#5367)
* [submodules] Copy src HumanSignal/dm2 Workflow run: https://github.com/HumanSignal/label-studio/actions/runs/7670167986 * ci: Build frontend Workflow run: https://github.com/HumanSignal/label-studio/actions/runs/7670194317 * [submodules] Copy src HumanSignal/dm2 Workflow run: https://github.com/HumanSignal/label-studio/actions/runs/7700836636 * [submodules] Copy src HumanSignal/dm2 Workflow run: https://github.com/HumanSignal/label-studio/actions/runs/7700844718 * ci: Build frontend Workflow run: https://github.com/HumanSignal/label-studio/actions/runs/7700874519 * [submodules] Copy src HumanSignal/dm2 Workflow run: https://github.com/HumanSignal/label-studio/actions/runs/7701229257 * adding unit test * ci: Build frontend Workflow run: https://github.com/HumanSignal/label-studio/actions/runs/7701262608 * [submodules] Copy src HumanSignal/dm2 Workflow run: https://github.com/HumanSignal/label-studio/actions/runs/7712689504 --------- Co-authored-by: Yousif Yassi <[email protected]> Co-authored-by: robot-ci-heartex <[email protected]> Co-authored-by: yyassi-heartex <[email protected]>
1 parent adb6007 commit cf83b47

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

web/dist/libs/datamanager/main.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/dist/libs/datamanager/main.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/libs/datamanager/src/components/CellViews/DateTimeCell.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { format, isValid } from "date-fns";
2+
export const dateTimeFormat = "MMM dd yyyy, HH:mm:ss";
23

34
export const DateTimeCell = (column) => {
45
const date = new Date(column.value);
5-
const dateFormat = "MMM dd yyyy, HH:mm:ss";
66

77
return column.value ? (
88
<div style={{ whiteSpace: "nowrap" }}>
9-
{isValid(date) ? format(date, dateFormat) : ""}
9+
{isValid(date) ? format(date, dateTimeFormat) : ""}
1010
</div>
1111
) : (
1212
""
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
1-
const valueToString = (value) => {
1+
import { format, isValid } from "date-fns";
2+
import { dateTimeFormat } from "./DateTimeCell";
3+
4+
export const valueToString = (value) => {
25
if (typeof value === "string") return value;
6+
/* if undefined or null we'll treat it as empty string */
7+
if (value === undefined || value === null) return "";
8+
if (value instanceof Date && isValid(value)) return format(value, dateTimeFormat);
39

410
try {
11+
/* JSON.stringify will handle JSON and non-strings, non-null, non-undefined */
512
return JSON.stringify(value);
613
} catch {
7-
return value.toString();
14+
return 'Error: Invalid JSON';
815
}
916
};
1017

1118
export const StringCell = ({ value }) => {
19+
const style = {
20+
maxHeight: "100%",
21+
overflow: "hidden",
22+
fontSize: 12,
23+
lineHeight: "16px",
24+
};
25+
1226
return (
13-
<div
14-
style={{
15-
maxHeight: "100%",
16-
overflow: "hidden",
17-
fontSize: 12,
18-
lineHeight: "16px",
19-
}}
20-
>
21-
{value ? valueToString(value) : ""}
27+
<div style={style}>
28+
{valueToString(value)}
2229
</div>
2330
);
2431
};

0 commit comments

Comments
 (0)