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