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

fix: invalid item in dropdown #809

Merged
merged 7 commits into from
Aug 11, 2023
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
2 changes: 1 addition & 1 deletion packages/console/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flyteorg/console",
"version": "0.0.49",
"version": "0.0.50",
"description": "Flyteconsole main app module",
"main": "./dist/index.js",
"module": "./lib/index.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useMemo } from 'react';
import { useQuery } from 'react-query';
import { useQuery, useQueryClient } from 'react-query';
import isEmpty from 'lodash/isEmpty';
import {
Box,
Expand All @@ -24,16 +24,17 @@ import { BreadcrumbEntity, BreadcrumbPopoverInterface } from '../types';

const BreadcrumbPopOver = (props: BreadcrumbPopoverInterface) => {
const history = useHistory();
const queryClient = useQueryClient();

const {
isLoading,
error,
data: popoverQueryData,
} = useQuery(
`breadcrumb-list-${props.id}`,
`breadcrumb-list-${props.id}-${props.value}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should fetch the project list every time the domain changes. I think we should separate the api call and the url generation step so we don't make unnecessary network calls

Copy link
Contributor

Choose a reason for hiding this comment

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

This would be a good enhancement, we'd probably need a query hash key, the formatter and data as separate params in the Breadcrumb objects. Some breadcrumbs don't change from url to url etc...

A note here is that it only fetches once the user opens that dropdown.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is how the original code worked, not an enhancement. If we separate the list request from the static url generation this wouldn't be a problem

() => props.asyncData(window.location, props),
{
staleTime: 1000 * 60 * 5, // 5 minutes
refetchOnMount: true,
},
);
const popoverData: BreadcrumbEntity[] = useMemo(() => {
Expand All @@ -46,13 +47,13 @@ const BreadcrumbPopOver = (props: BreadcrumbPopoverInterface) => {
error: viewAllQueryError,
data: viewAllQueryData,
} = useQuery(
`breadcrumb-view-all-${props.id}`,
['breadcrumb-view-all', props.id],
() => {
if (!props.asyncViewAllLink) return '';
return props.asyncViewAllLink(window.location, props);
},
{
staleTime: 1000 * 60 * 5, // 5 minutes
refetchOnMount: true,
},
);
const viewAllLinkData: string = useMemo(() => {
Expand Down Expand Up @@ -109,6 +110,7 @@ const BreadcrumbPopOver = (props: BreadcrumbPopoverInterface) => {
if (!isActive) {
history.push(url);
props.onClose();
queryClient.invalidateQueries(['breadcrumb-view-all']);
return;
}
};
Expand Down
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"dependencies": {
"@flyteorg/common": "^0.0.4",
"@flyteorg/console": "^0.0.49",
"@flyteorg/console": "^0.0.50",
"long": "^4.0.0",
"protobufjs": "~6.11.3",
"react-ga4": "^1.4.1",
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2032,7 +2032,7 @@ __metadata:
resolution: "@flyteconsole/client-app@workspace:website"
dependencies:
"@flyteorg/common": ^0.0.4
"@flyteorg/console": ^0.0.49
"@flyteorg/console": ^0.0.50
"@types/long": ^3.0.32
long: ^4.0.0
protobufjs: ~6.11.3
Expand Down Expand Up @@ -2071,7 +2071,7 @@ __metadata:
languageName: unknown
linkType: soft

"@flyteorg/console@^0.0.49, @flyteorg/console@workspace:packages/console":
"@flyteorg/console@^0.0.50, @flyteorg/console@workspace:packages/console":
version: 0.0.0-use.local
resolution: "@flyteorg/console@workspace:packages/console"
dependencies:
Expand Down