update table rename handling (#2393)

This commit is contained in:
Rikin Kachhia 2019-06-18 23:00:56 +05:30 committed by GitHub
parent 4ce2b2cc3b
commit 00e911e3cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 44 deletions

View File

@ -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');
};

View File

@ -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`));
});

View File

@ -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 = () => {

View File

@ -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 = () => {

View File

@ -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 });