-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Accelerator section in Admin Panel and feature flag
- Loading branch information
Showing
13 changed files
with
227 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { AcceleratorKind } from '~/k8sTypes'; | ||
|
||
export const mockAcceleratorProfile = (): AcceleratorKind => ({ | ||
apiVersion: 'dashboard.opendatahub.io/v1', | ||
kind: 'AcceleratorProfile', | ||
metadata: { | ||
name: 'test-accelerator', | ||
}, | ||
spec: { | ||
displayName: 'test-accelerator', | ||
enabled: true, | ||
identifier: 'nvidia.com/gpu', | ||
description: 'Test description', | ||
tolerations: [ | ||
{ | ||
key: 'nvidia.com/gpu', | ||
operator: 'Exists', | ||
effect: 'NoSchedule', | ||
}, | ||
], | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
frontend/src/__tests__/integration/pages/acceleratorProfiles/AcceleratorProfiles.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { navigateToStory } from '~/__tests__/integration/utils'; | ||
|
||
test('Empty State no Accelerator profile', async ({ page }) => { | ||
await page.goto( | ||
navigateToStory( | ||
'pages-acceleratorprofiles-acceleratorprofiles', | ||
'empty-state-no-accelerator-profile', | ||
), | ||
); | ||
|
||
// wait for page to load | ||
await page.waitForSelector('text=No available accelerator profiles yet'); | ||
|
||
// Test that the button is enabled | ||
await expect(page.getByRole('button', { name: 'Add new accelerator profile' })).toBeEnabled(); | ||
}); |
50 changes: 50 additions & 0 deletions
50
frontend/src/__tests__/integration/pages/acceleratorProfiles/AcceleratorProfiles.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react'; | ||
import { StoryFn, Meta, StoryObj } from '@storybook/react'; | ||
import { rest } from 'msw'; | ||
import { mockAcceleratorProfile } from '~/__mocks__/mockAcceleratorProfile'; | ||
import { mockProjectK8sResource } from '~/__mocks__/mockProjectK8sResource'; | ||
import { mockK8sResourceList } from '~/__mocks__/mockK8sResourceList'; | ||
import useDetectUser from '~/utilities/useDetectUser'; | ||
import { mockStatus } from '~/__mocks__/mockStatus'; | ||
|
||
import AcceleratorProfiles from '~/pages/acceleratorProfiles/AcceleratorProfiles'; | ||
|
||
export default { | ||
component: AcceleratorProfiles, | ||
parameters: { | ||
msw: { | ||
handlers: { | ||
status: [ | ||
rest.get('/api/k8s/apis/project.openshift.io/v1/projects', (req, res, ctx) => | ||
res(ctx.json(mockK8sResourceList([mockProjectK8sResource({})]))), | ||
), | ||
rest.get('/api/status', (req, res, ctx) => res(ctx.json(mockStatus()))), | ||
], | ||
accelerators: rest.get( | ||
'/api/k8s/apis/dashboard.opendatahub.io/v1/namespaces/opendatahub/acceleratorprofiles', | ||
(req, res, ctx) => res(ctx.json(mockK8sResourceList([mockAcceleratorProfile()]))), | ||
), | ||
}, | ||
}, | ||
}, | ||
} as Meta<typeof AcceleratorProfiles>; | ||
|
||
const Template: StoryFn<typeof AcceleratorProfiles> = (args) => { | ||
useDetectUser(); | ||
return <AcceleratorProfiles {...args} />; | ||
}; | ||
|
||
export const EmptyStateNoAcceleratorProfile: StoryObj = { | ||
render: Template, | ||
|
||
parameters: { | ||
msw: { | ||
handlers: { | ||
accelerators: rest.get( | ||
'/api/k8s/apis/dashboard.opendatahub.io/v1/namespaces/opendatahub/acceleratorprofiles', | ||
(req, res, ctx) => res(ctx.json(mockK8sResourceList([]))), | ||
), | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
frontend/src/pages/acceleratorProfiles/AcceleratorProfiles.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
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 AcceleratorProfiles: 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> | ||
You don't have any accelerator profiles yet. To get started, please ask your cluster | ||
administrator about 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} | ||
onClick={() => undefined} | ||
> | ||
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 AcceleratorProfiles; |
Oops, something went wrong.