mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
fix navigation after removal of a data source
[DSF-450]: https://hasurahq.atlassian.net/browse/DSF-450?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9703 Co-authored-by: Vijay Prasanna <11921040+vijayprasanna13@users.noreply.github.com> GitOrigin-RevId: 7f1a3caad428b73c7754b70a882417a2b79efd45
This commit is contained in:
parent
308ad0cf64
commit
bbb466d356
@ -4,8 +4,6 @@ import requestAction from '../../utils/requestAction';
|
|||||||
import requestActionPlain from '../../utils/requestActionPlain';
|
import requestActionPlain from '../../utils/requestActionPlain';
|
||||||
import Endpoints, { globalCookiePolicy } from '../../Endpoints';
|
import Endpoints, { globalCookiePolicy } from '../../Endpoints';
|
||||||
import { getFeaturesCompatibility } from '../../helpers/versionUtils';
|
import { getFeaturesCompatibility } from '../../helpers/versionUtils';
|
||||||
import { getRunSqlQuery } from '../Common/utils/v1QueryUtils';
|
|
||||||
import { currentDriver } from '../../dataSources';
|
|
||||||
import { defaultNotification, errorNotification } from './ConsoleNotification';
|
import { defaultNotification, errorNotification } from './ConsoleNotification';
|
||||||
import { updateConsoleNotificationsState } from '../../telemetry/Actions';
|
import { updateConsoleNotificationsState } from '../../telemetry/Actions';
|
||||||
import { getConsoleNotificationQuery } from '../Common/utils/v1QueryUtils';
|
import { getConsoleNotificationQuery } from '../Common/utils/v1QueryUtils';
|
||||||
@ -276,36 +274,6 @@ const setReadOnlyMode = data => ({
|
|||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const fetchPostgresVersion = (dispatch, getState) => {
|
|
||||||
if (currentDriver !== 'postgres') return;
|
|
||||||
|
|
||||||
const req = getRunSqlQuery(
|
|
||||||
'SELECT version()',
|
|
||||||
getState().tables.currentDataSource,
|
|
||||||
false,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
const options = {
|
|
||||||
method: 'POST',
|
|
||||||
credentials: globalCookiePolicy,
|
|
||||||
body: JSON.stringify(req),
|
|
||||||
headers: getState().tables.dataHeaders,
|
|
||||||
};
|
|
||||||
|
|
||||||
return dispatch(requestAction(Endpoints.query, options)).then(
|
|
||||||
({ result }) => {
|
|
||||||
if (result.length > 1 && result[1].length) {
|
|
||||||
const matchRes = result[1][0].match(/[0-9]{1,}(\.[0-9]{1,})?/);
|
|
||||||
if (matchRes.length) {
|
|
||||||
dispatch({ type: POSTGRES_VERSION_SUCCESS, payload: matchRes[0] });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dispatch({ type: POSTGRES_VERSION_ERROR });
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const featureCompatibilityInit = () => {
|
const featureCompatibilityInit = () => {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const { serverVersion } = getState().main;
|
const { serverVersion } = getState().main;
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import React, { useEffect } from 'react';
|
|
||||||
import { Link } from 'react-router';
|
import { Link } from 'react-router';
|
||||||
import { Analytics, REDACT_EVERYTHING } from '../../../features/Analytics';
|
import { Analytics, REDACT_EVERYTHING } from '../../../features/Analytics';
|
||||||
import globals from '../../../Globals';
|
import globals from '../../../Globals';
|
||||||
@ -8,27 +7,8 @@ import PageContainer from '../../Common/Layout/PageContainer/PageContainer';
|
|||||||
import DataSubSidebar from './DataSubSidebar';
|
import DataSubSidebar from './DataSubSidebar';
|
||||||
import { CLI_CONSOLE_MODE } from '../../../constants';
|
import { CLI_CONSOLE_MODE } from '../../../constants';
|
||||||
import styles from '../../Common/TableCommon/Table.module.scss';
|
import styles from '../../Common/TableCommon/Table.module.scss';
|
||||||
import { isFeatureSupported } from '../../../dataSources';
|
|
||||||
import { fetchPostgresVersion } from '../../Main/Actions';
|
|
||||||
// import { useEnvironmentState } from '../../../features/ConnectDBRedesign/hooks';
|
|
||||||
|
|
||||||
const DataPageContainer = ({
|
|
||||||
children,
|
|
||||||
location,
|
|
||||||
dispatch,
|
|
||||||
currentDataSource,
|
|
||||||
}) => {
|
|
||||||
// const { consoleType } = useEnvironmentState();
|
|
||||||
useEffect(() => {
|
|
||||||
// TODO: handle for different drivers
|
|
||||||
if (
|
|
||||||
currentDataSource &&
|
|
||||||
isFeatureSupported('driver.fetchVersion.enabled')
|
|
||||||
) {
|
|
||||||
dispatch(fetchPostgresVersion);
|
|
||||||
}
|
|
||||||
}, [dispatch, currentDataSource]);
|
|
||||||
|
|
||||||
|
const DataPageContainer = ({ children, location, currentDataSource }) => {
|
||||||
const currentLocation = location.pathname;
|
const currentLocation = location.pathname;
|
||||||
|
|
||||||
let migrationTab = null;
|
let migrationTab = null;
|
||||||
|
@ -3,15 +3,21 @@ import { useMetadataMigration } from '../../MetadataAPI';
|
|||||||
import { hasuraToast } from '../../../new-components/Toasts';
|
import { hasuraToast } from '../../../new-components/Toasts';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { MetadataMigrationOptions } from '../../MetadataAPI/hooks/useMetadataMigration';
|
import { MetadataMigrationOptions } from '../../MetadataAPI/hooks/useMetadataMigration';
|
||||||
|
import { useAppDispatch } from '../../../storeHooks';
|
||||||
|
import { UPDATE_CURRENT_DATA_SOURCE } from '../../../components/Services/Data/DataActions';
|
||||||
|
|
||||||
export const useDropSource = (props?: MetadataMigrationOptions) => {
|
export const useDropSource = (props?: MetadataMigrationOptions) => {
|
||||||
const { ...globalMutateOptions } = props;
|
const { ...globalMutateOptions } = props;
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
const invalidateMetadata = useInvalidateMetadata();
|
const invalidateMetadata = useInvalidateMetadata();
|
||||||
const { mutate, ...rest } = useMetadataMigration({
|
const { mutate, ...rest } = useMetadataMigration({
|
||||||
onSuccess: (data, variables, ctx) => {
|
onSuccess: (data, variables, ctx) => {
|
||||||
hasuraToast({ type: 'success', title: 'Source dropped from metadata!' });
|
hasuraToast({ type: 'success', title: 'Source dropped from metadata!' });
|
||||||
invalidateMetadata();
|
invalidateMetadata();
|
||||||
|
dispatch({
|
||||||
|
type: UPDATE_CURRENT_DATA_SOURCE,
|
||||||
|
source: '',
|
||||||
|
});
|
||||||
globalMutateOptions?.onSuccess?.(data, variables, ctx);
|
globalMutateOptions?.onSuccess?.(data, variables, ctx);
|
||||||
},
|
},
|
||||||
onError: (data, variables, ctx) => {
|
onError: (data, variables, ctx) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user