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

Feat aldeed account shop creation #5

Merged
merged 9 commits into from
Oct 15, 2019

Conversation

aldeed
Copy link
Contributor

@aldeed aldeed commented Oct 15, 2019

Impact: breaking
Type: feature

Changes

Generally these are changes around auth and making the UI work before a shop has been created.

  • The Countries client-only Meteor collection is no longer used. Instead, CountryDefinitions and CountryOptions are imported from api-utils
  • LanguageDefinitions and CurrencyDefinitions are imported from api-utils instead of being pulled from shop.languages and shop.currencies.
  • The toggles for enabling and disabling languages and currencies have been removed from the Shop Settings page. For now they are all enabled. We may add back this feature in a better way (such as for specific selects/forms) in the future.
  • The upper left logo now shows "Reaction Commerce" with the Reaction logo until you have created the primary shop.
  • If there isn't a shop, all of the sidebar menu options are hidden
  • If there isn't a shop, the landing page now hows a "Create a shop" form. Currently it has only a "Name" field on it. It creates the primary shop with defaults, which you can then change on the Shop Settings page.
  • In onCreateUser on the server, we no longer auto-create an account for every user during user creation. The welcome email isn't sent here, either. The account and email happen on the server when the user makes their first GraphQL request.
  • The router no longer uses shop.layout. For now, all layouts are hard-coded to keep things working, but PR refactor: merge the routers #3 should make them unnecessary.

Breaking changes from 2.x

  • We no longer auto-create an account for every user during user creation. It's possible for a newly registered user to not have a document in the Accounts collection. Related changes in the API ensure that the related account is created when the user makes their first GraphQL request.
  • Assuming the API has related changes from Various 3.0.0 fixes reaction#5722, on a fresh database, you will no longer be able to log in as admin@localhost immediately. Instead, you must click "Register" and register a new user. This user will then be make an installation owner and have permission to create the primary shop.

Testing

To test you will need to point to a 3.0.0 API with changes from reactioncommerce/reaction#5722 merged.

You will also need to update various places in the reaction-admin codebase to point to that correct API URL, unless #3 has been merged already.

Verify things generally work as before, specifically around login, logout, and registering the first user on a new database. On a fresh database, it should work like this:
- First register a new user in Reaction Admin.
- This will log you in to Reaction Admin, which causes it to make some GraphQL requests.
- When the first GraphQL request comes, the account for your user is created. Because no existing "owner" user is found, it assigns you to the "owner" group instead of "customer" as usual.
- Reaction Admin then detects that there is no primary shop. It hides most of the admin UI and shows a "Create first shop" form, which uses the new createShop GraphQL mutation to create the primary shop.
- At this point the rest of the admin UI appears and works as it did in 2.x.

Note: There is still some work to do on the Reaction Admin Accounts page, which will be done in a future PR. In particular, inviting new shop managers does not work.

Signed-off-by: Eric Dobbertin <eric@dairystatedesigns.com>
Signed-off-by: Eric Dobbertin <eric@dairystatedesigns.com>
Signed-off-by: Eric Dobbertin <eric@dairystatedesigns.com>
Signed-off-by: Eric Dobbertin <eric@dairystatedesigns.com>
Signed-off-by: Eric Dobbertin <eric@dairystatedesigns.com>
Signed-off-by: Eric Dobbertin <eric@dairystatedesigns.com>
Signed-off-by: Eric Dobbertin <eric@dairystatedesigns.com>
Signed-off-by: Eric Dobbertin <eric@dairystatedesigns.com>
@aldeed aldeed self-assigned this Oct 15, 2019
Signed-off-by: Eric Dobbertin <eric@dairystatedesigns.com>
Copy link
Member

@kieckhafer kieckhafer left a comment

Choose a reason for hiding this comment

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

This works mostly as expected (once pulling in the config updates from #3.

One issue I saw was when setting my shop name when creating the initial shop, I saw this error pop up in the consol and in the server logs:

stack: ReactionError: There may be only one primary shop
      at Object.createShop (file:///usr/local/src/app/src/core-services/shop/mutations/createShop.js:152:13)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)
      at async createShop (file:///usr/local/src/app/src/core-services/shop/resolvers/Mutation/createShop.js:19:16)

But it disapeared after a few seconds, and the shop was created as expected, and there is only one shop in the database. So for the sake of getting things going, I think this is OK to merge and we can address if we do see it again.

Anothing thing that needs to be addressed is the Login / registration page. This is fine for now, as we know how to step through it (create the account first), but we'll need to land on the registration for the first user before this is finalized.

@kieckhafer kieckhafer merged commit 4cfb1dc into trunk Oct 15, 2019
@kieckhafer kieckhafer deleted the feat-aldeed-account-shop-creation branch October 15, 2019 20:54
@kieckhafer kieckhafer mentioned this pull request Feb 6, 2020
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.

2 participants