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

feat(dashboard): handle v1 legacy workflows redirect #6734

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
172 changes: 88 additions & 84 deletions apps/dashboard/src/components/workflow-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import {
RiPulseFill,
RiRouteFill,
} from 'react-icons/ri';
import { createSearchParams, Link, useLocation, useNavigate, useSearchParams } from 'react-router-dom';

import { createSearchParams, Link, useLocation, useSearchParams } from 'react-router-dom';
import { getV2 } from '@/api/api.client';
import { DefaultPagination } from '@/components/default-pagination';
import { Badge, BadgeContent } from '@/components/primitives/badge';
Expand Down Expand Up @@ -45,13 +44,13 @@ import { WorkflowTags } from '@/components/workflow-tags';
import { useEnvironment } from '@/context/environment/hooks';
import { WorkflowOriginEnum, WorkflowStatusEnum } from '@/utils/enums';
import { QueryKeys } from '@/utils/query-keys';
import { buildRoute, ROUTES } from '@/utils/routes';
import { buildRoute, LEGACY_ROUTES, ROUTES } from '@/utils/routes';

export const WorkflowList = () => {
const { currentEnvironment } = useEnvironment();
const [searchParams, setSearchParams] = useSearchParams();
const location = useLocation();
const navigate = useNavigate();

const hrefFromOffset = (offset: number) => {
return `${location.pathname}?${createSearchParams({
...searchParams,
Expand Down Expand Up @@ -154,86 +153,91 @@ export const WorkflowList = () => {
</>
) : (
<>
{workflowsQuery.data.workflows.map((workflow) => (
<TableRow key={workflow._id} className="relative">
<TableCell className="font-medium">
<div className="flex items-center gap-1">
{workflow.origin === WorkflowOriginEnum.EXTERNAL && (
<Badge className="rounded-full px-1.5" variant="warning-light">
<BadgeContent variant="warning">
<FaCode className="size-3" />
</BadgeContent>
</Badge>
)}
<TruncatedText
className="cursor-pointer"
text={workflow.name}
onClick={() => {
navigate(
buildRoute(ROUTES.EDIT_WORKFLOW, {
environmentId: currentEnvironment?._id ?? '',
workflowId: workflow._id,
})
);
}}
/>
</div>
<TruncatedText className="text-foreground-400 font-code block text-xs" text={workflow._id} />
</TableCell>
<TableCell>
<WorkflowStatus status={workflow.status} />
</TableCell>
<TableCell>
<WorkflowSteps steps={workflow.stepTypeOverviews} />
</TableCell>
<TableCell>
<WorkflowTags tags={workflow.tags || []} />
</TableCell>
<TableCell className="text-foreground-600 text-sm font-medium">
{new Date(workflow.updatedAt).toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
})}
</TableCell>
<TableCell className="w-1">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="icon">
<RiMore2Fill />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-56">
<DropdownMenuGroup>
<DropdownMenuItem>
<RiPlayCircleLine />
Trigger workflow
</DropdownMenuItem>
<DropdownMenuItem disabled={workflow.status === WorkflowStatusEnum.ERROR}>
<RiGitPullRequestFill />
Promote to Production
</DropdownMenuItem>
<DropdownMenuItem>
<RiPulseFill />
View activity
</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem>
<RiPauseCircleLine />
Pause workflow
</DropdownMenuItem>
<DropdownMenuItem className="text-destructive">
<RiDeleteBin2Line />
Delete workflow
</DropdownMenuItem>
</DropdownMenuGroup>
</DropdownMenuContent>
</DropdownMenu>
</TableCell>
</TableRow>
))}
{workflowsQuery.data.workflows.map((workflow) => {
const isV1Workflow = workflow.origin === WorkflowOriginEnum.NOVU_CLOUD_V1;
const workflowLink = isV1Workflow
? buildRoute(LEGACY_ROUTES.EDIT_WORKFLOW, {
workflowId: workflow._id,
})
: buildRoute(ROUTES.EDIT_WORKFLOW, {
environmentId: currentEnvironment?._id ?? '',
workflowId: workflow._id,
});
return (
<TableRow key={workflow._id} className="relative">
<TableCell className="font-medium">
<div className="flex items-center gap-1">
{workflow.origin === WorkflowOriginEnum.EXTERNAL && (
<Badge className="rounded-full px-1.5" variant="warning-light">
<BadgeContent variant="warning">
<FaCode className="size-3" />
</BadgeContent>
</Badge>
)}
{/**
* reloadDocument is needed for v1 workflows to reload the document when the user navigates to the workflow editor
*/}
<Link to={workflowLink} reloadDocument={isV1Workflow}>
<TruncatedText className="cursor-pointer" text={workflow.name} />
</Link>
Comment on lines +180 to +182
Copy link
Member Author

Choose a reason for hiding this comment

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

wrapped it with Link to have url contexts and better UX

Copy link
Contributor

Choose a reason for hiding this comment

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

👏 praise: Awesome!!‏

</div>
<TruncatedText className="text-foreground-400 font-code block text-xs" text={workflow._id} />
</TableCell>
<TableCell>
<WorkflowStatus status={workflow.status} />
</TableCell>
<TableCell>
<WorkflowSteps steps={workflow.stepTypeOverviews} />
</TableCell>
<TableCell>
<WorkflowTags tags={workflow.tags || []} />
</TableCell>
<TableCell className="text-foreground-600 text-sm font-medium">
{new Date(workflow.updatedAt).toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
})}
</TableCell>
<TableCell className="w-1">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="icon">
<RiMore2Fill />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-56">
<DropdownMenuGroup>
<DropdownMenuItem>
<RiPlayCircleLine />
Trigger workflow
</DropdownMenuItem>
<DropdownMenuItem disabled={workflow.status === WorkflowStatusEnum.ERROR}>
<RiGitPullRequestFill />
Promote to Production
</DropdownMenuItem>
<DropdownMenuItem>
<RiPulseFill />
View activity
</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem>
<RiPauseCircleLine />
Pause workflow
</DropdownMenuItem>
<DropdownMenuItem className="text-destructive">
<RiDeleteBin2Line />
Delete workflow
</DropdownMenuItem>
</DropdownMenuGroup>
</DropdownMenuContent>
</DropdownMenu>
</TableCell>
</TableRow>
);
})}
</>
)}
</TableBody>
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/src/utils/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ export const LEGACY_ROUTES = {
BILLING: '/legacy/manage-account/billing',
INVITE_TEAM_MEMBERS: '/legacy/manage-account/team-members',
SETTINGS: '/legacy/manage-account/user-profile',
EDIT_WORKFLOW: '/legacy/workflows/edit/:workflowId',
};
Loading