allow only tracked tables in manual relationship definition in console (#3046)

This commit is contained in:
Rikin Kachhia 2019-10-08 13:45:05 +05:30 committed by GitHub
parent 0c74839934
commit 0fc70cd242
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,15 @@ import { ordinalColSort } from '../utils';
import { addRelViewMigrate, resetManualRelationshipForm } from './Actions';
import ExpandableEditor from '../../../Common/Layout/ExpandableEditor/Editor';
import ManualRelationshipSelector from './ManualRelationshipSelector';
import {
getColumnName,
getSchemaName,
getSchemaTables,
getTableColumnNames,
getTableName,
getTableSchema,
getTrackedTables,
} from '../../../Common/utils/pgUtils';
const AddManualRelationship = ({
tableSchema,
@ -17,20 +26,21 @@ const AddManualRelationship = ({
// columns in the right order with their indices
const orderedColumns = columns.map((c, i) => ({
name: c.column_name,
name: getColumnName(c),
index: i,
}));
relAdd.rSchema = relAdd.rSchema || tableSchema.table_schema;
relAdd.rSchema = relAdd.rSchema || getTableSchema(tableSchema);
const refTables = {};
allSchemas.forEach(ts => {
if (ts.table_schema === relAdd.rSchema) {
refTables[ts.table_name] = ts.columns.map(c => c.column_name);
}
});
const trackedSchemaTables = getTrackedTables(
getSchemaTables(allSchemas, relAdd.rSchema)
);
trackedSchemaTables.forEach(
ts => (refTables[getTableName(ts)] = getTableColumnNames(ts))
);
const orderedSchemaList = schemaList.map(s => s.schema_name).sort();
const orderedSchemaList = schemaList.map(s => getSchemaName(s)).sort();
const resetManualRel = () => {
dispatch(resetManualRelationshipForm());