-
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.
- Loading branch information
Showing
10 changed files
with
203 additions
and
17 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
25 changes: 25 additions & 0 deletions
25
frontend/src/pages/acceleratorProfiles/components/AcceleratorProfileEnableToggle.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,25 @@ | ||
import * as React from 'react'; | ||
import { Switch } from '@patternfly/react-core'; | ||
|
||
type AcceleratorProfileEnableToggleProps = { | ||
enabled: boolean; | ||
name: string; | ||
}; | ||
|
||
const AcceleratorProfileEnableToggle: React.FC<AcceleratorProfileEnableToggleProps> = ({ | ||
enabled, | ||
name, | ||
}) => { | ||
const label = enabled ? 'enabled' : 'stopped'; | ||
|
||
return ( | ||
<Switch | ||
aria-label={label} | ||
id={`${name}-enable-switch`} | ||
isChecked={enabled} | ||
onClick={() => undefined} | ||
/> | ||
); | ||
}; | ||
|
||
export default AcceleratorProfileEnableToggle; |
Empty file.
41 changes: 41 additions & 0 deletions
41
frontend/src/pages/acceleratorProfiles/components/TableData.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,41 @@ | ||
import { SortableData } from '~/components/table'; | ||
import { AcceleratorKind } from '~/k8sTypes'; | ||
|
||
export const columns: SortableData<AcceleratorKind>[] = [ | ||
{ | ||
field: 'name', | ||
label: 'Name', | ||
sortable: (a, b) => a.spec.displayName.localeCompare(b.spec.displayName), | ||
width: 30, | ||
}, | ||
{ | ||
field: 'identifier', | ||
label: 'Identifier', | ||
sortable: (a, b) => a.spec.identifier.localeCompare(b.spec.identifier), | ||
info: { | ||
tooltip: 'The resource identifier of the accelerator device.', | ||
}, | ||
}, | ||
{ | ||
field: 'enablement', | ||
label: 'Enable', | ||
sortable: (a, b) => Number(a.spec.enabled ?? false) - Number(b.spec.enabled ?? false), | ||
info: { | ||
tooltip: 'Indicates whether the accelerator profile is available for new resources.', | ||
}, | ||
}, | ||
{ | ||
field: 'last_modified', | ||
label: 'Last modified', | ||
sortable: (a, b): number => { | ||
const first = a.metadata.annotations?.['opendatahub.io/modified-date']; | ||
const second = b.metadata.annotations?.['opendatahub.io/modified-date']; | ||
return new Date(first ?? 0).getTime() - new Date(second ?? 0).getTime(); | ||
}, | ||
}, | ||
{ | ||
field: 'kebab', | ||
label: '', | ||
sortable: false, | ||
}, | ||
]; |
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
23 changes: 23 additions & 0 deletions
23
frontend/src/pages/acceleratorProfiles/screens/list/AcceleratorProfilesTable.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,23 @@ | ||
import * as React from 'react'; | ||
import { Table } from '~/components/table'; | ||
import { columns } from '~/pages/acceleratorProfiles/components/TableData'; | ||
import AcceleratorProfilesTableRow from '~/pages/acceleratorProfiles/screens/list/AcceleratorProfilesTableRow'; | ||
import { AcceleratorKind } from '~/k8sTypes'; | ||
|
||
type AcceleratorProfilesTableProps = { | ||
accelerators: AcceleratorKind[]; | ||
}; | ||
|
||
const AcceleratorProfilesTable: React.FC<AcceleratorProfilesTableProps> = ({ accelerators }) => ( | ||
<Table | ||
enablePagination | ||
data={accelerators} | ||
columns={columns} | ||
emptyTableView={'No projects match your filters.'} | ||
rowRenderer={(accelerator) => ( | ||
<AcceleratorProfilesTableRow key={accelerator.metadata.uid} accelerator={accelerator} /> | ||
)} | ||
/> | ||
); | ||
|
||
export default AcceleratorProfilesTable; |
56 changes: 56 additions & 0 deletions
56
frontend/src/pages/acceleratorProfiles/screens/list/AcceleratorProfilesTableRow.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,56 @@ | ||
import * as React from 'react'; | ||
import { Text, TextContent, TextVariants, Timestamp, Truncate } from '@patternfly/react-core'; | ||
import { ActionsColumn, Td, Tr } from '@patternfly/react-table'; | ||
import { AcceleratorKind } from '~/k8sTypes'; | ||
import AcceleratorProfileEnableToggle from '~/pages/acceleratorProfiles/components/AcceleratorProfileEnableToggle'; | ||
|
||
type AcceleratorProfilesTableRow = { | ||
accelerator: AcceleratorKind; | ||
}; | ||
|
||
const AcceleratorProfilesTableRow: React.FC<AcceleratorProfilesTableRow> = ({ accelerator }) => ( | ||
<Tr> | ||
<Td dataLabel="Name"> | ||
<TextContent> | ||
<Text>{accelerator.spec.displayName}</Text> | ||
{accelerator.spec.description && ( | ||
<Text component={TextVariants.small}> | ||
<Truncate content={accelerator.spec.description} /> | ||
</Text> | ||
)} | ||
</TextContent> | ||
</Td> | ||
<Td dataLabel="Identifier">{accelerator.spec.identifier}</Td> | ||
<Td dataLabel="Enable"> | ||
<AcceleratorProfileEnableToggle | ||
enabled={accelerator.spec.enabled} | ||
name={accelerator.spec.displayName} | ||
/> | ||
</Td> | ||
<Td dataLabel="Last modified"> | ||
{accelerator.metadata.annotations?.['opendatahub.io/modified-date'] ? ( | ||
<Timestamp | ||
date={new Date(accelerator.metadata.annotations['opendatahub.io/modified-date'])} | ||
/> | ||
) : ( | ||
'--' | ||
)} | ||
</Td> | ||
<Td isActionCell> | ||
<ActionsColumn | ||
items={[ | ||
{ | ||
title: 'Edit', | ||
onClick: () => undefined, | ||
}, | ||
{ | ||
title: 'Delete', | ||
onClick: () => undefined, | ||
}, | ||
]} | ||
/> | ||
</Td> | ||
</Tr> | ||
); | ||
|
||
export default AcceleratorProfilesTableRow; |