Commit Graph

12 Commits

Author SHA1 Message Date
Thibaut Patel
dc9c812d9c Renamed isAdmin/isOwner/isAdminOrOwner to reduce confusion
issue https://github.com/TryGhost/Team/issues/857

- The goal is to avoid testing for the owner role only is cases where we should be testing for the owner or admin role
- `isOwner` => `isOwnerOnly`
- `isAdmin` => `isAdminOnly`
- `isOwnerOrAdmin` => `isAdmin` (concerns now both Owner and Admins)
2021-07-12 14:55:56 +02:00
Kevin Ansfield
c646e78fff Made session.user a synchronous property rather than a promise
no issue

Having `session.user` return a promise made dealing with it in components difficult because you always had to remember it returned a promise rather than a model and had to handle the async behaviour. It also meant that you couldn't use any current user properties directly inside getters which made refactors to Glimmer/Octane idioms harder to reason about.

`session.user` was a cached computed property so it really made no sense for it to be a promise - it was loaded on first access and then always returned instantly but with a fulfilled promise rather than the  underlying model.

Refactoring to a synchronous property that is loaded as part of the authentication flows (we load the current user to check that we're logged in - we may as well make use of that!) means one less thing to be aware of/remember and provides a nicer migration process to Glimmer components. As part of the refactor, the auth flows and pre-load of required data across other services was also simplified to make it easier to find and follow.

- refactored app setup and `session.user`
  - added `session.populateUser()` that fetches a user model from the current user endpoint and sets it on `session.user`
  - removed knowledge of app setup from the `cookie` authenticator and moved it into = `session.postAuthPreparation()`, this means we have the same post-authentication setup no matter which authenticator is used so we have more consistent behaviour in tests which don't use the `cookie` authenticator
  - switched `session` service to native class syntax to get the expected `super()` behaviour
  - updated `handleAuthentication()` so it populate's `session.user` and performs post-auth setup before transitioning (handles sign-in after app load)
  - updated `application` route to remove duplicated knowledge of app preload behaviour that now lives in `session.postAuthPreparation()` (handles already-authed app load)
  - removed out-of-date attempt at pre-loading data from setup controller as that's now handled automatically via `session.handleAuthentication`
- updated app code to not treat `session.user` as a promise
  - predominant usage was router `beforeModel` hooks that transitioned users without valid permissions, this sets us up for an easier removal of the `current-user-settings` mixin in the future
2021-07-08 14:54:31 +01:00
Rishabh
e066fb5345 Reverted "Added home redirect for pricing wizard"
This reverts commit 0cf2fc9c24.

Hiding the launch wizard when there are existing prices causes an annoying flicker on the dashboard everytime we reload the page or navigate away. Instead of handling this client side, we'll push up the logic to hide the wizard on server.
2021-05-07 16:15:29 +05:30
Rishabh
0cf2fc9c24 Added home redirect for pricing wizard
refs https://github.com/TryGhost/Team/issues/644

In case the prices are already set for the default product, its confusing to have the launch wizard show the price setup again. We remove the wizard completely if the prices are already created for the default product.
2021-05-07 14:34:59 +05:30
Kevin Ansfield
10b48b1d6d Removed remaining uses of tour item components
no issue

- tour items in general are being removed
- preparation for full removal of all tour-related code (to be done in following commit to allow future revert without merge errors through template divergence)
2021-03-02 14:19:52 +00:00
Kevin Ansfield
916c12546f Fixed liquid-wormhole error when directly accessing /launch
refs b4e750466d

- liquid-wormhole was throwing an error with the previous approach because it appeared to be trying to run it's destroy routines after the element had already been removed or hadn't been rendered yet
2021-02-09 12:07:44 +00:00
Kevin Ansfield
5092e936cc Fixed unauthed access to launch wizard and updated test to use Owner user
refs 6a14087ccc

- `super()` is needed in `beforeModel()` hook so that the AuthenticatedRoute redirect can occur
- launch wizard acceptance test needs to use an Owner user because Admins don't have access
2021-02-04 17:45:16 +00:00
Kevin Ansfield
6a14087ccc Made launch wizard only accessible to owners
refs https://github.com/TryGhost/Team/issues/460

- member payment settings are only changeable by owners which would leave the wizard being a single step
- wizard is designed to be used as one of the first things after initial site setup which will be completed as the owner user
2021-02-04 17:36:29 +00:00
Kevin Ansfield
214158bee8 Refactored launch wizard
refs https://github.com/TryGhost/Team/issues/450

- swapped individual step routes for single launch route and query params to allow for easier management of step content and preview via components
- defined all wizard steps inside of launch controller
- updated templates to use a fixed preview across all steps
2021-02-02 16:08:06 +00:00
Kevin Ansfield
4b5f3f64a4 Added launch wizard prototype
refs https://github.com/TryGhost/Team/issues/450

Initial prototype of new launch-site wizard, meant to speed up the setup of a members site with the following steps:

1. Customise design
2. Connect Stripe
3. Set subscription pricing

- added wizard link to dashboard screen
- added `/launch/*` screens representing the wizard steps
- duplicated and refactored relevant general and members setting code and templates into each step
2021-02-02 16:08:03 +00:00
Kevin Ansfield
72d8b4f14d Reverted launch wizard prototype
no issue

- removing launch wizard from master ready to re-apply in 4.0 branch
2021-01-21 09:02:19 +00:00
Kevin Ansfield
d48abaa1f8 Added outline launch wizard framework
refs https://github.com/TryGhost/Team/issues/450

- adds `launch/*` routes corresponding to launch wizard steps
- sets up navigation between each wizard step
- adds components for each `launch/*` step to contain step-related functionality and facilitate later refactoring to a generalised wizard component
- adds link to the launch wizard from the dashboard screen
2021-01-18 13:48:23 +00:00