Redirect directly to workflow run when observer task created (#1662)

This commit is contained in:
Shuchang Zheng
2025-01-28 04:57:14 +08:00
committed by GitHub
parent 1dc9308053
commit 81d5babcf0
2 changed files with 11 additions and 31 deletions

View File

@@ -1,13 +1,11 @@
import { getClient } from "@/api/AxiosClient"; import { getClient } from "@/api/AxiosClient";
import { ObserverTask } from "@/api/types"; import { ObserverTask } from "@/api/types";
import { Button } from "@/components/ui/button";
import { toast } from "@/components/ui/use-toast"; import { toast } from "@/components/ui/use-toast";
import { useCredentialGetter } from "@/hooks/useCredentialGetter"; import { useCredentialGetter } from "@/hooks/useCredentialGetter";
import { ReloadIcon } from "@radix-ui/react-icons"; import { ReloadIcon } from "@radix-ui/react-icons";
import { ToastAction } from "@radix-ui/react-toast";
import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useMutation, useQueryClient } from "@tanstack/react-query";
import { AxiosError } from "axios"; import { AxiosError } from "axios";
import { Link, useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
type Props = { type Props = {
exampleId: string; exampleId: string;
@@ -35,17 +33,6 @@ function ExampleCasePill({ exampleId, version, icon, label, prompt }: Props) {
variant: "success", variant: "success",
title: "Workflow Run Created", title: "Workflow Run Created",
description: `Workflow run created successfully.`, description: `Workflow run created successfully.`,
action: (
<ToastAction altText="View">
<Button asChild>
<Link
to={`/workflows/${response.data.workflow_permanent_id}/${response.data.workflow_run_id}`}
>
View
</Link>
</Button>
</ToastAction>
),
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: ["workflowRuns"], queryKey: ["workflowRuns"],
@@ -53,6 +40,9 @@ function ExampleCasePill({ exampleId, version, icon, label, prompt }: Props) {
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: ["workflows"], queryKey: ["workflows"],
}); });
navigate(
`/workflows/${response.data.workflow_permanent_id}/${response.data.workflow_run_id}`,
);
}, },
onError: (error: AxiosError) => { onError: (error: AxiosError) => {
toast({ toast({

View File

@@ -12,7 +12,8 @@ import { GraphIcon } from "@/components/icons/GraphIcon";
import { InboxIcon } from "@/components/icons/InboxIcon"; import { InboxIcon } from "@/components/icons/InboxIcon";
import { MessageIcon } from "@/components/icons/MessageIcon"; import { MessageIcon } from "@/components/icons/MessageIcon";
import { TrophyIcon } from "@/components/icons/TrophyIcon"; import { TrophyIcon } from "@/components/icons/TrophyIcon";
import { Button } from "@/components/ui/button"; import { ProxySelector } from "@/components/ProxySelector";
import { Input } from "@/components/ui/input";
import { import {
CustomSelectItem, CustomSelectItem,
Select, Select,
@@ -21,6 +22,7 @@ import {
SelectTrigger, SelectTrigger,
SelectValue, SelectValue,
} from "@/components/ui/select"; } from "@/components/ui/select";
import { Switch } from "@/components/ui/switch";
import { toast } from "@/components/ui/use-toast"; import { toast } from "@/components/ui/use-toast";
import { useCredentialGetter } from "@/hooks/useCredentialGetter"; import { useCredentialGetter } from "@/hooks/useCredentialGetter";
import { import {
@@ -31,20 +33,16 @@ import {
PlusIcon, PlusIcon,
ReloadIcon, ReloadIcon,
} from "@radix-ui/react-icons"; } from "@radix-ui/react-icons";
import { ToastAction } from "@radix-ui/react-toast";
import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useMutation, useQueryClient } from "@tanstack/react-query";
import { AxiosError } from "axios"; import { AxiosError } from "axios";
import { useState } from "react"; import { useState } from "react";
import { Link, useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { stringify as convertToYAML } from "yaml"; import { stringify as convertToYAML } from "yaml";
import { import {
generatePhoneNumber, generatePhoneNumber,
generateUniqueEmail, generateUniqueEmail,
} from "../data/sampleTaskData"; } from "../data/sampleTaskData";
import { ExampleCasePill } from "./ExampleCasePill"; import { ExampleCasePill } from "./ExampleCasePill";
import { Input } from "@/components/ui/input";
import { ProxySelector } from "@/components/ProxySelector";
import { Switch } from "@/components/ui/switch";
function createTemplateTaskFromTaskGenerationParameters( function createTemplateTaskFromTaskGenerationParameters(
values: TaskGenerationApiResponse, values: TaskGenerationApiResponse,
@@ -174,17 +172,6 @@ function PromptBox() {
variant: "success", variant: "success",
title: "Workflow Run Created", title: "Workflow Run Created",
description: `Workflow run created successfully.`, description: `Workflow run created successfully.`,
action: (
<ToastAction altText="View">
<Button asChild>
<Link
to={`/workflows/${response.data.workflow_permanent_id}/${response.data.workflow_run_id}`}
>
View
</Link>
</Button>
</ToastAction>
),
}); });
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: ["workflowRuns"], queryKey: ["workflowRuns"],
@@ -192,6 +179,9 @@ function PromptBox() {
queryClient.invalidateQueries({ queryClient.invalidateQueries({
queryKey: ["workflows"], queryKey: ["workflows"],
}); });
navigate(
`/workflows/${response.data.workflow_permanent_id}/${response.data.workflow_run_id}`,
);
}, },
onError: (error: AxiosError) => { onError: (error: AxiosError) => {
toast({ toast({