Add job agent (#1672)
Co-authored-by: Muhammed Salih Altun <muhammedsalihaltun@gmail.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { getClient } from "@/api/AxiosClient";
|
import { getClient } from "@/api/AxiosClient";
|
||||||
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
|
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
|
||||||
import { cn } from "@/util/utils";
|
import { cn } from "@/util/utils";
|
||||||
import { ReloadIcon } from "@radix-ui/react-icons";
|
import { Cross2Icon, FileIcon, ReloadIcon } from "@radix-ui/react-icons";
|
||||||
import { useMutation } from "@tanstack/react-query";
|
import { useMutation } from "@tanstack/react-query";
|
||||||
import { useId, useState } from "react";
|
import { useId, useState } from "react";
|
||||||
import { Button } from "./ui/button";
|
import { Button } from "./ui/button";
|
||||||
@@ -113,11 +113,16 @@ function FileUpload({ value, onChange }: Props) {
|
|||||||
</TabsList>
|
</TabsList>
|
||||||
<TabsContent value="upload">
|
<TabsContent value="upload">
|
||||||
{isManualUpload && ( // redundant check for ts compiler
|
{isManualUpload && ( // redundant check for ts compiler
|
||||||
<div className="flex h-full items-center gap-4">
|
<div className="flex h-full items-center gap-4 p-4">
|
||||||
<a href={value.presignedUrl} className="underline">
|
<a href={value.presignedUrl} className="underline">
|
||||||
<span>{file.name}</span>
|
<div className="flex gap-2">
|
||||||
|
<FileIcon className="size-6" />
|
||||||
|
<span>{file.name}</span>
|
||||||
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<Button onClick={() => reset()}>Change</Button>
|
<Button onClick={() => reset()} size="icon" variant="secondary">
|
||||||
|
<Cross2Icon />
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{value === null && (
|
{value === null && (
|
||||||
|
|||||||
@@ -30,10 +30,11 @@ import {
|
|||||||
useParams,
|
useParams,
|
||||||
useSearchParams,
|
useSearchParams,
|
||||||
} from "react-router-dom";
|
} from "react-router-dom";
|
||||||
import { WorkflowApiResponse } from "./types/workflowTypes";
|
|
||||||
import { WorkflowActions } from "./WorkflowActions";
|
import { WorkflowActions } from "./WorkflowActions";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { StatusFilterDropdown } from "@/components/StatusFilterDropdown";
|
import { StatusFilterDropdown } from "@/components/StatusFilterDropdown";
|
||||||
|
import { useWorkflowQuery } from "./hooks/useWorkflowQuery";
|
||||||
|
import { globalWorkflowIds } from "@/util/env";
|
||||||
|
|
||||||
function WorkflowPage() {
|
function WorkflowPage() {
|
||||||
const credentialGetter = useCredentialGetter();
|
const credentialGetter = useCredentialGetter();
|
||||||
@@ -49,7 +50,12 @@ function WorkflowPage() {
|
|||||||
queryKey: ["workflowRuns", workflowPermanentId, { statusFilters }, page],
|
queryKey: ["workflowRuns", workflowPermanentId, { statusFilters }, page],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const client = await getClient(credentialGetter);
|
const client = await getClient(credentialGetter);
|
||||||
|
const isGlobalWorkflow =
|
||||||
|
workflowPermanentId && globalWorkflowIds.includes(workflowPermanentId);
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
|
if (isGlobalWorkflow) {
|
||||||
|
params.set("template", "true");
|
||||||
|
}
|
||||||
params.append("page", String(page));
|
params.append("page", String(page));
|
||||||
return client
|
return client
|
||||||
.get(`/workflows/${workflowPermanentId}/runs`, {
|
.get(`/workflows/${workflowPermanentId}/runs`, {
|
||||||
@@ -60,16 +66,9 @@ function WorkflowPage() {
|
|||||||
refetchOnMount: "always",
|
refetchOnMount: "always",
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data: workflow, isLoading: workflowIsLoading } =
|
const { data: workflow, isLoading: workflowIsLoading } = useWorkflowQuery({
|
||||||
useQuery<WorkflowApiResponse>({
|
workflowPermanentId,
|
||||||
queryKey: ["workflow", workflowPermanentId],
|
});
|
||||||
queryFn: async () => {
|
|
||||||
const client = await getClient(credentialGetter);
|
|
||||||
return client
|
|
||||||
.get(`/workflows/${workflowPermanentId}`)
|
|
||||||
.then((response) => response.data);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!workflowPermanentId) {
|
if (!workflowPermanentId) {
|
||||||
return null; // this should never happen
|
return null; // this should never happen
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
TooltipProvider,
|
TooltipProvider,
|
||||||
TooltipTrigger,
|
TooltipTrigger,
|
||||||
} from "@/components/ui/tooltip";
|
} from "@/components/ui/tooltip";
|
||||||
|
import { globalWorkflowIds } from "@/util/env";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -30,6 +31,9 @@ function WorkflowHeader({
|
|||||||
onTitleChange,
|
onTitleChange,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const { workflowPermanentId } = useParams();
|
const { workflowPermanentId } = useParams();
|
||||||
|
const isGlobalWorkflow = Boolean(
|
||||||
|
workflowPermanentId && globalWorkflowIds.includes(workflowPermanentId),
|
||||||
|
);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -51,6 +55,7 @@ function WorkflowHeader({
|
|||||||
size="icon"
|
size="icon"
|
||||||
variant="tertiary"
|
variant="tertiary"
|
||||||
className="size-10"
|
className="size-10"
|
||||||
|
disabled={isGlobalWorkflow}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onSave();
|
onSave();
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { getClient } from "@/api/AxiosClient";
|
|||||||
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
|
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { WorkflowApiResponse } from "../types/workflowTypes";
|
import { WorkflowApiResponse } from "../types/workflowTypes";
|
||||||
|
import { globalWorkflowIds } from "@/util/env";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
workflowPermanentId?: string;
|
workflowPermanentId?: string;
|
||||||
@@ -13,8 +14,14 @@ function useWorkflowQuery({ workflowPermanentId }: Props) {
|
|||||||
queryKey: ["workflow", workflowPermanentId],
|
queryKey: ["workflow", workflowPermanentId],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const client = await getClient(credentialGetter);
|
const client = await getClient(credentialGetter);
|
||||||
|
const isGlobalWorkflow =
|
||||||
|
workflowPermanentId && globalWorkflowIds.includes(workflowPermanentId);
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
if (isGlobalWorkflow) {
|
||||||
|
params.set("template", "true");
|
||||||
|
}
|
||||||
return client
|
return client
|
||||||
.get(`/workflows/${workflowPermanentId}`)
|
.get(`/workflows/${workflowPermanentId}`, { params })
|
||||||
.then((response) => response.data);
|
.then((response) => response.data);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
statusIsNotFinalized,
|
statusIsNotFinalized,
|
||||||
statusIsRunningOrQueued,
|
statusIsRunningOrQueued,
|
||||||
} from "@/routes/tasks/types";
|
} from "@/routes/tasks/types";
|
||||||
|
import { globalWorkflowIds } from "@/util/env";
|
||||||
import { keepPreviousData, useQuery } from "@tanstack/react-query";
|
import { keepPreviousData, useQuery } from "@tanstack/react-query";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
|
|
||||||
@@ -16,8 +17,16 @@ function useWorkflowRunQuery() {
|
|||||||
queryKey: ["workflowRun", workflowPermanentId, workflowRunId],
|
queryKey: ["workflowRun", workflowPermanentId, workflowRunId],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const client = await getClient(credentialGetter);
|
const client = await getClient(credentialGetter);
|
||||||
|
const isGlobalWorkflow =
|
||||||
|
workflowPermanentId && globalWorkflowIds.includes(workflowPermanentId);
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
if (isGlobalWorkflow) {
|
||||||
|
params.set("template", "true");
|
||||||
|
}
|
||||||
return client
|
return client
|
||||||
.get(`/workflows/${workflowPermanentId}/runs/${workflowRunId}`)
|
.get(`/workflows/${workflowPermanentId}/runs/${workflowRunId}`, {
|
||||||
|
params,
|
||||||
|
})
|
||||||
.then((response) => response.data);
|
.then((response) => response.data);
|
||||||
},
|
},
|
||||||
refetchInterval: (query) => {
|
refetchInterval: (query) => {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { keepPreviousData, useQuery } from "@tanstack/react-query";
|
|||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import { WorkflowRunTimelineItem } from "../types/workflowRunTypes";
|
import { WorkflowRunTimelineItem } from "../types/workflowRunTypes";
|
||||||
import { useWorkflowRunQuery } from "./useWorkflowRunQuery";
|
import { useWorkflowRunQuery } from "./useWorkflowRunQuery";
|
||||||
|
import { globalWorkflowIds } from "@/util/env";
|
||||||
|
|
||||||
function useWorkflowRunTimelineQuery() {
|
function useWorkflowRunTimelineQuery() {
|
||||||
const { workflowRunId, workflowPermanentId } = useParams();
|
const { workflowRunId, workflowPermanentId } = useParams();
|
||||||
@@ -15,8 +16,17 @@ function useWorkflowRunTimelineQuery() {
|
|||||||
queryKey: ["workflowRunTimeline", workflowPermanentId, workflowRunId],
|
queryKey: ["workflowRunTimeline", workflowPermanentId, workflowRunId],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const client = await getClient(credentialGetter);
|
const client = await getClient(credentialGetter);
|
||||||
|
const isGlobalWorkflow =
|
||||||
|
workflowPermanentId && globalWorkflowIds.includes(workflowPermanentId);
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
if (isGlobalWorkflow) {
|
||||||
|
params.set("template", "true");
|
||||||
|
}
|
||||||
return client
|
return client
|
||||||
.get(`/workflows/${workflowPermanentId}/runs/${workflowRunId}/timeline`)
|
.get(
|
||||||
|
`/workflows/${workflowPermanentId}/runs/${workflowRunId}/timeline`,
|
||||||
|
{ params },
|
||||||
|
)
|
||||||
.then((response) => response.data);
|
.then((response) => response.data);
|
||||||
},
|
},
|
||||||
refetchInterval:
|
refetchInterval:
|
||||||
|
|||||||
@@ -21,10 +21,29 @@ if (!artifactApiBaseUrl) {
|
|||||||
|
|
||||||
const apiPathPrefix = import.meta.env.VITE_API_PATH_PREFIX ?? "";
|
const apiPathPrefix = import.meta.env.VITE_API_PATH_PREFIX ?? "";
|
||||||
|
|
||||||
|
function getGlobalWorkflowIds(): Array<string> {
|
||||||
|
const globalWorkflowIds = import.meta.env.VITE_GLOBAL_WORKFLOW_IDS;
|
||||||
|
if (!globalWorkflowIds) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const globalWorkflowIdsAsAList = JSON.parse(globalWorkflowIds);
|
||||||
|
if (Array.isArray(globalWorkflowIdsAsAList)) {
|
||||||
|
return globalWorkflowIdsAsAList;
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
} catch {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const globalWorkflowIds = getGlobalWorkflowIds();
|
||||||
|
|
||||||
export {
|
export {
|
||||||
apiBaseUrl,
|
apiBaseUrl,
|
||||||
environment,
|
environment,
|
||||||
envCredential,
|
envCredential,
|
||||||
artifactApiBaseUrl,
|
artifactApiBaseUrl,
|
||||||
apiPathPrefix,
|
apiPathPrefix,
|
||||||
|
globalWorkflowIds,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user