Commit Graph

91 Commits

Author SHA1 Message Date
Kevin Ansfield
c09dcd38af 🐛 Fixed preview modal showing outdated content if opened before autosave is triggered
refs https://github.com/TryGhost/Team/issues/609

There's a 3 second timeout before a background save is triggered after the last edit, if the preview modal is opened in that timeframe it would show outdated content.

- added a task that is triggered when the preview modal is opened
  - if a save task is already running it will wait for it to finish
  - otherwise if the post is a draft and the editor has dirty attributes it will trigger a save
- modal shows a loading spinner whilst waiting for the save to finish so the preview contents always match the latest editor changes
2021-11-09 12:13:23 +00:00
Kevin Ansfield
847aabd5f4 Fixed error when calling hasOwnProperty on null/undefined when saving posts
refs 89a6bc683b

- `options` did not have a default value and it's always passed in. Added a default value of an empty object so we're not tripped up with null/undefined
2021-10-15 15:49:19 +01:00
Kevin Ansfield
89a6bc683b 🐛 Fixed incorrect publish type showing in publish menu after close/re-open
closes https://github.com/TryGhost/Team/issues/1151

The publish-type state was being set directly on the model in the publish menu rather than being internal to the menu until publishing. A previous attempt had been made to fix that but it wasn't complete and resulted in the menu showing that it would "Publish" after setting it and closing/re-opening when in fact it would "Publish and send".

- moved all state for the distribution type and email settings to be stored in the `<PublishMenu>` component rather than split across the the component and model
- when saving a post from the publish menu, we now pass `emailOnly` as an option to the editor's save task the same as `sendEmailWhenPublished` (corresponding to the `email_recipient_filter` query param) so that we're back to one place controlling email behaviour for a post
- when `emailOnly` is passed as an option to the editor save task it will set the property on the model before saving and reset it back if the save fails. That way the email-only flag behaves as close to the "send when published" flag as possible without it also being sent as a query param.
2021-10-15 15:42:32 +01:00
Naz
0af2c464b0 Fixed incorrect status showing up when sent post is updated
refs https://linear.app/tryghost/issue/CORE-79/editing-saving-a-post-that-has-already-been-sent-flashes-sent-as-the

- The mapping was wong in a previous version - when the status changes from 'sent' to 'sent' the notification box should show 'Updated' instead of 'sent', doh!
2021-10-05 23:01:52 +13:00
Kevin Ansfield
b2bbaf153d Converted post-preview modal to EPM based modal
refs https://github.com/TryGhost/Team/issues/559

- moved the modal component class, template, and sub-components into a `components/modals/` directory to keep the top-level dir cleaner
- migrated component class to full glimmer syntax
2021-09-13 13:01:12 +01:00
Kevin Ansfield
a122711043 Converted delete-post modal to EPM based modal
refs https://github.com/TryGhost/Team/issues/559

- moved the modal component class and template into a `components/modals/` directory to keep the top-level dir cleaner
- migrated component class to glimmer syntax
- moved route transition behaviour directly into the class to avoid weird route-action indirection
2021-09-13 13:01:12 +01:00
Kevin Ansfield
5ce67c7892 Initial ember-promise-modals implementation
refs https://github.com/TryGhost/Team/issues/559

We want to get rid of our existing modals implementation because it doesn't play well with Glimmer compoments and the animation library it uses is now unmaintained and blocking our Ember.js upgrades.

- installed addon using customised fork
  - fork allows passthrough of `allowOutsideClick` to `focus-trap` so we can allow clicks on dropdowns and other wormholed content inside of a modal
- extended the `modals` service locally so we can customise click-outside-to-close behaviour and tie in with our `dropdowns` service
- set up styles in `modals-new.css`, mostly copied from `modals.css` with a few specific overrides
  - once all modals are converted we can drop the old `modals.css` and rename `modals-new.css`
2021-09-13 13:01:12 +01:00
Naz
f2883c3636 Fixed a routing error when a "sent" post was edited
refs https://github.com/TryGhost/Team/issues/954

- When an email-only post with a "sent" status was edited, it's status changed to "draft", which is an incorrect behavior. This change is causing the "sent" status to persist and removes the transition error.
2021-08-31 20:16:53 +04:00
Kevin Ansfield
4184543307 Added confirmation modal when updating an existing snippet
refs https://github.com/TryGhost/Team/issues/973

- show confirmation modal instead of immediately replacing content of the existing snippet
2021-08-23 17:12:26 +01:00
Kevin Ansfield
daa7f2e781 Added ability to update snippet contents
refs https://github.com/TryGhost/Team/issues/973

- added `@showCreate` option to `<GhInputWithSelect>` that enables the create option without having to pass a function in `@showCreateWhen`
- fixed autofocus not focusing input element in `<GhInputWithSelect>` when `autofocus="true"` isn't enough by itself
- updated `selectOrCreate` in `<GhInputWithSelect>` to trigger `onChange` if it's passed in rather than `onInput`
- swapped input in labs snippet input to `<GhInputWithSelect>`
- added actions for updating a snippet when an existing snippet is selected
- added action to editor control for saving an updated snippet
2021-08-23 16:00:01 +01:00
Naz
49b47b7016 Fixed crashing transition when email only post is sent
refs https://github.com/TryGhost/Team/issues/954

- The transition values wever missing for new "sent" email status and caused a 500 error to be displayed even though it had nothing to do with server errors
- There will be more tweaks to this in future iterations, this is a stop gap solution to have a working UI
2021-08-13 18:18:02 +04:00
Rishabh
031339ad6d Fixed typo in post save notification
refs 1ad2c05d37 (diff-7541a4cdb9acc4ffbfc9317258269618a25bc5ea9aa3fadd1a9123c6dc0839a9L959-R959)

-  removes typo `.htmlSafe` from actions to fix the save message
2021-07-16 13:20:28 +05:30
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
8630be5a87 🐛 Fixed re-authenticate modal not showing when saving in editor
closes https://github.com/TryGhost/Team/issues/865

Ghost now returns a forbidden error rather than an unauthorized error when saving whilst logged out so the session invalidation was not being triggered.

- added forbidden check to ajax service to trigger session invalidation
- added automatic retry of save in editor when re-authenticating
- fixed re-population of user and proxy services when re-authenticating, it's not needed at that point because nothing has been cleared
2021-07-14 12:28:09 +01:00
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
449f24cffb Removed potentially confusing Ctrl/Cmd+S wording in editor connection error
no issue

- there can be cases where the connection fails but Ctrl/Cmd+S won't work as a direct retry (eg, publish fails so the status reverts, in that case Cmd+S would save a draft rather than re-attempt a publish)
- switched to a neutral "try again" message
2021-07-05 17:15:01 +01:00
Kevin Ansfield
73d4ac8a26 Made server unreachable and maintenance error request retries application-wide
closes https://github.com/TryGhost/Team/issues/837

We previously added automatic retries to the editor controller for post saves; reviewing the resulting logs in Sentry we can see this stopped the "Server unreachable" error alerts showing to users because the requests typically succeeded on the first retry that was made 5 seconds later. However the problem is not limited to post saves and we can see other requests hitting the same issue, including when working in the editor such as adding embed cards, uploading images, or fetching member counts before publishing.

All of the API network requests we make in Admin run through an `ajax` service that makes and handles the request/response. By moving the retry logic for specific errors out of the editor controller and into the ajax service we can make temporary connection handling more graceful across the app.

- move retry behaviour from the editor controller to the `ajax` service so we can retry any request rather than just post save requests
- speed up retries so we reconnect as soon as possible
  - first retry at 500ms, then every 1000ms (previous was every 5s which meant overly long waits)
- reduce total retry time from >30s to 15s
- improve reporting to Sentry
  - report when a retry was required
  - report when a retry failed
  - include the total time taken for both success and failure reports
  - include the `server` header value from requests to distinguish between CDNs
  - include type of error so we can distinguish "server unreachable" from "maintenance" retries
2021-06-30 14:51:40 +01:00
Kevin Ansfield
6f0955d232 Fixed validation errors not showing after failed save in editor
refs a6c6def7e1

- we weren't checking if an error was a validation error by examining the number of errors on the post model, this meant we weren't falling through to the generic error handling/display logic that shows an alert for validation errors when a save isn't a background/silent save
2021-06-28 15:52:36 +01:00
Kevin Ansfield
766de0d475 Added automatic retry of failed editor saves when Ghost is in maintenance mode
no issue

- when Ghost is in maintenance mode after an upgrade we know it will come back shortly so automatically retrying the save in the same way we do for "server unreachable" errors provides a smoother experience compared to halting and showing a red alert bar
2021-06-28 15:33:40 +01:00
Kevin Ansfield
53dbbf33a5 Fixed confusing editor state after a failed status change
no issue

- post status was not being reset after certain types of failure to publish/unpublish/schedule which meant that the editor could be left in an odd in-between state where the displayed status did not reflect reality
- fixed "saving/publish/schedule failed:" wording in error message when a server unreachable error was detected, the "saving/publish/schedule" did not reflect the actual status change because we were passing through only the current status rather than previous+new status'
2021-06-28 15:29:07 +01:00
Kevin Ansfield
a6c6def7e1 Fixed "Saving failed: undefined" error message in editor
no issue

- if a ServerUnreachable error is triggered by a non-background-save then we'd show the expected custom alert and then immediately overwrite it because `savePost`'s catch was not expecting an `undefined` error
2021-06-28 15:29:07 +01:00
Kevin Ansfield
386d59d709 Fixed editor save retry attempts data not making it to Sentry
no issue

- the options passed to `captureMessage` have specific top-level keys, arbitrary data needs to be supplied by the `extra` key rather
2021-06-28 10:34:21 +01:00
Kevin Ansfield
1c9b7bba9d Fixed number of post save retry attempts
refs ac094821c8

- 2 attempts were used to speed up development, should have been 6 to match the 30seconds total retry period
2021-06-22 12:11:35 +01:00
Kevin Ansfield
a8c05f4be7 Fixed linting errors
refs ac094821c8

- stray console.logs
2021-06-21 18:15:17 +01:00
Kevin Ansfield
ac094821c8 Improved "Server unreachable" error handling in editor
refs https://github.com/TryGhost/Team/issues/788

- automatically retry any failed save attempts every 5 seconds for up to 30 seconds
- only show error bar after when we completely give up
- clear error bar if a later save is successful
- update error message to specify there's a connection problem and to retry with Cmd+S
- notify Sentry of a successful save after an initial failure including the number of attempts that were made and the total time for save to succeed in seconds
2021-06-21 18:13:45 +01:00
Kevin Ansfield
2770c73bab Fixed tests
refs 37a6197f81

- fixed find/replace whoopsie with `slugGenerator.generateSlug()`
- updated editor controller unit tests to match rename
2021-06-21 15:18:11 +01:00
Kevin Ansfield
37a6197f81 Renamed editor tasks to use xTask naming
no issue

- helps indicate that you're dealing with an ember-concurrency task object rather than a function/action so you know to use `perform` and that you have access to derived state
2021-06-21 15:05:41 +01:00
Kevin Ansfield
a41cb42a87 First pass at fixed rather than popover post settings sidebar
refs https://github.com/TryGhost/Team/issues/786

Enabled through labs `psmRedesign` flag, rough implementation to help design direction.

- fixed rather than popover when opened by putting editor and sidebar inside a flex container
- settings toggle fixed in top right rather than separate close button
2021-06-17 19:00:59 +01:00
Kevin Ansfield
0d30077325 Switched to new component for labs feature image redesign
refs https://github.com/TryGhost/Team/issues/771

- added `<GhEditorFeatureImage>` for more flexibility than offered by `<GhImageUploaderWithPreview>`
  - updated to more closely match intended designs
- removed alt/caption support from `<GhImageUploaderWithPreview>` as it's no longer used
- fixed upload/delete/upload not working due to file input references getting out of sync
2021-06-16 17:56:25 +01:00
Kevin Ansfield
ba47b710cb 🎨 Moved default focus in editor from body to title for new posts
refs https://github.com/TryGhost/Team/issues/707

Placing focus in the title aligns better with typical editorial process.

- switched `autofocus` attribute from body to title for new posts
- added a default value to the `mobiledoc` attr on the Post model, without it the autosave when moving from title to editor creates a forced re-render and clears the focus whilst you're typing
2021-06-14 15:35:59 +01:00
Kevin Ansfield
bd60c8089b 🐛 Fixed confusing member count shown in save notification and editor header
closes https://github.com/TryGhost/Team/issues/776

Since switching to using a real NQL filter in the `posts.email_recipient_filter` field where we used to show `free members`, `paid members`, or `all members` we were showing `status:free`, `status:-free`, and `status:free,status:-free` respectively. If labels are used in a filter the text became even longer.

- added a `membersCountCache` service
  - `.count(filter)` fetches a numeric count from the members API, if the filter has been counted in the last minute it returns the count directly from a cache instead to avoid hammering the members API when we show counts in multiple places across the UI
  - `.countString(filter)` fetches a count but returns a humanized string with the logic extracted from what we displayed in the confirm email sending modal
- added a `<GhRecipientFilterCount @filter="" />` component that acts as a wrapper around the async count from `membersCountCache`
- updated confirm email send modal, plus save notification and editor status displays for scheduled posts to use the new service and component
2021-06-11 11:44:50 +01:00
Kevin Ansfield
ceb16b5e9f Added first version of feature image with caption inside editor (#1999)
refs https://github.com/TryGhost/Team/issues/771

- updated `<GhImageUploaderWithPreview>` to take an `@includeMetadata` argument that shows a basic html supporting caption field underneath (ready for toggle between caption/alt but not fully implemented)
- added feature image alt/caption properties to post model
- updated UI behind "featureImageMeta" labs flag
  - added the feature image uploader to the top of `<GhKoenigEditor>` for display above the editor title
  - removed feature image uploader from post settings menu
- added labs flag checkbox
2021-06-10 20:42:32 +01:00
Kevin Ansfield
f45f250a1d Sorted snippets alphabetically in card menus
no issue

- more logical ordering
2021-05-26 20:29:41 +01:00
Kevin Ansfield
4c9eeddd79 Lock file maintenance with fixes
no issue

- catch `undefined` error when saving posts in editor which is thrown by our validation system and handled elsewhere
- bumped `ember-power-select` and switched `ember-power-datepicker` to a github ref so dependency-update fixes are included (version not released yet, see https://github.com/cibernox/ember-power-datepicker/issues/61)
- added a resolution for `ember-basic-dropdown@3.0.16`, with the latest `3.0.17` nothing is shown for the publish/post-settings menus for the date picker dropdown
2021-05-12 15:47:37 +01:00
Kevin Ansfield
e584569914 Switch deprecated htmlSafe imports from @ember/string to @ember/template
no issue

See https://deprecations.emberjs.com/v3.x#toc_ember-string-htmlsafe-ishtmlsafe
2021-05-12 12:33:40 +01:00
Sanne de Vries
0d1f288beb Fixed dark mode issues 2021-02-15 18:03:07 +01:00
Kevin Ansfield
4f50f0f870 Removed redundant "View preview" link in saved draft notification
refs https://github.com/TryGhost/Team/issues/459

- post previews are now always accessible from the editor header so there's no need for a separate preview link that takes you out of the editor
2021-02-08 18:43:45 +00:00
Kevin Ansfield
be01fa6920 Added publish menu to post preview modal
refs https://github.com/TryGhost/Team/issues/459

- pass required properties+actions through editor->post preview modal->publish menu
- replace publish button placeholder with `<GhPublishMenu>`
- close modal when saving if not a silent save
2021-02-02 16:08:08 +00:00
Peter Zimon
04d9caefed Updated navigation (#1832)
no issue

Updated settings navigation to a completely redesigned flow for Ghost 4.0 🎉

Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk>
Co-authored-by: Fabien O'Carroll <fabien@allou.is>
Co-authored-by: Rish <zrishabhgarg@gmail.com>
2021-02-02 16:08:06 +00:00
Kevin Ansfield
56f18c8886 Added post.{isPost,isPage} computed properties
no issue

- removes the need to check `post.displayName === 'post/page'` any time we need a conditional on post type
2021-02-02 16:08:05 +00:00
Kevin Ansfield
e932af26a7 Added first pass at new post preview
refs https://github.com/TryGhost/Team/issues/451

Start of new post preview prototype.

- adds preview button next to publish button
- opens new combined preview modal with desktop/email/social tabs
- desktop preview shows front-end preview url in iframe
- email preview fetches preview data as per the older email preview modal
- social preview to come later
2021-02-02 16:08:04 +00:00
Rishabh Garg
49b86b466a Allowed sending newsletter to free members only (#1751)
refs 6140a98351

This officially decouples the newsletter recipients from the post visibility allowing us to send emails to free members only.
2020-11-07 00:24:27 +05:30
Kevin Ansfield
c6753a0efd Hid snippet management UI from staff users without permissions
no issue

- snippets can only be created and deleted by owners/admins/editors
- added a property in the editor controller to determine if the logged in user has sufficient permissions, then only pass the appropriate save/delete snippet actions to the editor component if the check is passed
- updates koenig menus and toolbars to skip rendering of buttons if the associated action function is not available
2020-10-27 14:42:59 +00:00
Kevin Ansfield
1bd4b5cda7 Added delete button with confirmation to snippets in card menus
no issue

- show a delete icon when a snippet is hovered in plus/slash menus
- show a confirmation dialog when the delete icon is clicked
- keep menus open whilst displaying the delete confirmation dialog
2020-10-26 17:09:39 +00:00
Kevin Ansfield
3d48ce6bc4 Fixed snippets not loading in background when accessing editor
no issue

- add the missing snippets API query to the editor's background loaded
2020-10-16 19:22:09 +01:00
Kevin Ansfield
7e169a2a86 Renamed snippet.title to snippet.name for consistency
no issue

- all of our models which allow users to name something use `name` as the field descriptor rather than `title` so `snippet.title` was renamed for consistency
- also fixes typo in the plus-menu component that stopped clicking on snippets from working
2020-10-16 10:15:07 +01:00
Kevin Ansfield
b590ce1b95 Implemented first iteration of content snippets
closes https://github.com/TryGhost/Team/issues/411

- adds "Create snippet" icon to the editor toolbar
- uses the same link input component design for specifying snippet titles
- snippets are loaded in the background when the editor is accessed
- snippets are listed at the bottom of the card menus of the + and / menus
- clicking a snippet inserts the snippet's contents in place of the current blank section
2020-10-15 18:03:35 +01:00
Roshan Dash
8df1892185 🐛 Fixed incorrect scheduled date in toast (#1663)
closes https://github.com/TryGhost/Ghost/issues/12102

- The scheduled date was incorrectly shown as month number in the toast box after scheduling
- Updates to correctly show the selected date
2020-08-04 13:04:24 +05:30
Kevin Ansfield
0a2530c1cc Fixed "View post" rather than "View page" in save notifications
no issue

- the post/page conditional was looking at the old `post.page` property rather than the `post.displayName` that was added when posts and pages became separate models
2020-06-30 15:07:58 +01:00
Kevin Ansfield
ecf85f27e6 Updated "successfully scheduled" notification message
refs https://github.com/TryGhost/Ghost/issues/11965

- be more explicit about when the post will be published
- indicate if and to which type of members the post will be emailed
- improved description formatting by making sure pertinent pieces of information do not wrap
2020-06-30 11:15:39 +01:00