-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Accounts dashboard base UI for Feature: "Marketplace and Shop owners should be able to create custom permission groups" #2543
Accounts dashboard base UI for Feature: "Marketplace and Shop owners should be able to create custom permission groups" #2543
Conversation
* Modifies Shops publication to return all shops with matching domain by removing limit * Rewrite of shop selector dropdown * Use Shops publication instead of SellerShops publication in dropdown * Remove requirement for marketplace ownership to see shop selector * Change Reaction.ShopId when shop selector is changed * TODO: Convert shop selector to React
* Eliminates console warnings
@mikemurray will you review the React code in this PR - I don't feel like I've got a firm enough grasp on our React patterns to do it justice? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're almost there! Let's make sure the permissions are checking the group's shopId and see what @mikemurray thinks about the React and then I'm good to merge.
There are also some lodash functions that we don't need. I know lodash will fall back to native when available, but I'd like to remove the dependency when we can.
<div> | ||
{{> React component=accountsDash }} | ||
</div> | ||
<!--<div class="container-fluid-sm"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's get rid of commented code
@@ -123,7 +126,7 @@ class SortableTable extends Component { | |||
|
|||
// Add minWidth = undefined to override 100px default set by ReactTable | |||
const displayColumns = columnMetadata.map((element) => { | |||
return _.assignIn({}, element, { | |||
return _.extend({}, element, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use native ES2015 in place of lodash when we can. Object.assign
should work in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll change those. I inherited those changes and haven't looked at the in detail
|
||
function getPermissionMap(permissions) { | ||
const permissionMap = {}; | ||
_.each(permissions, existing => (permissionMap[existing.permission] = existing.label)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should be able to use native Array.each here.
|
||
const pubHandle = Meteor.subscribe(publication, this.state.query, _.assignIn({}, options)); | ||
const pubHandle = Meteor.subscribe(publication, this.state.query, _.extend({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Object.assign should work here without needing lodash
server/methods/core/groups.js
Outdated
check(shopId, String); | ||
let res; | ||
let _id; | ||
|
||
if (!Reaction.hasPermission("admin")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we chatte about, let's make sure these are checking permissions for the shopId that is associated with the group being modified.
server/methods/core/groups.js
Outdated
@@ -66,7 +66,6 @@ Meteor.methods({ | |||
check(groupId, String); | |||
check(newGroupData, Object); | |||
check(newGroupData.name, String); | |||
check(newGroupData.permissions, [String]); | |||
check(shopId, String); | |||
|
|||
if (!Reaction.hasPermission("admin")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check group shopId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. 👍 I'm curious to know why we went with _.assignIn
instead of Object.assign
in some of these spots, but not a blocker for sure.
@spencern Actually, it wasn't my change. So I returned it to the original code. I can do a check to see when that component was added, and ask author if there's a specific reason it was added. |
if (Array.isArray(groups)) { | ||
return groups.map((group, index) => { | ||
return ( | ||
<div key={index}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this <div>
necessary? you can add key
to the <AccountsTable />
. If it necessary, put a className
on it like rui accounts-table-container
or something appropriate.
getHeader(headerName) { | ||
if (headerName === "name") { | ||
return ( | ||
<div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs className
} | ||
if (headerName === "email") { | ||
return ( | ||
<div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs className
} | ||
if (headerName === "createdAt") { | ||
return ( | ||
<div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs className
|
||
if (columnName === "button") { | ||
return ( | ||
<div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this div necessary? if so needs className
|
||
render() { | ||
return ( | ||
<div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs className
@mikemurray I've pushed my recent changes here, plus fixes to the few comments you added initially. You can take a look now |
@mikemurray did you get a chance to look at this since updates? |
this.setState({ groups, selectedGroup }); | ||
} | ||
|
||
selectGroup = grp => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always use the paren ()
around the params for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. we probably should add that to our eslintrc, so that it gets flagged for everyone too when working
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good!
@spencern I leave the final task of merging up to you. |
bitHound seems to be struggling, so going to merge this. If we end up with any eslint errors we'll fix them once bitHound comes through. I ran though creating groups and moving users between groups again and it works well. |
Relates to (and partly resolves) #2184 and #2194
This PR implements new layout from the designs here. It however focuses on the basic/core functionalities for Permission Groups management. More updates and styling needs to be done as marketplace work progresses.
To Test
Make
the user part of the new group. Clicking this should add the user to that groupEdited by @impactmass