Skip to content

Commit

Permalink
Update project selector
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-phillips-18 committed Sep 18, 2024
1 parent cd5bce0 commit 4d6e7ee
Show file tree
Hide file tree
Showing 34 changed files with 175 additions and 229 deletions.
2 changes: 1 addition & 1 deletion backend/src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const blankDashboardCR: DashboardConfig = {
disablePipelineExperiments: false,
disableDistributedWorkloads: false,
disableModelRegistry: true,
disableConnectionTypes: true,
disableConnectionTypes: false,
disableStorageClasses: true,
},
notebookController: {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/searchSelector/SearchSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const SearchSelector: React.FC<SearchSelectorProps> = ({
isFullWidth={isFullWidth}
data-testid={`${dataTestId}-toggle`}
variant={toggleVariant}
className={toggleVariant === 'plainText' ? 'pf-v5-u-px-0 pf-v5-u-py-sm' : undefined}
>
<Truncate content={toggleText} />
</MenuToggle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { RunTypeOption } from './types';

type CloneRecurringRunPageProps = {
detailsRedirect: (recurringRunId: string) => string;
getProjectRedirectPath: (namespace: string) => string;
contextExperiment?: ExperimentKFv2 | null;
contextPipeline?: PipelineKFv2 | null;
contextPipelineVersion?: PipelineVersionKFv2 | null;
Expand All @@ -20,6 +21,7 @@ const CloneRecurringRunPage: React.FC<PathProps & CloneRecurringRunPageProps> =
breadcrumbPath,
contextPath,
detailsRedirect,
getProjectRedirectPath,
...props
}) => {
const { recurringRunId } = useParams();
Expand Down Expand Up @@ -47,6 +49,7 @@ const CloneRecurringRunPage: React.FC<PathProps & CloneRecurringRunPageProps> =
loaded={loaded}
loadError={error}
empty={false}
getRedirectPath={getProjectRedirectPath}
>
<RunPage
cloneRun={recurringRun}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { RunTypeOption } from './types';

type CloneRunPageProps = {
detailsRedirect: (runId: string) => string;
getProjectRedirectPath: (namespace: string) => string;
contextExperiment?: ExperimentKFv2 | null;
contextPipeline?: PipelineKFv2 | null;
contextPipelineVersion?: PipelineVersionKFv2 | null;
Expand All @@ -20,6 +21,7 @@ const CloneRunPage: React.FC<PathProps & CloneRunPageProps> = ({
breadcrumbPath,
contextPath,
detailsRedirect,
getProjectRedirectPath,
...props
}) => {
const { runId } = useParams();
Expand Down Expand Up @@ -47,6 +49,7 @@ const CloneRunPage: React.FC<PathProps & CloneRunPageProps> = ({
loaded={loaded}
loadError={error}
empty={false}
getRedirectPath={getProjectRedirectPath}
>
<RunPage
cloneRun={run}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const PipelineDetails: PipelineCoreDetailsPageComponent = ({ breadcrumbPath }) =
})}
empty={false}
loaded={isLoaded}
getRedirectPath={(ns) => `${ns}/pipelines`}
headerAction={
isPipelineVersionLoaded && (
<Flex
Expand Down
29 changes: 8 additions & 21 deletions frontend/src/concepts/projects/ProjectSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import { Bullseye, Divider, Flex, FlexItem, MenuItem, Truncate } from '@patternfly/react-core';
import { Divider, MenuItem, MenuToggle, Truncate } from '@patternfly/react-core';
import { byName, ProjectsContext } from '~/concepts/projects/ProjectsContext';
import { ProjectObjectType, typedObjectImage } from '~/concepts/design/utils';
import { getDisplayNameFromK8sResource } from '~/concepts/k8s/utils';
import SearchSelector from '~/components/searchSelector/SearchSelector';
import { ProjectKind } from '~/k8sTypes';
Expand All @@ -12,6 +11,7 @@ type ProjectSelectorProps = {
invalidDropdownPlaceholder?: string;
selectAllProjects?: boolean;
primary?: boolean;
variant?: React.ComponentProps<typeof MenuToggle>['variant'];
filterLabel?: string;
showTitle?: boolean;
selectorLabel?: string;
Expand All @@ -24,6 +24,7 @@ const ProjectSelector: React.FC<ProjectSelectorProps> = ({
invalidDropdownPlaceholder,
selectAllProjects,
primary,
variant = 'plainText',
filterLabel,
showTitle = false,
selectorLabel = 'Project',
Expand All @@ -48,7 +49,10 @@ const ProjectSelector: React.FC<ProjectSelectorProps> = ({
: projects;
const visibleProjects = filteredProjects.filter(bySearchText);

const toggleLabel = projects.length === 0 ? 'No projects' : selectionDisplayName;
const toggleLabel =
projects.length === 0
? 'No projects'
: `${showTitle ? `${selectorLabel}: ` : ''}${selectionDisplayName}`;
const selector = (
<SearchSelector
dataTestId="project-selector"
Expand All @@ -60,7 +64,7 @@ const ProjectSelector: React.FC<ProjectSelectorProps> = ({
searchPlaceholder="Project name"
searchValue={searchText}
toggleText={toggleLabel}
toggleVariant={primary ? 'primary' : undefined}
toggleVariant={primary ? 'primary' : variant}
>
<>
{selectAllProjects && (
Expand Down Expand Up @@ -96,23 +100,6 @@ const ProjectSelector: React.FC<ProjectSelectorProps> = ({
</SearchSelector>
);

if (showTitle) {
return (
<Flex spaceItems={{ default: 'spaceItemsXs' }} alignItems={{ default: 'alignItemsCenter' }}>
<img
src={typedObjectImage(ProjectObjectType.project)}
alt=""
style={{ height: 'var(--pf-v5-global--icon--FontSize--lg)' }}
/>
<Flex spaceItems={{ default: 'spaceItemsSm' }} alignItems={{ default: 'alignItemsCenter' }}>
<FlexItem>
<Bullseye>{selectorLabel}</Bullseye>
</FlexItem>
<FlexItem>{selector}</FlexItem>
</Flex>
</Flex>
);
}
return selector;
};

Expand Down
20 changes: 20 additions & 0 deletions frontend/src/pages/ApplicationsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
EmptyStateHeader,
Flex,
} from '@patternfly/react-core';
import ProjectSelectorNavigator from '~/concepts/projects/ProjectSelectorNavigator';

type ApplicationsPageProps = {
title?: React.ReactNode;
Expand All @@ -30,6 +31,7 @@ type ApplicationsPageProps = {
emptyStatePage?: React.ReactNode;
headerAction?: React.ReactNode;
headerContent?: React.ReactNode;
getRedirectPath?: (namespace: string) => string;
provideChildrenPadding?: boolean;
removeChildrenTopPadding?: boolean;
subtext?: React.ReactNode;
Expand All @@ -50,6 +52,7 @@ const ApplicationsPage: React.FC<ApplicationsPageProps> = ({
emptyStatePage,
headerAction,
headerContent,
getRedirectPath,
provideChildrenPadding,
removeChildrenTopPadding,
subtext,
Expand Down Expand Up @@ -143,6 +146,23 @@ const ApplicationsPage: React.FC<ApplicationsPageProps> = ({

return (
<>
{getRedirectPath ? (
<PageSection
variant="light"
stickyOnBreakpoint={{ default: 'top' }}
className="pf-v5-u-py-0"
style={{
borderBottom:
'var(--pf-v5-global--BorderWidth--sm) solid var(--pf-v5-global--BorderColor--100)',
}}
>
<ProjectSelectorNavigator
getRedirectPath={getRedirectPath}
showTitle
invalidDropdownPlaceholder="Select project"
/>
</PageSection>
) : null}
{breadcrumb && <PageBreadcrumb>{breadcrumb}</PageBreadcrumb>}
{!noHeader && renderHeader()}
{renderContents()}
Expand Down
41 changes: 14 additions & 27 deletions frontend/src/pages/ComingSoonPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import { PageSection, Stack, StackItem, Title } from '@patternfly/react-core';
import EmptyDetailsView from '~/components/EmptyDetailsView';
import ProjectSelectorNavigator from '~/concepts/projects/ProjectSelectorNavigator';
import ApplicationsPage from '~/pages/ApplicationsPage';

type ComingSoonPageProps = {
title: string;
Expand All @@ -10,31 +9,19 @@ type ComingSoonPageProps = {
};

const ComingSoonPage: React.FC<ComingSoonPageProps> = ({ title, namespaced, path }) => (
<PageSection aria-label="details-section" variant="light">
<Stack hasGutter>
{namespaced ? (
<StackItem>
<ProjectSelectorNavigator
getRedirectPath={(ns) => `/projects/${ns}/${path}`}
showTitle
invalidDropdownPlaceholder="Select project"
/>
</StackItem>
) : null}
<StackItem>
<Title headingLevel="h2" size="xl">
{title}
</Title>
</StackItem>
<StackItem isFilled>
<EmptyDetailsView
title="This page is coming soon."
description="Not yet implemented"
imageAlt="coming soon"
/>
</StackItem>
</Stack>
</PageSection>
<ApplicationsPage
loaded
empty
getRedirectPath={namespaced ? (ns) => `/projects/${ns}/${path}` : undefined}
title={title}
emptyStatePage={
<EmptyDetailsView
title="This page is coming soon."
description="Not yet implemented"
imageAlt="coming soon"
/>
}
/>
);

export default ComingSoonPage;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import DistributedWorkloadsNoProjects from '~/pages/distributedWorkloads/global/
import GlobalDistributedWorkloadsTabs from '~/pages/distributedWorkloads/global/GlobalDistributedWorkloadsTabs';
import { MetricsCommonContextProvider } from '~/concepts/metrics/MetricsCommonContext';
import { RefreshIntervalTitle } from '~/concepts/metrics/types';
import ProjectSelectorNavigator from '~/concepts/projects/ProjectSelectorNavigator';
import { useQueryParams } from '~/utilities/useQueryParams';

const title = 'Distributed Workload Metrics';
Expand Down Expand Up @@ -44,14 +43,7 @@ const GlobalDistributedWorkloads: React.FC = () => {
{...{ title, description }}
loaded
empty={false}
headerContent={
<ProjectSelectorNavigator
getRedirectPath={(ns: string) =>
`/projects/${ns}/distributedWorkloads?tab=${activeTab.path}`
}
showTitle
/>
}
getRedirectPath={(ns: string) => `/projects/${ns}/distributedWorkloads?tab=${activeTab.path}`}
>
<MetricsCommonContextProvider initialRefreshInterval={RefreshIntervalTitle.THIRTY_MINUTES}>
<DistributedWorkloadsContextProvider namespace={preferredProject.metadata.name}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const CustomServingRuntimeView: React.FC = () => {
empty={servingRuntimeTemplates.length === 0}
emptyStatePage={<EmptyCustomServingRuntime />}
provideChildrenPadding
headerContent={<CustomServingRuntimeHeaderLabels />}
headerAction={<CustomServingRuntimeHeaderLabels />}
>
<CustomServingRuntimeListView />
</ApplicationsPage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { byName, ProjectsContext } from '~/concepts/projects/ProjectsContext';
import InvalidProject from '~/concepts/projects/InvalidProject';
import ModelServingContextProvider from '~/pages/modelServing/ModelServingContext';
import ModelServingNoProjects from '~/pages/modelServing/screens/global/ModelServingNoProjects';
import ModelServingProjectSelection from '~/pages/modelServing/screens/global/ModelServingProjectSelection';

type ApplicationPageProps = React.ComponentProps<typeof ApplicationsPage>;
type EmptyStateProps = 'emptyStatePage' | 'empty';
Expand Down Expand Up @@ -65,7 +64,7 @@ const GlobalModelServingCoreLoader: React.FC<GlobalModelServingCoreLoaderProps>
title="Deployed models"
description="Manage and view the health and performance of your deployed models."
loaded
headerContent={<ModelServingProjectSelection getRedirectPath={getInvalidRedirectPath} />}
getRedirectPath={getInvalidRedirectPath}
provideChildrenPadding
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { ProjectObjectType } from '~/concepts/design/utils';
import TitleWithIcon from '~/concepts/design/TitleWithIcon';
import EmptyModelServing from './EmptyModelServing';
import InferenceServiceListView from './InferenceServiceListView';
import ModelServingProjectSelection from './ModelServingProjectSelection';
import ModelServingLoading from './ModelServingLoading';

const ModelServingGlobal: React.FC = () => {
Expand Down Expand Up @@ -48,11 +47,7 @@ const ModelServingGlobal: React.FC = () => {
description="Manage and view the health and performance of your deployed models."
loadError={notInstalledError}
loaded={servingRuntimesLoaded && inferenceServicesLoaded}
headerContent={
<ModelServingProjectSelection
getRedirectPath={(namespace: string) => `/modelServing/${namespace}`}
/>
}
getRedirectPath={(namespace: string) => `/modelServing/${namespace}`}
provideChildrenPadding
loadingContent={
currentProject ? undefined : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const MetricsPage: React.FC<MetricsPageProps> = ({ title, breadcrumbItems, type,
loaded
description={null}
empty={false}
getRedirectPath={(ns) => `/modelServing/${ns}`}
headerAction={
tab === MetricsTabKeys.BIAS && (
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const BiasConfigurationPage: React.FC<BiasConfigurationPageProps> = ({
/>
</PageSection>
}
getRedirectPath={(ns) => `/modelServing/${ns}`}
>
<BiasConfigurationTable
inferenceService={inferenceService}
Expand Down
Loading

0 comments on commit 4d6e7ee

Please sign in to comment.