Change routing rules in workflow pages (#882)

This commit is contained in:
Kerem Yilmaz
2024-09-25 07:15:02 -07:00
committed by GitHub
parent 8a93c08d67
commit dfc769f807
5 changed files with 22 additions and 9 deletions

View File

@@ -102,6 +102,10 @@ const router = createBrowserRouter([
children: [ children: [
{ {
index: true, index: true,
element: <Navigate to="runs" />,
},
{
path: "edit",
element: <WorkflowEditor />, element: <WorkflowEditor />,
}, },
{ {

View File

@@ -3,7 +3,7 @@ import GitHubButton from "react-github-btn";
import { Link, useMatch } from "react-router-dom"; import { Link, useMatch } from "react-router-dom";
function Header() { function Header() {
const match = useMatch("/workflows/:workflowPermanentId"); const match = useMatch("/workflows/:workflowPermanentId/edit");
if (match) { if (match) {
return null; return null;

View File

@@ -22,6 +22,7 @@ import {
import { useCredentialGetter } from "@/hooks/useCredentialGetter"; import { useCredentialGetter } from "@/hooks/useCredentialGetter";
import { basicTimeFormat } from "@/util/timeFormat"; import { basicTimeFormat } from "@/util/timeFormat";
import { cn } from "@/util/utils"; import { cn } from "@/util/utils";
import { Pencil2Icon } from "@radix-ui/react-icons";
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import { import {
Link, Link,
@@ -84,11 +85,19 @@ function WorkflowPage() {
</> </>
)} )}
</div> </div>
<Button asChild> <div className="flex gap-2">
<Link to={`/workflows/${workflowPermanentId}/run`}> <Button asChild variant="secondary">
Create New Run <Link to={`/workflows/${workflowPermanentId}/edit`}>
</Link> <Pencil2Icon className="mr-2 h-4 w-4" />
</Button> Edit Workflow
</Link>
</Button>
<Button asChild>
<Link to={`/workflows/${workflowPermanentId}/run`}>
Create New Run
</Link>
</Button>
</div>
</header> </header>
<div className="space-y-4"> <div className="space-y-4">
<header> <header>

View File

@@ -111,7 +111,7 @@ function Workflows() {
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: ["workflows"], queryKey: ["workflows"],
}); });
navigate(`/workflows/${response.data.workflow_permanent_id}`); navigate(`/workflows/${response.data.workflow_permanent_id}/edit`);
}, },
}); });
@@ -250,7 +250,7 @@ function Workflows() {
onClick={(event) => { onClick={(event) => {
handleIconClick( handleIconClick(
event, event,
`/workflows/${workflow.workflow_permanent_id}`, `/workflows/${workflow.workflow_permanent_id}/edit`,
); );
}} }}
> >

View File

@@ -2,7 +2,7 @@ import { cn } from "@/util/utils";
import { Outlet, useMatch } from "react-router-dom"; import { Outlet, useMatch } from "react-router-dom";
function WorkflowsPageLayout() { function WorkflowsPageLayout() {
const match = useMatch("/workflows/:workflowPermanentId"); const match = useMatch("/workflows/:workflowPermanentId/edit");
return ( return (
<main <main