-
Notifications
You must be signed in to change notification settings - Fork 59
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: refactor nav components #598 #599
Conversation
Codecov Report
@@ Coverage Diff @@
## master #599 +/- ##
==========================================
+ Coverage 69.08% 69.26% +0.18%
==========================================
Files 440 442 +2
Lines 10434 10450 +16
Branches 1789 1790 +1
==========================================
+ Hits 7208 7238 +30
+ Misses 3226 3212 -14
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: Carina Ursu <[email protected]>
Signed-off-by: Carina Ursu <[email protected]>
d1f74c2
to
c41dd85
Compare
export const DefaultAppBarContent = (props: DefaultAppBarProps) => { | ||
const { console, items } = props; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
export const DefaultAppBarContent = (props: DefaultAppBarProps) => { | |
const { console, items } = props; | |
export const DefaultAppBarContent = ({ console, items }: DefaultAppBarProps) => { |
url: 'https://github.com/flyteorg/flyteconsole#google-analytics', | ||
}, | ||
]; | ||
const versions: VersionInfo[] = React.useMemo( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
move to import {useMemo} from 'react';
- I'm trying to get us to this way of importing standard hooks, as sometimes it saves lines 😆 not in this case, but a lot of state definitions became more readable as one-liners IMO
const defaultButton = getByRole('button'); | ||
expect(defaultButton).not.toBeNull(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think switching to queryBy
is better to check presence of an element, as it returns null
if element is not found, while get throws an error
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 { baseUrl, items: menuItems, config } = props; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: destructure props on definition
export const NavigationDropdown = ({ baseUrl, items: menuItems, config }: NavigationDropdownProps) => {
|
||
const [selectedPage, setSelectedPage] = React.useState<string>(ConsoleItem.title); | ||
const basePathName = React.useMemo(() => getBasePathName(), []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: update useState and useMemo imports
import {useMemo, useState} from 'react';
export const makeRoute = (baseUrl: string, path: string) => `${baseUrl}${path}`; | ||
|
||
export const getBasePathName = () => { | ||
const pathName = window.location.pathname; | ||
|
||
return `/${pathName?.split('/')?.[1]}`; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
should this folder's name be capitalized (Utils
)? it's not gonna be a component, and seems out of pattern with other non-component folders, ie routes
, touched in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few not critical suggestions, lmk what you think!
Signed-off-by: Carina Ursu [email protected]
TL;DR
Refactor of Navigation Dropdown into its own component
Type
Are all requirements met?
Complete description
Refactor of Navigation Dropdown into a plugin
Tracking Issue
flyteorg/flyte#598
Follow-up issue
flyteorg/flyte#598