Files
twenty/packages/twenty-ui/src/json-visualizer/components/JsonNode.tsx
T
Thomas Trompette cbfd73cbd8 Enable filters in iterators (#15017)
Filters should not cut the whole workflow. These should only stop the
branch. This PR:
- adds a new skipped status 
- when a filter stops, it still goes to the next step
- the next step will execute if there is at least a successful step
- if only skipped step, it will be skipped as well

It allows to use filters in iterators.


https://github.com/user-attachments/assets/1cfca052-55c0-4ce5-9eb8-63736618d082
2025-10-09 23:14:54 +02:00

102 lines
2.1 KiB
TypeScript

import {
isBoolean,
isNonEmptyString,
isNumber,
isString,
} from '@sniptt/guards';
import {
IconCheckbox,
IconCircleOff,
IconNumber9,
IconTypography,
} from '@ui/display';
import { JsonArrayNode } from '@ui/json-visualizer/components/JsonArrayNode';
import { JsonObjectNode } from '@ui/json-visualizer/components/JsonObjectNode';
import { JsonValueNode } from '@ui/json-visualizer/components/JsonValueNode';
import { useJsonTreeContextOrThrow } from '@ui/json-visualizer/hooks/useJsonTreeContextOrThrow';
import { isArray } from '@ui/json-visualizer/utils/isArray';
import { isDefined } from 'twenty-shared/utils';
import { type JsonValue } from 'type-fest';
export const JsonNode = ({
label,
value,
depth,
keyPath,
}: {
label?: string;
value: JsonValue;
depth: number;
keyPath: string;
}) => {
const { getNodeHighlighting, emptyStringLabel } = useJsonTreeContextOrThrow();
const highlighting = getNodeHighlighting?.(keyPath);
if (!isDefined(value)) {
return (
<JsonValueNode
label={label}
valueAsString="null"
Icon={IconCircleOff}
highlighting={highlighting}
/>
);
}
if (isString(value)) {
return (
<JsonValueNode
label={label}
valueAsString={isNonEmptyString(value) ? value : emptyStringLabel}
Icon={IconTypography}
highlighting={highlighting}
/>
);
}
if (isNumber(value)) {
return (
<JsonValueNode
label={label}
valueAsString={String(value)}
Icon={IconNumber9}
highlighting={highlighting}
/>
);
}
if (isBoolean(value)) {
return (
<JsonValueNode
label={label}
valueAsString={String(value)}
Icon={IconCheckbox}
highlighting={highlighting}
/>
);
}
if (isArray(value)) {
return (
<JsonArrayNode
label={label}
value={value}
depth={depth}
keyPath={keyPath}
highlighting={highlighting}
/>
);
}
return (
<JsonObjectNode
label={label}
value={value}
depth={depth}
keyPath={keyPath}
highlighting={highlighting}
/>
);
};