这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions console/src/components/Services/Data/DataState.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const defaultQueryPermissions = {
check: {},
allow_upsert: true,
set: {},
columns: [],
localSet: [
{
...defaultInsertSetState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ const modifyReducer = (tableName, schemas, modifyStateOrig, action) => {
...getBasePermissionsState(
action.tableSchema,
action.role,
action.query
action.query,
action.insertPermColumnRestriction
),
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,29 @@ export const SET_TYPE_CONFIG = 'ModifyTable/SET_TYPE_CONFIG';

/* */

const queriesWithPermColumns = ['select', 'update'];
const getQueriesWithPermColumns = insert => {
const queries = ['select', 'update'];
if (insert) {
queries.push('insert');
}
return queries;
};
const permChangeTypes = {
save: 'update',
delete: 'delete',
};

const permOpenEdit = (tableSchema, role, query) => ({
const permOpenEdit = (
tableSchema,
role,
query,
insertPermColumnRestriction
) => ({
type: PERM_OPEN_EDIT,
tableSchema,
role,
query,
insertPermColumnRestriction,
});
const permSetFilter = filter => ({ type: PERM_SET_FILTER, filter });
const permSetFilterSameAs = filter => ({
Expand Down Expand Up @@ -122,7 +134,12 @@ const setConfigValueType = value => {
: 'static';
};

const getBasePermissionsState = (tableSchema, role, query) => {
const getBasePermissionsState = (
tableSchema,
role,
query,
insertPermColumnRestriction
) => {
const _permissions = JSON.parse(JSON.stringify(defaultPermissionsState));

_permissions.table = tableSchema.table_name;
Expand All @@ -139,6 +156,13 @@ const getBasePermissionsState = (tableSchema, role, query) => {
// If the query is insert, transform set object if exists to an array
if (q === 'insert') {
// If set is an object
if (insertPermColumnRestriction) {
if (!_permissions[q].columns) {
_permissions[q].columns = tableSchema.columns.map(
c => c.column_name
);
}
}
if ('set' in _permissions[q]) {
if (
Object.keys(_permissions[q].set).length > 0 &&
Expand Down Expand Up @@ -619,7 +643,7 @@ export {
permSetBulkSelect,
toggleColumn,
toggleAllColumns,
queriesWithPermColumns,
getQueriesWithPermColumns,
getFilterKey,
getBasePermissionsState,
updatePermissionsState,
Expand Down
Loading