Commit Graph

18645 Commits

Author SHA1 Message Date
Michael Barrett
72cc285184
Refactor validating specified newsletters in custom sign-up form (#18032)
refs https://github.com/TryGhost/Product/issues/3837

Moved the logic for validating specified newsletters to controller so
that the request can be failed
2023-09-08 13:55:02 +01:00
Daniel Lockyer
6dc1d08590 Re-enabled general eslint rules in TS config
refs https://github.com/TryGhost/DevOps/issues/50

- when creating a TS config in our `eslint-plugin-ghost` dependency, I
  only extended the recommended config, which left out a lot of
  stylistic things we used to enforce in JS
- this fixes that by bumping the dependency to a version which extends
  those shared configs, and fixes all the code that currently goes
  against those rules
2023-09-08 13:47:42 +02:00
renovate[bot]
68dcb0f012 Update dependency i18next to v23.5.1 2023-09-08 10:47:33 +00:00
Simon Backx
669be72673
Wired up pagination to recommendations (#18018)
fixes https://github.com/TryGhost/Product/issues/3822
fixes https://github.com/TryGhost/Product/issues/3838

This PR became a bit big because it affected multiple parts of Ghost
that needed to be updated to prevent breaking anything.

### Backend
- Added pagination to the recommendations API's
- Updated BookshelfRepository template implementation to handle
pagination
- Allow to pass `page` and `limit` options to Models `findAll`, to allow
fetching a page without also fetching the count/metadata (=> in the
repository pattern we prefer to fetch the count explicitly if we need
pagination metadata)
- Added E2E tests for public recommendations API (content API)
- Extended E2E tests of admin recommendations API

### Portal
- Corrected recommendations always loaded in Portal. Instead they are
now only fetched when the recommendations page is opened.

### Admin-X
- Added `usePagination` hook: internally used in the new
`usePaginatedQuery` hook. This automatically adds working pagination to
a query that can be used to display in a table by passing the
`pagination` and `isLoading` results to the `<Table>`
- Added placeholder `<LoadingIndicator>` component
- Added a loading indicator to `<Table>`. This remembers the previous
height of the table, to avoid layout jumps when going to the next page.
2023-09-08 12:32:06 +02:00
Princi Vershwal
f663774cf9
Added support for multiple newsletters in custom signup form (#18023)
refs https://github.com/TryGhost/Product/issues/3514

---------

Co-authored-by: Michael Barrett <mike182uk@gmail.com>
2023-09-08 11:09:44 +01:00
Fabien "egg" O'Carroll
c9fff97c75 fixup! Added logging to collections event handlers 2023-09-08 14:46:38 +07:00
Fabien "egg" O'Carroll
ff8a3fbf32 fixup! Added logging to collections event handlers 2023-09-08 14:46:38 +07:00
Fabien "egg" O'Carroll
c6f908d31d Added logging to collections event handlers
This will help us with debugging issues we're seeing with large sites
2023-09-08 14:46:38 +07:00
Naz
fc5f139d39 Removed stray console.log
refs 367584f1c2

- I fucked up. ESLint fucked up. Life happened to all of us
2023-09-08 15:28:47 +08:00
Naz
367584f1c2 Optimized PostEditedEvent processing in collections
refs https://github.com/TryGhost/Arch/issues/86

- When PostEditedEvent data contains no visible changes we can skip the matching collections update process alltogether. Each call to `updatePostInMatchingCollections` creates a transaction in addition to fetching all collections. There's no need to process anything when there are no relevant changes in the post edit!
2023-09-08 13:46:44 +08:00
renovate[bot]
9e3e1d8c73 Update dependency newrelic to v11.1.0 2023-09-07 21:33:43 +00:00
Princi Vershwal
83282ca4cd
Added checks for subscription to multiple newsletter through custom sign up form (#17994)
refs https://github.com/TryGhost/Product/issues/3810

---------

Co-authored-by: Michael Barrett <mike@ghost.org>
2023-09-07 18:27:32 +01:00
Jono M
1366296330
Bumped AdminX settings and fixed default JS path (#18007)
no issue
2023-09-07 08:53:51 +00:00
Jono M
9e45afddb8
Updated AdminX to load via ES Modules to enable code splitting (#17971)
refs https://github.com/TryGhost/Product/issues/3349
2023-09-07 06:38:20 +00:00
Naz
07ed1677df Fixed test coverage checks in adapter-cache-redis package
no issue

- The previous configuration did not trigger check failures when the coverage dropped below the threshold.
2023-09-07 13:32:00 +08:00
Naz
cc48ead945 Added option to share redis connections across caches
closes https://github.com/TryGhost/Arch/issues/85

- Added a cache configuration option to signal "reuse of redis connection" for Redis cache adapter. The connection reuse it turned on by default to be shared between caches. They rely on unique "keyPrefix" structure, so there is no collision side-effects when reusing same Redis Store.
- The Redis connection options like "ttl" are shared with the first connection that's crated. So if there's a need to have unique configuration, a separate connection has to be created by passing `"reuseConnection": false` parameter
2023-09-07 13:32:00 +08:00
Kevin Ansfield
8c91662a47
Added conversion to beta editor format when creating content via ?source=html (#18000)
closes https://github.com/TryGhost/Product/issues/3803

Previously when the beta editor was enabled, using `?source=html` to create posts via the API would create posts in the old editor rather than the beta. This change switches conversion over to the new editor format when the beta is enabled so the full flow can be tested.

- added `htmlToLexicalConverter` method to our lexical library
- updated post and page input serializers to add html-to-lexical conversion when the beta editor is enabled
- updated post model to handle the mobiledoc+lexical co-existing state
  - this is a special case that is only valid for `?source=html` because providing both directly via the API is prohibited
  - we need the extra check here because at the input serializer layer we don't have access to the model to check if we're updating a mobiledoc post or a lexical post so the serializer sets both formats on a `?source=html` request when the beta is enabled and lets the model handle choosing the correct one
2023-09-06 21:16:40 +00:00
Simon Backx
62ee0928bb Bumped Portal to v2.35.0 2023-09-06 17:33:42 +02:00
renovate[bot]
a3a71a6728 Update dependency ws to v8.14.0 2023-09-06 15:27:00 +00:00
Simon Backx
f71c074d31
Added one-click-subscribe detection (#17995)
fixes https://github.com/TryGhost/Product/issues/3820

- This adds a new public site endpoint in the members API to check if a
site can offer the one-click-subscribe feature
- This is implemented on the members API as a copy of the `site`
endpoint because the admin API site endpoint is protected by CORS and
mainly because it can be served on a different domain than the
recommended site and this is hard to detect reliably from the frontend
- Added a new calculated setting `allow_self_signup`, which can replace
the setting that is currently used in Portal (best to do this after a
release otherwise we risk creating issues if a patch release happens)
2023-09-06 15:11:14 +00:00
Ghost CI
0387f75eeb Merged v5.61.3 into main 2023-09-06 10:55:49 +00:00
Ghost CI
1fd32288e0 v5.61.3 2023-09-06 10:55:47 +00:00
Kevin Ansfield
37a13cceb4
🐛 Fixed bookmark card creation and pasted link unfurls (#17990)
no issue

- recently added code to grab apple touch icons or SVGs before falling back to the default metascraper behaviour wrongly assumed that every size would have a `rel` and `href` attribute which is not the case
2023-09-06 11:30:56 +01:00
Kevin Ansfield
309184f5da
🐛 Fixed bookmark card creation and pasted link unfurls (#17990)
no issue

- recently added code to grab apple touch icons or SVGs before falling back to the default metascraper behaviour wrongly assumed that every size would have a `rel` and `href` attribute which is not the case
2023-09-06 10:22:45 +00:00
Sag
8f272e730b
Updated recommendation modal copy when triggered after signup (#17985)
refs https://github.com/TryGhost/Product/issues/3771
2023-09-05 18:50:34 +00:00
Sag
a08e0ed14e
Added logic to update the recommendations_enabled setting on add/delete (#17975)
closes https://github.com/TryGhost/Product/issues/3799

- the recommendations_enabled setting is updated when a recommendation
is created or deleted. It's enabled as soon as there is at least one
recommendation in the database
- the recommendations_enabled setting exists to avoid fetching the
recommendation count from the database directly in themes. The setting
is cached and doesn't need a read every time from the database
2023-09-05 18:31:48 +00:00
Ghost CI
ca91b847f3 Merged v5.61.2 into main 2023-09-05 17:55:54 +00:00
Ghost CI
50341d164f v5.61.2 2023-09-05 17:55:51 +00:00
Kevin Ansfield
0b37e835af
🐛 Fixed incorrect rendering of links following line breaks in beta editor
closes https://github.com/TryGhost/Product/issues/3827

- links following a line break in the editor were being rendered before the line break when previewing/publishing
- bumps Koenig packages which includes relevant fix in `@tryghost/kg-lexical-html-renderer`
2023-09-05 18:28:39 +01:00
Kevin Ansfield
92d07a97ab
Revert "Added drop of intermediate post saves between current running and latest triggered" (#17978)
reverts TryGhost/Ghost#17912

- unfortunately dropping save tasks when one is already running has side-effects for code that is initiating the save tasks
- e.g. the slug or title update actions call `saveTask.perform()` and if that related save request fails they expect to get a standard request error so they can show a message and perform a model rollback. However with `keepLatest` the save task can be dropped and "fail" immediately with a `TaskCancelation` error which has unintended side-effects:
  1. error handling is no longer tied to the specific request meaning we could have slug-related failures being handled by non-slug-save code which is unexpected
  2. the internal `TaskCancelation` error is handled as if it was general error and we end up showing a useless error in the red error bar that makes it look like something failed when it didn't
  3. we initiate a model rollback when we do not have a failure situation that requires it meaning we can lose changes
2023-09-05 18:28:31 +01:00
Kevin Ansfield
d00f437cf2
Revert "Added drop of intermediate post saves between current running and latest triggered" (#17978)
reverts TryGhost/Ghost#17912

- unfortunately dropping save tasks when one is already running has side-effects for code that is initiating the save tasks
- e.g. the slug or title update actions call `saveTask.perform()` and if that related save request fails they expect to get a standard request error so they can show a message and perform a model rollback. However with `keepLatest` the save task can be dropped and "fail" immediately with a `TaskCancelation` error which has unintended side-effects:
  1. error handling is no longer tied to the specific request meaning we could have slug-related failures being handled by non-slug-save code which is unexpected
  2. the internal `TaskCancelation` error is handled as if it was general error and we end up showing a useless error in the red error bar that makes it look like something failed when it didn't
  3. we initiate a model rollback when we do not have a failure situation that requires it meaning we can lose changes
2023-09-05 13:38:59 +00:00
Simon Backx
8b1ca62025
Added "Recommended you" section to settings (#17973)
fixes https://github.com/TryGhost/Product/issues/3808 
refs https://github.com/TryGhost/Product/issues/3791
2023-09-05 12:46:27 +02:00
renovate[bot]
0d6e979077 Update dependency express-hbs to v2.4.2 2023-09-05 06:52:42 +00:00
renovate[bot]
cfdc53e062 Update dependency tracked-built-ins to v3.2.0 2023-09-05 08:26:59 +02:00
renovate[bot]
dd4e27a729 Update dependency terser to v5.19.4 2023-09-04 16:04:36 +00:00
renovate[bot]
eac96067bc Update dependency jose to v4.14.6 2023-09-04 16:03:49 +00:00
renovate[bot]
8ba5470c5e Update dependency ember-svg-jar to v2.4.5 2023-09-04 16:58:56 +02:00
Daniel Lockyer
f65c31c8b2 Removed unnecessary callback function
- `serveStatic` doesn't even support this parameter, so the function is
  never called
- this clears up a big red line in code editors
2023-09-04 16:50:53 +02:00
Sag
d7504bdbf5
Added recommendation modal trigger on signup (#17925)
refs https://github.com/TryGhost/Product/issues/3771

- if recommendations are enabled, render the recommendation modal on
sign up, in Portal
- for free signups, the recommendations modal is rendered after clicking
on the magic link
- for paid signups, the recommendations modal is rendered after Stripe
Checkout
- the recommendations modal is not rendered on a free to paid upgrade
2023-09-04 14:35:56 +00:00
Uvindu Rajapakshe
31a9b15a41
Updated Sinhalese translations (#17939)
refs https://github.com/TryGhost/Team/issues/2795
2023-09-04 12:09:32 +02:00
Ghost CI
d7c0b2392b Merged v5.61.1 into main 2023-09-04 08:11:31 +00:00
Ghost CI
be3905b822 v5.61.1 2023-09-04 08:11:30 +00:00
Daniel Lockyer
d4217bd321
🐛 Fixed missing Admin assets in published tarball
refs https://github.com/TryGhost/Ghost/issues/17932

- we were missing `chunk.208.dbf172ad32f72f21a5dc.js` from our published tarball
- turns out this is due to the lines in the `.npmignore` file to remove
  .db files, which also matched this file
- we can make the regex more specific to avoid these cases
2023-09-04 10:09:16 +02:00
renovate[bot]
196945c1e7 Update dependency jose to v4.14.5 2023-09-04 06:09:56 +00:00
Fabien "egg" O'Carroll
5e3470a3a1 Fixed invalid Offers from throwing when reading
closes https://github.com/TryGhost/Product/issues/3675
refs c98bf80248

As part of our architecture guidelines Repository implementations should protect
against invalid or malformed data in persistence. We do not want read operations
of Entities to throw because of such data. For some fields that bad data can be
fixed or handled in the constructor or static create factory method and replaced
with valid data, others will cause the factory to throw.

This means that Repositories should catch these errors and exclude those
entities from their results. We log the errors in Sentry so that we have
visibility on the state of bad data in DBs
2023-09-02 16:58:48 +07:00
Fabien "egg" O'Carroll
84e6026408 Fixed Offer entity types in OfferBookshelfRepository
JSDoc has a problem with using values as types across repositories, rather than
getting `Offer` as the type we end up with `typeof Offer` as the type - which is
incorrect. Instead we use `import` syntax inside of JSDoc which resolves correctly
2023-09-02 16:58:48 +07:00
Fabien "egg" O'Carroll
127c61d4c6 Moved OfferRepository to core
As per our architecture guidelines we want to keep bookshelf implementations of
Repositories in Ghost core, so that all the bookshelf code is kept together, and
the packages implementing business logic with entities and services require less
dependencies to test. This separation should also help us inadvertently add
business logic to repository implementations by having a more "physical"
boundary between them.
2023-09-02 16:58:48 +07:00
Fabien "egg" O'Carroll
b64be18e74 Export Offer from @tryghost/members-offers
This will allow us to implement the Repository outside of the package, as it
needs access to the Entity factory to create instances.
2023-09-02 16:58:48 +07:00
Fabien "egg" O'Carroll
00072a204f Simplified use of ValueObject in OfferRepository
I don't think we need to instantiate and use the `equals` method here. It adds
an extra dependency to the Repository implementation, but it is slightly more
"correct" as it means that we leak internals by comparing strings exactly?

The ValueObject pattern here was very much a trial and isn't something we're
necessarily sticking with, so I don't see a problem with this string comparison.
2023-09-02 16:58:48 +07:00
Fabien "egg" O'Carroll
a97383f2de Moved Offer event logic into the Offer Entity
We do not want our Repositories to implement business logic like deciding which
events should be created. As that creates too tight of a coupling, and makes it
harder to swap out repositories in future. Instead they should only be concerned
with the storage, retrieval and hydration of Entities from the persistence engine.
2023-09-02 16:58:48 +07:00