forked from opendatahub-io/odh-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
58cbe32
commit 6c270e4
Showing
6 changed files
with
157 additions
and
4 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
56 changes: 56 additions & 0 deletions
56
frontend/src/pages/connectionTypes/DeleteConnectionTypeModal.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 React from 'react'; | ||
import DeleteModal from '~/pages/projects/components/DeleteModal'; | ||
import { ConnectionTypeKind } from '~/k8sTypes'; | ||
import { deleteConnectionType } from '~/services/connectionTypesService'; | ||
|
||
type DeleteConnectionTypeModalProps = { | ||
connectionType?: ConnectionTypeKind; | ||
onClose: (deleted: boolean) => void; | ||
}; | ||
|
||
const DeleteConnectionTypeModal: React.FC<DeleteConnectionTypeModalProps> = ({ | ||
connectionType, | ||
onClose, | ||
}) => { | ||
const [isDeleting, setIsDeleting] = React.useState(false); | ||
const [error, setError] = React.useState<Error | undefined>(); | ||
|
||
const onBeforeClose = (deleted: boolean) => { | ||
onClose(deleted); | ||
setIsDeleting(false); | ||
setError(undefined); | ||
}; | ||
|
||
const deleteName = connectionType?.spec.displayName || 'this accelerator profile'; | ||
|
||
return ( | ||
<DeleteModal | ||
title="Delete accelerator profile?" | ||
isOpen={!!connectionType} | ||
onClose={() => onBeforeClose(false)} | ||
submitButtonLabel="Delete" | ||
onDelete={() => { | ||
if (connectionType) { | ||
setIsDeleting(true); | ||
deleteConnectionType(connectionType.metadata.name) | ||
.then(() => { | ||
onBeforeClose(true); | ||
}) | ||
.catch((e) => { | ||
setError(e); | ||
setIsDeleting(false); | ||
}); | ||
} | ||
}} | ||
deleting={isDeleting} | ||
error={error} | ||
deleteName={deleteName} | ||
> | ||
The <b>{deleteName}</b> accelerator profile will be deleted and will no longer be available | ||
for use with new workbenches and runtimes. Existing resources using this profile will retain | ||
it unless a new profile is selected. | ||
</DeleteModal> | ||
); | ||
}; | ||
|
||
export default DeleteConnectionTypeModal; |
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,38 @@ | ||
import axios from '~/utilities/axios'; | ||
import { ConnectionTypeKind } from '~/k8sTypes'; | ||
import { ResponseStatus } from '~/types'; | ||
|
||
export const createConnectionType = ( | ||
connectionType: ConnectionTypeKind['spec'], | ||
): Promise<ResponseStatus> => { | ||
const url = '/api/connection-type'; | ||
return axios | ||
.post(url, connectionType) | ||
.then((response) => response.data) | ||
.catch((e) => { | ||
throw new Error(e.response.data.message); | ||
}); | ||
}; | ||
|
||
export const deleteConnectionType = (name: string): Promise<ResponseStatus> => { | ||
const url = `/api/connection-types/${name}`; | ||
return axios | ||
.delete(url) | ||
.then((response) => response.data) | ||
.catch((e) => { | ||
throw new Error(e.response.data.message); | ||
}); | ||
}; | ||
|
||
export const updateConnectionType = ( | ||
name: string, | ||
spec: Partial<ConnectionTypeKind['spec']>, | ||
): Promise<ResponseStatus> => { | ||
const url = `/api/connection-types/${name}`; | ||
return axios | ||
.put(url, spec) | ||
.then((response) => response.data) | ||
.catch((e) => { | ||
throw new Error(e.response.data.message); | ||
}); | ||
}; |