mirror of
https://github.com/zhigang1992/graphql-engine.git
synced 2026-05-24 17:03:37 +08:00
fix console schema update quirks (#2286)
This commit is contained in:
committed by
Rikin Kachhia
parent
95a27fba89
commit
f9fc0cc5e3
@@ -128,6 +128,7 @@ export const passSearchTables = () => {
|
||||
validateCT(getTableName(0, testName), 'success');
|
||||
cy.get(getElementFromAlias('search-tables')).type('0');
|
||||
cy.get(getElementFromAlias('table-links')).should('not.contain', '1');
|
||||
cy.get(getElementFromAlias('search-tables')).type('{home}{del}');
|
||||
};
|
||||
|
||||
export const checkInsertRoute = () => {
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
deleteBITestTable,
|
||||
checkInsertRoute,
|
||||
failBIWrongDataType,
|
||||
failBINullKeys,
|
||||
failBIUniqueKeys,
|
||||
passBIInsert20Rows,
|
||||
checkBrowseRoute,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// import GraphiQL parts
|
||||
import GraphiQLWrapper from './src/components/ApiExplorer/GraphiQLWrapper/GraphiQLWrapper';
|
||||
import GraphiQLWrapper from './src/components/Services/ApiExplorer/GraphiQLWrapper/GraphiQLWrapper';
|
||||
|
||||
// import Data Tab parts
|
||||
import dataRouter from './src/components/Services/Data/DataRouter';
|
||||
@@ -8,8 +8,7 @@ import dataHeaders from './src/components/Services/Data/Common/Headers';
|
||||
import { handleMigrationErrors } from './src/components/Services/Data/TableModify/ModifyActions';
|
||||
import {
|
||||
fetchSchemaList,
|
||||
loadSchema,
|
||||
loadUntrackedSchema,
|
||||
updateSchemaInfo,
|
||||
UPDATE_CURRENT_SCHEMA,
|
||||
UPDATE_DATA_HEADERS,
|
||||
ACCESS_KEY_ERROR,
|
||||
@@ -28,7 +27,7 @@ import routes from './src/routes';
|
||||
import globals from './src/Globals';
|
||||
import endpoints from './src/Endpoints';
|
||||
import mainState from './src/components/Main/State';
|
||||
import { changeRequestHeader } from './src/components/ApiExplorer/Actions';
|
||||
import { changeRequestHeader } from './src/components/Services/ApiExplorer/Actions';
|
||||
import { validateLogin } from './src/components/Main/Actions';
|
||||
|
||||
const filterQueryScss = require('./src/components/Common/FilterQuery/FilterQuery.scss');
|
||||
@@ -39,7 +38,7 @@ export { GraphiQLWrapper };
|
||||
|
||||
// export Data Tab parts
|
||||
export { dataRouter, dataReducer };
|
||||
export { fetchSchemaList, loadSchema, loadUntrackedSchema };
|
||||
export { fetchSchemaList, updateSchemaInfo };
|
||||
export { UPDATE_CURRENT_SCHEMA, UPDATE_DATA_HEADERS, ACCESS_KEY_ERROR };
|
||||
export { dataHeaders };
|
||||
|
||||
|
||||
@@ -22,11 +22,6 @@
|
||||
line-height: 26px;
|
||||
}
|
||||
|
||||
.changeSchema {
|
||||
margin-left: 10px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
height: calc(100vh - 26px);
|
||||
overflow: auto;
|
||||
@@ -178,11 +173,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
.heading_tooltip {
|
||||
display: inline-block;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
.activeTable {
|
||||
a {
|
||||
// border-left: 4px solid #FFC627;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import defaultState from './AddState';
|
||||
|
||||
import _push from '../push';
|
||||
import { loadUntrackedRelations, makeMigrationCall } from '../DataActions';
|
||||
import { updateSchemaInfo, makeMigrationCall } from '../DataActions';
|
||||
import {
|
||||
showSuccessNotification,
|
||||
showErrorNotification,
|
||||
@@ -268,7 +268,7 @@ const createTableSql = () => {
|
||||
dispatch({ type: REQUEST_SUCCESS });
|
||||
dispatch({ type: SET_DEFAULTS });
|
||||
dispatch(setTable(state.tableName.trim()));
|
||||
dispatch(loadUntrackedRelations()).then(() =>
|
||||
dispatch(updateSchemaInfo()).then(() =>
|
||||
dispatch(
|
||||
_push(
|
||||
'/schema/' +
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import defaultState from './AddExistingTableViewState';
|
||||
import _push from '../push';
|
||||
import {
|
||||
loadUntrackedRelations,
|
||||
updateSchemaInfo,
|
||||
fetchTrackedFunctions,
|
||||
makeMigrationCall,
|
||||
} from '../DataActions';
|
||||
@@ -58,7 +58,7 @@ const addExistingTableSql = () => {
|
||||
const errorMsg = 'Adding existing table/view failed';
|
||||
const customOnSuccess = () => {
|
||||
dispatch({ type: REQUEST_SUCCESS });
|
||||
dispatch(loadUntrackedRelations()).then(() => {
|
||||
dispatch(updateSchemaInfo()).then(() => {
|
||||
const newTable = getState().tables.allSchemas.find(
|
||||
t =>
|
||||
t.table_name === state.tableName.trim() &&
|
||||
@@ -213,7 +213,7 @@ const addAllUntrackedTablesSql = tableList => {
|
||||
const customOnSuccess = () => {
|
||||
dispatch(showSuccessNotification('Existing table/view added!'));
|
||||
dispatch({ type: REQUEST_SUCCESS });
|
||||
dispatch(loadUntrackedRelations()).then(() => {
|
||||
dispatch(updateSchemaInfo()).then(() => {
|
||||
dispatch(_push('/schema/' + currentSchema));
|
||||
});
|
||||
return;
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import styles from '../../../../Common/TableCommon/Table.scss';
|
||||
import { fkViolationOnUpdate, fkViolationOnDelete } from './Tooltips';
|
||||
import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger';
|
||||
import { loadSchema } from '../../DataActions';
|
||||
import { updateSchemaInfo } from '../../DataActions';
|
||||
|
||||
const violiationActions = [
|
||||
'restrict',
|
||||
@@ -36,7 +36,7 @@ const ForeignKeySelector = ({
|
||||
}
|
||||
newFks[index].refSchemaName = event.target.value;
|
||||
dispatch(setForeignKeys(newFks));
|
||||
dispatch(loadSchema({ schemas: [event.target.value] }));
|
||||
dispatch(updateSchemaInfo({ schemas: [event.target.value] }));
|
||||
};
|
||||
return (
|
||||
<div className={`${styles.add_mar_bottom}`}>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import sanitize from 'sanitize-filename';
|
||||
import { push } from 'react-router-redux';
|
||||
|
||||
import Endpoints, { globalCookiePolicy } from '../../../Endpoints';
|
||||
import requestAction from '../../../utils/requestAction';
|
||||
@@ -36,7 +37,6 @@ const SET_TABLE = 'Data/SET_TABLE';
|
||||
const LOAD_FUNCTIONS = 'Data/LOAD_FUNCTIONS';
|
||||
const LOAD_NON_TRACKABLE_FUNCTIONS = 'Data/LOAD_NON_TRACKABLE_FUNCTIONS';
|
||||
const LOAD_TRACKED_FUNCTIONS = 'Data/LOAD_TRACKED_FUNCTIONS';
|
||||
const UPDATE_TRACKED_FUNCTIONS = 'Data/UPDATE_TRACKED_FUNCTIONS';
|
||||
const LOAD_SCHEMA = 'Data/LOAD_SCHEMA';
|
||||
const LOAD_UNTRACKED_RELATIONS = 'Data/LOAD_UNTRACKED_RELATIONS';
|
||||
const FETCH_SCHEMA_LIST = 'Data/FETCH_SCHEMA_LIST';
|
||||
@@ -172,19 +172,24 @@ const initQueries = {
|
||||
const fetchTrackedFunctions = () => {
|
||||
return (dispatch, getState) => {
|
||||
const url = Endpoints.getSchema;
|
||||
|
||||
const currentSchema = getState().tables.currentSchema;
|
||||
|
||||
const body = initQueries.loadTrackedFunctions;
|
||||
body.args.where.function_schema = currentSchema;
|
||||
|
||||
const options = {
|
||||
credentials: globalCookiePolicy,
|
||||
method: 'POST',
|
||||
headers: dataHeaders(getState),
|
||||
body: JSON.stringify(body),
|
||||
};
|
||||
|
||||
return dispatch(requestAction(url, options)).then(
|
||||
data => {
|
||||
let consistentFunctions = data;
|
||||
const { inconsistentObjects } = getState().metadata;
|
||||
|
||||
if (inconsistentObjects.length > 0) {
|
||||
consistentFunctions = filterInconsistentMetadata(
|
||||
data,
|
||||
@@ -192,6 +197,7 @@ const fetchTrackedFunctions = () => {
|
||||
'functions'
|
||||
);
|
||||
}
|
||||
|
||||
dispatch({ type: LOAD_TRACKED_FUNCTIONS, data: consistentFunctions });
|
||||
},
|
||||
error => {
|
||||
@@ -206,91 +212,105 @@ const setUntrackedRelations = () => (dispatch, getState) => {
|
||||
getState().tables.allSchemas,
|
||||
getState().tables.currentSchema
|
||||
).bulkRelTrack;
|
||||
|
||||
dispatch({
|
||||
type: LOAD_UNTRACKED_RELATIONS,
|
||||
untrackedRelations,
|
||||
});
|
||||
};
|
||||
|
||||
const loadSchema = configOptions => (dispatch, getState) => {
|
||||
const url = Endpoints.getSchema;
|
||||
let allSchemas = getState().tables.allSchemas;
|
||||
if (
|
||||
!configOptions ||
|
||||
((!configOptions.schemas || configOptions.schemas.length === 0) &&
|
||||
!configOptions.tables)
|
||||
) {
|
||||
configOptions = {
|
||||
schemas: [getState().tables.currentSchema],
|
||||
};
|
||||
}
|
||||
if (configOptions) {
|
||||
if (configOptions.schemas) {
|
||||
allSchemas = allSchemas.filter(
|
||||
schemaInfo =>
|
||||
!configOptions.schemas.some(item => item === schemaInfo.table_schema)
|
||||
);
|
||||
const loadSchema = configOptions => {
|
||||
return (dispatch, getState) => {
|
||||
const url = Endpoints.getSchema;
|
||||
|
||||
let allSchemas = getState().tables.allSchemas;
|
||||
|
||||
if (
|
||||
!configOptions ||
|
||||
((!configOptions.schemas || configOptions.schemas.length === 0) &&
|
||||
(!configOptions.tables || configOptions.tables.length === 0))
|
||||
) {
|
||||
configOptions = {
|
||||
schemas: [getState().tables.currentSchema],
|
||||
};
|
||||
}
|
||||
|
||||
if (configOptions.tables) {
|
||||
allSchemas = allSchemas.filter(
|
||||
schemaInfo =>
|
||||
!configOptions.tables.some(
|
||||
item =>
|
||||
item.table_schema === schemaInfo.table_schema &&
|
||||
item.table_name === schemaInfo.table_name
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const body = {
|
||||
type: 'bulk',
|
||||
args: [
|
||||
fetchTableListQuery(configOptions),
|
||||
fetchTrackedTableListQuery(configOptions), // v1/query
|
||||
fetchTrackedTableFkQuery(configOptions),
|
||||
fetchTrackedTableReferencedFkQuery(configOptions),
|
||||
],
|
||||
};
|
||||
const options = {
|
||||
credentials: globalCookiePolicy,
|
||||
method: 'POST',
|
||||
headers: dataHeaders(getState),
|
||||
body: JSON.stringify(body),
|
||||
};
|
||||
|
||||
return dispatch(requestAction(url, options)).then(
|
||||
data => {
|
||||
const mergedData = mergeLoadSchemaData(
|
||||
JSON.parse(data[0].result[1]),
|
||||
data[1],
|
||||
JSON.parse(data[2].result[1]),
|
||||
JSON.parse(data[3].result[1])
|
||||
);
|
||||
const maybeInconsistentSchemas = allSchemas.concat(mergedData);
|
||||
let consistentSchemas;
|
||||
const { inconsistentObjects } = getState().metadata;
|
||||
if (inconsistentObjects.length > 0) {
|
||||
consistentSchemas = filterInconsistentMetadata(
|
||||
maybeInconsistentSchemas,
|
||||
inconsistentObjects,
|
||||
'tables'
|
||||
if (configOptions) {
|
||||
if (configOptions.schemas) {
|
||||
allSchemas = allSchemas.filter(
|
||||
schemaInfo =>
|
||||
!configOptions.schemas.some(
|
||||
item => item === schemaInfo.table_schema
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (configOptions.tables) {
|
||||
allSchemas = allSchemas.filter(
|
||||
schemaInfo =>
|
||||
!configOptions.tables.some(
|
||||
item =>
|
||||
item.table_schema === schemaInfo.table_schema &&
|
||||
item.table_name === schemaInfo.table_name
|
||||
)
|
||||
);
|
||||
}
|
||||
dispatch({
|
||||
type: LOAD_SCHEMA,
|
||||
allSchemas: consistentSchemas || maybeInconsistentSchemas,
|
||||
});
|
||||
dispatch(loadInconsistentObjects());
|
||||
},
|
||||
error => {
|
||||
console.error('Failed to load schema ' + JSON.stringify(error));
|
||||
}
|
||||
);
|
||||
|
||||
const body = {
|
||||
type: 'bulk',
|
||||
args: [
|
||||
fetchTableListQuery(configOptions),
|
||||
fetchTrackedTableListQuery(configOptions), // v1/query
|
||||
fetchTrackedTableFkQuery(configOptions),
|
||||
fetchTrackedTableReferencedFkQuery(configOptions),
|
||||
],
|
||||
};
|
||||
|
||||
const options = {
|
||||
credentials: globalCookiePolicy,
|
||||
method: 'POST',
|
||||
headers: dataHeaders(getState),
|
||||
body: JSON.stringify(body),
|
||||
};
|
||||
|
||||
return dispatch(requestAction(url, options)).then(
|
||||
data => {
|
||||
const mergedData = mergeLoadSchemaData(
|
||||
JSON.parse(data[0].result[1]),
|
||||
data[1],
|
||||
JSON.parse(data[2].result[1]),
|
||||
JSON.parse(data[3].result[1])
|
||||
);
|
||||
|
||||
const { inconsistentObjects } = getState().metadata;
|
||||
|
||||
const maybeInconsistentSchemas = allSchemas.concat(mergedData);
|
||||
|
||||
let consistentSchemas;
|
||||
if (inconsistentObjects.length > 0) {
|
||||
consistentSchemas = filterInconsistentMetadata(
|
||||
maybeInconsistentSchemas,
|
||||
inconsistentObjects,
|
||||
'tables'
|
||||
);
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: LOAD_SCHEMA,
|
||||
allSchemas: consistentSchemas || maybeInconsistentSchemas,
|
||||
});
|
||||
|
||||
dispatch(loadInconsistentObjects());
|
||||
},
|
||||
error => {
|
||||
console.error('Failed to load schema ' + JSON.stringify(error));
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
const loadUntrackedRelations = options => dispatch => {
|
||||
const updateSchemaInfo = options => dispatch => {
|
||||
return dispatch(loadSchema(options)).then(() => {
|
||||
dispatch(setUntrackedRelations());
|
||||
});
|
||||
@@ -308,6 +328,7 @@ const setConsistentFunctions = data => ({
|
||||
|
||||
const fetchDataInit = () => (dispatch, getState) => {
|
||||
const url = Endpoints.getSchema;
|
||||
|
||||
const body = {
|
||||
type: 'bulk',
|
||||
args: [initQueries.schemaList],
|
||||
@@ -319,10 +340,11 @@ const fetchDataInit = () => (dispatch, getState) => {
|
||||
headers: dataHeaders(getState),
|
||||
body: JSON.stringify(body),
|
||||
};
|
||||
|
||||
return dispatch(requestAction(url, options)).then(
|
||||
data => {
|
||||
dispatch({ type: FETCH_SCHEMA_LIST, schemaList: data[0] });
|
||||
dispatch(loadUntrackedRelations());
|
||||
dispatch(updateSchemaInfo());
|
||||
},
|
||||
error => {
|
||||
console.error('Failed to fetch schema ' + JSON.stringify(error));
|
||||
@@ -374,6 +396,17 @@ const fetchFunctionInit = () => (dispatch, getState) => {
|
||||
);
|
||||
};
|
||||
|
||||
const updateCurrentSchema = schemaName => dispatch => {
|
||||
dispatch(push(`${globals.urlPrefix}/data/schema/${schemaName}`));
|
||||
|
||||
Promise.all([
|
||||
dispatch({ type: UPDATE_CURRENT_SCHEMA, currentSchema: schemaName }),
|
||||
dispatch(setUntrackedRelations()),
|
||||
dispatch(fetchFunctionInit()),
|
||||
dispatch(updateSchemaInfo()),
|
||||
]);
|
||||
};
|
||||
|
||||
/* ************ action creators *********************** */
|
||||
const fetchSchemaList = () => (dispatch, getState) => {
|
||||
const url = Endpoints.getSchema;
|
||||
@@ -480,7 +513,7 @@ const makeMigrationCall = (
|
||||
if (globals.consoleMode === 'cli') {
|
||||
dispatch(loadMigrationStatus()); // don't call for server mode
|
||||
}
|
||||
dispatch(loadSchema());
|
||||
dispatch(updateSchemaInfo());
|
||||
}
|
||||
if (successMsg) {
|
||||
dispatch(showSuccessNotification(successMsg));
|
||||
@@ -593,13 +626,6 @@ const dataReducer = (state = defaultState, action) => {
|
||||
return {
|
||||
...state,
|
||||
trackedFunctions: action.data,
|
||||
listedFunctions: action.data,
|
||||
};
|
||||
|
||||
case UPDATE_TRACKED_FUNCTIONS:
|
||||
return {
|
||||
...state,
|
||||
listedFunctions: [...action.data],
|
||||
};
|
||||
case LOAD_SCHEMA:
|
||||
// remove duplicates
|
||||
@@ -634,7 +660,6 @@ const dataReducer = (state = defaultState, action) => {
|
||||
return {
|
||||
...state,
|
||||
trackedFunctions: action.data,
|
||||
listedFunctions: action.data,
|
||||
};
|
||||
case UPDATE_CURRENT_SCHEMA:
|
||||
return { ...state, currentSchema: action.currentSchema };
|
||||
@@ -697,25 +722,25 @@ export {
|
||||
REQUEST_SUCCESS,
|
||||
REQUEST_ERROR,
|
||||
setTable,
|
||||
loadSchema,
|
||||
updateSchemaInfo,
|
||||
handleMigrationErrors,
|
||||
makeMigrationCall,
|
||||
LOAD_UNTRACKED_RELATIONS,
|
||||
UPDATE_CURRENT_SCHEMA,
|
||||
loadUntrackedRelations,
|
||||
fetchSchemaList,
|
||||
fetchDataInit,
|
||||
fetchFunctionInit,
|
||||
updateCurrentSchema,
|
||||
ADMIN_SECRET_ERROR,
|
||||
UPDATE_DATA_HEADERS,
|
||||
UPDATE_REMOTE_SCHEMA_MANUAL_REL,
|
||||
RESET_MANUAL_REL_TABLE_LIST,
|
||||
fetchTrackedFunctions,
|
||||
UPDATE_TRACKED_FUNCTIONS,
|
||||
initQueries,
|
||||
LOAD_SCHEMA,
|
||||
setConsistentSchema,
|
||||
setConsistentFunctions,
|
||||
fetchColumnTypes,
|
||||
RESET_COLUMN_TYPE_LIST,
|
||||
setUntrackedRelations,
|
||||
};
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router';
|
||||
import _push from './push';
|
||||
import globals from '../../../Globals';
|
||||
|
||||
import LeftContainer from '../../Common/Layout/LeftContainer/LeftContainer';
|
||||
import PageContainer from '../../Common/Layout/PageContainer/PageContainer';
|
||||
import DataSubSidebar from './DataSubSidebar';
|
||||
|
||||
import {
|
||||
loadUntrackedRelations,
|
||||
UPDATE_CURRENT_SCHEMA,
|
||||
fetchFunctionInit,
|
||||
} from './DataActions';
|
||||
import { updateCurrentSchema } from './DataActions';
|
||||
|
||||
const sectionPrefix = '/data';
|
||||
|
||||
@@ -44,13 +39,7 @@ const DataPageContainer = ({
|
||||
}
|
||||
|
||||
const handleSchemaChange = e => {
|
||||
const updatedSchema = e.target.value;
|
||||
dispatch(_push(`/schema/${updatedSchema}`));
|
||||
Promise.all([
|
||||
dispatch({ type: UPDATE_CURRENT_SCHEMA, currentSchema: updatedSchema }),
|
||||
dispatch(loadUntrackedRelations()),
|
||||
dispatch(fetchFunctionInit()),
|
||||
]);
|
||||
dispatch(updateCurrentSchema(e.target.value));
|
||||
};
|
||||
|
||||
const sidebarContent = (
|
||||
|
||||
@@ -32,7 +32,7 @@ import {
|
||||
fetchDataInit,
|
||||
fetchFunctionInit,
|
||||
UPDATE_CURRENT_SCHEMA,
|
||||
loadUntrackedRelations,
|
||||
updateSchemaInfo,
|
||||
// UPDATE_DATA_HEADERS,
|
||||
// ADMIN_SECRET_ERROR,
|
||||
} from './DataActions';
|
||||
@@ -162,7 +162,7 @@ const dataRouterUtils = (connect, store, composeOnEnterHooks) => {
|
||||
currentSchema: currentSchema,
|
||||
}),
|
||||
store.dispatch(fetchDataInit()),
|
||||
store.dispatch(loadUntrackedRelations()),
|
||||
store.dispatch(updateSchemaInfo()),
|
||||
store.dispatch(fetchFunctionInit()),
|
||||
]).then(
|
||||
() => {
|
||||
|
||||
@@ -155,7 +155,6 @@ const defaultState = {
|
||||
postgresFunctions: [],
|
||||
nonTrackablePostgresFunctions: [],
|
||||
trackedFunctions: [],
|
||||
listedFunctions: [],
|
||||
listingSchemas: [],
|
||||
untrackedRelations: [],
|
||||
schemaList: ['public'],
|
||||
|
||||
@@ -4,8 +4,6 @@ import { Link } from 'react-router';
|
||||
|
||||
import LeftSubSidebar from '../../Common/Layout/LeftSubSidebar/LeftSubSidebar';
|
||||
|
||||
import { UPDATE_TRACKED_FUNCTIONS } from './DataActions';
|
||||
|
||||
const appPrefix = '/data';
|
||||
|
||||
class DataSubSidebar extends React.Component {
|
||||
@@ -13,51 +11,37 @@ class DataSubSidebar extends React.Component {
|
||||
super();
|
||||
|
||||
this.tableSearch = this.tableSearch.bind(this);
|
||||
this.setTrackedTables = this.setTrackedTables.bind(this);
|
||||
this.state = {
|
||||
trackedTables: [],
|
||||
tableList: [],
|
||||
searchInput: '',
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { currentSchema, schema } = this.props;
|
||||
this.setTrackedTables(currentSchema, schema);
|
||||
}
|
||||
static getDerivedStateFromProps(props) {
|
||||
const { currentSchema, schema } = props;
|
||||
|
||||
shouldComponentUpdate(nextProps) {
|
||||
const { currentSchema, schema } = this.props;
|
||||
if (
|
||||
currentSchema !== nextProps.currentSchema ||
|
||||
schema !== nextProps.schema
|
||||
) {
|
||||
this.setTrackedTables(nextProps.currentSchema, nextProps.schema);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
setTrackedTables(currentSchema, schema) {
|
||||
const trackedTables = schema.filter(
|
||||
table => table.is_table_tracked && table.table_schema === currentSchema
|
||||
);
|
||||
this.setState({
|
||||
|
||||
return {
|
||||
trackedTables: trackedTables,
|
||||
tableList: trackedTables,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps) {
|
||||
if (nextProps.metadata.ongoingRequest) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
tableSearch(e) {
|
||||
const searchTerm = e.target.value;
|
||||
|
||||
this.state.tableList = this.state.trackedTables.filter(
|
||||
t => t.table_name.indexOf(searchTerm) !== -1
|
||||
);
|
||||
|
||||
const matchedFuncs = this.props.functionsList.filter(
|
||||
f => f.function_name.indexOf(searchTerm) !== -1
|
||||
);
|
||||
|
||||
this.props.dispatch({ type: UPDATE_TRACKED_FUNCTIONS, data: matchedFuncs });
|
||||
this.setState({
|
||||
searchInput: searchTerm,
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -66,23 +50,25 @@ class DataSubSidebar extends React.Component {
|
||||
const functionSymbolActive = require('../../Common/Layout/LeftSubSidebar/function_high.svg');
|
||||
const {
|
||||
functionsList,
|
||||
listedFunctions,
|
||||
currentTable,
|
||||
currentSchema,
|
||||
migrationMode,
|
||||
location,
|
||||
currentFunction,
|
||||
metadata,
|
||||
} = this.props;
|
||||
|
||||
if (metadata.ongoingRequest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { trackedTables, tableList } = this.state;
|
||||
const { trackedTables, searchInput } = this.state;
|
||||
|
||||
const trackedTablesLength = trackedTables.length;
|
||||
|
||||
const tableList = trackedTables.filter(t =>
|
||||
t.table_name.includes(searchInput)
|
||||
);
|
||||
|
||||
const listedFunctions = functionsList.filter(f =>
|
||||
f.function_name.includes(searchInput)
|
||||
);
|
||||
|
||||
const getSearchInput = () => {
|
||||
return (
|
||||
<input
|
||||
@@ -249,7 +235,6 @@ const mapStateToProps = state => {
|
||||
currentTable: state.tables.currentTable,
|
||||
migrationMode: state.main.migrationMode,
|
||||
functionsList: state.tables.trackedFunctions,
|
||||
listedFunctions: state.tables.listedFunctions,
|
||||
currentFunction: state.functions.functionName,
|
||||
serverVersion: state.main.serverVersion ? state.main.serverVersion : '',
|
||||
metadata: state.metadata,
|
||||
|
||||
@@ -14,7 +14,7 @@ const prefixUrl = globals.urlPrefix + appPrefix;
|
||||
|
||||
import { fetchCustomFunction } from '../customFunctionReducer';
|
||||
import {
|
||||
loadUntrackedRelations,
|
||||
updateSchemaInfo,
|
||||
UPDATE_CURRENT_SCHEMA,
|
||||
fetchFunctionInit,
|
||||
setTable,
|
||||
@@ -66,7 +66,7 @@ class Permission extends React.Component {
|
||||
type: UPDATE_CURRENT_SCHEMA,
|
||||
currentSchema: setOffTableSchema,
|
||||
}),
|
||||
dispatch(loadUntrackedRelations()),
|
||||
dispatch(updateSchemaInfo()),
|
||||
dispatch(fetchFunctionInit()),
|
||||
dispatch(setTable(setOffTable)),
|
||||
]);
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
/* eslint-disable space-infix-ops */
|
||||
/* eslint-disable no-loop-func */
|
||||
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import React, { Component } from 'react';
|
||||
@@ -22,9 +19,9 @@ import {
|
||||
addExistingFunction,
|
||||
} from '../Add/AddExistingTableViewActions';
|
||||
import {
|
||||
loadUntrackedRelations,
|
||||
updateSchemaInfo,
|
||||
fetchFunctionInit,
|
||||
UPDATE_CURRENT_SCHEMA,
|
||||
updateCurrentSchema,
|
||||
} from '../DataActions';
|
||||
import {
|
||||
autoAddRelName,
|
||||
@@ -49,7 +46,7 @@ class Schema extends Component {
|
||||
|
||||
this.props.dispatch(fetchFunctionInit());
|
||||
this.props.dispatch(
|
||||
loadUntrackedRelations({ schemas: [this.props.currentSchema] })
|
||||
updateSchemaInfo({ schemas: [this.props.currentSchema] })
|
||||
);
|
||||
}
|
||||
|
||||
@@ -66,20 +63,10 @@ class Schema extends Component {
|
||||
trackedFunctions,
|
||||
} = this.props;
|
||||
|
||||
const styles = require('../../../Common/Layout/LeftSubSidebar/LeftSubSidebar.scss');
|
||||
|
||||
const updateCurrentSchema = schemaName => {
|
||||
dispatch(push(`${appPrefix}/schema/${schemaName}`));
|
||||
|
||||
Promise.all([
|
||||
dispatch({ type: UPDATE_CURRENT_SCHEMA, currentSchema: schemaName }),
|
||||
dispatch(fetchFunctionInit()),
|
||||
dispatch(loadUntrackedRelations({ schemas: [schemaName] })),
|
||||
]);
|
||||
};
|
||||
const styles = require('../../../Common/Common.scss');
|
||||
|
||||
const handleSchemaChange = e => {
|
||||
updateCurrentSchema(e.target.value);
|
||||
dispatch(updateCurrentSchema(e.target.value));
|
||||
};
|
||||
|
||||
/***********/
|
||||
@@ -165,14 +152,18 @@ class Schema extends Component {
|
||||
};
|
||||
|
||||
const handleCreateClick = () => {
|
||||
const schemaName = schemaNameEdit.trim();
|
||||
|
||||
const successCb = () => {
|
||||
updateCurrentSchema(schemaNameEdit.trim());
|
||||
dispatch(updateCurrentSchema(schemaName));
|
||||
|
||||
this.setState({
|
||||
schemaNameEdit: '',
|
||||
createSchemaOpen: false,
|
||||
});
|
||||
};
|
||||
dispatch(createNewSchema(schemaNameEdit.trim(), successCb));
|
||||
|
||||
dispatch(createNewSchema(schemaName, successCb));
|
||||
};
|
||||
|
||||
const handleCancelCreateNewSchema = () => {
|
||||
@@ -236,8 +227,9 @@ class Schema extends Component {
|
||||
if (migrationMode) {
|
||||
const handleDelete = () => {
|
||||
const successCb = () => {
|
||||
updateCurrentSchema('public');
|
||||
dispatch(updateCurrentSchema('public'));
|
||||
};
|
||||
|
||||
dispatch(deleteCurrentSchema(successCb));
|
||||
};
|
||||
|
||||
@@ -262,7 +254,12 @@ class Schema extends Component {
|
||||
<div className={styles.display_inline}>
|
||||
<select
|
||||
onChange={handleSchemaChange}
|
||||
className={styles.changeSchema + ' form-control'}
|
||||
className={
|
||||
styles.add_mar_left_mid +
|
||||
' ' +
|
||||
styles.width_auto +
|
||||
' form-control'
|
||||
}
|
||||
value={currentSchema}
|
||||
>
|
||||
{schemaOptions}
|
||||
@@ -349,7 +346,11 @@ class Schema extends Component {
|
||||
|
||||
const heading = (
|
||||
<div>
|
||||
<h4 className={`${styles.subheading_text} ${styles.heading_tooltip}`}>
|
||||
<h4
|
||||
className={`${styles.subheading_text} ${styles.display_inline} ${
|
||||
styles.add_mar_right_mid
|
||||
}`}
|
||||
>
|
||||
Untracked tables or views
|
||||
</h4>
|
||||
<OverlayTrigger placement="right" overlay={untrackedTip}>
|
||||
@@ -455,7 +456,11 @@ class Schema extends Component {
|
||||
|
||||
const heading = (
|
||||
<div>
|
||||
<h4 className={`${styles.subheading_text} ${styles.heading_tooltip}`}>
|
||||
<h4
|
||||
className={`${styles.subheading_text} ${styles.display_inline} ${
|
||||
styles.add_mar_right_mid
|
||||
}`}
|
||||
>
|
||||
Untracked foreign-key relations
|
||||
</h4>
|
||||
<OverlayTrigger placement="right" overlay={untrackedRelTip}>
|
||||
@@ -484,7 +489,9 @@ class Schema extends Component {
|
||||
const heading = (
|
||||
<div>
|
||||
<h4
|
||||
className={`${styles.subheading_text} ${styles.heading_tooltip}`}
|
||||
className={`${styles.subheading_text} ${styles.display_inline} ${
|
||||
styles.add_mar_right_mid
|
||||
}`}
|
||||
>
|
||||
Untracked custom functions
|
||||
</h4>
|
||||
@@ -544,7 +551,9 @@ class Schema extends Component {
|
||||
const heading = (
|
||||
<div>
|
||||
<h4
|
||||
className={`${styles.subheading_text} ${styles.heading_tooltip}`}
|
||||
className={`${styles.subheading_text} ${styles.display_inline} ${
|
||||
styles.add_mar_right_mid
|
||||
}`}
|
||||
>
|
||||
Non trackable custom functions
|
||||
</h4>
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
} from '../Common/ReusableComponents/utils';
|
||||
import ExpandableEditor from '../../../Common/Layout/ExpandableEditor/Editor';
|
||||
import ForeignKeySelector from '../Common/ReusableComponents/ForeignKeySelector';
|
||||
import { loadSchema } from '../DataActions';
|
||||
import { updateSchemaInfo } from '../DataActions';
|
||||
|
||||
const ForeignKeyEditor = ({
|
||||
tableSchema,
|
||||
@@ -46,7 +46,7 @@ const ForeignKeyEditor = ({
|
||||
});
|
||||
useEffect(() => {
|
||||
dispatch(setForeignKeys(existingForeignKeys));
|
||||
dispatch(loadSchema({ schemas: Object.keys(schemasToBeFetched) }));
|
||||
dispatch(updateSchemaInfo({ schemas: Object.keys(schemasToBeFetched) }));
|
||||
}, []);
|
||||
|
||||
const numFks = fkModify.length;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import requestAction from '../../../../utils/requestAction';
|
||||
import Endpoints, { globalCookiePolicy } from '../../../../Endpoints';
|
||||
import {
|
||||
loadUntrackedRelations,
|
||||
updateSchemaInfo,
|
||||
handleMigrationErrors,
|
||||
makeMigrationCall,
|
||||
LOAD_SCHEMA,
|
||||
@@ -544,7 +544,7 @@ const deleteTableSql = tableName => {
|
||||
const errorMsg = 'Deleting table failed';
|
||||
|
||||
const customOnSuccess = () => {
|
||||
dispatch(loadUntrackedRelations()).then(() => {
|
||||
dispatch(updateSchemaInfo()).then(() => {
|
||||
dispatch(_push('/'));
|
||||
});
|
||||
};
|
||||
@@ -625,7 +625,7 @@ const untrackTableSql = tableName => {
|
||||
table_name: tableName,
|
||||
});
|
||||
dispatch(
|
||||
loadUntrackedRelations({
|
||||
updateSchemaInfo({
|
||||
tables: tableData,
|
||||
})
|
||||
).then(() => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import inflection from 'inflection';
|
||||
|
||||
import {
|
||||
makeMigrationCall,
|
||||
loadUntrackedRelations,
|
||||
updateSchemaInfo,
|
||||
RESET_MANUAL_REL_TABLE_LIST,
|
||||
} from '../DataActions';
|
||||
import gqlPattern, { gqlRelErrorNotif } from '../Common/GraphQLValidation';
|
||||
@@ -204,7 +204,7 @@ const deleteRelMigrate = relMeta => (dispatch, getState) => {
|
||||
const errorMsg = 'Deleting relationship failed';
|
||||
|
||||
const customOnSuccess = () => {
|
||||
dispatch(loadUntrackedRelations());
|
||||
dispatch(updateSchemaInfo());
|
||||
};
|
||||
const customOnError = () => {};
|
||||
|
||||
@@ -250,7 +250,7 @@ const addRelNewFromStateMigrate = () => (dispatch, getState) => {
|
||||
|
||||
const customOnSuccess = () => {
|
||||
dispatch(
|
||||
loadUntrackedRelations({
|
||||
updateSchemaInfo({
|
||||
tables: [
|
||||
{
|
||||
table_schema: state.lSchema,
|
||||
@@ -522,7 +522,7 @@ const autoTrackRelations = autoTrackData => (dispatch, getState) => {
|
||||
const successMsg = 'Relationship created';
|
||||
const errorMsg = 'Creating relationship failed';
|
||||
const customOnSuccess = () => {
|
||||
dispatch(loadUntrackedRelations());
|
||||
dispatch(updateSchemaInfo());
|
||||
};
|
||||
const customOnError = () => {};
|
||||
|
||||
@@ -558,7 +558,7 @@ const autoAddRelName = obj => (dispatch, getState) => {
|
||||
const errorMsg = 'Creating relationship failed';
|
||||
|
||||
const customOnSuccess = () => {
|
||||
Promise.all([dispatch(loadUntrackedRelations())]);
|
||||
Promise.all([dispatch(updateSchemaInfo())]);
|
||||
};
|
||||
const customOnError = () => {};
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
import {
|
||||
UPDATE_REMOTE_SCHEMA_MANUAL_REL,
|
||||
RESET_MANUAL_REL_TABLE_LIST,
|
||||
loadSchema,
|
||||
updateSchemaInfo,
|
||||
} from '../DataActions';
|
||||
import Button from '../../../Common/Button/Button';
|
||||
|
||||
@@ -37,11 +37,9 @@ class AddManualRelationship extends Component {
|
||||
data: this.props.currentSchema,
|
||||
});
|
||||
this.props.dispatch(
|
||||
loadSchema(
|
||||
{
|
||||
schemas: [this.props.currentSchema],
|
||||
}
|
||||
)
|
||||
updateSchemaInfo({
|
||||
schemas: [this.props.currentSchema],
|
||||
})
|
||||
);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
@@ -60,11 +58,9 @@ class AddManualRelationship extends Component {
|
||||
data: [],
|
||||
});
|
||||
this.props.dispatch(
|
||||
loadSchema(
|
||||
{
|
||||
schemas: [e.target.value],
|
||||
}
|
||||
)
|
||||
updateSchemaInfo({
|
||||
schemas: [e.target.value],
|
||||
})
|
||||
);
|
||||
}
|
||||
onRelNameChange(e) {
|
||||
@@ -102,7 +98,9 @@ class AddManualRelationship extends Component {
|
||||
currentSchema,
|
||||
} = this.props;
|
||||
|
||||
const tableSchema = allSchemas.find(t => t.table_name === tableName && t.table_schema === currentSchema);
|
||||
const tableSchema = allSchemas.find(
|
||||
t => t.table_name === tableName && t.table_schema === currentSchema
|
||||
);
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.subheading_text}> {titleInfo} </div>
|
||||
|
||||
@@ -3,7 +3,7 @@ import _push from '../push';
|
||||
import { loadTriggers, makeMigrationCall, setTrigger } from '../EventActions';
|
||||
import { showSuccessNotification } from '../Notification';
|
||||
import { UPDATE_MIGRATION_STATUS_ERROR } from '../../../Main/Actions';
|
||||
import { loadSchema } from '../../Data/DataActions';
|
||||
import { updateSchemaInfo } from '../../Data/DataActions';
|
||||
|
||||
const SET_DEFAULTS = 'AddTrigger/SET_DEFAULTS';
|
||||
const SET_TRIGGERNAME = 'AddTrigger/SET_TRIGGERNAME';
|
||||
@@ -187,7 +187,7 @@ const createTrigger = () => {
|
||||
};
|
||||
|
||||
const loadTableList = schemaName => {
|
||||
return dispatch => dispatch(loadSchema({ schemas: [schemaName] }));
|
||||
return dispatch => dispatch(updateSchemaInfo({ schemas: [schemaName] }));
|
||||
};
|
||||
|
||||
const operationToggleColumn = (column, operation) => {
|
||||
|
||||
Reference in New Issue
Block a user