Skip to content

Commit

Permalink
feat: general codeeditor input. can accept any language
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-vm committed Dec 5, 2023
1 parent 1b50c0d commit 187e7da
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const ArrayInput: React.FC<ArrayInputItemProps> = ({
return "DatetimeInput";
} else if (
subItemSchema?.type === "string" &&
subItemSchema?.widget === "codeeditor"
subItemSchema?.widget.includes("codeeditor")
) {
return "CodeEditorInput";
} else if (subItemSchema?.type === "object") {
Expand Down Expand Up @@ -300,7 +300,14 @@ const ArrayInput: React.FC<ArrayInputItemProps> = ({
)}
{!fromUpstream && elementType === "CodeEditorInput" && (
<Grid item xs={9}>
<CodeEditorInput name={`${name}.${index}.value`} />
<CodeEditorInput
language={
subItemSchema?.widget === "codeeditor"
? "python"
: subItemSchema.widget.replace("codeeditor-", "")
}
name={`${name}.${index}.value`}
/>
</Grid>
)}
{!fromUpstream && elementType === "Unknown" && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,50 +181,21 @@ const PieceFormItem: React.FC<PieceFormItemProps> = ({
("type" in schema &&
"widget" in schema &&
schema.type === "string" &&
(schema.widget === "codeeditor" ||
schema.widget === "codeeditor-python")) ||
schema.widget?.includes("codeeditor")) ??
("widget" in schema &&
(schema.widget === "codeeditor" ||
schema.widget === "codeeditor-python") &&
anyOfType === "string")
) {
inputElement = (
<CodeEditorInput<IWorkflowPieceData>
name={`inputs.${itemKey}.value`}
language="python"
placeholder="Enter Python code."
/>
);
} else if (
("type" in schema &&
"widget" in schema &&
schema.type === "string" &&
schema.widget === "codeeditor-json") ||
("widget" in schema &&
(schema.widget === "codeeditor" || schema.widget === "codeeditor-json") &&
anyOfType === "string")
) {
inputElement = (
<CodeEditorInput<IWorkflowPieceData>
name={`inputs.${itemKey}.value`}
language="json"
placeholder="Enter JSON code."
/>
);
} else if (
("type" in schema &&
"widget" in schema &&
schema.type === "string" &&
schema.widget === "codeeditor-sql") ||
("widget" in schema &&
(schema.widget === "codeeditor" || schema.widget === "codeeditor-sql") &&
schema.widget?.includes("codeeditor") &&
anyOfType === "string")
) {
const language =
schema.widget === "codeeditor"
? "python"
: schema.widget.replace("codeeditor-", "");

inputElement = (
<CodeEditorInput<IWorkflowPieceData>
name={`inputs.${itemKey}.value`}
language="sql"
placeholder="Enter SQL code."
language={language}
placeholder={`Enter yor ${language} code here.`}
/>
);
} else if (
Expand Down

0 comments on commit 187e7da

Please sign in to comment.