mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-26 14:26:00 +00:00
handle error when saving to DB
This commit is contained in:
@@ -40,6 +40,8 @@ import DataGridContextMenu from './DataGridContextMenu';
|
|||||||
import useSocket from '../utility/SocketProvider';
|
import useSocket from '../utility/SocketProvider';
|
||||||
import LoadingInfo from '../widgets/LoadingInfo';
|
import LoadingInfo from '../widgets/LoadingInfo';
|
||||||
import ErrorInfo from '../widgets/ErrorInfo';
|
import ErrorInfo from '../widgets/ErrorInfo';
|
||||||
|
import showModal from '../modals/showModal';
|
||||||
|
import ErrorMessageModal from '../modals/ErrorMessageModal';
|
||||||
|
|
||||||
const GridContainer = styled.div`
|
const GridContainer = styled.div`
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -817,7 +819,7 @@ export default function DataGridCore(props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleConfirmSql() {
|
async function handleConfirmSql() {
|
||||||
await axios.request({
|
const resp = await axios.request({
|
||||||
url: 'database-connections/query-data',
|
url: 'database-connections/query-data',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
params: {
|
params: {
|
||||||
@@ -827,9 +829,14 @@ export default function DataGridCore(props) {
|
|||||||
data: { sql: confirmSql },
|
data: { sql: confirmSql },
|
||||||
});
|
});
|
||||||
|
|
||||||
dispatchChangeSet({ type: 'reset', value: createChangeSet() });
|
const { errorMessage } = resp.data || {};
|
||||||
setConfirmSql(null);
|
if (errorMessage) {
|
||||||
display.reload();
|
showModal((modalState) => <ErrorMessageModal modalState={modalState} message={errorMessage} title='Error when saving' />);
|
||||||
|
} else {
|
||||||
|
dispatchChangeSet({ type: 'reset', value: createChangeSet() });
|
||||||
|
setConfirmSql(null);
|
||||||
|
display.reload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const insertNewRow = () => {
|
const insertNewRow = () => {
|
||||||
|
|||||||
33
packages/web/src/modals/ErrorMessageModal.js
Normal file
33
packages/web/src/modals/ErrorMessageModal.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import ModalBase from './ModalBase';
|
||||||
|
import FormStyledButton from '../widgets/FormStyledButton';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import { FontIcon } from '../icons';
|
||||||
|
import { FormButtonRow } from '../utility/forms';
|
||||||
|
|
||||||
|
const Wrapper = styled.div`
|
||||||
|
display:flex
|
||||||
|
align-items:center
|
||||||
|
`;
|
||||||
|
|
||||||
|
const IconWrapper = styled.div`
|
||||||
|
margin-right: 10px;
|
||||||
|
font-size: 20pt;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default function ErrorMessageModal({ modalState, title = 'Error', message }) {
|
||||||
|
return (
|
||||||
|
<ModalBase modalState={modalState}>
|
||||||
|
<h2>{title}</h2>
|
||||||
|
<Wrapper>
|
||||||
|
<IconWrapper>
|
||||||
|
<FontIcon icon="fas fa-times-circle red" />
|
||||||
|
</IconWrapper>
|
||||||
|
{message}
|
||||||
|
</Wrapper>
|
||||||
|
<FormButtonRow>
|
||||||
|
<FormStyledButton type="button" value="Close" onClick={modalState.close} />
|
||||||
|
</FormButtonRow>
|
||||||
|
</ModalBase>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user