mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
This commit is contained in:
parent
61d6610ed6
commit
86ab64232d
@ -33,6 +33,7 @@ const defaultPermissionsState = {
|
|||||||
limitEnabled: true,
|
limitEnabled: true,
|
||||||
bulkSelect: [],
|
bulkSelect: [],
|
||||||
applySamePermissions: [],
|
applySamePermissions: [],
|
||||||
|
isEditing: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultPresetsState = {
|
const defaultPresetsState = {
|
||||||
|
@ -250,15 +250,18 @@ const modifyReducer = (tableName, schemas, modifyStateOrig, action) => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
case PERM_OPEN_EDIT:
|
case PERM_OPEN_EDIT:
|
||||||
|
const isNewRole = modifyState.permissionsState.newRole === action.role;
|
||||||
const permState = getBasePermissionsState(
|
const permState = getBasePermissionsState(
|
||||||
action.tableSchema,
|
action.tableSchema,
|
||||||
action.role,
|
action.role,
|
||||||
action.query
|
action.query,
|
||||||
|
isNewRole
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
...modifyState,
|
...modifyState,
|
||||||
permissionsState: {
|
permissionsState: {
|
||||||
...permState,
|
...permState,
|
||||||
|
isEditing: true,
|
||||||
},
|
},
|
||||||
prevPermissionState: {
|
prevPermissionState: {
|
||||||
...permState,
|
...permState,
|
||||||
@ -396,11 +399,17 @@ const modifyReducer = (tableName, schemas, modifyStateOrig, action) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
case PERM_SET_ROLE_NAME:
|
case PERM_SET_ROLE_NAME:
|
||||||
|
const newRole = action.data;
|
||||||
|
const role = modifyState.permissionsState.isEditing
|
||||||
|
? newRole
|
||||||
|
: modifyState.permissionsState.role;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...modifyState,
|
...modifyState,
|
||||||
permissionsState: {
|
permissionsState: {
|
||||||
...modifyState.permissionsState,
|
...modifyState.permissionsState,
|
||||||
newRole: action.data,
|
newRole: newRole,
|
||||||
|
role: role,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ const getFilterKey = query => {
|
|||||||
return query === 'insert' ? 'check' : 'filter';
|
return query === 'insert' ? 'check' : 'filter';
|
||||||
};
|
};
|
||||||
|
|
||||||
const getBasePermissionsState = (tableSchema, role, query) => {
|
const getBasePermissionsState = (tableSchema, role, query, isNewRole) => {
|
||||||
const _permissions = JSON.parse(JSON.stringify(defaultPermissionsState));
|
const _permissions = JSON.parse(JSON.stringify(defaultPermissionsState));
|
||||||
|
|
||||||
_permissions.table = tableSchema.table_name;
|
_permissions.table = tableSchema.table_name;
|
||||||
@ -165,7 +165,9 @@ const getBasePermissionsState = (tableSchema, role, query) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (isNewRole) {
|
||||||
_permissions.newRole = role;
|
_permissions.newRole = role;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,7 +512,7 @@ class Permissions extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getEditSection = (tableSchema, queryTypes, roleList) => {
|
const getEditSection = (tableSchema, queryTypes, roleList) => {
|
||||||
if (!permissionsState.role || !permissionsState.query) {
|
if (!permissionsState.isEditing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user