Skip to content

Commit

Permalink
refactor: remove pipeline versions (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cahllagerfeld authored Jul 29, 2024
1 parent 0e5c0ef commit 6fb83d6
Show file tree
Hide file tree
Showing 14 changed files with 729 additions and 358 deletions.
16 changes: 1 addition & 15 deletions src/app/pipelines/[namespace]/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import { InlineAvatar } from "@/components/InlineAvatar";
import { routes } from "@/router/routes";
import { CodeRepository } from "@/types/code-repository";
import { PipelineRun, PipelineRunBody } from "@/types/pipeline-runs";
import { PipelineBody } from "@/types/pipelines";
import { Stack } from "@/types/stack";
import { User } from "@/types/user";
import { ColumnDef } from "@tanstack/react-table";
import { Badge, Tag } from "@zenml-io/react-component-library";
import { Tag } from "@zenml-io/react-component-library";
import { Link } from "react-router-dom";

export function getPipelineDetailColumns(): ColumnDef<PipelineRun>[] {
Expand Down Expand Up @@ -48,19 +47,6 @@ export function getPipelineDetailColumns(): ColumnDef<PipelineRun>[] {
);
}
},
{
id: "version",
header: "Version",
accessorFn: (row) => row.body?.pipeline?.body?.version,
cell: ({ getValue }) => {
const version = getValue<PipelineBody["version"]>();
return (
<Badge color="purple" className="inline-flex" size="sm">
{version}
</Badge>
);
}
},
{
id: "stack",
header: "Stack",
Expand Down
16 changes: 8 additions & 8 deletions src/app/pipelines/columns.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import RunIcon from "@/assets/icons/terminal.svg?react";
import PipelineIcon from "@/assets/icons/pipeline.svg?react";
import RunIcon from "@/assets/icons/terminal.svg?react";
import { CopyButton } from "@/components/CopyButton";
import { ExecutionStatusIcon, getExecutionStatusColor } from "@/components/ExecutionStatus";
import { routes } from "@/router/routes";
import { ExecutionStatus } from "@/types/pipeline-runs";
import { PipelineNamespace, PipelineNamespaceBody } from "@/types/pipelines";
import { Pipeline } from "@/types/pipelines";
import { ColumnDef } from "@tanstack/react-table";
import { Tag, TagProps } from "@zenml-io/react-component-library";
import { Link } from "react-router-dom";
import { routes } from "@/router/routes";
import { CopyButton } from "@/components/CopyButton";

export function getPipelineColumns(): ColumnDef<PipelineNamespace>[] {
export function getPipelineColumns(): ColumnDef<Pipeline>[] {
return [
{
id: "name",
header: "Pipeline",
accessorFn: (row) => ({ name: row.name, status: row.body?.latest_run_status }),
cell: ({ getValue }) => {
const { name, status } = getValue<{
name: PipelineNamespace["name"];
status: PipelineNamespaceBody["latest_run_status"];
name: string;
status: ExecutionStatus;
}>();

return (
Expand Down Expand Up @@ -46,7 +46,7 @@ export function getPipelineColumns(): ColumnDef<PipelineNamespace>[] {
cell: ({ getValue }) => {
const { runId, status } = getValue<{
runId?: string;
status?: PipelineNamespaceBody["latest_run_status"];
status?: ExecutionStatus;
}>();

if (!runId || !status) return <div>No run</div>;
Expand Down
22 changes: 9 additions & 13 deletions src/app/pipelines/page.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
import Refresh from "@/assets/icons/refresh.svg?react";
import { PageHeader } from "@/components/PageHeader";
import Pagination from "@/components/Pagination";
import { SearchField } from "@/components/SearchField";
import { useAllPipelineNamespaces } from "@/data/pipelines/pipeline-namespaces-query";
import { pipelineQueries } from "@/data/pipelines";
import { useBreadcrumbsContext } from "@/layouts/AuthenticatedLayout/BreadcrumbsContext";
import { useQuery } from "@tanstack/react-query";
import { Button, DataTable, Skeleton } from "@zenml-io/react-component-library";
import { useEffect } from "react";
import { getPipelineColumns } from "./columns";
import { usePipelineOverviewSearchParams } from "./service";
import Pagination from "@/components/Pagination";
import { useBreadcrumbsContext } from "@/layouts/AuthenticatedLayout/BreadcrumbsContext";
import { useEffect } from "react";

export default function PipelinesPage() {
const { setCurrentBreadcrumbData } = useBreadcrumbsContext();
const queryParams = usePipelineOverviewSearchParams();

const { data, refetch } = useAllPipelineNamespaces(
{
params: {
...queryParams,
sort_by: "desc:updated"
}
},
{ throwOnError: true }
);
const { data, refetch } = useQuery({
...pipelineQueries.pipelineList({ ...queryParams, sort_by: "desc:latest_run" }),
throwOnError: true
});

useEffect(() => {
setCurrentBreadcrumbData({ segment: "pipelines", data: null });
Expand Down
4 changes: 2 additions & 2 deletions src/app/pipelines/service.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PipelineNamespacesParams } from "@/types/pipelines";
import { PipelineListParams } from "@/types/pipelines";
import { useSearchParams } from "react-router-dom";

import { z } from "zod";
Expand All @@ -11,7 +11,7 @@ const filterParamsSchema = z.object({
operator: z.enum(["and", "or"]).optional()
});

export function usePipelineOverviewSearchParams(): PipelineNamespacesParams {
export function usePipelineOverviewSearchParams(): PipelineListParams {
const [searchParams] = useSearchParams();

const { page, name, operator } = filterParamsSchema.parse({
Expand Down
3 changes: 0 additions & 3 deletions src/app/runs/[id]/_Tabs/Overview/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ export function Details() {
>
<Pipelines className="h-4 w-4 fill-theme-text-brand" />
{data.body?.pipeline?.name}
<div className="rounded-sm bg-primary-50 px-1 py-0.25">
{data.body?.pipeline?.body?.version}
</div>
</Tag>
</Link>
</Value>
Expand Down
2 changes: 1 addition & 1 deletion src/app/stacks/create/new-infrastructure/Steps/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from "zod";
import { stackNameSchema } from "../../components/sharedSchema";

export const providerSchema = z.enum(["aws", "gcp"]);
export const providerSchema = z.enum(["aws", "gcp", "azure"]);

export const providerFormSchema = z.object({
provider: providerSchema
Expand Down
4 changes: 0 additions & 4 deletions src/components/artifacts/artifact-node-sheet/DetailCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ export function DetailsCard({ artifactVersionId }: Props) {
>
<Pipelines className="mr-1 h-4 w-4 fill-theme-text-brand" />
{pipelineRun.data.body?.pipeline?.name}

<div className="rounded-sm bg-primary-50 px-1 py-0.25">
{pipelineRun.data.body?.pipeline?.body?.version}
</div>
</Tag>
</Link>
}
Expand Down
3 changes: 0 additions & 3 deletions src/components/steps/step-sheet/DetailsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@ export function StepDetailsTab({ stepId, runId }: Props) {
>
<Pipelines className="mr-1 h-4 w-4 fill-theme-text-brand" />
{pipelineRunData.body?.pipeline?.name}
<div className="rounded-sm bg-primary-50 px-1 py-0.25">
{pipelineRunData.body?.pipeline?.body?.version}
</div>
</Tag>
</Link>
}
Expand Down
2 changes: 1 addition & 1 deletion src/data/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const apiPaths = {
settings: "/settings",
onboarding: "/onboarding_state",
pipelines: {
namespaces: "/pipeline_namespaces"
all: "/pipelines"
},
artifactVersions: {
detail: (versionId: string) => `/artifact_versions/${versionId}`,
Expand Down
12 changes: 12 additions & 0 deletions src/data/pipelines/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { PipelineListParams } from "@/types/pipelines";
import { queryOptions } from "@tanstack/react-query";
import { fetchAllPipelines } from "./pipeline-list-query";

export const pipelineQueries = {
all: ["pipelines"],
pipelineList: (queryParams: PipelineListParams) =>
queryOptions({
queryKey: [...pipelineQueries.all, queryParams],
queryFn: async () => fetchAllPipelines({ params: queryParams })
})
};
31 changes: 31 additions & 0 deletions src/data/pipelines/pipeline-list-query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { FetchError } from "@/lib/fetch-error";
import { notFound } from "@/lib/not-found-error";
import { objectToSearchParams } from "@/lib/url";
import { PipelineListParams } from "@/types/pipelines";
import { apiPaths, createApiPath } from "../api";
import { fetcher } from "../fetch";

export type PipelineOverview = {
params: PipelineListParams;
};

export async function fetchAllPipelines({ params }: PipelineOverview) {
const url = createApiPath(apiPaths.pipelines.all + "?" + objectToSearchParams(params));
const res = await fetcher(url, {
method: "GET",
headers: {
"Content-Type": "application/json"
}
});

if (res.status === 404) notFound();

if (!res.ok) {
throw new FetchError({
message: "Error while fetching pipelines",
status: res.status,
statusText: res.statusText
});
}
return res.json();
}
47 changes: 0 additions & 47 deletions src/data/pipelines/pipeline-namespaces-query.ts

This file was deleted.

Loading

0 comments on commit 6fb83d6

Please sign in to comment.