Change parameter addition overlay to include a new tab for credentials (#1886)
Co-authored-by: Muhammed Salih Altun <muhammedsalihaltun@gmail.com>
This commit is contained in:
@@ -20,7 +20,7 @@ function SwitchBar({ options, value, onChange }: Props) {
|
|||||||
<div
|
<div
|
||||||
key={option.value}
|
key={option.value}
|
||||||
className={cn(
|
className={cn(
|
||||||
"cursor-pointer rounded-sm px-3 py-2 text-xs hover:bg-slate-700",
|
"cursor-pointer whitespace-nowrap rounded-sm px-3 py-2 text-xs hover:bg-slate-700",
|
||||||
{
|
{
|
||||||
"bg-slate-700": selected,
|
"bg-slate-700": selected,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ function WorkflowBlockInput(props: Props) {
|
|||||||
<PlusIcon className="size-4" />
|
<PlusIcon className="size-4" />
|
||||||
</div>
|
</div>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent>
|
<PopoverContent className="w-[22rem]">
|
||||||
<WorkflowBlockParameterSelect
|
<WorkflowBlockParameterSelect
|
||||||
nodeId={nodeId}
|
nodeId={nodeId}
|
||||||
onAdd={(parameterKey) => {
|
onAdd={(parameterKey) => {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ function WorkflowBlockInputTextarea(props: Props) {
|
|||||||
<PlusIcon className="size-4" />
|
<PlusIcon className="size-4" />
|
||||||
</div>
|
</div>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent>
|
<PopoverContent className="w-[22rem]">
|
||||||
<WorkflowBlockParameterSelect
|
<WorkflowBlockParameterSelect
|
||||||
nodeId={nodeId}
|
nodeId={nodeId}
|
||||||
onAdd={(parameterKey) => {
|
onAdd={(parameterKey) => {
|
||||||
|
|||||||
@@ -23,7 +23,17 @@ function WorkflowBlockParameterSelect({ nodeId, onAdd }: Props) {
|
|||||||
edges,
|
edges,
|
||||||
nodeId,
|
nodeId,
|
||||||
);
|
);
|
||||||
const workflowParameterKeys = workflowParameters.map(
|
const credentialParameters = workflowParameters.filter(
|
||||||
|
(parameter) => parameter.parameterType === "credential",
|
||||||
|
);
|
||||||
|
const credentialParameterKeys = credentialParameters.map(
|
||||||
|
(parameter) => parameter.key,
|
||||||
|
);
|
||||||
|
|
||||||
|
const nonCredentialParameters = workflowParameters.filter(
|
||||||
|
(parameter) => parameter.parameterType !== "credential",
|
||||||
|
);
|
||||||
|
const nonCredentialParameterKeys = nonCredentialParameters.map(
|
||||||
(parameter) => parameter.key,
|
(parameter) => parameter.key,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -40,6 +50,10 @@ function WorkflowBlockParameterSelect({ nodeId, onAdd }: Props) {
|
|||||||
label: "Parameters",
|
label: "Parameters",
|
||||||
value: "parameters",
|
value: "parameters",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "Credentials",
|
||||||
|
value: "credentials",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: "Block Outputs",
|
label: "Block Outputs",
|
||||||
value: "outputs",
|
value: "outputs",
|
||||||
@@ -48,9 +62,9 @@ function WorkflowBlockParameterSelect({ nodeId, onAdd }: Props) {
|
|||||||
/>
|
/>
|
||||||
<ScrollArea>
|
<ScrollArea>
|
||||||
<ScrollAreaViewport className="max-h-96">
|
<ScrollAreaViewport className="max-h-96">
|
||||||
{content === "parameters" && (
|
{content === "credentials" && (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{workflowParameterKeys.map((parameterKey) => {
|
{credentialParameterKeys.map((parameterKey) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={parameterKey}
|
key={parameterKey}
|
||||||
@@ -64,7 +78,28 @@ function WorkflowBlockParameterSelect({ nodeId, onAdd }: Props) {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{workflowParameterKeys.length === 0 && (
|
{credentialParameterKeys.length === 0 && (
|
||||||
|
<div className="text-xs">No credentials</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{content === "parameters" && (
|
||||||
|
<div className="space-y-2">
|
||||||
|
{nonCredentialParameterKeys.map((parameterKey) => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={parameterKey}
|
||||||
|
className="flex cursor-pointer justify-between rounded-md bg-slate-elevation1 px-3 py-2 text-xs hover:bg-slate-elevation2"
|
||||||
|
onClick={() => {
|
||||||
|
onAdd(parameterKey);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{parameterKey}
|
||||||
|
<PlusIcon />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
{nonCredentialParameterKeys.length === 0 && (
|
||||||
<div className="text-xs">No workflow parameters</div>
|
<div className="text-xs">No workflow parameters</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user