Skip to content
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

Delete connection ref from notebooks when connection is deleted #3428

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const ConnectedResources: React.FC<Props> = ({ connection }) => {
return <Spinner size="sm" />;
}

if (!connectedNotebooks.length) {
if (!connectedNotebooks.length && !connectedModels.length) {
return '-';
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { K8sStatus } from '@openshift/dynamic-plugin-sdk-utils';
import {
Badge,
Bullseye,
Expand All @@ -20,19 +19,18 @@
import { useNotebooksStates } from '~/pages/projects/notebook/useNotebooksStates';
import { NotebookKind } from '~/k8sTypes';
import { useInferenceServicesForConnection } from '~/pages/projects/useInferenceServicesForConnection';
import { deleteSecret, removeNotebookSecret } from '~/api';

type Props = {
namespace: string;
deleteConnection: Connection;
onClose: (deleted?: boolean) => void;
onDelete: () => Promise<K8sStatus>;
};

export const ConnectionsDeleteModal: React.FC<Props> = ({
namespace,
deleteConnection,
onClose,
onDelete,
}) => {
const [isDeleting, setIsDeleting] = React.useState(false);
const [error, setError] = React.useState<Error>();
Expand Down Expand Up @@ -61,8 +59,18 @@
onDelete={() => {
setIsDeleting(true);
setError(undefined);

onDelete()
Promise.all(
connectedNotebooks.map((notebook) =>

Check warning on line 63 in frontend/src/pages/projects/screens/detail/connections/ConnectionsDeleteModal.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/pages/projects/screens/detail/connections/ConnectionsDeleteModal.tsx#L63

Added line #L63 was not covered by tests
removeNotebookSecret(
notebook.metadata.name,
notebook.metadata.namespace,
deleteConnection.metadata.name,
),
),
)
.then(() =>
deleteSecret(deleteConnection.metadata.namespace, deleteConnection.metadata.name),
)
.then(() => {
onClose(true);
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react';
import { Connection, ConnectionTypeConfigMapObj } from '~/concepts/connectionTypes/types';
import { deleteSecret } from '~/api';
import { Table } from '~/components/table';
import ConnectionsTableRow from './ConnectionsTableRow';
import { getColumns } from './connectionsTableColumns';
Expand Down Expand Up @@ -65,9 +64,6 @@ const ConnectionsTable: React.FC<ConnectionsTableProps> = ({
refreshConnections();
}
}}
onDelete={() =>
deleteSecret(deleteConnection.metadata.namespace, deleteConnection.metadata.name)
}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const mockNotebooks = [
mockNotebookK8sResource({ name: 'another-notebook', displayName: 'Another notebook' }),
];
describe('Delete connection modal', () => {
const onDelete = jest.fn();
const onClose = jest.fn();

beforeEach(() => {
Expand Down Expand Up @@ -68,7 +67,6 @@ describe('Delete connection modal', () => {
namespace={deleteConnection.metadata.namespace}
deleteConnection={deleteConnection}
onClose={onClose}
onDelete={onDelete}
/>,
);

Expand Down Expand Up @@ -104,7 +102,6 @@ describe('Delete connection modal', () => {
namespace={deleteConnection.metadata.namespace}
deleteConnection={deleteConnection}
onClose={onClose}
onDelete={onDelete}
/>,
);

Expand Down
Loading