Skip to content

Commit

Permalink
chore: update navigationDropdown usage (#517)
Browse files Browse the repository at this point in the history
Signed-off-by: Work <[email protected]>

Co-authored-by: Work <[email protected]>
  • Loading branch information
anrusina and Work authored Jun 23, 2022
1 parent 075a1f9 commit 161d7ee
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const useStyles = makeStyles((theme: Theme) => ({

interface DefaultAppBarProps {
items: FlyteNavItem[];
console?: string;
}

/** Renders the default content for the app bar, which is the logo and help links */
Expand Down Expand Up @@ -61,7 +62,11 @@ export const DefaultAppBarContent = (props: DefaultAppBarProps) => {
<Link className={classnames(commonStyles.linkUnstyled)} to={Routes.SelectProject.path}>
<FlyteLogo size={32} />
</Link>
{props.items?.length > 0 ? <NavigationDropdown items={props.items} /> : false}
{props.items?.length > 0 ? (
<NavigationDropdown items={props.items} console={props.console} />
) : (
false
)}
<div className={styles.spacer} />
{isFlagEnabled && <OnlyMine />}
<UserInformation />
Expand Down
2 changes: 1 addition & 1 deletion packages/zapp/console/src/components/Navigation/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const NavBar = (props: NavBarProps) => {
const content = props.useCustomContent ? (
<div id={navBarContentId} />
) : (
<DefaultAppBarContent items={navData?.items ?? []} />
<DefaultAppBarContent items={navData?.items ?? []} console={navData?.console} />
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,20 @@ const useStyles = makeStyles((theme: Theme) => ({
}));

interface NavigationDropdownProps {
items: FlyteNavItem[];
items: FlyteNavItem[]; // all other navigation items
console?: string; // name for default navigation, if not provided "Console" is used.
}

// Flyte Console list item - always there ans is first in the list
const ConsoleItem: FlyteNavItem = {
title: 'Console',
url: makeRoute('/'),
};

/** Renders the default content for the app bar, which is the logo and help links */
export const NavigationDropdown = (props: NavigationDropdownProps) => {
// Flyte Console list item - always there ans is first in the list
const ConsoleItem: FlyteNavItem = React.useMemo(() => {
return {
title: props.console ?? 'Console',
url: makeRoute('/'),
};
}, [props.console]);

const [selectedPage, setSelectedPage] = React.useState<string>(ConsoleItem.title);
const [open, setOpen] = React.useState(false);

Expand Down
7 changes: 4 additions & 3 deletions packages/zapp/console/src/components/Navigation/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ Essentially FLYTE_NAVIGATION is a JSON object

```
{
color:"white", // default NavBar text color
background:"black", // default NavBar background color
items:[
color:"white", // optional - default NavBar text color, if not provided uses Flyte colors
background:"black", // optional - default NavBar background color, if not provided uses Flyte colors
console:"FlyteConsole" // optional - name of the default navigation, if not provided uses "Console"
items:[ // required - if no dropdown needed provide an empty array
{title:"Remote", url:"https://remote.site/"},
{title:"Dashboard", url:"+/projects/flytesnacks/executions?domain=development&duration=all"},
{title:"Information", url:"/information"}
Expand Down
1 change: 1 addition & 0 deletions packages/zapp/console/src/components/Navigation/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface FlyteNavItem {
export interface FlyteNavigation {
color?: string;
background?: string;
console?: string;
items: FlyteNavItem[];
}

Expand Down

0 comments on commit 161d7ee

Please sign in to comment.