Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
fix(toolkit): fix boolean issue (#963)
Browse files Browse the repository at this point in the history
Because

- fix boolean issue among the pipeline-builder form

This commit

- fix boolean issue among the pipeline-builder form
  • Loading branch information
EiffelFly committed Oct 13, 2023
1 parent db5edfe commit 761b6a5
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion packages/toolkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@instill-ai/toolkit",
"version": "0.69.0",
"version": "0.69.1-rc.9",
"description": "Instill AI's frontend toolkit",
"repository": "https://github.com/instill-ai/design-system.git",
"bugs": "https://github.com/instill-ai/design-system/issues",
Expand Down
19 changes: 7 additions & 12 deletions packages/toolkit/src/view/data/DataComponentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
composeEdgesFromReferences,
extractReferencesFromConfiguration,
recursiveReplaceNullAndEmptyStringWithUndefined,
recursiveTransformToString,
usePipelineBuilderStore,
validateIntillUpstreamTypes,
} from "../pipeline-builder";
Expand All @@ -31,8 +32,8 @@ export const DataResourceSchema = z
// Pinecone - TASK_QUERY
namespace: z.string().nullable().optional(),
top_k: z.string().nullable().optional(),
include_values: z.coerce.boolean().nullable().optional(),
include_metadata: z.coerce.boolean().nullable().optional(),
include_values: z.boolean().nullable().optional(),
include_metadata: z.boolean().nullable().optional(),
vector: z.string().nullable().optional(),

// Pinecone - TASK_UPSERT
Expand Down Expand Up @@ -238,15 +239,7 @@ export const DataComponentForm = ({
},
});

const {
reset,
watch,
formState: { errors },
} = form;

React.useEffect(() => {
console.log(errors);
}, [errors]);
const { reset, watch } = form;

React.useEffect(() => {
reset({
Expand All @@ -258,7 +251,9 @@ export const DataComponentForm = ({

function onSubmit(data: z.infer<typeof DataResourceSchema>) {
if (!selectedConnectorNodeId) return;
const modifiedData = recursiveReplaceNullAndEmptyStringWithUndefined(data);
const modifiedData = recursiveReplaceNullAndEmptyStringWithUndefined(
recursiveTransformToString(data)
);

const newNodes = nodes.map((node) => {
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ const InputPropertyValue = (props: {
);

if (!reference || !reference.nodeId) {
return propertyConfiguration ? (
return propertyConfiguration !== null ||
propertyConfiguration !== undefined ? (
<div className="min-h-[32px] min-w-[100px] break-all rounded-sm text-semantic-fg-secondary border border-semantic-bg-line px-2 py-1.5 product-body-text-3-regular">
{propertyConfiguration}
{`${propertyConfiguration}`}
</div>
) : null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ export function recursiveTransformToString(obj: any) {
return obj;
}

// We directly allow boolean values, because boolean values
// can't be written in referernce syntax right now
if (typeof obj === "boolean") {
return obj;
}

if (Array.isArray(obj)) {
for (const key in obj) {
obj[key] = recursiveTransformToString(obj[key]) as any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ export const templates: PipelineTemplate[] = [
},
images: "{ai_1.output.images}",
},
task: "TASK_COMMIT",
},
type: "COMPONENT_TYPE_CONNECTOR_BLOCKCHAIN",
definition_name: "connector-definitions/blockchain-numbers",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const ObjectField = (props: ObjectFieldProps) => {
return (
<ConnectorNodeFieldRoot title={title} key={`${title}-field`}>
<div className="flex w-full">
<pre className="min-h-[16px] whitespace-pre-line max-w-[480px] breal-all flex flex-1 text-semantic-fg-primary product-body-text-4-regular">
<pre className="min-h-[16px] whitespace-pre-line max-w-[480px] break-all flex flex-1 text-semantic-fg-primary product-body-text-4-regular">
{JSON.stringify(object, null, 2)}
</pre>
</div>
Expand All @@ -25,7 +25,7 @@ export const ObjectField = (props: ObjectFieldProps) => {
return (
<EndNodeFieldRoot title={title} key={`${title}-field`}>
<div className="flex w-full">
<pre className="min-h-[16px] whitespace-pre-line max-w-[480px] breal-all flex flex-1 text-semantic-fg-primary product-body-text-4-regular">
<pre className="min-h-[16px] whitespace-pre-line max-w-[480px] break-all flex flex-1 text-semantic-fg-primary product-body-text-4-regular">
{JSON.stringify(object, null, 2)}
</pre>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const ObjectsField = (props: ObjectsFieldProps) => {
{objects?.map((object) => (
<pre
key={`${title}-${JSON.stringify(object)}-field`}
className="min-h-[16px] whitespace-pre-line max-w-[480px] breal-all flex flex-1 text-semantic-fg-primary product-body-text-4-regular"
className="min-h-[16px] whitespace-pre-line max-w-[480px] break-all flex flex-1 text-semantic-fg-primary product-body-text-4-regular"
>
{JSON.stringify(object, null, 2)}
</pre>
Expand All @@ -33,7 +33,7 @@ export const ObjectsField = (props: ObjectsFieldProps) => {
{objects?.map((object) => (
<pre
key={`${title}-${JSON.stringify(object)}-field`}
className="min-h-[16px] whitespace-pre-line max-w-[480px] breal-all flex flex-1 text-semantic-fg-primary product-body-text-4-regular"
className="min-h-[16px] whitespace-pre-line max-w-[480px] break-all flex flex-1 text-semantic-fg-primary product-body-text-4-regular"
>
{JSON.stringify(object, null, 2)}
</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const TextField = (props: TextFieldProps) => {
return (
<ConnectorNodeFieldRoot title={title} key={`${title}-field`}>
<div className="flex p-2 relative w-full rounded-sm border border-semantic-bg-line flex-row justify-between gap-x-2">
<pre className="min-h-[36px] whitespace-pre-line max-w-[480px] breal-all flex flex-1 text-semantic-fg-primary product-body-text-4-regular">
<pre className="min-h-[36px] whitespace-pre-line max-w-[480px] break-all flex flex-1 text-semantic-fg-primary product-body-text-4-regular">
{text}
</pre>
{text ? (
Expand All @@ -32,7 +32,7 @@ export const TextField = (props: TextFieldProps) => {
return (
<EndNodeFieldRoot title={title} key={`${title}-field`}>
<div className="flex p-2 relative w-full rounded-sm border border-semantic-bg-line flex-row justify-between gap-x-2">
<pre className="min-h-[36px] whitespace-pre-line max-w-[480px] breal-all flex flex-1 text-semantic-fg-primary product-body-text-4-regular">
<pre className="min-h-[36px] whitespace-pre-line max-w-[480px] break-all flex flex-1 text-semantic-fg-primary product-body-text-4-regular">
{text}
</pre>
{text ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const TextsField = (props: TextsFieldProps) => {
key={`${title}-${text}-field`}
className="flex w-full p-2 relative border rounded-sm border-semantic-bg-line flex-row justify-between gap-x-2"
>
<pre className="min-h-[16px] whitespace-pre-line max-w-[480px] breal-all flex flex-1 text-semantic-fg-primary product-body-text-4-regular">
<pre className="min-h-[16px] whitespace-pre-line max-w-[480px] break-all flex flex-1 text-semantic-fg-primary product-body-text-4-regular">
{text}
</pre>
{text ? (
Expand All @@ -42,7 +42,7 @@ export const TextsField = (props: TextsFieldProps) => {
key={`${title}-${text}-field`}
className="flex w-full p-2 border border-semantic-bg-line rounded-sm relative flex-row justify-between gap-x-2"
>
<pre className="min-h-[16px] whitespace-pre-line max-w-[480px] breal-all flex flex-1 text-semantic-fg-primary product-body-text-4-regular">
<pre className="min-h-[16px] whitespace-pre-line max-w-[480px] break-all flex flex-1 text-semantic-fg-primary product-body-text-4-regular">
{text}
</pre>
{text ? (
Expand Down

1 comment on commit 761b6a5

@vercel
Copy link

@vercel vercel bot commented on 761b6a5 Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.