-
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.
Update modals and generate meaningful k8s name for images
- Loading branch information
1 parent
2c849f3
commit e233810
Showing
20 changed files
with
735 additions
and
531 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
39 changes: 39 additions & 0 deletions
39
frontend/src/pages/BYONImages/BYONImageDependenciesList.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,39 @@ | ||
import * as React from 'react'; | ||
import { | ||
DescriptionListDescription, | ||
DescriptionListGroup, | ||
DescriptionListTerm, | ||
Text, | ||
TextContent, | ||
} from '@patternfly/react-core'; | ||
|
||
type BYONImageDependenciesListProps = { | ||
dependencies: string[]; | ||
term: string; | ||
}; | ||
|
||
const BYONImageDependenciesList: React.FC<BYONImageDependenciesListProps> = ({ | ||
term, | ||
dependencies, | ||
}) => { | ||
if (dependencies.length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<DescriptionListGroup> | ||
<DescriptionListTerm>{term}</DescriptionListTerm> | ||
<DescriptionListDescription> | ||
<TextContent> | ||
{dependencies.map((dep, i) => ( | ||
<Text style={{ marginBottom: 0 }} key={i} component="small"> | ||
{dep} | ||
</Text> | ||
))} | ||
</TextContent> | ||
</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
); | ||
}; | ||
|
||
export default BYONImageDependenciesList; |
File renamed without changes.
111 changes: 111 additions & 0 deletions
111
frontend/src/pages/BYONImages/BYONImageModal/DisplayedContentTabContent.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,111 @@ | ||
import * as React from 'react'; | ||
import { | ||
Button, | ||
EmptyState, | ||
EmptyStateBody, | ||
EmptyStateIcon, | ||
EmptyStatePrimary, | ||
EmptyStateVariant, | ||
TabContent, | ||
Title, | ||
} from '@patternfly/react-core'; | ||
import { PlusCircleIcon } from '@patternfly/react-icons'; | ||
import { BYONImagePackage } from '~/types'; | ||
import { DisplayedContentTab } from './ManageBYONImageModal'; | ||
import DisplayedContentTable from './DisplayedContentTable'; | ||
|
||
type DisplayedContentTabContentProps = { | ||
activeKey: string | number; | ||
tabKey: DisplayedContentTab; | ||
resources: BYONImagePackage[]; | ||
setResources: React.Dispatch<React.SetStateAction<BYONImagePackage[]>>; | ||
tempResources: BYONImagePackage[]; | ||
setTempResources: React.Dispatch<React.SetStateAction<BYONImagePackage[]>>; | ||
editIndex?: number; | ||
setEditIndex: (index?: number) => void; | ||
}; | ||
|
||
const DisplayedContentTabContent: React.FC<DisplayedContentTabContentProps> = ({ | ||
activeKey, | ||
tabKey, | ||
resources, | ||
setResources, | ||
tempResources, | ||
setTempResources, | ||
editIndex, | ||
setEditIndex, | ||
}) => { | ||
const resourceType = tabKey === DisplayedContentTab.SOFTWARE ? 'software' : 'packages'; | ||
|
||
const addEmptyRow = React.useCallback(() => { | ||
setTempResources((prev) => [ | ||
...prev, | ||
{ | ||
name: '', | ||
version: '', | ||
visible: true, | ||
}, | ||
]); | ||
setEditIndex(tempResources.length); | ||
}, [tempResources.length, setTempResources, setEditIndex]); | ||
|
||
return ( | ||
<TabContent | ||
id={`tabContent-${tabKey}`} | ||
eventKey={tabKey} | ||
activeKey={activeKey} | ||
hidden={tabKey !== activeKey} | ||
> | ||
{tempResources.length === 0 ? ( | ||
<EmptyState variant={EmptyStateVariant.small}> | ||
<EmptyStateIcon icon={PlusCircleIcon} /> | ||
<Title headingLevel="h2" size="lg"> | ||
No {resourceType} displayed | ||
</Title> | ||
<EmptyStateBody> | ||
Displayed contents help inform other users of what your notebook image contains. To add | ||
displayed content, add the names of software or packages included in your image that you | ||
want users to know about. | ||
</EmptyStateBody> | ||
<EmptyStatePrimary> | ||
<Button | ||
data-id={`add-${resourceType}-button`} | ||
variant="secondary" | ||
onClick={addEmptyRow} | ||
> | ||
Add {resourceType} | ||
</Button> | ||
</EmptyStatePrimary> | ||
</EmptyState> | ||
) : ( | ||
<DisplayedContentTable | ||
tabKey={tabKey} | ||
onReset={() => { | ||
setTempResources([...resources]); | ||
setEditIndex(undefined); | ||
}} | ||
onConfirm={(rowIndex, name, version) => { | ||
const copiedArray = [...tempResources]; | ||
copiedArray[rowIndex].name = name; | ||
copiedArray[rowIndex].version = version; | ||
setTempResources(copiedArray); | ||
setResources(copiedArray); | ||
setEditIndex(undefined); | ||
}} | ||
resources={tempResources} | ||
onAdd={addEmptyRow} | ||
editIndex={editIndex} | ||
onEdit={setEditIndex} | ||
onDelete={(index) => { | ||
const copiedArray = [...resources]; | ||
copiedArray.splice(index, 1); | ||
setTempResources(copiedArray); | ||
setResources(copiedArray); | ||
}} | ||
/> | ||
)} | ||
</TabContent> | ||
); | ||
}; | ||
|
||
export default DisplayedContentTabContent; |
84 changes: 84 additions & 0 deletions
84
frontend/src/pages/BYONImages/BYONImageModal/DisplayedContentTable.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,84 @@ | ||
import * as React from 'react'; | ||
import { Button, Panel, PanelFooter, PanelHeader, PanelMainBody } from '@patternfly/react-core'; | ||
import { PlusCircleIcon } from '@patternfly/react-icons'; | ||
import Table from '~/components/table/Table'; | ||
import { BYONImagePackage } from '~/types'; | ||
import { DisplayedContentTab } from './ManageBYONImageModal'; | ||
import { getColumns } from './tableData'; | ||
import DisplayedContentTableRow from './DisplayedContentTableRow'; | ||
|
||
type DisplayedContentTableProps = { | ||
tabKey: DisplayedContentTab; | ||
onReset: () => void; | ||
onConfirm: (rowIndex: number, name: string, version: string) => void; | ||
resources: BYONImagePackage[]; | ||
onAdd: () => void; | ||
editIndex?: number; | ||
onEdit: (index: number) => void; | ||
onDelete: (index: number) => void; | ||
}; | ||
|
||
const DisplayedContentTable: React.FC<DisplayedContentTableProps> = ({ | ||
tabKey, | ||
onReset, | ||
onConfirm, | ||
resources, | ||
onAdd, | ||
editIndex, | ||
onEdit, | ||
onDelete, | ||
}) => { | ||
const content = tabKey === DisplayedContentTab.SOFTWARE ? 'software' : 'packages'; | ||
const columns = getColumns(tabKey); | ||
|
||
return ( | ||
<Panel> | ||
<PanelHeader> | ||
Add the {content} labels that will be displayed with this notebook image. Modifying the{' '} | ||
{content} here does not effect the contents of the notebook image. | ||
</PanelHeader> | ||
<PanelMainBody> | ||
<Table | ||
variant="compact" | ||
data={resources} | ||
columns={columns} | ||
disableRowRenderSupport | ||
rowRenderer={(resource, rowIndex) => ( | ||
<DisplayedContentTableRow | ||
key={rowIndex} | ||
obj={resource} | ||
tabKey={tabKey} | ||
isActive={editIndex === rowIndex} | ||
isEditing={editIndex !== undefined} | ||
onConfirm={(name, version) => onConfirm(rowIndex, name, version)} | ||
onReset={onReset} | ||
onEdit={() => onEdit(rowIndex)} | ||
onDelete={() => onDelete(rowIndex)} | ||
onMoveToNextRow={() => { | ||
if (rowIndex === resources.length - 1) { | ||
onAdd(); | ||
} else { | ||
onEdit(rowIndex + 1); | ||
} | ||
}} | ||
/> | ||
)} | ||
/> | ||
</PanelMainBody> | ||
<PanelFooter> | ||
<Button | ||
data-id="add-resource-button" | ||
variant="link" | ||
icon={<PlusCircleIcon />} | ||
onClick={onAdd} | ||
isDisabled={editIndex !== undefined} | ||
isInline | ||
> | ||
Add {content} | ||
</Button> | ||
</PanelFooter> | ||
</Panel> | ||
); | ||
}; | ||
|
||
export default DisplayedContentTable; |
Oops, something went wrong.