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: refactor nav components #598 #599

Closed
wants to merge 2 commits into from
Closed

Conversation

ursucarina
Copy link
Contributor

Signed-off-by: Carina Ursu [email protected]

TL;DR

Refactor of Navigation Dropdown into its own component

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added
  • Code documentation added
  • Any pending items have an associated Issue

Complete description

Refactor of Navigation Dropdown into a plugin

Tracking Issue

flyteorg/flyte#598

Follow-up issue

flyteorg/flyte#598

@ursucarina ursucarina requested review from a team, eugenejahn, jsonporter and james-union and removed request for a team September 27, 2022 20:44
@codecov
Copy link

codecov bot commented Sep 27, 2022

Codecov Report

Merging #599 (c41dd85) into master (b9ffd81) will increase coverage by 0.18%.
The diff coverage is 62.50%.

@@            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     
Impacted Files Coverage Δ
...src/components/Navigation/DefaultAppBarContent.tsx 0.00% <0.00%> (ø)
.../zapp/console/src/components/Navigation/NavBar.tsx 0.00% <0.00%> (ø)
...es/zapp/console/src/components/Navigation/utils.ts 0.00% <ø> (ø)
...ents/src/NavigationDropdown/NavigationDropdown.tsx 82.14% <92.85%> (ø)
...plugins/components/src/NavigationDropdown/index.ts 100.00% <100.00%> (ø)
packages/plugins/components/src/Utils/index.tsx 100.00% <100.00%> (ø)
packages/zapp/console/src/routes/utils.ts 83.33% <100.00%> (+3.33%) ⬆️

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]>
Comment on lines 35 to +36
export const DefaultAppBarContent = (props: DefaultAppBarProps) => {
const { console, items } = props;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
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(
Copy link
Contributor

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

Comment on lines +32 to +33
const defaultButton = getByRole('button');
expect(defaultButton).not.toBeNull();
Copy link
Contributor

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

Comment on lines 52 to +53
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;
Copy link
Contributor

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(), []);
Copy link
Contributor

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';

Comment on lines +1 to +7
export const makeRoute = (baseUrl: string, path: string) => `${baseUrl}${path}`;

export const getBasePathName = () => {
const pathName = window.location.pathname;

return `/${pathName?.split('/')?.[1]}`;
};
Copy link
Contributor

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

Copy link
Contributor

@olga-union olga-union left a 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!

@ursucarina ursucarina closed this Jan 13, 2023
@ursucarina ursucarina deleted the carina/navdropdown branch March 8, 2023 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants