Skip to content

Commit

Permalink
Add Accelerator section in Admin Panel and feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
dpanshug committed Oct 26, 2023
1 parent c8595db commit d162244
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 4 deletions.
1 change: 1 addition & 0 deletions frontend/src/__mocks__/mockDashboardConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const mockDashboardConfig = ({
modelMetricsNamespace: 'test-project',
disablePipelines: false,
disableProjectSharing: false,
disableAccelerators: false,
},
notebookController: {
enabled: true,
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/app/AppRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ const DependencyMissingPage = React.lazy(
() => import('../pages/dependencies/DependencyMissingPage'),
);

const AcceleratorProfile = React.lazy(
() => import('../pages/acceleratorProfile/AcceleratorProfile'),
);

const AppRoutes: React.FC = () => {
const { isAdmin, isAllowed } = useUser();

Expand Down Expand Up @@ -76,6 +80,7 @@ const AppRoutes: React.FC = () => {
<>
<Route path="/notebookImages" element={<BYONImagesPage />} />
<Route path="/clusterSettings" element={<ClusterSettingsPage />} />
<Route path="/accelerators" element={<AcceleratorProfile />} />
<Route path="/servingRuntimes/*" element={<CustomServingRuntimeRoutes />} />
<Route path="/groupSettings" element={<GroupSettingsPage />} />
</>
Expand Down
73 changes: 73 additions & 0 deletions frontend/src/pages/acceleratorProfile/AcceleratorProfile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import * as React from 'react';
import {
Button,
ButtonVariant,
Flex,
FlexItem,
EmptyState,
EmptyStateIcon,
EmptyStateVariant,
EmptyStateBody,
PageSection,
PageSectionVariants,
Title,
} from '@patternfly/react-core';
import { PlusCircleIcon } from '@patternfly/react-icons';
import ApplicationsPage from '~/pages/ApplicationsPage';
import useAccelerators from '~/pages/notebookController/screens/server/useAccelerators';
import { useDashboardNamespace } from '~/redux/selectors';

const description = `Manage accelerator profile settings for users in your organization`;

const AcceleratorProfile: React.FC = () => {
const { dashboardNamespace } = useDashboardNamespace();
const [accelerators, loaded, loadError] = useAccelerators(dashboardNamespace);

const isEmpty = !accelerators || accelerators.length === 0;

const noAcceleratorProfilePageSection = (
<PageSection isFilled>
<EmptyState variant={EmptyStateVariant.full} data-id="empty-empty-state">
<EmptyStateIcon icon={PlusCircleIcon} />
<Title headingLevel="h5" size="lg">
No available accelerator profiles yet
</Title>
<EmptyStateBody>
{/* eslint-disable-next-line react/no-unescaped-entities */}
You don't have any accelerator profiles yet. To get started, please ask your cluster
administrator about
<br /> the accelerator availability in your cluster and create corresponding profiles in
Openshift Data Science.
</EmptyStateBody>
<Button
data-id="display-accelerator-modal-button"
variant={ButtonVariant.primary}
// eslint-disable-next-line @typescript-eslint/no-empty-function
onClick={() => {}}
>
Add new accelerator profile
</Button>
</EmptyState>
</PageSection>
);

return (
<ApplicationsPage
title="Accelerator profiles"
description={description}
loaded={loaded}
empty={isEmpty}
loadError={loadError}
errorMessage="Unable to load accelerator profiles."
emptyStatePage={noAcceleratorProfilePageSection}
>
<PageSection variant={PageSectionVariants.light} padding={{ default: 'noPadding' }}>
<Flex direction={{ default: 'column' }}>
<FlexItem>{/* Todo: Create accelerator table */}</FlexItem>
</Flex>
</PageSection>
</ApplicationsPage>
);
};

export default AcceleratorProfile;
1 change: 1 addition & 0 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export type DashboardCommonConfig = {
disableCustomServingRuntimes: boolean;
modelMetricsNamespace: string;
disablePipelines: boolean;
disableAccelerators: boolean;
};

export type NotebookControllerUserState = {
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/utilities/NavData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ const getSettingsNav = (
});
}

if (featureFlagEnabled(dashboardConfig.spec.dashboardConfig.disableAccelerators)) {
settingsNavs.push({
id: 'accelerator-profile',
label: 'Accelerator profiles',
href: '/accelerators',
});
}

if (
featureFlagEnabled(dashboardConfig.spec.dashboardConfig.disableCustomServingRuntimes) &&
featureFlagEnabled(dashboardConfig.spec.dashboardConfig.disableModelServing)
Expand Down
10 changes: 6 additions & 4 deletions manifests/crd/odhdashboardconfigs.opendatahub.io.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ spec:
type: string
disablePipelines:
type: boolean
disableAccelerators:
type: boolean
groupsConfig:
type: object
required:
Expand Down Expand Up @@ -134,10 +136,10 @@ spec:
notebookTolerationSettings:
type: object
properties:
enabled:
type: boolean
key:
type: string
enabled:
type: boolean
key:
type: string
storageClassName:
type: string
templateOrder:
Expand Down

0 comments on commit d162244

Please sign in to comment.