-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38c10f4
commit 46feee9
Showing
44 changed files
with
763 additions
and
186 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { ClusterCreateScreen } from "src/screens/directory/datagraph/ClusterCreateScreen/ClusterCreateScreen"; | ||
|
||
export default async function Page() { | ||
return <ClusterCreateScreen />; | ||
} |
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
File renamed without changes.
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
File renamed without changes.
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 |
---|---|---|
@@ -1,35 +1,80 @@ | ||
import { ChevronRightIcon } from "@heroicons/react/24/outline"; | ||
import { ChevronRightIcon, PlusCircleIcon } from "@heroicons/react/24/outline"; | ||
import { pull } from "lodash"; | ||
import { FormEventHandler, ForwardedRef, Fragment, forwardRef } from "react"; | ||
|
||
import { | ||
DirectoryPath, | ||
joinDirectoryPath, | ||
} from "src/screens/directory/datagraph/useDirectoryPath"; | ||
import { Input } from "src/theme/components/Input"; | ||
import { Link } from "src/theme/components/Link"; | ||
|
||
import { HStack } from "@/styled-system/jsx"; | ||
|
||
type Props = { | ||
directoryPath: DirectoryPath; | ||
create: "hide" | "show" | "edit"; | ||
value?: string; | ||
defaultValue?: string; | ||
onChange?: FormEventHandler<HTMLInputElement>; | ||
}; | ||
|
||
export function Breadcrumbs(props: Props) { | ||
export const _Breadcrumbs = ( | ||
{ directoryPath, create, value, defaultValue, onChange, ...rest }: Props, | ||
ref: ForwardedRef<HTMLInputElement>, | ||
) => { | ||
const isEditing = create == "edit" && onChange !== undefined; | ||
const editingPath = isEditing ? directoryPath.slice(0, -1) : directoryPath; | ||
const paths = pull(editingPath, "new"); | ||
const jointNew = joinDirectoryPath(directoryPath, "new"); | ||
|
||
return ( | ||
<HStack color="fg.subtle"> | ||
<Link href="/directory" size="xs"> | ||
<HStack w="full" color="fg.subtle"> | ||
<Link minW="min" href="/directory" size="xs"> | ||
Directory | ||
</Link> | ||
{props.directoryPath.map((p) => ( | ||
<> | ||
{paths.map((p) => ( | ||
<Fragment key={p}> | ||
<ChevronRightIcon width="1rem" /> | ||
<Link | ||
key={p} | ||
href={`/directory/${joinDirectoryPath(props.directoryPath, p)}`} | ||
href={`/directory/${joinDirectoryPath(paths, p)}`} | ||
size="xs" | ||
> | ||
{p} | ||
</Link> | ||
</> | ||
</Fragment> | ||
))} | ||
{create == "show" && ( | ||
<> | ||
<ChevronRightIcon width="1rem" /> | ||
<Link | ||
flexShrink="0" | ||
kind="primary" | ||
href={`/directory/${jointNew}`} | ||
size="xs" | ||
> | ||
<PlusCircleIcon /> Create | ||
</Link> | ||
</> | ||
)} | ||
{isEditing && ( | ||
<> | ||
<ChevronRightIcon width="1rem" /> | ||
<Input | ||
ref={ref} | ||
w="full" | ||
size="xs" | ||
placeholder="URL slug" | ||
defaultValue={defaultValue} | ||
value={value} | ||
onChange={onChange} | ||
{...rest} | ||
/> | ||
</> | ||
)} | ||
</HStack> | ||
); | ||
} | ||
}; | ||
|
||
export const Breadcrumbs = forwardRef(_Breadcrumbs); |
2 changes: 1 addition & 1 deletion
2
web/src/components/directory/datagraph/ClusterCard/ClusterCard.tsx
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,21 @@ | ||
import { last, nth, takeWhile } from "lodash"; | ||
|
||
export function getTargetSlug(slug: string[]): [string, string, boolean] { | ||
const top = last(slug); | ||
|
||
const isNew = top === "new"; | ||
|
||
const target = isNew | ||
? // If the tail item is "new" then walk back until we find an actual slug. | ||
last(takeWhile(slug, (s) => s !== "new")) | ||
: // Otherwise, it's whatever the last item is. | ||
top; | ||
|
||
// The fallback is for when the target is actually an item. Items cannot have | ||
// children, so we can assume the parent is the left-most slug of the target, | ||
// which is the third index from the end of the slug array. This is an edge | ||
// case though as the only way to hit this would be to manually add "/new". | ||
const fallback = slug.length > 2 ? nth(slug, -3) : ""; | ||
|
||
return [target ?? "", fallback ?? "", isNew]; | ||
} |
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 |
---|---|---|
@@ -1,11 +1,16 @@ | ||
import { PencilIcon } from "@heroicons/react/24/outline"; | ||
import { PropsWithChildren } from "react"; | ||
|
||
import { Button, ButtonProps } from "src/theme/components/Button"; | ||
|
||
export function EditAction(props: ButtonProps) { | ||
export function EditAction({ | ||
children, | ||
...props | ||
}: PropsWithChildren<ButtonProps>) { | ||
return ( | ||
<Button kind="ghost" size="xs" {...props}> | ||
<PencilIcon width="0.5em" height="0.5em" /> | ||
{children} | ||
</Button> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,11 +1,15 @@ | ||
import { CloudArrowUpIcon } from "@heroicons/react/24/outline"; | ||
import { PropsWithChildren } from "react"; | ||
|
||
import { Button, ButtonProps } from "src/theme/components/Button"; | ||
|
||
export function SaveAction(props: ButtonProps) { | ||
export function SaveAction({ | ||
children, | ||
...props | ||
}: PropsWithChildren<ButtonProps>) { | ||
return ( | ||
<Button kind="ghost" size="sm" {...props}> | ||
<CloudArrowUpIcon width="1.4em" /> | ||
<Button kind="ghost" size="xs" {...props}> | ||
<CloudArrowUpIcon width="1.4em" /> {children} | ||
</Button> | ||
); | ||
} |
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.