Skip to content

Commit

Permalink
Merge branch 'master' into browse-as-parse-user
Browse files Browse the repository at this point in the history
* master:
  fixed master key not being passed in when saving file in global config (parse-community#1581)
  Fix pointer CLPs (parse-community#1556)
  Clear state.data when setting relation to column type mismatch. (parse-community#1564)
  • Loading branch information
NinoZX committed Sep 1, 2020
2 parents 4b24fb8 + 57953df commit 14a5b4e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 24 deletions.
63 changes: 41 additions & 22 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);
};

this.observer = new IntersectionObserver(callback, {
Expand Down Expand Up @@ -589,13 +589,15 @@ 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 || []);
// The double check is necessary because the permissions object seems to be empty when accessing the CLP section
// if the class was recently created.
(pointerPermsSubset.get = permissions.get && permissions.get.pointerFields || []),
(pointerPermsSubset.find = permissions.find && permissions.find.pointerFields || []),
(pointerPermsSubset.count = permissions.count && permissions.count.pointerFields || []),
(pointerPermsSubset.create = permissions.create && permissions.create.pointerFields || []),
(pointerPermsSubset.update = permissions.update && permissions.update.pointerFields || []),
(pointerPermsSubset.delete = permissions.delete && permissions.delete.pointerFields || []),
(pointerPermsSubset.addField = permissions.addField && permissions.addField.pointerFields || []);
}

let pointerPerms = {};
Expand Down Expand Up @@ -764,6 +766,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 +794,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 +828,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,7 +930,7 @@ 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) {
Expand Down Expand Up @@ -964,7 +983,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 +1015,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 @@ -1238,7 +1257,7 @@ export default class PermissionsDialog extends React.Component {
)}
{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
3 changes: 2 additions & 1 deletion src/dashboard/Data/Browser/Browser.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ class Browser extends DashboardView {
setRelation(relation, filters) {
this.setState({
relation: relation,
data: null,
}, () => {
let filterQueryString;
if (filters && filters.size) {
Expand Down Expand Up @@ -971,7 +972,7 @@ class Browser extends DashboardView {
onDialogToggle(opened){
this.setState({showPermissionsDialog: opened});
}

renderContent() {
let browser = null;
let className = this.props.params.className;
Expand Down
2 changes: 1 addition & 1 deletion src/dashboard/Data/Config/ConfigDialog.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function numberValidator(onChange) {

function saveFile(onChange, file) {
let value = new Parse.File(file.name, file);
value.save().then(() => onChange(value));
value.save({ useMasterKey: true }).then(() => onChange(value));
}

const EDITORS = {
Expand Down

0 comments on commit 14a5b4e

Please sign in to comment.