-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'future' into refactor/prd-390--onboarding
- Loading branch information
Showing
42 changed files
with
833 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import HorizontalDots from "@/assets/icons/dots-horizontal.svg?react"; | ||
import Edit from "@/assets/icons/edit.svg?react"; | ||
import Trash from "@/assets/icons/trash.svg?react"; | ||
import { DialogItem } from "@/components/dialog/DialogItem"; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuTrigger | ||
} from "@zenml-io/react-component-library"; | ||
import { useRef, useState } from "react"; | ||
import { DeleteStackDialog, UpdateStackDialog } from "./DialogItems"; | ||
|
||
type Props = { name: string }; | ||
export function StackActionsMenu({ name }: Props) { | ||
const [hasOpenDialog, setHasOpenDialog] = useState(false); | ||
const [dropdownOpen, setDropdownOpen] = useState(false); | ||
|
||
const dropdownTriggerRef = useRef(null); | ||
const focusRef = useRef<HTMLElement | null>(null); | ||
|
||
function handleDialogItemSelect() { | ||
focusRef.current = dropdownTriggerRef.current; | ||
} | ||
|
||
function handleDialogItemOpenChange(open: boolean) { | ||
setHasOpenDialog(open); | ||
if (open === false) { | ||
setDropdownOpen(false); | ||
} | ||
} | ||
|
||
return ( | ||
<DropdownMenu open={dropdownOpen} onOpenChange={setDropdownOpen}> | ||
<DropdownMenu> | ||
<DropdownMenuTrigger className="z-10" ref={dropdownTriggerRef}> | ||
<HorizontalDots className="h-5 w-5 fill-theme-text-secondary" /> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent | ||
hidden={hasOpenDialog} | ||
onCloseAutoFocus={(event) => { | ||
if (focusRef.current) { | ||
focusRef.current.focus(); | ||
focusRef.current = null; | ||
event.preventDefault(); | ||
} | ||
}} | ||
className="z-10" | ||
align="end" | ||
sideOffset={1} | ||
> | ||
<DialogItem | ||
onSelect={handleDialogItemSelect} | ||
onOpenChange={handleDialogItemOpenChange} | ||
icon={<Edit className="h-3 w-3 !fill-neutral-400" />} | ||
triggerChildren="Update" | ||
> | ||
<UpdateStackDialog | ||
name={name} | ||
className="lg:min-w-[600px]" | ||
closeModal={() => handleDialogItemOpenChange(false)} | ||
/> | ||
</DialogItem> | ||
<DialogItem | ||
onSelect={handleDialogItemSelect} | ||
onOpenChange={handleDialogItemOpenChange} | ||
icon={<Trash className="h-3 w-3 !fill-neutral-400" />} | ||
triggerChildren="Delete" | ||
> | ||
<DeleteStackDialog | ||
name={name} | ||
className="lg:min-w-[600px]" | ||
closeModal={() => handleDialogItemOpenChange(false)} | ||
/> | ||
</DialogItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
</DropdownMenu> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { DialogContent, DialogHeader, DialogTitle } from "@zenml-io/react-component-library"; | ||
import { ComponentPropsWithoutRef, ElementRef, forwardRef } from "react"; | ||
import { InfoBox as InfoboxPrimitive } from "@/components/Infobox"; | ||
import { Codesnippet } from "@/components/CodeSnippet"; | ||
|
||
type Props = { | ||
closeModal?: () => void; | ||
name: string; | ||
}; | ||
|
||
export const UpdateStackDialog = forwardRef< | ||
ElementRef<typeof DialogContent>, | ||
ComponentPropsWithoutRef<typeof DialogContent> & Props | ||
>(({ closeModal, name, ...rest }, ref) => { | ||
return ( | ||
<DialogContent {...rest} ref={ref}> | ||
<DialogHeader> | ||
<DialogTitle>Update Stack</DialogTitle> | ||
</DialogHeader> | ||
<div className="space-y-5 p-7"> | ||
<Infobox action="update" /> | ||
<div className="space-y-1"> | ||
<p className="text-text-sm text-theme-text-secondary">Update a stack</p> | ||
<Codesnippet | ||
codeClasses="whitespace-pre-wrap" | ||
wrap | ||
code={`zenml stack update ${name} -o NEW_ORCHESTRATOR_NAME`} | ||
/> | ||
</div> | ||
</div> | ||
</DialogContent> | ||
); | ||
}); | ||
|
||
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"; | ||
}; | ||
export function Infobox({ action }: InfoProps) { | ||
function getAction() { | ||
switch (action) { | ||
case "delete": | ||
return "delete"; | ||
case "update": | ||
return "update"; | ||
case "describe": | ||
return "get details of"; | ||
} | ||
} | ||
|
||
return ( | ||
<InfoboxPrimitive> | ||
<div className="flex w-full flex-wrap justify-between gap-2"> | ||
<div className="min-w-0"> | ||
<p className="truncate text-text-sm font-semibold"> | ||
We are working on the new Stacks experience. | ||
</p> | ||
<p className="truncate text-text-sm"> | ||
Meanwhile you can use the CLI to {getAction()} your stack. | ||
</p> | ||
</div> | ||
</div> | ||
</InfoboxPrimitive> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.