Skip to content

Commit

Permalink
feat: manual stack registration (#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cahllagerfeld authored Aug 5, 2024
1 parent 17c4041 commit 16dffc9
Show file tree
Hide file tree
Showing 42 changed files with 1,220 additions and 521 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@dagrejs/dagre": "^1.1.2",
"@fontsource/inter": "^5.0.18",
"@hookform/resolvers": "^3.5.0",
"@radix-ui/react-tabs": "^1.1.0",
"@tanstack/react-query": "^5.40.1",
"@tanstack/react-table": "^8.17.3",
"@tisoap/react-flow-smart-edge": "^3.0.0",
Expand Down
103 changes: 88 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions src/app/stacks/ActionsDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import {
DropdownMenuTrigger
} from "@zenml-io/react-component-library";
import { useRef, useState } from "react";
import { DeleteStackDialog, UpdateStackDialog } from "./DialogItems";
import { UpdateStackDialog } from "./DialogItems";
import { AlertDialogItem } from "../../components/AlertDialogDropdownItem";
import { DeleteStackDialog } from "./DeleteStackModal";

type Props = { name: string };
export function StackActionsMenu({ name }: Props) {
type Props = { name: string; id: string };
export function StackActionsMenu({ name, id }: Props) {
const [hasOpenDialog, setHasOpenDialog] = useState(false);
const [dropdownOpen, setDropdownOpen] = useState(false);

Expand Down Expand Up @@ -60,18 +62,19 @@ export function StackActionsMenu({ name }: Props) {
closeModal={() => handleDialogItemOpenChange(false)}
/>
</DialogItem>
<DialogItem
<AlertDialogItem
onSelect={handleDialogItemSelect}
onOpenChange={handleDialogItemOpenChange}
icon={<Trash className="h-3 w-3 !fill-neutral-400" />}
triggerChildren="Delete"
>
<DeleteStackDialog
stackId={id}
name={name}
className="lg:min-w-[600px]"
closeModal={() => handleDialogItemOpenChange(false)}
/>
</DialogItem>
</AlertDialogItem>
</DropdownMenuContent>
</DropdownMenu>
</DropdownMenu>
Expand Down
58 changes: 58 additions & 0 deletions src/app/stacks/DeleteStackModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import {
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogTitle
} from "@zenml-io/react-component-library";
import { Button } from "@zenml-io/react-component-library/components/server";
import { ComponentPropsWithoutRef, ElementRef, forwardRef } from "react";
import { useDeleteStack } from "./useDeleteStack";

type DeleteDialogProps = {
closeModal?: () => void;
name: string;
stackId: string;
};

export const DeleteStackDialog = forwardRef<
ElementRef<typeof AlertDialogContent>,
ComponentPropsWithoutRef<typeof AlertDialogContent> & DeleteDialogProps
>(({ closeModal, name, stackId, ...rest }, ref) => {
const { handleDelete, deleteStack } = useDeleteStack(stackId);

return (
<AlertDialogContent {...rest} className="p-0" ref={ref}>
<AlertDialogTitle className="m-0 py-2 pl-5 pr-3 text-text-lg font-semibold">
Delete {name}
</AlertDialogTitle>
<div className="border-y border-theme-border-moderate px-5 py-5">
<AlertDialogDescription>
Are you sure you want to delete this stack? <br />
This action cannot be undone.
</AlertDialogDescription>
</div>
<div className="flex justify-end gap-3 px-5 py-3">
<AlertDialogCancel onClick={() => closeModal?.()} asChild>
<Button intent="secondary">Cancel</Button>
</AlertDialogCancel>
<Button
disabled={deleteStack.isPending}
type="button"
onClick={() => handleDelete()}
intent="danger"
>
{deleteStack.isPending && (
<div
role="alert"
aria-busy="true"
className="full h-[20px] w-[20px] animate-spin rounded-rounded border-2 border-theme-text-negative border-b-theme-text-error"
></div>
)}
Delete
</Button>
</div>
</AlertDialogContent>
);
});

DeleteStackDialog.displayName = "DeleteStackDialog";
22 changes: 0 additions & 22 deletions src/app/stacks/DialogItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,6 @@ export const UpdateStackDialog = forwardRef<

UpdateStackDialog.displayName = "UpdateStackDialog";

export const DeleteStackDialog = forwardRef<
ElementRef<typeof DialogContent>,
ComponentPropsWithoutRef<typeof DialogContent> & Props
>(({ closeModal, name, ...rest }, ref) => {
return (
<DialogContent {...rest} ref={ref}>
<DialogHeader>
<DialogTitle>Delete Stack</DialogTitle>
</DialogHeader>
<div className="space-y-5 p-7">
<Infobox action="delete" />
<div className="space-y-1">
<p className="text-text-sm text-theme-text-secondary">Delete a stack</p>
<Codesnippet codeClasses="whitespace-pre-wrap" wrap code={`zenml stack delete ${name}`} />
</div>
</div>
</DialogContent>
);
});

DeleteStackDialog.displayName = "DeleteStackDialog";

type InfoProps = {
action: "delete" | "update" | "describe";
};
Expand Down
54 changes: 0 additions & 54 deletions src/app/stacks/Fallback/Fragments.tsx

This file was deleted.

Loading

0 comments on commit 16dffc9

Please sign in to comment.