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

Add ProtectedFields dialog and enhance Permissions dialogs #1478

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
797265b
chip and multiselect dense variant
BufferUnderflower Feb 26, 2020
e510991
autocomplete component
BufferUnderflower Feb 26, 2020
e1f7bd1
popover refactor, ContextProxy -> portal
BufferUnderflower Feb 26, 2020
145cef7
add intersection observer component
BufferUnderflower Feb 26, 2020
39c74d2
suggestions for autocomplete
BufferUnderflower Feb 26, 2020
8dbd321
do not show security dialog in edit modal
BufferUnderflower Feb 26, 2020
c0cd458
table will ignore keys when security modal opened
BufferUnderflower Feb 26, 2020
95bead4
add autocomplete for ACL
BufferUnderflower Feb 26, 2020
a109b50
add protected fields dialog component
BufferUnderflower Feb 26, 2020
16a2e50
permissioons dialog refactor
BufferUnderflower Feb 26, 2020
9aacf62
add new dialogs to databroowser toolbar
BufferUnderflower Feb 26, 2020
7a3fae3
protected fields dialog example
BufferUnderflower Feb 26, 2020
4597a59
removed comments
BufferUnderflower Feb 27, 2020
fb9362b
fix floating menus - show on top of toolbar
BufferUnderflower Feb 27, 2020
4e06e40
add whitespaces in toolbar menu
BufferUnderflower Feb 27, 2020
d34bc05
use menuitem
BufferUnderflower Feb 27, 2020
f1c67d6
trailing newlines
BufferUnderflower Feb 27, 2020
0c5c1d3
Merge branch 'master' into better-clp-dialogs
davimacedo Feb 29, 2020
7b718bd
update examples
BufferUnderflower Feb 29, 2020
cb0de2e
adds scroll hint
BufferUnderflower Feb 29, 2020
c55caf6
handle case when no fields to protect
BufferUnderflower Feb 29, 2020
13687b3
Merge branch 'master' into better-clp-dialogs
davimacedo Mar 4, 2020
43e0015
Merge branch 'master' into better-clp-dialogs
davimacedo Mar 4, 2020
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
58 changes: 49 additions & 9 deletions src/components/ACLEditor/ACLEditor.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,58 @@ import PermissionsDialog from 'components/PermissionsDialog/PermissionsDialog.re
import React from 'react';

function validateEntry(text) {
let userQuery = Parse.Query.or(
new Parse.Query(Parse.User).equalTo('username', text),
new Parse.Query(Parse.User).equalTo('objectId', text)
);
let roleQuery = new Parse.Query(Parse.Role).equalTo('name', text);
return Promise.all([userQuery.find({ useMasterKey: true }), roleQuery.find({ useMasterKey: true })]).then(([user, role]) => {

let userQuery;
let roleQuery;

if (text === '*') {
return Promise.resolve({ entry: '*', type: 'public' });
}

if (text.startsWith('user:')) {
// no need to query roles
roleQuery = {
find: () => Promise.resolve([])
};

let user = text.substring(5);
userQuery = new Parse.Query.or(
new Parse.Query(Parse.User).equalTo('username', user),
new Parse.Query(Parse.User).equalTo('objectId', user)
);
} else if (text.startsWith('role:')) {
// no need to query users
userQuery = {
find: () => Promise.resolve([])
};
let role = text.substring(5);
roleQuery = new Parse.Query.or(
new Parse.Query(Parse.Role).equalTo('name', role),
new Parse.Query(Parse.Role).equalTo('objectId', role)
);
} else {
// query both
userQuery = Parse.Query.or(
new Parse.Query(Parse.User).equalTo('username', text),
new Parse.Query(Parse.User).equalTo('objectId', text)
);

roleQuery = Parse.Query.or(
new Parse.Query(Parse.Role).equalTo('name', text),
new Parse.Query(Parse.Role).equalTo('objectId', text)
);
}

return Promise.all([
userQuery.find({ useMasterKey: true }),
roleQuery.find({ useMasterKey: true })
]).then(([user, role]) => {
if (user.length > 0) {
return { user: user[0] };
return { entry: user[0], type: 'user' };
} else if (role.length > 0) {
return { role: role[0] };
return { entry: role[0], type: 'role' };
} else {
throw new Error();
return Promise.reject();
}
});
}
Expand Down
64 changes: 64 additions & 0 deletions src/components/Autocomplete/Autocomplete.example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright (c) 2016-present, Parse, LLC
* All rights reserved.
*
* This source code is licensed under the license found in the LICENSE file in
* the root directory of this source tree.
*/
import React from 'react';
import Autocomplete from 'components/Autocomplete/Autocomplete.react';

export const component = Autocomplete;

class AutocompleteDemo extends React.Component {
constructor() {
super();

this.state = {
suggestions: ['aaa', 'abc', 'xxx', 'xyz']
};

this.onSubmit = input => console.log('onSubmit: ' + input);
this.onUserInput = input => {
console.log(`input: ${input}`);
};
this.buildLabel = input =>
input.length > 0
? `You've typed ${input.length} characters`
: 'Start typing';
this.buildSuggestions = input =>
this.state.suggestions.filter(s => s.startsWith(input));
}

render() {
return (
<Autocomplete
inputStyle={{
width: '400px',
padding: '0 6px',
margin: '10px 20px'
}}
suggestionsStyle={{
margin: '-6px 0px 0px 20px',
width: '400px'
}}
locked={true}
onChange={this.onUserInput}
onSubmit={this.onSubmit}
placeholder={'Placeholder'}
buildSuggestions={this.buildSuggestions}
buildLabel={this.buildLabel}
/>
);
}
}

export const demos = [
{
render: () => (
<div>
<AutocompleteDemo />
</div>
)
}
];
Loading