Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pointer CLPs #1556

Merged
Merged
Changes from 1 commit
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
65 changes: 39 additions & 26 deletions src/components/PermissionsDialog/PermissionsDialog.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ export default class PermissionsDialog extends React.Component {
// hide suggestions to avoid ugly footer overlap
this.refEntry.current.setHidden(hidden);
// also show indicator when input is not visible
this.refScrollHint.current.toggleActive(hidden);
// this.refScrollHint.current.toggleActive(hidden);
Copy link
Contributor Author

@mess-lelouch mess-lelouch Jun 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was throwing an error... the variable does not even exists (or at least I could not find it)... so I commented it out since I don't have enough context to fix it.

};

this.observer = new IntersectionObserver(callback, {
Expand Down Expand Up @@ -589,13 +589,13 @@ export default class PermissionsDialog extends React.Component {
perms.delete = perms.delete || Map();
perms.addField = perms.addField || Map();

(pointerPermsSubset.get = perms.get.pointerFields || []),
(pointerPermsSubset.find = perms.find.pointerFields || []),
(pointerPermsSubset.count = perms.count.pointerFields || []),
(pointerPermsSubset.create = perms.create.pointerFields || []),
(pointerPermsSubset.update = perms.update.pointerFields || []),
(pointerPermsSubset.delete = perms.delete.pointerFields || []),
(pointerPermsSubset.addField = perms.addField.pointerFields || []);
(pointerPermsSubset.get = permissions.get.pointerFields || []),
(pointerPermsSubset.find = permissions.find.pointerFields || []),
(pointerPermsSubset.count = permissions.count.pointerFields || []),
(pointerPermsSubset.create = permissions.create.pointerFields || []),
(pointerPermsSubset.update = permissions.update.pointerFields || []),
(pointerPermsSubset.delete = permissions.delete.pointerFields || []),
(pointerPermsSubset.addField = permissions.addField.pointerFields || []);
}

let pointerPerms = {};
Expand Down Expand Up @@ -764,6 +764,7 @@ export default class PermissionsDialog extends React.Component {
let nextKeys;
let nextEntryTypes;
let nextPerms = this.state.perms;
let nextPointerPerms = this.state.pointerPerms;

if (next.user || next.role) {
id = next.user ? next.user.id : next.role.id;
Expand Down Expand Up @@ -791,17 +792,32 @@ export default class PermissionsDialog extends React.Component {
}

// create new permissions
if (this.props.advanced) {
nextPerms = nextPerms.setIn(['get', key], true);
nextPerms = nextPerms.setIn(['find', key], true);
nextPerms = nextPerms.setIn(['count', key], true);
nextPerms = nextPerms.setIn(['create', key], true);
nextPerms = nextPerms.setIn(['update', key], true);
nextPerms = nextPerms.setIn(['delete', key], true);
nextPerms = nextPerms.setIn(['addField', key], true);
if (next.pointer) {
if (this.props.advanced) {
nextPointerPerms = nextPointerPerms.setIn([entry, 'get'], true)
nextPointerPerms = nextPointerPerms.setIn([entry, 'find'], true)
nextPointerPerms = nextPointerPerms.setIn([entry, 'count'], true)
nextPointerPerms = nextPointerPerms.setIn([entry, 'create'], true)
nextPointerPerms = nextPointerPerms.setIn([entry, 'update'], true)
nextPointerPerms = nextPointerPerms.setIn([entry, 'delete'], true)
nextPointerPerms = nextPointerPerms.setIn([entry, 'addField'], true)
} else {
nextPointerPerms = nextPointerPerms.setIn([entry, 'read'], true)
nextPointerPerms = nextPointerPerms.setIn([entry, 'write'], true)
}
} else {
nextPerms = nextPerms.setIn(['read', key], true);
nextPerms = nextPerms.setIn(['write', key], true);
if (this.props.advanced) {
nextPerms = nextPerms.setIn(['get', key], true);
nextPerms = nextPerms.setIn(['find', key], true);
nextPerms = nextPerms.setIn(['count', key], true);
nextPerms = nextPerms.setIn(['create', key], true);
nextPerms = nextPerms.setIn(['update', key], true);
nextPerms = nextPerms.setIn(['delete', key], true);
nextPerms = nextPerms.setIn(['addField', key], true);
} else {
nextPerms = nextPerms.setIn(['read', key], true);
nextPerms = nextPerms.setIn(['write', key], true);
}
}

nextKeys = this.state.newKeys.concat([key]);
Expand All @@ -810,6 +826,7 @@ export default class PermissionsDialog extends React.Component {
return this.setState(
{
perms: nextPerms,
pointerPerms: nextPointerPerms,
newKeys: nextKeys,
entryTypes: nextEntryTypes,
newEntry: '',
Expand Down Expand Up @@ -911,15 +928,14 @@ export default class PermissionsDialog extends React.Component {
return;
}
if (k === 'requiresAuthentication' && !v){
// only acceppt requiresAuthentication with true
// only acceppt requiresAuthentication with true
return
}
if (v) {
output[field][k] = true;
}
});
});

let readUserFields = [];
let writeUserFields = [];
this.state.pointerPerms.forEach((perms, key) => {
Expand All @@ -929,7 +945,6 @@ export default class PermissionsDialog extends React.Component {
if (perms.get('write')) {
writeUserFields.push(key);
}

fields.forEach(op => {
if (perms.get(op)) {
if (!output[op].pointerFields) {
Expand Down Expand Up @@ -964,7 +979,7 @@ export default class PermissionsDialog extends React.Component {
// types is immutable.js Map
const type = (types && types.get(key)) || {};

let pointer;
let pointer = this.state.pointerPerms.has(key);
let label = <span>{key}</span>;

if (type.user) {
Expand Down Expand Up @@ -996,7 +1011,7 @@ export default class PermissionsDialog extends React.Component {
</p>
</span>
);
} else if (type.pointer) {
} else if (pointer) {
// get class info from schema
let { type, targetClass } = columns[key];

Expand Down Expand Up @@ -1153,7 +1168,6 @@ export default class PermissionsDialog extends React.Component {
} else {
placeholderText = 'Role or User\u2026';
}

return (
<Popover
fadeIn={true}
Expand Down Expand Up @@ -1230,15 +1244,14 @@ export default class PermissionsDialog extends React.Component {
{this.renderAuthenticatedCheckboxes()}
</div>
) : null}

{this.state.keys
.slice(this.props.advanced ? 2 : 1)
.map(key =>
this.renderRow(key, this.state.columns, this.state.entryTypes)
)}
{this.props.advanced
? this.state.pointers.map(pointer =>
this.renderRow(pointer, true)
this.renderRow(pointer, this.state.columns)
)
: null}
{this.state.newKeys.map(key =>
Expand Down