-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List connected notebooks for each connection table row #3256
Merged
openshift-merge-bot
merged 1 commit into
opendatahub-io:main
from
jeff-phillips-18:connected-workbenches
Sep 27, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import _ from 'lodash-es'; | ||
import { NotebookKind } from '~/k8sTypes'; | ||
import { NotebookState, NotebookRefresh } from '~/pages/projects/notebook/types'; | ||
|
||
type MockConfigType = { | ||
isStarting?: boolean; | ||
isRunning?: boolean; | ||
isStopping?: boolean; | ||
isStopped?: boolean; | ||
runningPodUid?: string; | ||
refresh?: NotebookRefresh; | ||
}; | ||
|
||
export const mockNotebookState = ( | ||
notebook: NotebookKind, | ||
mockConfig?: MockConfigType, | ||
): NotebookState => ({ | ||
notebook, | ||
..._.merge( | ||
{ | ||
isStarting: false, | ||
isRunning: false, | ||
isStopping: false, | ||
isStopped: false, | ||
runningPodUid: '', | ||
refresh: () => Promise.resolve(), | ||
}, | ||
mockConfig, | ||
), | ||
}); |
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,44 @@ | ||
import * as React from 'react'; | ||
import { SVGIconProps } from '@patternfly/react-icons/dist/esm/createIcon'; | ||
import { ProjectObjectType, typedColor } from '~/concepts/design/utils'; | ||
import NotebookIcon from '~/images/icons/NotebookIcon'; | ||
import ModelIcon from '~/images/icons/ModelsIcon'; | ||
|
||
type TypedObjectIconProps = SVGIconProps & { | ||
resourceType: ProjectObjectType; | ||
useTypedColor?: boolean; | ||
size?: number; | ||
}; | ||
const TypedObjectIcon: React.FC<TypedObjectIconProps> = ({ | ||
resourceType, | ||
useTypedColor, | ||
style, | ||
...rest | ||
}) => { | ||
switch (resourceType) { | ||
case ProjectObjectType.notebook: | ||
return ( | ||
<NotebookIcon | ||
style={{ | ||
color: useTypedColor ? typedColor(resourceType) : undefined, | ||
...(style || {}), | ||
}} | ||
{...rest} | ||
/> | ||
); | ||
case ProjectObjectType.deployedModels: | ||
return ( | ||
<ModelIcon | ||
style={{ | ||
color: useTypedColor ? typedColor(resourceType) : undefined, | ||
...(style || {}), | ||
}} | ||
{...rest} | ||
/> | ||
); | ||
default: | ||
return null; | ||
} | ||
}; | ||
|
||
export default TypedObjectIcon; |
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,13 @@ | ||
import { createIcon } from '@patternfly/react-icons/dist/esm/createIcon'; | ||
|
||
const ModelIcon = createIcon({ | ||
name: 'ModelIcon', | ||
width: 32, | ||
height: 32, | ||
svgPath: | ||
'M19.5 11H12.5C11.6729 11 11 10.3271 11 9.5V2.5C11 1.6729 11.6729 1 12.5 1H19.5C20.3271 1 21 1.6729 21 2.5V9.5C21 10.3271 20.3271 11 19.5 11ZM19 3H13V9H19V3ZM12.5 25H5.5C4.6729 25 4 24.3271 4 23.5V16.5C4 15.6729 4.6729 15 5.5 15H12.5C13.3271 15 14 15.6729 14 16.5V23.5C14 24.3271 13.3271 25 12.5 25ZM12 17H6V23H12V17ZM2 29H30C30.5527 29 31 29.4478 31 30C31 30.5522 30.5527 31 30 31H2C1.4473 31 1 30.5522 1 30C1 29.4478 1.4473 29 2 29ZM18 16.5V23.5C18 24.3271 18.6729 25 19.5 25H26.5C27.3271 25 28 24.3271 28 23.5V16.5C28 15.6729 27.3271 15 26.5 15H19.5C18.6729 15 18 15.6729 18 16.5ZM20 17H26V23H20V17Z', | ||
xOffset: 0, | ||
yOffset: 0, | ||
}); | ||
|
||
export default ModelIcon; |
2 changes: 1 addition & 1 deletion
2
frontend/src/pages/projects/notebook/ConnectedNotebookNames.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
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
43 changes: 43 additions & 0 deletions
43
frontend/src/pages/projects/screens/detail/connections/ConnectedResources.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,43 @@ | ||
import * as React from 'react'; | ||
import { LabelGroup, Spinner } from '@patternfly/react-core'; | ||
import { | ||
useRelatedNotebooks, | ||
ConnectedNotebookContext, | ||
} from '~/pages/projects/notebook/useRelatedNotebooks'; | ||
import { Connection } from '~/concepts/connectionTypes/types'; | ||
import { ProjectObjectType } from '~/concepts/design/utils'; | ||
import ResourceLabel from '~/pages/projects/screens/detail/connections/ResourceLabel'; | ||
import { getDisplayNameFromK8sResource } from '~/concepts/k8s/utils'; | ||
|
||
type Props = { | ||
connection: Connection; | ||
}; | ||
|
||
const ConnectedResources: React.FC<Props> = ({ connection }) => { | ||
const { notebooks: connectedNotebooks, loaded: notebooksLoaded } = useRelatedNotebooks( | ||
ConnectedNotebookContext.EXISTING_DATA_CONNECTION, | ||
connection.metadata.name, | ||
); | ||
|
||
if (!notebooksLoaded) { | ||
return <Spinner size="sm" />; | ||
} | ||
|
||
if (!connectedNotebooks.length) { | ||
return '-'; | ||
} | ||
|
||
return ( | ||
<LabelGroup> | ||
{connectedNotebooks.map((notebook) => ( | ||
<ResourceLabel | ||
key={notebook.metadata.name} | ||
resourceType={ProjectObjectType.notebook} | ||
title={getDisplayNameFromK8sResource(notebook)} | ||
/> | ||
))} | ||
</LabelGroup> | ||
); | ||
}; | ||
|
||
export default ConnectedResources; |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the mocks, I believe we need to append " (Running)" to the display name, if
notebook.running === true