这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions console/cypress/integration/data/modify/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`));
});
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -484,6 +486,7 @@ const changeTableOrViewName = (isTable, oldName, newName, callback) => {
)
);
}

if (!gqlPattern.test(newName)) {
const gqlValidationError = isTable
? gqlTableErrorNotif
Expand Down Expand Up @@ -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 });
Expand Down