diff --git a/console/src/components/Services/Data/TableCommon/TableReducer.js b/console/src/components/Services/Data/TableCommon/TableReducer.js index 8b73f6a310231..7c28151e1ba27 100644 --- a/console/src/components/Services/Data/TableCommon/TableReducer.js +++ b/console/src/components/Services/Data/TableCommon/TableReducer.js @@ -157,14 +157,7 @@ const modifyReducer = (tableName, schemas, modifyStateOrig, action) => { return { ...modifyState, relAdd: { - isActive: true, - tableName: '', - name: '', - isObjRel: null, - lcol: [], - rTable: null, - rcol: [], - manualColumns: [], + ...defaultModifyState.relAdd, }, }; case REL_SET_TYPE: diff --git a/console/src/components/Services/Data/TablePermissions/Permissions.js b/console/src/components/Services/Data/TablePermissions/Permissions.js index 92cacf130807e..a23117f3b3698 100644 --- a/console/src/components/Services/Data/TablePermissions/Permissions.js +++ b/console/src/components/Services/Data/TablePermissions/Permissions.js @@ -765,164 +765,164 @@ class Permissions extends Component { const setOptions = insertState && insertState.localSet && insertState.localSet.length > 0 ? insertState.localSet.map((s, i) => { - return ( -
-
+
+ - - {columns && columns.length > 0 - ? columns.map((c, key) => ( - - )) - : null} - -
-
+ {columns && columns.length > 0 + ? columns.map((c, key) => ( + + )) + : null} + +
+
+ - - - - -
-
+ + + +
+
- {setConfigValueType(s.value) === 'session' ? ( - - X-Hasura- - this.onSetValueBlur(e, i, null)} - data-index-id={i} - data-prefix-val={X_HASURA_CONST} - disabled={disableInput} - /> - - ) : ( - + {setConfigValueType(s.value) === 'session' ? ( + + X-Hasura- + this.onSetValueBlur(e, i, null)} + data-index-id={i} data-prefix-val={X_HASURA_CONST} disabled={disableInput} /> - )} -
- {setConfigValueType(s.value) === 'session' ? ( -
+ ) : ( + + )} +
+ {setConfigValueType(s.value) === 'session' ? ( +
+ } + > e.g. X-Hasura-User-Id -
- ) : ( -
+ ) : ( +
+ } + > e.g. false, 1, some-text -
- )} - {i !== insertState.localSet.length - 1 ? ( -
+ )} + {i !== insertState.localSet.length - 1 ? ( +
+ - -
- ) : ( -
+
+ ) : ( +
- )} -
- ); - }) + } + /> + )} +
+ ); + }) : null; return ( diff --git a/console/src/components/Services/Data/TableRelationships/Actions.js b/console/src/components/Services/Data/TableRelationships/Actions.js index c542136e8e8f6..57bcc568a94c6 100644 --- a/console/src/components/Services/Data/TableRelationships/Actions.js +++ b/console/src/components/Services/Data/TableRelationships/Actions.js @@ -189,7 +189,8 @@ const addRelNewFromStateMigrate = () => (dispatch, getState) => { state.lcol, state.rTable, state.rcol, - state.isObjRel + state.isObjRel, + currentSchema ); const relChangesUp = [upQuery]; const relChangesDown = [downQuery]; diff --git a/console/src/components/Services/Data/TableRelationships/AddManualRelationship.js b/console/src/components/Services/Data/TableRelationships/AddManualRelationship.js index aa2ddda274115..0f5a53a37edb6 100644 --- a/console/src/components/Services/Data/TableRelationships/AddManualRelationship.js +++ b/console/src/components/Services/Data/TableRelationships/AddManualRelationship.js @@ -151,7 +151,13 @@ class AddManualRelationship extends Component { className={'form-control'} onChange={this.onSchemaChange} data-test="remote-schema" - value={manualRelInfo.remoteSchema} + value={ + manualRelInfo && + 'remoteSchema' in manualRelInfo && + manualRelInfo.remoteSchema + ? manualRelInfo.remoteSchema + : '' + } > {schemaList.map((s, i) => ( diff --git a/console/src/components/Services/Data/TableRelationships/Relationships.js b/console/src/components/Services/Data/TableRelationships/Relationships.js index ef1311fbbfa8d..cc6c483589abe 100644 --- a/console/src/components/Services/Data/TableRelationships/Relationships.js +++ b/console/src/components/Services/Data/TableRelationships/Relationships.js @@ -221,18 +221,34 @@ const AddRelationship = ({ // Finding the object from the suggestedRelationshipsArray which is currently selected if (cachedRelationshipData.isObjRel) { selectedRelationship = suggestedRelationshipsData.objectRel.find(rel => { + const cLcol = + typeof cachedRelationshipData.lcol === 'string' + ? [cachedRelationshipData.lcol] + : cachedRelationshipData.lcol; + const cRcol = + typeof cachedRelationshipData.rcol === 'string' + ? [cachedRelationshipData.rcol] + : cachedRelationshipData.rcol; return ( - rel.lcol.join(',') === cachedRelationshipData.lcol.join(',') && - rel.rcol.join(',') === cachedRelationshipData.rcol.join(',') && + rel.lcol.join(',') === cLcol.join(',') && + rel.rcol.join(',') === cRcol.join(',') && rel.rTable === cachedRelationshipData.rTable && rel.tableName === cachedRelationshipData.tableName ); }); } else { selectedRelationship = suggestedRelationshipsData.arrayRel.find(rel => { + const cLcol = + typeof cachedRelationshipData.lcol === 'string' + ? [cachedRelationshipData.lcol] + : cachedRelationshipData.lcol; + const cRcol = + typeof cachedRelationshipData.rcol === 'string' + ? [cachedRelationshipData.rcol] + : cachedRelationshipData.rcol; return ( - rel.lcol.join(',') === cachedRelationshipData.lcol.join(',') && - rel.rcol.join(',') === cachedRelationshipData.rcol.join(',') && + rel.lcol.join(',') === cLcol.join(',') && + rel.rcol.join(',') === cRcol.join(',') && rel.rTable === cachedRelationshipData.rTable && rel.tableName === cachedRelationshipData.tableName ); diff --git a/console/src/components/Services/Data/TableRelationships/autoRelations.js b/console/src/components/Services/Data/TableRelationships/autoRelations.js index e17a26e915640..e2a60135e7d87 100644 --- a/console/src/components/Services/Data/TableRelationships/autoRelations.js +++ b/console/src/components/Services/Data/TableRelationships/autoRelations.js @@ -1,3 +1,13 @@ +const getTableName = t => { + const typ = typeof t; + if (typ === 'string') { + return t; + } else if (typ === 'object') { + return 'name' in t ? t.name : ''; + } + return ''; +}; + const suggestedRelationshipsRaw = (tableName, allSchemas) => { const objRels = []; const arrRels = []; @@ -75,7 +85,7 @@ const suggestedRelationshipsRaw = (tableName, allSchemas) => { if ( currRCol.sort().join(',') === rcol.sort().join(',') && - currTable === constraint.table_name + getTableName(currTable) === constraint.table_name ) { // existing relationship isExistingArrayRel = true;