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

feat(graph): add loading spinner on project details #23023

Merged
merged 1 commit into from
Apr 26, 2024
Merged
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
16 changes: 15 additions & 1 deletion graph/project-details/src/lib/project-details-wrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars

import { useNavigate, useSearchParams } from 'react-router-dom';
import { useNavigate, useNavigation, useSearchParams } from 'react-router-dom';

/* eslint-disable @nx/enforce-module-boundaries */
// nx-ignore-next-line
Expand All @@ -10,6 +10,8 @@ import {
useEnvironmentConfig,
useRouteConstructor,
} from '@nx/graph/shared';
import { Spinner } from '@nx/graph/ui-components';

import {
ProjectDetails,
ProjectDetailsImperativeHandle,
Expand All @@ -26,6 +28,7 @@ export function ProjectDetailsWrapper(props: ProjectDetailsProps) {
const environment = useEnvironmentConfig()?.environment;
const externalApiService = getExternalApiService();
const navigate = useNavigate();
const { state: navigationState, location } = useNavigation();
const routeConstructor = useRouteConstructor();
const [searchParams, setSearchParams] = useSearchParams();

Expand Down Expand Up @@ -143,6 +146,17 @@ export function ProjectDetailsWrapper(props: ProjectDetailsProps) {
}
}, [searchParams, props.project.data.targets, projectDetailsRef]);

if (
navigationState === 'loading' &&
!location.pathname.includes('project-details') // do not show spinner when updating search params
) {
return (
<div className="flex justify-center">
<Spinner />
</div>
);
}

return (
<ProjectDetails
ref={projectDetailsRef}
Expand Down