Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update navigationDropdown usage #517

Merged
merged 1 commit into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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