Support tier visibility editing Allowed Tiers Admin API to set visibility

refs https://github.com/TryGhost/Team/issues/1387

This will allow us to move from the portal_products and portal_plans
settings to using the visibility property on tiers to determine whether
or not a tier should be visible in Portal.

This also fixes a bug with the Tiers Admin API read method permissions.
This commit is contained in:
Fabien 'egg' O'Carroll 2022-03-07 14:46:42 +00:00 committed by GitHub
parent 1a3aa69c68
commit fa1165de6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 11 deletions

View File

@ -54,7 +54,9 @@ module.exports = {
}
}
},
permissions: true,
permissions: {
docName: 'products'
},
async query(frame) {
const model = await membersService.api.productRepository.get(frame.data, frame.options);

View File

@ -58,7 +58,7 @@
"@nexes/nql": "0.6.0",
"@sentry/node": "6.18.1",
"@tryghost/adapter-manager": "0.2.28",
"@tryghost/admin-api-schema": "2.10.0",
"@tryghost/admin-api-schema": "2.11.0",
"@tryghost/bookshelf-plugins": "0.3.10",
"@tryghost/bootstrap-socket": "0.2.17",
"@tryghost/color-utils": "0.1.8",
@ -84,7 +84,7 @@
"@tryghost/logging": "2.0.4",
"@tryghost/magic-link": "1.0.20",
"@tryghost/member-events": "0.4.0",
"@tryghost/members-api": "5.0.4",
"@tryghost/members-api": "5.1.0",
"@tryghost/members-events-service": "0.3.1",
"@tryghost/members-importer": "0.5.3",
"@tryghost/members-offers": "0.10.8",

View File

@ -1,3 +1,4 @@
const assert = require('assert');
const {
agentProvider,
fixtureManager,
@ -91,4 +92,29 @@ describe('Tiers API', function () {
}]
});
});
it('Can read Tiers', async function () {
const {body: {tiers: [tier]}} = await agent.get('/tiers/');
await agent.get(`/tiers/${tier.id}/`)
.expectStatus(200);
});
it('Can edit visibility', async function () {
const {body: {tiers: [tier]}} = await agent.get('/tiers/?type:paid&limit=1');
const visibility = tier.visibility === 'none' ? 'public' : 'none';
await agent.put(`/tiers/${tier.id}/`)
.body({
tiers: [{
visibility
}]
})
.expectStatus(200);
const {body: {tiers: [updatedTier]}} = await agent.get(`/tiers/${tier.id}/`);
assert(updatedTier.visibility === visibility, `The visibility of the Tier should have been updated to ${visibility}`);
});
});

View File

@ -1744,10 +1744,10 @@
dependencies:
"@tryghost/errors" "^1.2.1"
"@tryghost/admin-api-schema@2.10.0":
version "2.10.0"
resolved "https://registry.yarnpkg.com/@tryghost/admin-api-schema/-/admin-api-schema-2.10.0.tgz#5d0966f3d937251070933314d64bd1486e6c93f5"
integrity sha512-EATkl1UYNN8Xmpk7xizjjrcmZW6B97z9yAtBDt+4lPEDpdZoCd/yVau640/Y5q257lWjaXq0CeQ6O9kpN7WwJQ==
"@tryghost/admin-api-schema@2.11.0":
version "2.11.0"
resolved "https://registry.yarnpkg.com/@tryghost/admin-api-schema/-/admin-api-schema-2.11.0.tgz#13e50b70a28bd6dfee01da46dbfbed1fc9a444f5"
integrity sha512-bY6qBFkB3i71Ci2lpnOgIFvxHnHYgDg/wK/fx2v7U6rXqO8wbtqo69GELyi7BaCS+Ji/CUBCsjuFWn2idh7u3A==
dependencies:
"@tryghost/errors" "^0.2.10"
lodash "^4.17.11"
@ -2173,10 +2173,10 @@
"@tryghost/domain-events" "^0.1.8"
"@tryghost/member-events" "^0.4.0"
"@tryghost/members-api@5.0.4":
version "5.0.4"
resolved "https://registry.yarnpkg.com/@tryghost/members-api/-/members-api-5.0.4.tgz#0e9bbef7e1381e4f11ac2ac512777cc4389e57ab"
integrity sha512-/ngQfgJsCMulAcprxC7sKFQukPlrkzxVKM6Fv33eBnSlIKBCVEhUWde7Pf2bp6zb1ZKMjz6YpS+193m+aEgcXg==
"@tryghost/members-api@5.1.0":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@tryghost/members-api/-/members-api-5.1.0.tgz#83280b8bd1f2a31160e3dd7a0885936ece0b3d00"
integrity sha512-JHXIg/+HPUZhm5j+EcL9h6mHUen0vaMIK8yFeLYBJXMfnl/lnd5FFVDLOTpFvo1pX+66hH2W+LonnhIspbvAaQ==
dependencies:
"@nexes/nql" "^0.6.0"
"@tryghost/debug" "^0.1.2"