mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
update table rename handling (#2393)
This commit is contained in:
parent
4ce2b2cc3b
commit
00e911e3cd
@ -50,14 +50,14 @@ export const passMTRenameTable = () => {
|
||||
.clear()
|
||||
.type(getTableName(3, testName));
|
||||
cy.get(getElementFromAlias('heading-edit-table-save')).click();
|
||||
cy.wait(25000);
|
||||
cy.wait(15000);
|
||||
validateCT(getTableName(3, testName), 'success');
|
||||
cy.get(getElementFromAlias('heading-edit-table')).click();
|
||||
cy.get(getElementFromAlias('heading-edit-table-input'))
|
||||
.clear()
|
||||
.type(getTableName(0, testName));
|
||||
cy.get(getElementFromAlias('heading-edit-table-save')).click();
|
||||
cy.wait(25000);
|
||||
cy.wait(15000);
|
||||
validateCT(getTableName(0, testName), 'success');
|
||||
};
|
||||
|
||||
|
@ -396,7 +396,7 @@ const modifyResolver = () => {
|
||||
const customOnSuccess = data => {
|
||||
// dispatch({ type: REQUEST_SUCCESS });
|
||||
dispatch({ type: RESET, data: data });
|
||||
dispatch(push(`${prefixUrl}/manage/schemas`)); // Hack to avoid 404
|
||||
dispatch(push(`${prefixUrl}/manage/schemas`)); // to avoid 404
|
||||
dispatch(fetchResolvers()).then(() => {
|
||||
dispatch(push(`${prefixUrl}/manage/${remoteSchemaName}/details`));
|
||||
});
|
||||
|
@ -1,7 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router';
|
||||
import Helmet from 'react-helmet';
|
||||
import globals from '../../../../Globals';
|
||||
import { changeTableOrViewName } from '../TableModify/ModifyActions';
|
||||
import EditableHeading from '../../../Common/EditableHeading/EditableHeading';
|
||||
import BreadCrumb from '../../../Common/Layout/BreadCrumb/BreadCrumb';
|
||||
@ -18,26 +17,9 @@ const ViewHeader = ({
|
||||
let capitalised = tabName;
|
||||
capitalised = capitalised[0].toUpperCase() + capitalised.slice(1);
|
||||
const activeTab = tabNameMap[tabName];
|
||||
const viewRenameCallback = newName => {
|
||||
const currentPath = window.location.pathname.replace(
|
||||
new RegExp(globals.urlPrefix, 'g'),
|
||||
''
|
||||
);
|
||||
const newPath = currentPath.replace(
|
||||
/(\/schema\/.*)\/views\/(\w*)(\/.*)?/,
|
||||
`$1/views/${newName}$3`
|
||||
);
|
||||
window.location.replace(
|
||||
`${window.location.origin}${globals.urlPrefix}${newPath}`
|
||||
);
|
||||
};
|
||||
|
||||
const saveViewNameChange = newName => {
|
||||
dispatch(
|
||||
changeTableOrViewName(false, tableName, newName, () =>
|
||||
viewRenameCallback(newName)
|
||||
)
|
||||
);
|
||||
dispatch(changeTableOrViewName(false, tableName, newName));
|
||||
};
|
||||
|
||||
const getBreadCrumbs = () => {
|
||||
|
@ -1,5 +1,4 @@
|
||||
import React from 'react';
|
||||
import globals from '../../../../Globals';
|
||||
import { Link } from 'react-router';
|
||||
import Helmet from 'react-helmet';
|
||||
import { changeTableOrViewName } from '../TableModify/ModifyActions';
|
||||
@ -24,26 +23,8 @@ const TableHeader = ({
|
||||
}
|
||||
const activeTab = tabNameMap[tabName];
|
||||
|
||||
const tableRenameCallback = newName => {
|
||||
const currentPath = window.location.pathname.replace(
|
||||
new RegExp(globals.urlPrefix, 'g'),
|
||||
''
|
||||
);
|
||||
const newPath = currentPath.replace(
|
||||
/(\/schema\/.*)\/tables\/(\w*)(\/.*)?/,
|
||||
`$1/tables/${newName}$3`
|
||||
);
|
||||
window.location.replace(
|
||||
`${window.location.origin}${globals.urlPrefix}${newPath}`
|
||||
);
|
||||
};
|
||||
|
||||
const saveTableNameChange = newName => {
|
||||
dispatch(
|
||||
changeTableOrViewName(true, tableName, newName, () =>
|
||||
tableRenameCallback(newName)
|
||||
)
|
||||
);
|
||||
dispatch(changeTableOrViewName(true, tableName, newName));
|
||||
};
|
||||
|
||||
const getBreadCrumbs = () => {
|
||||
|
@ -472,10 +472,12 @@ const setUniqueKeys = keys => ({
|
||||
keys,
|
||||
});
|
||||
|
||||
const changeTableOrViewName = (isTable, oldName, newName, callback) => {
|
||||
const changeTableOrViewName = (isTable, oldName, newName) => {
|
||||
return (dispatch, getState) => {
|
||||
const property = isTable ? 'table' : 'view';
|
||||
|
||||
dispatch({ type: SAVE_NEW_TABLE_NAME });
|
||||
|
||||
if (oldName === newName) {
|
||||
return dispatch(
|
||||
showErrorNotification(
|
||||
@ -484,6 +486,7 @@ const changeTableOrViewName = (isTable, oldName, newName, callback) => {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (!gqlPattern.test(newName)) {
|
||||
const gqlValidationError = isTable
|
||||
? gqlTableErrorNotif
|
||||
@ -522,7 +525,20 @@ const changeTableOrViewName = (isTable, oldName, newName, callback) => {
|
||||
const errorMsg = `Renaming ${property} failed`;
|
||||
|
||||
const customOnSuccess = () => {
|
||||
callback();
|
||||
dispatch(_push('/schema/' + currentSchema)); // to avoid 404
|
||||
dispatch(updateSchemaInfo()).then(() => {
|
||||
dispatch(
|
||||
_push(
|
||||
'/schema/' +
|
||||
currentSchema +
|
||||
'/' +
|
||||
property +
|
||||
's/' +
|
||||
newName +
|
||||
'/modify'
|
||||
)
|
||||
);
|
||||
});
|
||||
};
|
||||
const customOnError = err => {
|
||||
dispatch({ type: UPDATE_MIGRATION_STATUS_ERROR, data: err });
|
||||
|
Loading…
Reference in New Issue
Block a user