mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
console: add confirm dialog before untracking stored procedures
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9305 GitOrigin-RevId: 5764f00a7558f2a9f5c16b220ebceb63f0685d5f
This commit is contained in:
parent
8f0451ce42
commit
01b54b49b6
@ -18,6 +18,8 @@ import {
|
||||
STORED_PROCEDURE_UNTRACK_ERROR,
|
||||
STORED_PROCEDURE_UNTRACK_SUCCESS,
|
||||
} from '../../constants';
|
||||
import { useDestructiveAlert } from '../../../../../new-components/Alert';
|
||||
import { getQualifiedTable } from '../../../ManageTable/utils';
|
||||
|
||||
// this is local type for the table row. Do not export
|
||||
type RowType = { dataSourceName: string } & StoredProcedure;
|
||||
@ -42,30 +44,45 @@ export const ListStoredProcedures = () => {
|
||||
.flat()
|
||||
);
|
||||
|
||||
// const { hasuraAlert } = useHasuraAlert();
|
||||
|
||||
const { destructiveConfirm } = useDestructiveAlert();
|
||||
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
const onRemoveClick = (data: RowType, index: number) => {
|
||||
setActiveRow(index);
|
||||
untrackStoredProcedure({
|
||||
data: {
|
||||
dataSourceName: data.dataSourceName,
|
||||
stored_procedure: data.stored_procedure,
|
||||
},
|
||||
onSuccess: () => {
|
||||
hasuraToast({
|
||||
type: 'success',
|
||||
title: STORED_PROCEDURE_UNTRACK_SUCCESS,
|
||||
});
|
||||
},
|
||||
onError: err => {
|
||||
hasuraToast({
|
||||
type: 'error',
|
||||
title: STORED_PROCEDURE_UNTRACK_ERROR,
|
||||
children: <DisplayToastErrorMessage message={err.message} />,
|
||||
});
|
||||
},
|
||||
onSettled: () => {
|
||||
setActiveRow(undefined);
|
||||
},
|
||||
destructiveConfirm({
|
||||
resourceName: getQualifiedTable(data.stored_procedure).join(' / '),
|
||||
resourceType: 'Stored Procedure',
|
||||
destroyTerm: 'remove',
|
||||
onConfirm: () =>
|
||||
new Promise(resolve => {
|
||||
setActiveRow(index);
|
||||
|
||||
untrackStoredProcedure({
|
||||
data: {
|
||||
dataSourceName: data.dataSourceName,
|
||||
stored_procedure: data.stored_procedure,
|
||||
},
|
||||
onSuccess: () => {
|
||||
hasuraToast({
|
||||
type: 'success',
|
||||
title: STORED_PROCEDURE_UNTRACK_SUCCESS,
|
||||
});
|
||||
resolve(true);
|
||||
},
|
||||
onError: err => {
|
||||
hasuraToast({
|
||||
type: 'error',
|
||||
title: STORED_PROCEDURE_UNTRACK_ERROR,
|
||||
children: <DisplayToastErrorMessage message={err.message} />,
|
||||
});
|
||||
resolve(false);
|
||||
},
|
||||
onSettled: () => {
|
||||
setActiveRow(undefined);
|
||||
},
|
||||
});
|
||||
}),
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user