Skip to content

Commit a9b2483

Browse files
committed
Update cluster storage connected resources
1 parent b880467 commit a9b2483

File tree

9 files changed

+62
-81
lines changed

9 files changed

+62
-81
lines changed

frontend/src/__tests__/cypress/cypress/pages/clusterStorage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ class ClusterStorageRow extends TableRow {
88
return this;
99
}
1010

11-
findConnectedWorkbenches() {
12-
return this.find().find('[data-label="Workbench connections"]');
11+
findConnectedResources() {
12+
return this.find().find('[data-label="Connected resources"]');
1313
}
1414

1515
toggleExpandableContent() {

frontend/src/__tests__/cypress/cypress/tests/e2e/dataScienceProjects/workbenches/workbenches.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('Workbench and PVSs tests', () => {
104104
cy.step(`Check the cluster storage ${PVCDisplayName} is now connected to ${workbenchName}`);
105105
projectDetails.findSectionTab('cluster-storages').click();
106106
const csRow = clusterStorage.getClusterStorageRow(PVCDisplayName);
107-
csRow.findConnectedWorkbenches().should('have.text', workbenchName);
107+
csRow.findConnectedResources().should('have.text', workbenchName);
108108
},
109109
);
110110
});

frontend/src/__tests__/cypress/cypress/tests/mocked/projects/tabs/clusterStorage.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ describe('ClusterStorage', () => {
451451
const clusterStorageRow = clusterStorage.getClusterStorageRow('Test Storage');
452452
clusterStorageRow.findStorageClassColumn().should('not.exist');
453453
clusterStorageRow.shouldHaveStorageTypeValue('Generic persistent storage');
454-
clusterStorageRow.findConnectedWorkbenches().should('have.text', 'No connections');
454+
clusterStorageRow.findConnectedResources().should('have.text', '');
455455
clusterStorageRow.findSizeColumn().contains('5GiB');
456456

457457
//sort by Name

frontend/src/pages/modelServing/screens/projects/InferenceServiceModal/ConnectionSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import {
3939
import { isModelPathValid } from '#~/pages/modelServing/screens/projects/utils';
4040
import DashboardPopupIconButton from '#~/concepts/dashboard/DashboardPopupIconButton';
4141
import { AccessTypes } from '#~/pages/projects/dataConnections/const';
42-
import { SupportedArea, useIsAreaAvailable } from '#~/concepts/areas/index.ts';
42+
import { SupportedArea, useIsAreaAvailable } from '#~/concepts/areas/index';
4343
import ConnectionS3FolderPathField from './ConnectionS3FolderPathField';
4444
import ConnectionOciPathField from './ConnectionOciPathField';
4545
import { ConnectionOciAlert } from './ConnectionOciAlert';

frontend/src/pages/projects/notebook/ConnectedNotebookNames.tsx

Lines changed: 0 additions & 45 deletions
This file was deleted.

frontend/src/pages/projects/screens/detail/connections/ConnectedResources.tsx

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,69 @@ import { ProjectObjectType } from '#~/concepts/design/utils';
99
import ResourceLabel from '#~/pages/projects/screens/detail/connections/ResourceLabel';
1010
import { getDisplayNameFromK8sResource } from '#~/concepts/k8s/utils';
1111
import { useInferenceServicesForConnection } from '#~/pages/projects/useInferenceServicesForConnection';
12+
import { PersistentVolumeClaimKind } from '#~/k8sTypes';
13+
import { isModelStorage } from '#~/pages/projects/screens/detail/storage/utils';
14+
import { useIsAreaAvailable, SupportedArea } from '#~/concepts/areas/index';
1215

13-
type Props = {
14-
connection: Connection;
15-
};
16+
export type ConnectedResourcesProps =
17+
| { connection: Connection; pvc?: undefined }
18+
| { connection?: undefined; pvc: PersistentVolumeClaimKind };
1619

17-
const ConnectedResources: React.FC<Props> = ({ connection }) => {
20+
const ConnectedResources: React.FC<ConnectedResourcesProps> = ({ connection, pvc }) => {
1821
const { notebooks: connectedNotebooks, loaded: notebooksLoaded } = useRelatedNotebooks(
19-
ConnectedNotebookContext.EXISTING_DATA_CONNECTION,
20-
connection.metadata.name,
22+
connection
23+
? ConnectedNotebookContext.EXISTING_DATA_CONNECTION
24+
: ConnectedNotebookContext.EXISTING_PVC,
25+
connection ? connection.metadata.name : pvc.metadata.name,
26+
);
27+
const modelName = React.useMemo(
28+
() => pvc?.metadata.annotations?.['dashboard.opendatahub.io/model-name'],
29+
[pvc],
2130
);
31+
const modelStorage = React.useMemo(() => (pvc ? isModelStorage(pvc) : false), [pvc]);
32+
const pvcServing = useIsAreaAvailable(SupportedArea.PVCSERVING).status;
2233
const connectedModels = useInferenceServicesForConnection(connection);
2334

2435
if (!notebooksLoaded) {
2536
return <Spinner size="sm" />;
2637
}
2738

28-
if (!connectedNotebooks.length && !connectedModels.length) {
39+
if (!connectedNotebooks.length && !connectedModels.length && !modelStorage) {
2940
return '-';
3041
}
3142

43+
const renderNotebookLabels = () =>
44+
connectedNotebooks.map((notebook) => (
45+
<ResourceLabel
46+
key={notebook.metadata.name}
47+
resourceType={ProjectObjectType.build}
48+
title={getDisplayNameFromK8sResource(notebook)}
49+
/>
50+
));
51+
52+
const renderModelLabels = () =>
53+
connectedModels.map((model) => (
54+
<ResourceLabel
55+
key={model.metadata.name}
56+
resourceType={ProjectObjectType.deployedModelsList}
57+
title={getDisplayNameFromK8sResource(model)}
58+
/>
59+
));
60+
61+
const renderPVCModelLabel = () =>
62+
modelStorage && pvcServing ? (
63+
<ResourceLabel
64+
key={modelName ?? 'Unknown model'}
65+
resourceType={ProjectObjectType.deployedModelsList}
66+
title={modelName ?? 'Unknown model'}
67+
/>
68+
) : null;
69+
3270
return (
3371
<LabelGroup>
34-
{connectedNotebooks.map((notebook) => (
35-
<ResourceLabel
36-
key={notebook.metadata.name}
37-
resourceType={ProjectObjectType.build}
38-
title={getDisplayNameFromK8sResource(notebook)}
39-
/>
40-
))}
41-
{connectedModels.map((model) => (
42-
<ResourceLabel
43-
key={model.metadata.name}
44-
resourceType={ProjectObjectType.deployedModelsList}
45-
title={getDisplayNameFromK8sResource(model)}
46-
/>
47-
))}
72+
{renderNotebookLabels()}
73+
{renderModelLabels()}
74+
{renderPVCModelLabel()}
4875
</LabelGroup>
4976
);
5077
};

frontend/src/pages/projects/screens/detail/storage/StorageTableRow.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import {
1212
import { ExclamationTriangleIcon, HddIcon } from '@patternfly/react-icons';
1313
import { PersistentVolumeClaimKind } from '#~/k8sTypes';
1414
import StorageSizeBar from '#~/pages/projects/components/StorageSizeBars';
15-
import ConnectedNotebookNames from '#~/pages/projects/notebook/ConnectedNotebookNames';
16-
import { ConnectedNotebookContext } from '#~/pages/projects/notebook/useRelatedNotebooks';
1715
import { TableRowTitleDescription } from '#~/components/table';
1816
import {
1917
getDescriptionFromK8sResource,
@@ -23,6 +21,7 @@ import { SupportedArea, useIsAreaAvailable } from '#~/concepts/areas';
2321
import { getStorageClassConfig } from '#~/pages/storageClasses/utils';
2422
import { getPvcAccessMode } from '#~/pages/projects/utils.ts';
2523
import AccessModeFullName from '#~/pages/projects/screens/detail/storage/AccessModeFullName';
24+
import ConnectedResources from '#~/pages/projects/screens/detail/connections/ConnectedResources';
2625
import useIsRootVolume from './useIsRootVolume';
2726
import StorageWarningStatus from './StorageWarningStatus';
2827
import { StorageTableData } from './types';
@@ -163,11 +162,8 @@ const StorageTableRow: React.FC<StorageTableRowProps> = ({
163162
<StorageSizeBar pvc={obj.pvc} />
164163
</Td>
165164
{workbenchEnabled && (
166-
<Td dataLabel="Workbench connections">
167-
<ConnectedNotebookNames
168-
context={ConnectedNotebookContext.EXISTING_PVC}
169-
relatedResourceName={obj.pvc.metadata.name}
170-
/>
165+
<Td dataLabel="Connected resources">
166+
<ConnectedResources pvc={obj.pvc} />
171167
</Td>
172168
)}
173169
<Td isActionCell>

frontend/src/pages/projects/screens/detail/storage/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const columns: SortableData<StorageTableData>[] = [
5454
},
5555
{
5656
field: 'connected',
57-
label: 'Workbench connections',
57+
label: 'Connected resources',
5858
width: 20,
5959
sortable: false,
6060
},

frontend/src/pages/projects/useInferenceServicesForConnection.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ import { Connection } from '#~/concepts/connectionTypes/types';
44
import { ProjectDetailsContext } from '#~/pages/projects/ProjectDetailsContext';
55

66
export const useInferenceServicesForConnection = (
7-
connection: Connection,
7+
connection?: Connection,
88
): InferenceServiceKind[] => {
99
const {
1010
inferenceServices: {
1111
data: { items: inferenceServices },
1212
},
1313
} = React.useContext(ProjectDetailsContext);
14-
const connectionName = connection.metadata.name;
14+
const connectionName = connection?.metadata.name;
15+
if (!connection) {
16+
return [];
17+
}
1518

1619
return inferenceServices.filter(
1720
(inferenceService) =>

0 commit comments

Comments
 (0)