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

Redesign the workflow editor experience #6802

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ const createStep = (type: StepTypeEnum): Step => ({
_id: crypto.randomUUID(),
});

const For = ({ items, renderItem }: { items: any[]; renderItem: (item: any) => ReactNode }) => {
return <>{items.map(renderItem)}</>;
};

const Liquid = ({ template, data }: { template: string; data: any }) => {
const compiledTemplate = compileTemplate(template);
return <>{compiledTemplate(data)}</>;
};

const compileTemplate = (template: string) => {
// Implement the logic to compile the Liquid template
return (data: any) => {
// Implement the logic to render the compiled template with data
return template;
};
};

export const WorkflowEditorProvider = ({ children }: { children: ReactNode }) => {
const changesSavedToastIdRef = useRef<string | number>();
const { currentEnvironment } = useEnvironment();
Expand Down Expand Up @@ -125,6 +142,8 @@ export const WorkflowEditorProvider = ({ children }: { children: ReactNode }) =>
const value = useMemo(
() => ({
addStep,
For,
Liquid,
}),
[addStep]
);
Expand Down
24 changes: 24 additions & 0 deletions apps/dashboard/src/components/workflow-editor/workflow-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,34 @@ export const WorkflowEditor = () => {
Trigger
</Link>
</TabsTrigger>
<TabsTrigger value="advanced" asChild>
<Link
to={buildRoute(ROUTES.ADVANCED_WORKFLOW, {
environmentId,
workflowId,
})}
>
Advanced
</Link>
</TabsTrigger>
</TabsList>
<TabsContent value="workflow" className="mt-0 h-full w-full">
{steps && <WorkflowCanvas steps={steps} />}
</TabsContent>
<TabsContent value="advanced" className="mt-0 h-full w-full">
<div className="p-4">
<h2 className="text-lg font-semibold">Advanced Data Manipulation</h2>
<p className="mt-2 text-sm text-gray-600">Use the helper components to manipulate data:</p>
<ul className="mt-4 list-disc list-inside">
<li>
<strong>For:</strong> Loop through items and render them.
</li>
<li>
<strong>Liquid:</strong> Use Liquid templates to render dynamic content.
</li>
</ul>
</div>
</TabsContent>
</Tabs>
</div>
);
Expand Down
9 changes: 8 additions & 1 deletion apps/dashboard/src/components/workflow-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export const WorkflowList = () => {
<TableHead>Steps</TableHead>
<TableHead>Tags</TableHead>
<TableHead>Last updated</TableHead>
<TableHead>Advanced Data</TableHead>
<TableHead />
</TableRow>
</TableHeader>
Expand All @@ -148,6 +149,9 @@ export const WorkflowList = () => {
<TableCell className="text-foreground-600 text-sm font-medium">
<Skeleton className="h-5 w-[14ch] rounded-full" />
</TableCell>
<TableCell>
<Skeleton className="h-5 w-[10ch] rounded-full" />
</TableCell>
<TableCell className="text-foreground-600 text-sm font-medium">
<RiMore2Fill className="size-4 opacity-50" />
</TableCell>
Expand Down Expand Up @@ -202,6 +206,9 @@ export const WorkflowList = () => {
day: 'numeric',
})}
</TableCell>
<TableCell className="text-foreground-600 text-sm font-medium">
{workflow.advancedData || 'N/A'}
</TableCell>
<TableCell className="w-1">
<DropdownMenu>
<DropdownMenuTrigger asChild>
Expand Down Expand Up @@ -247,7 +254,7 @@ export const WorkflowList = () => {
{workflowsQuery.data && limit < workflowsQuery.data.totalCount && (
<TableFooter>
<TableRow>
<TableCell colSpan={5}>
<TableCell colSpan={6}>
<div className="flex items-center justify-between">
{workflowsQuery.data ? (
<span className="text-foreground-600 block text-sm font-normal">
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/pages/edit-workflow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Toaster } from '@/components/primitives/sonner';
import { AnimatedOutlet } from '@/components/animated-outlet';

const asideClassName =
'text-foreground-950 flex h-full w-[300px] max-w-[350px] flex-col border-l pb-5 pt-3.5 [&_input]:text-xs [&_input]:text-neutral-600 [&_label]:text-xs [&_label]:font-medium [&_textarea]:text-xs [&_textarea]:text-neutral-600';
'text-foreground-950 flex h-full w-[300px] max-w-[350px] flex-col border-l pb-5 pt-3.5 [&_input]:text-xs [&_input]:text-neutral-600 [&_label]:text-xs [&_label]:font-medium [&_textarea]:text-xs [&_textarea]:text-neutral-600 [&_advanced-data]:text-xs [&_advanced-data]:text-neutral-600';

export const EditWorkflowPage = () => {
return (
Expand Down
Loading