mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
allow only tracked tables in manual relationship definition in console (#3046)
This commit is contained in:
parent
0c74839934
commit
0fc70cd242
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user