Commit Graph

15621 Commits

Author SHA1 Message Date
Rishabh
665c30f255 Added new {{tiers}} theme helper
refs https://github.com/TryGhost/Team/issues/1004

- adds new `{{tiers}}` helper behind `multipleProducts` flag
- `{{tiers}}` outputs a string with list of tiers that have access to specific post when used in a post context in theme
- outputs empty string when used out of a post context and without access to `visibility` property
- uses tiers attached to post column for data
2022-03-04 18:22:59 +05:30
Rishabh
a328e3e88b Fixed include option not working for fetching tiers via #get helper
refs https://github.com/TryGhost/Team/issues/1004

The output serializer for product was not handling `include` option value as comma separated string, which is passed via `#get` helper to fetch related prices for tiers. This change fixes the handling to work with both array as well as comma-separated include values.
2022-03-04 18:22:59 +05:30
Rishabh
eac732f620 Added tiers data for posts with non tiers visibility
refs https://github.com/TryGhost/Team/issues/1004

The `tiers` column for a post/page only contained data if its visibility is set to `tiers`, otherwise its empty. This is because originally the purpose of `tiers` column on `post` was to capture specific tiers with access to post.
The best way to ensure a consistent behavior for `tiers` column data on post is to update it to always contain list of all `tiers` that have access to post, and not just when the visibility is `tiers`. This means the value is set to all tiers when visibility is one of public|members, and only paid tiers when visibility is `paid`.  This change also allows on frontend to get all relevant `tiers` information for a post locally within post context instead of relying on additional information from outside.

This change -

- updates the output serializer for post/page to add all desired tiers manually in case of visibility is not `tiers`
- updates tests
2022-03-04 18:22:59 +05:30
Kevin Ansfield
df27b1993f Removed membersTimeFilters labs flag
refs https://github.com/TryGhost/Admin/pull/2290

- feature has gone GA and is no longer used in Admin
2022-03-04 12:11:48 +00:00
Matt Hanley
cd081e46fb Removed migration requirement for sqlite 2022-03-04 11:27:04 +00:00
Kevin Ansfield
9f2d655a19 Added membersContainsFilters labs flag
refs https://github.com/TryGhost/Team/issues/1408

- flag for gating access to "Name" and "Email" members filters in Admin
2022-03-04 11:18:47 +00:00
Matt Hanley
c6617459a5
Switched products.visible for products.visibility (#14264)
- We have an existing pattern for using `visibility: public` instead of `visible: true|false`
- We no-op the existing migration and roll forward so that we don't have to manually revert db changes
2022-03-04 11:07:38 +00:00
Rishabh Garg
c411a5d915
Added member's tier name on Portal account home (#14266)
Adds name of the tier on account home page for a logged-in member in Portal, as with multiple tiers the price/plan info is not sufficient.
2022-03-04 15:57:40 +05:30
Renovate Bot
e4df868886 Update actions/upload-artifact action to v3 2022-03-04 11:02:53 +01:00
Rishabh
c9577cec71 Removed archived tiers from portal tiers list
refs https://github.com/TryGhost/Team/issues/1404

The archived tiers are hidden in Portal normally as they are automatically not included in the `portal_products` list. This change also removes the archived tiers from being sent in list of tiers sent as part of site data to Portal. This ensures Portal doesn't use any archived tier.
2022-03-04 15:05:15 +05:30
Matt Hanley
01a6d576b3 Removed public cache-control header for member site endpoint
- Caching is causing issues with Portal preview
- Changes to tiers and Portal settings are taking too long to display on the site, causing confusion for users
- This reverts commit 5d8f491823.
2022-03-03 15:25:49 +00:00
Simon Backx
f389bab6ab
🐛 {{access}} property incorrect when using get/next-post/prev-post helpers (#14256)
refs https://github.com/TryGhost/Team/issues/1367

- The {{access}} property of a post always returned false for non-public content
- Added the member context to the get, next-post and prev-post helpers
- The get, next-post and prev-post helpers didn't add the member context to the internal API calls
- Added the members context to these calls
- Added tests that check if the member context is passed to the API calls
- Transformed next_post helper tests to async await syntax
- Transformed prev_post helper tests to async await syntax
2022-03-03 16:18:05 +01:00
Simon Backx
e97abeceb5
Added >, <, >=, and <= operators to match helper (#14215)
refs https://github.com/TryGhost/Team/issues/1386

- The current match handler supports normal (in)equality operators, but no numeric comparisons (<, >, <=, >=)
- A use case for these new operators is to show the latest post in a separate way from other posts

Includes unit tests to check the new behaviour.
Run via `yarn test test/unit/frontend/helpers/match.test.js`
2022-03-03 15:43:47 +01:00
Renovate Bot
5220083470 Update actions/stale action to v5 2022-03-03 14:56:07 +01:00
Daniel Lockyer
34a8307217 Updated all @tryghost dependencies
- I recently went across every repo and made sure our c8 config was
  correct, but this resulted in us having to publish patch versions of a
  bunch of packages
- given these don't contain any code changes, we can just bump them all
  at once
2022-03-03 14:52:48 +01:00
Fabien "egg" O'Carroll
df3f7a2c1b Added support for Tiers API to the get helper
https://github.com/TryGhost/Team/issues/1405

This will allow themes to fetch the list of tiers for creating custom
signup pages.
2022-03-03 15:15:43 +02:00
Fabien "egg" O'Carroll
1b96ce2794 Added /tiers endpoint to Content API
refs https://github.com/TryGhost/Team/issues/1313

When adding the tiers endpoint the Content API was missed, this is
needed so that themes can access Tiers via the `{{#get}}` helper.
2022-03-03 15:15:43 +02:00
Fabien "egg" O'Carroll
c00b398abf Added visible property to Tiers API
refs https://github.com/TryGhost/Team/issues/1387

This is also added to the Products API so that the Admin can use it
without having to switch to the new Tiers API.
2022-03-03 15:15:43 +02:00
renovate[bot]
5fbfdf011e
Update dependency @tryghost/members-stripe-service to v0.8.4 (#14235)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-03-03 12:18:21 +02:00
renovate[bot]
079d9ad825
Update dependency @tryghost/members-offers to v0.10.8 (#14233)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-03-03 11:51:43 +02:00
Daniel Lockyer
bf6f607f42 Switched to mysql2 library
refs https://github.com/TryGhost/Toolbox/issues/174

- this commit switches Ghost from using the `mysql` library to the
  `mysql2` one
- we've done this for several reasons:
  - `mysql2` is more actively maintained
  - `mysql2` natively supports the default auth plugin on MySQL 8
  - `mysql2` is fasterrrr
- there have been various other commits refactoring the groundwork for
  this commit but this commit should be short and sweet:
  - alias `mysql` to `mysql2` client so we maintain backwards
    compatibility with all configs who use `"client": "mysql"`
  - enabled `decimalNumbers` so we maintain the same functionality as
    `mysql`
  - replaced the dependencies and updated `knex-migrator`
  - hardcoded the newer authentication plugin in MySQL 8 CI. Before
    switching to `mysql2`, this would break because it didn't support
    this
2022-03-03 09:59:37 +01:00
Naz
da0dee548c Added alias for non-versioned API endpoints
refs https://github.com/TryGhost/Toolbox/issues/169

- Before next major version release we need to prepare for removal of API versioning.
- This change allows unversioned API requests to work under following endpoints:
- /ghost/api/admin
- /ghost/api/content
- This change should allow further preparation of the API clients (SDKs, Integrations, etc.) to non-versioned APIs in Ghost instances in ^5.0.0
- Changed default e2e test targets to non-versioned API. It's a trial, to have working examples. In the future all tests should switch to use only non-versioned endpoints.
2022-03-03 20:21:22 +13:00
Naz
cd1183c9d8 Added JWT authentication for non-versioned API
refs https://github.com/TryGhost/Toolbox/issues/169

- As Ghost prepares to drop API versioning in future major release it the authentication mechanism should take into account non-versioned token audience support. The audience for non-versioned api requests would be limited to "admin" rather than "canary/admin"
2022-03-03 20:21:22 +13:00
Naz
6b730cf201 Fixed use of anyDate matcher
refs c5f8853ad9

- The change in referenced commit was introduced by mistake
2022-03-03 12:06:40 +07:00
Kevin Ansfield
ac02b95c5c Added membersTimeFilters labs flag
no issue

- flag for gating access to in-development date based filters for the members list screen in Admin
2022-03-02 21:35:57 +00:00
Thibaut Patel
c5f8853ad9
Ignore casper install on setup (#14218)
refs https://github.com/TryGhost/Team/issues/1362

- Casper is already installed, so the installation from github always fail.
- There is no need to display an error message in that case.

Added regression tests for blog setup with the default theme:
- Check whether there are no notifications after completing the setup
- Also test the setup with the default theme
2022-03-02 18:22:20 +01:00
Daniel Lockyer
2a0cc9e8d4 Aliased mysql to mysql2 in schema client
refs https://github.com/TryGhost/Toolbox/issues/174

- this just uses the same SQL queries for certain queries when using the
  `mysql2` library as when using the `mysql` one
- we can remove the `mysql` line when we fully switch to `mysql2`
2022-03-02 16:06:37 +01:00
Daniel Lockyer
47260f405a Updated DB client timezone to Z
- whilst `UTC` was working, it's technically not supported as per the
  docs for `mysql`: https://www.npmjs.com/package/mysql#connection-options
- `mysql2`, however, is a bit more strict and throws a warning for
  unsupported values, so it was flagging up when I was looking at
  switching to that library
- this commit switches over to `Z` AKA Zulu -
  https://en.wikipedia.org/wiki/Coordinated_Universal_Time so both
  libraries are happy
2022-03-02 16:06:37 +01:00
renovate[bot]
700065372f
Update dependency @tryghost/members-importer to v0.5.3 (#14232)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-03-02 16:31:48 +02:00
Daniel Lockyer
d0e71524ca Switched to util for retrieving DB info in migrations
refs https://github.com/TryGhost/Toolbox/issues/174

- right now, our migrations manually check the client of the knex
  instance to see whether we're running on MySQL or SQLite
- that's been working fine, but the problem is that we're due to switch
  to the mysql2 driver soon, so all these checks will be faulty
- i've altered the functionality of `@tryghost/database-info` to accept
  a knex instance, and it'll return if the DB is MySQL or SQLite in some
  helper functions
- this commit bumps the package and switches to that format
- originally I used a shared instance of the class within
  `@tryghost/database-info` but there's a chance that the knex instance
  inside migrations actually comes from knex-migrator, and not Ghost, so
  that wouldn't work
2022-03-02 15:05:55 +01:00
Thibaut Patel
91d5fa0fc5 Prevent an event-processing error if there is no timezone setting
refs https://github.com/TryGhost/Ghost/pull/14197

- We default to UTC when there is no setting timezone
2022-03-02 13:58:26 +01:00
Thibaut Patel
527ef79955 Added the last_seen_at update on member page view
refs https://github.com/TryGhost/Team/issues/1306

- This adds a `MemberPageViewEvent` event when a page is viewed by a member (post/page/tag/author/...)
- Integrates the `LastSeenAtUpdater` service that listens to the `MemberPageViewEvent` events to update `member.last_seen_at`
- Follows the latest testing recommendation (end to end test + testing for side-effects)
2022-03-02 13:58:26 +01:00
Thibaut Patel
73a049c942 Added the last_seen_at update on email open
refs https://github.com/TryGhost/Team/issues/1306

- Updates once every day (in the publication timezone)
- Also updates when the value is `NULL`
- This is implemented as a SQL query as the code is on the job and doesn't have visibility to the members code
2022-03-02 13:58:26 +01:00
Daniel Lockyer
bf45ef4a87 Cleaned up DB connection fallback in migrations commands
- throughout the migration utils we use the passed in DB connection or
  fallback to the `db.knex` instance
- this works, but it means we have places we need to make sure to
  implement `(transaction || db.knex)` everywhere
- as I'm working on refactoring the utils, this was also causing
  problems because I'd be checking the `transaction` instance but that may
  be null/undefined
- this commit pulls the fallback into the function parameters where it's
  evaluated at runtime
- this also has the added benefit that we get jsdoc typing now because
  the types are easy to figure out
- note: `transaction` should probably be renamed to `connection` because
  it's not necessary a transaction... but baby steps 🤓
2022-03-02 13:27:21 +01:00
Daniel Lockyer
11f64e91c0
Added extra handling for errors when adding foreign key
- this section of code handles the errors that arise when we add a
  foreign key to a table
- locally, I get different errors than the one listed - `ER_FK_DUP_KEY`
  and `ER_FK_DUP_NAME`
- I've been trying to find a good source for what each code is but it
  looks highly likely to be differences in DB engines
- we should probably handle these errors anyway because we don't want
  migrations to error out
2022-03-02 12:37:39 +01:00
Naz
1cc38733ba Added Media and Files APIs to API key allowlist
refs https://github.com/TryGhost/Toolbox/issues/219

- These two APIs similarly to Images API should be accessible by the Admin-API SDK. Opens up a way to write custom scripts uploading files and media
2022-03-02 16:33:56 +07:00
renovate[bot]
fbb23f4e66
Update dependency @tryghost/members-ssr to v1.0.22 (#14234)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-03-02 11:33:49 +02:00
renovate[bot]
457623dc8c
Update dependency @tryghost/members-api to v5.0.4 (#14231)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-03-02 11:33:30 +02:00
Renovate Bot
83af4795e2 Update actions/checkout action to v3 2022-03-02 08:06:56 +01:00
Renovate Bot
11ce137571 Update dependency cssnano to v5.1.0 2022-03-02 08:06:14 +01:00
Fabien 'egg' O'Carroll
db202fb162
Added visible column to products table (#14221)
refs https://github.com/TryGhost/Team/issues/1387

We are moving away from the portal_products setting to instead store
each tiers visiblity on the tier itself. This column will be used for
that data.

Both of the default Tiers should be visible, but newly created tiers
should not be.
2022-03-01 18:11:59 +02:00
Naz
b3bf19e9e3 Renamed e2e framework date matchers
refs f48892028d
refs 33da584161

- There was another mather added recently: anyDateWithTimezoneOffset. The naming of date-related matchers was getting long and confusing. Renamed existing date matcher to better reflect what they do and they types of matches they are responsible for, following renames have been done:
- anyShortDate  -> anyISODate
- anyDate  -> anyISODateTime
- anyDateWithTimezoneOffset  -> anyISODateTimeWithTZ
2022-03-01 18:17:13 +07:00
Renovate Bot
a17ef130f9 Update dependency @tryghost/validator to v0.1.14 2022-03-01 08:32:27 +01:00
Renovate Bot
54f8f46194 Update dependency @tryghost/root-utils to v0.3.11 2022-03-01 08:32:13 +01:00
Renovate Bot
d87a8f1a6e Update actions/setup-node action to v3 2022-03-01 08:31:42 +01:00
Renovate Bot
8e48991e7d Update dependency @playwright/test to v1.19.2 2022-03-01 08:31:33 +01:00
Renovate Bot
b803aa1d8c Update dependency postcss to v8.4.7 2022-03-01 08:31:21 +01:00
Renovate Bot
121e76b0d5
Update dependency @sentry/node to v6.18.1 2022-02-28 17:54:56 +00:00
Naz
b9e26c836b 🐛 Fixed missing index page from pages sitemaps
closes https://github.com/TryGhost/Ghost/issues/14180
refs 597ec51afb

- The index page `/` was missing from sitemaps.xml. It was a regression instoruced with a referenced commit.
2022-02-28 22:23:11 +07:00
Renovate Bot
f9fccc43a2 Update dependency eslint to v8.10.0 2022-02-28 12:28:44 +00:00