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_ERROR,
|
||||||
STORED_PROCEDURE_UNTRACK_SUCCESS,
|
STORED_PROCEDURE_UNTRACK_SUCCESS,
|
||||||
} from '../../constants';
|
} from '../../constants';
|
||||||
|
import { useDestructiveAlert } from '../../../../../new-components/Alert';
|
||||||
|
import { getQualifiedTable } from '../../../ManageTable/utils';
|
||||||
|
|
||||||
// this is local type for the table row. Do not export
|
// this is local type for the table row. Do not export
|
||||||
type RowType = { dataSourceName: string } & StoredProcedure;
|
type RowType = { dataSourceName: string } & StoredProcedure;
|
||||||
@ -42,30 +44,45 @@ export const ListStoredProcedures = () => {
|
|||||||
.flat()
|
.flat()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// const { hasuraAlert } = useHasuraAlert();
|
||||||
|
|
||||||
|
const { destructiveConfirm } = useDestructiveAlert();
|
||||||
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
const onRemoveClick = (data: RowType, index: number) => {
|
const onRemoveClick = (data: RowType, index: number) => {
|
||||||
setActiveRow(index);
|
destructiveConfirm({
|
||||||
untrackStoredProcedure({
|
resourceName: getQualifiedTable(data.stored_procedure).join(' / '),
|
||||||
data: {
|
resourceType: 'Stored Procedure',
|
||||||
dataSourceName: data.dataSourceName,
|
destroyTerm: 'remove',
|
||||||
stored_procedure: data.stored_procedure,
|
onConfirm: () =>
|
||||||
},
|
new Promise(resolve => {
|
||||||
onSuccess: () => {
|
setActiveRow(index);
|
||||||
hasuraToast({
|
|
||||||
type: 'success',
|
untrackStoredProcedure({
|
||||||
title: STORED_PROCEDURE_UNTRACK_SUCCESS,
|
data: {
|
||||||
});
|
dataSourceName: data.dataSourceName,
|
||||||
},
|
stored_procedure: data.stored_procedure,
|
||||||
onError: err => {
|
},
|
||||||
hasuraToast({
|
onSuccess: () => {
|
||||||
type: 'error',
|
hasuraToast({
|
||||||
title: STORED_PROCEDURE_UNTRACK_ERROR,
|
type: 'success',
|
||||||
children: <DisplayToastErrorMessage message={err.message} />,
|
title: STORED_PROCEDURE_UNTRACK_SUCCESS,
|
||||||
});
|
});
|
||||||
},
|
resolve(true);
|
||||||
onSettled: () => {
|
},
|
||||||
setActiveRow(undefined);
|
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