Commit Graph

16 Commits

Author SHA1 Message Date
Kevin Ansfield
9bdb25d184
Fixed hosting management screen not loading after sign-in process (#15763)
refs https://github.com/TryGhost/Team/issues/2110

- dynamically defined properties on the config service did not have
autotracking set up properly if they were accessed in any way before the
property was defined, this caused problems in a number of areas because
we have both "unauthed" and "authed" sets of config and when not logged
in we had parts of the app checking for authed config properties that
don't exist until after sign-in and subsequent config re-fetch
- renamed `config` service to `configManager` and updated to only
contain methods for fetching config data
- added a `config` instance initializer that sets up a `TrackedObject`
instance with some custom properties/methods and registers it on
`config:main`
- uses application instance initializer rather than a standard
initializer because standard initializers are only called once when
setting up the test suite so we'd end up with config leaking across
tests
- added an `@inject` decorator that when used takes the property name
and injects whatever is registered at `${propertyName}:main`, this
allows us to use dependency injection for any object rather than just
services or controllers
- using `application.inject()` in the initializer was initially used but
that only works for objects that extend from `EmberObject`, the
injections weren't available in native-class glimmer components so this
decorator keeps the injection syntax consistent
  - swapped all `@service config` uses to `@inject config`
2022-11-03 11:14:36 +00:00
Kevin Ansfield
7b443d4b63 Removed need for .get() with config service
no issue

The `config` service has been a source of confusion when writing with modern Ember patterns because it's use of the deprecated `ProxyMixin` forced all property access/setting to go via `.get()` and `.set()` whereas the rest of the system has mostly (there are a few other uses of ProxyObjects remaining) eliminated the use of the non-native get/set methods.

- removed use of `ProxyMixin` in the `config` service by grabbing the API response after fetching and using `Object.defineProperty()` to add native getters/setters that pass through to a tracked object holding the API response data. Ember's autotracking automatically works across the native getters/setters so we can then use the service as if it was any other native object
- updated all code to use `config.{attrName}` directly for getting/setting instead of `.get()` and `.set()`
- removed unnecessary async around `config.availableTimezones` which wasn't making any async calls
2022-10-07 16:14:57 +01:00
Kevin Ansfield
8cc4c6c4a1 Dropped ember-concurrency-decorators dependency
no issue

- since `ember-concurrency@2.0` it's possible to use the standard imports as decorators removing the need for the extra `ember-concurrency-decorators` dependency and imports
2022-02-09 10:49:38 +00:00
Kevin Ansfield
1ad2c05d37 Bumped eslint-plugin-ghost and fixed linter errors
no issue

- new linting rules that needed fixing:
   - calling `super` in lifecycle hooks
   - no usage of String prototype extensions
2021-07-15 15:27:29 +01:00
Kevin Ansfield
d96046cf1b Handled SecurityError when accessing iframe in <GhSiteIframe>
no issue

- when a site has a separate front-end and admin URL the `site` screen could throw errors due to cross-origin access to the iframe content
- detect the error and fall back to a less efficient forced refresh on guid change
2021-06-18 13:08:19 +01:00
Kevin Ansfield
3d43964bcd 🐛 Fixed portal preview resize when using split front-end/admin URLs (#1980)
no issue

- switched to listening to Portal's `message` events that now include a height
- removes need to reach into Portal preview iframe contents which is blocked by browser security when working cross-origin
2021-05-27 13:20:37 +01:00
Kevin Ansfield
baafe011a2 Fixed portal preview resize and cached page bugs
no issue

- moved `@onLoad` trigger from `load` event to the `makeVisible()` task so that consumer code isn't called before load has fully finished
  - fixes issue with portal sometimes not being ready when we perform the resize on the membership screen
- added guid as a cache-busting `?v={guid}` query param
  - fixes issue where preview iframe can load stale data after a settings change resulting in a blank preview after going from "nobody" to "invite/anybody" because the loaded homepage is stale and doesn't have the portal script injected
2021-05-24 17:28:01 +01:00
Kevin Ansfield
b8e6107c6a Fixed portal previews flashing background (#1975)
refs https://github.com/TryGhost/Team/issues/701
requires Portal@1.4.2 or later

- changed `<GhSiteIframe @invisibleUntilLoaded>` to accept a string in place of a `true/false` value
    - if a string is passed then we'll set up a message event listener than listens for a `postMessage` from the iframe with data that matches the supplied string
- updated `<GhSiteIframe>` usage for portal previews to use `@invisibleUntilLoaded="portal-ready"` so they listen for a message event rather than displaying as soon as we get a load event
2021-05-24 14:03:08 +01:00
Kevin Ansfield
2826ebfac4 Added timeout to help prevent site background flashes in portal previews
refs https://github.com/TryGhost/Team/issues/701

- `onload` event fires once the page has loaded but scripts may still be processing that would render an overlay. Wait for 100ms for renders to occur before making the iframe contents visible to allow for renders to occur
2021-05-24 11:02:26 +01:00
Kevin Ansfield
6339770a67 Fixed "connect to stripe" button in portal settings modal
no issue

- passed correct action for opening stripe connect modal through to portal settings modal
- updated `<GhTaskButton>` to accept a `@unlinkedTask=true/false` property
  - ember-concurrency will throw warnings about unsafe task cancellation if the initiator of a task is destroyed due to the actions of a task. Eg. the stripe connect button being replaced with the plan checkboxes because stripe connect details are added to settings
  - to avoid warnings ember-concurrency expects the task initiation to be marked as "unlinked" so that the task is allowed to continue even though the initiator is destroyed
- updated `<GhSiteIframe>` to force a refresh when the `@guid` property changes
  - we want the portal preview to fully reload so that it can fetch server data and see that stripe is connected
- updated portal settings modal to initiate a refresh when switching from "connect to stripe" to the plans checkboxes that happens automatically after a successful stripe connection
2021-05-19 20:24:18 +01:00
Kevin Ansfield
db09b317eb Added auto height adjustment to membership portal preview
no issue

- added `@onDestroyed` argument to `<GhSiteIframe>` so consumers can clean up any references
- used `@onLoaded` and `@onDestroyed` to handle a reference to the preview iframe
- updated portal preview load handler and update method to trigger a resize task
  - add a 100ms delay to allow for portal to re-render itself
  - reach through the two iframes to get the portal container element and use it's height to set the style attribute on the portal preview container element
2021-05-18 18:26:07 +01:00
Kevin Ansfield
602549097a Fixed flash of site when portal preview is loading
no issue

- added `@invisibleUntilLoaded` boolean argument to `<GhSiteIframe>`
  - when set to true add `.invisible` class until iframe's `load` event is triggered
- removed manual iframe hiding with 1.2sec delay from portal settings modal
- added `@onLoad` argument to `<GhSiteIframe>` for consumers to hook in if needed
2021-05-18 16:36:18 +01:00
Kevin Ansfield
b4a6eb594d Converted <GhSiteIframe> to a glimmer component
no issue

- updated to class syntax and glimmer component behaviour
- tidied up and standardised usage of the component
2021-05-18 16:08:13 +01:00
Kevin Ansfield
2b41499b22 Added design customisation and preview to launch wizard
refs https://github.com/TryGhost/Team/issues/450

- moved next/finish buttons into wizard step components in case they need to save before triggering transition
- added icon, logo, and cover image upload+removal to "customise design" step alongside a preview that reloads each time an image is changed
2021-01-18 17:48:11 +00:00
Rishabh Garg
23537355b6 Added live preview to members settings modal (#1622)
no issue

- Adds live preview of members.js modal UI to the new settings modal behind dev flag
- Uses `gh-site-iframe` to render site in preview mode with custom portal url
2020-06-26 02:15:47 +05:30
Kevin Ansfield
e7b740ba5f Added reset-to-homepage behaviour when clicking "view site" link
no issue
- return a basic "guid" from the site's `model` hook so that we have some data which changes on each refresh
- add an action to the wrapper element of the "view site" link which will cause the route to refresh when clicked if we're already on the route
- move the site iframe into a component so that it can watch an @uuid property and force a reset of the iframe's `src` when it detects a change
2019-03-21 17:55:58 +00:00