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

Accounts dashboard base UI for Feature: "Marketplace and Shop owners should be able to create custom permission groups" #2543

Merged
merged 156 commits into from
Jul 22, 2017

Conversation

rhenshaw56
Copy link
Contributor

@rhenshaw56 rhenshaw56 commented Jul 10, 2017

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

  • Clone this branch, and reaction reset
  • Login as admin & open Accounts dashboard
  • In place of the old look, you should see the new default "Owner" group showing (in a Sortable table). It should show the default admin account under owner table
  • Click on the heading of the "Owner" table (i.e the part with text "Owner).
  • The ActionView should slide out. It should show 3 sections.
  • The first section is the "Add Admin User" section. Test it out. It should send an invitation successfully to an email filled in. Test with an existing email too. Confirm that the inline Alerts show based on success or error. Note if there are errors in the browser console too.
  • NB: When you send an invite, you currently won't see the account show under any group. This will be fixed in the ticket about "inviting a user directly as part of a group"
  • The second section is "Edit Group" section. It should show the list of current groups (plus a "New Group" item); and a Permissions list block of switches.
    • The group that was selected to open the actionView should be highlighted bold. It's active permissions should also be reflected in the Permissions block
    • NB: The design goal is to make the Permissions block show directly under each group, as opposed to under the entire group list. This will come in later.
    • Toggling Permissions to on and off should work
    • Clicking on the pencil icon in from of a group name should show a form to edit the name and description (with the current values in place)
    • Clicking New Group should open similar form with blank values, and all permissions toggled off
    • Test out creating new groups. Confirm it works, with no errors
    • With more groups, switching a user from one group to the other (via the group dropdown in the account row) should work. (NB: Currently, you can move the default admin from owner to another group without restriction. Work will be done on this later.
  • The third section is to add users to a group (the currently selected group).
    • If you have admin users, they'll show up in the user list here. (NB: Review how we decide admin users)
    • Hovering over a user, the group name changes to action to Make the user part of the new group. Clicking this should add the user to that group
Edited by @impactmass

spencern and others added 30 commits June 6, 2017 12:20
* 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
@impactmass impactmass changed the title [WIP] Accounts dashboard base UI for Feature: "Marketplace and Shop owners should be able to create custom permission groups" Accounts dashboard base UI for Feature: "Marketplace and Shop owners should be able to create custom permission groups" Jul 20, 2017
@spencern spencern requested a review from mikemurray July 20, 2017 21:50
@spencern
Copy link
Contributor

@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?

Copy link
Contributor

@spencern spencern left a 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">
Copy link
Contributor

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, {
Copy link
Contributor

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.

Copy link
Contributor

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));
Copy link
Contributor

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({
Copy link
Contributor

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

check(shopId, String);
let res;
let _id;

if (!Reaction.hasPermission("admin")) {
Copy link
Contributor

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.

@@ -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")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

check group shopId

@impactmass impactmass self-assigned this Jul 21, 2017
Copy link
Contributor

@spencern spencern left a 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.

@impactmass
Copy link
Contributor

@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}>
Copy link
Member

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>
Copy link
Member

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>
Copy link
Member

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>
Copy link
Member

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>
Copy link
Member

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>
Copy link
Member

Choose a reason for hiding this comment

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

needs className

@impactmass
Copy link
Contributor

@mikemurray I've pushed my recent changes here, plus fixes to the few comments you added initially. You can take a look now

@spencern
Copy link
Contributor

@mikemurray did you get a chance to look at this since updates?

this.setState({ groups, selectedGroup });
}

selectGroup = grp => {
Copy link
Member

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixing now.

Copy link
Contributor

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

Copy link
Member

@mikemurray mikemurray left a comment

Choose a reason for hiding this comment

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

looks good!

@mikemurray
Copy link
Member

@spencern I leave the final task of merging up to you.

@spencern
Copy link
Contributor

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.

@spencern spencern merged commit df0b24a into marketplace Jul 22, 2017
@spencern spencern deleted the rowland-accounts-react-conversion-2184 branch July 22, 2017 06:53
@spencern spencern mentioned this pull request Oct 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants