Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🙏 Update workflow sidebar #1130

Merged
merged 9 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion next/src/components/PrimaryButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function PrimaryButton({ children, onClick, icon, className }: Pr
<Button
onClick={onClick}
className={clsx(
"group rounded-full border border-black bg-white text-black transition duration-200 ease-in-out hover:hover:bg-neutral-200 focus-visible:bg-white/90 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-white/30",
"group rounded-full border border-black bg-white text-black transition duration-300 ease-in-out hover:hover:bg-neutral-200 focus-visible:bg-white/90 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-white/30",
className
)}
>
Expand Down
43 changes: 32 additions & 11 deletions next/src/components/drawer/WorkflowSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import clsx from "clsx";
import React from "react";
import { FaBars } from "react-icons/fa";
import type { Edge, Node } from "reactflow";
Expand All @@ -13,7 +14,7 @@ import {
} from "../../services/workflow/node-block-definitions";
import type { WorkflowEdge, WorkflowNode } from "../../types/workflow";
import WorkflowSidebarInput from "../../ui/WorkflowSidebarInput";
import TextButton from "../TextButton";
import PrimaryButton from "../PrimaryButton";

type WorkflowControls = {
selectedNode: Node<WorkflowNode> | undefined;
Expand Down Expand Up @@ -41,16 +42,32 @@ const WorkflowSidebar = ({ show, setShow, controls }: WorkflowSidebarProps) => {

return (
<Sidebar show={show} setShow={setShow} side="right">
<div className="text-color-primary flex h-screen flex-col gap-2">
<div className="text-color-primary mx-2 flex h-screen flex-col gap-2">
<div className="flex flex-row items-center gap-1">
<button
className="neutral-button-primary rounded-md border-none transition-all"
onClick={() => setShow(!show)}
>
<FaBars size="15" className="z-20 m-2" />
<FaBars size="15" className="z-20 mr-2" />
</button>
<TextButton onClick={() => setTab("inspect")}>Inspect</TextButton>
<TextButton onClick={() => setTab("create")}>Create</TextButton>
<div className="rounded-full bg-white/10 p-0.5">
<PrimaryButton
className={clsx(
tab != "inspect" && "border-transparent bg-white/0 text-white hover:text-black"
)}
onClick={() => setTab("inspect")}
>
Inspect
</PrimaryButton>
<PrimaryButton
className={clsx(
tab != "create" && "border-transparent bg-white/0 text-white hover:text-black"
)}
onClick={() => setTab("create")}
>
Create
</PrimaryButton>
</div>
<div />
</div>
{tab === "inspect" && <InspectSection {...controls} />}
Expand All @@ -69,7 +86,11 @@ type InspectSectionProps = {

const InspectSection = ({ selectedNode, updateNode, nodes, edges }: InspectSectionProps) => {
if (selectedNode == undefined)
return <div>No components selected. Click on a component to select it</div>;
return (
<div className="text-sm font-light">
No components selected. Click on a component to select it
</div>
);

const definition = getNodeBlockDefinitionFromNode(selectedNode);

Expand Down Expand Up @@ -127,7 +148,7 @@ const InspectSection = ({ selectedNode, updateNode, nodes, edges }: InspectSecti
<div key={definition?.type + outputField.name}>
<p>
<span className="text-sm font-bold">{outputField.name}:</span>{" "}
<span className="text-sm font-thin">{outputField.type}</span>
<span className="text-sm">{outputField.type}</span>
</p>
<p className="text-sm font-thin">{outputField.description}</p>
</div>
Expand Down Expand Up @@ -165,7 +186,7 @@ type NodeBlockProps = {
const NodeBlock = ({ definition, createNode }: NodeBlockProps) => {
return (
<div
className="flex cursor-pointer flex-row gap-2 rounded-md border border-white/20 p-2 hover:bg-white/10 "
className="flex cursor-pointer flex-col gap-2 rounded-md border border-white/20 p-2 hover:bg-white/10 "
onClick={() => {
const input: Record<string, string> = {};
for (const field of definition.input_fields) {
Expand All @@ -175,11 +196,11 @@ const NodeBlock = ({ definition, createNode }: NodeBlockProps) => {
createNode({ input: input, type: definition.type });
}}
>
<definition.icon size={20} className="mt-1" />
<div>
<div className="flex items-center gap-2">
<definition.icon size={17} />
<h3 className="font-medium">{definition.type}</h3>
<p className="text-sm font-thin">{definition.description}</p>
</div>
<p className="text-sm font-thin">{definition.description}</p>
</div>
);
};
Expand Down
8 changes: 7 additions & 1 deletion next/src/components/workflow/Flowchart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,15 @@ const FlowChart: FC<FlowChartProps> = ({
fitViewOptions={fitViewOptions}
{...props}
>
<Background
variant={BackgroundVariant.Lines}
lineWidth={1}
gap={80}
className="bg-neutral-800"
color="#FFFFFF10"
/>
{props.minimap && <MiniMap nodeStrokeWidth={3} />}
{props.controls && <Controls />}
<Background variant={BackgroundVariant.Lines} lineWidth={0} />
</ReactFlow>
);
};
Expand Down
20 changes: 17 additions & 3 deletions next/src/services/workflow/node-block-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type { WorkflowNode } from "../../types/workflow";

const IOFieldSchema = z.object({
name: z.string(),
description: z.string(),
description: z.string().optional(),
type: z.enum(["string", "array", "enum"]),
items: z.object({ type: z.string() }).optional(),
enum: z.array(z.string()).optional(),
Expand Down Expand Up @@ -145,14 +145,28 @@ const IfBlockDefinition: NodeBlockDefinition = {
image_url: "/tools/web.png",
icon: FaCodeBranch,
input_fields: [
{
name: "value_one",
type: "string",
},
{
name: "operator",
description: "The type of equality to check for",
type: "string",
enum: ["=", "!="],
enum: ["==", "!="],
},
{
name: "value_two",
type: "string",
},
],
output_fields: [
{
name: "result",
description: "The result of the condition",
type: "string",
},
],
output_fields: [],
};

const TriggerBlockDefinition: NodeBlockDefinition = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Node,
WorkflowFull,
)
from reworkd_platform.schemas.workflow.blocks.conditions.ifcondition import (
from reworkd_platform.schemas.workflow.blocks.conditions.if_condition import (
IfCondition,
IfOutput,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from reworkd_platform.schemas.workflow.blocks.conditions.ifcondition import (
from reworkd_platform.schemas.workflow.blocks.conditions.if_condition import (
IfCondition,
IfInput,
IfOutput,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
from reworkd_platform.schemas.workflow.blocks.agents.web_interaction_agent import (
WebInteractionAgent,
)
from reworkd_platform.schemas.workflow.blocks.conditions.ifcondition import IfCondition
from reworkd_platform.schemas.workflow.blocks.conditions.if_condition import IfCondition
from reworkd_platform.schemas.workflow.blocks.manual_trigger import ManualTriggerBlock
from reworkd_platform.schemas.workflow.blocks.slack_webhook import SlackWebhook
from reworkd_platform.schemas.workflow.blocks.status_check import UrlStatusCheckBlock
from reworkd_platform.schemas.workflow.blocks.summarization_webhook import (
SummaryWebhook,
)
from reworkd_platform.schemas.workflow.blocks.text_input_webhook import TextInputWebhook
from reworkd_platform.schemas.workflow.blocks.url_status_check import (
UrlStatusCheckBlock,
)


def get_block_runner(block: Block) -> Block:
Expand Down