mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 17:00:55 +00:00
remove hidden contentTypes from permission actions list + fix tests
Signed-off-by: Pierre Noël <petersg83@gmail.com>
This commit is contained in:
parent
d8a4490cbf
commit
bbb1353927
@ -106,14 +106,8 @@ describe('Action Provider Service', () => {
|
|||||||
section: 'plugins',
|
section: 'plugins',
|
||||||
};
|
};
|
||||||
|
|
||||||
await actionProviderService.register([action1, action2]);
|
expect(() => actionProviderService.register([action1, action2])).toThrow(
|
||||||
|
'Duplicated action id: plugins::aPlugin.marketplace.delete. You may want to change the actions name.'
|
||||||
expect(global.strapi.stopWithError).toHaveBeenCalledWith(
|
|
||||||
expect.objectContaining({
|
|
||||||
name: 'ValidationError',
|
|
||||||
message:
|
|
||||||
'Duplicated action keys: plugins::aPlugin.marketplace.delete. You may want to change the actions name.',
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ describe('Permission Service', () => {
|
|||||||
const getAll = jest.fn(() => []);
|
const getAll = jest.fn(() => []);
|
||||||
|
|
||||||
global.strapi = {
|
global.strapi = {
|
||||||
admin: { permissionProvider: { getAll } },
|
admin: { services: { permission: { provider: { getAll } } } },
|
||||||
query() {
|
query() {
|
||||||
return { delete: deleteFn, create };
|
return { delete: deleteFn, create };
|
||||||
},
|
},
|
||||||
@ -42,11 +42,11 @@ describe('Permission Service', () => {
|
|||||||
const getAll = jest.fn(() =>
|
const getAll = jest.fn(() =>
|
||||||
Array(5)
|
Array(5)
|
||||||
.fill(0)
|
.fill(0)
|
||||||
.map((v, i) => ({ permissionId: `action-${i}` }))
|
.map((v, i) => ({ actionId: `action-${i}` }))
|
||||||
);
|
);
|
||||||
|
|
||||||
global.strapi = {
|
global.strapi = {
|
||||||
admin: { permissionProvider: { getAll } },
|
admin: { services: { permission: { provider: { getAll } } } },
|
||||||
query() {
|
query() {
|
||||||
return { delete: deleteFn, create };
|
return { delete: deleteFn, create };
|
||||||
},
|
},
|
||||||
|
@ -9,7 +9,7 @@ const actionProviderFactory = () => {
|
|||||||
return {
|
return {
|
||||||
get(uid, pluginName) {
|
get(uid, pluginName) {
|
||||||
const actionId = getActionId({ pluginName, uid });
|
const actionId = getActionId({ pluginName, uid });
|
||||||
const action = actions.find(p => p.actionId === actionId);
|
const action = actions.get(actionId);
|
||||||
return _.cloneDeep(action);
|
return _.cloneDeep(action);
|
||||||
},
|
},
|
||||||
getAll() {
|
getAll() {
|
||||||
|
@ -359,7 +359,7 @@ describe('Role CRUD End to End', () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
action: 'plugins::content-manager.create',
|
action: 'plugins::content-manager.create',
|
||||||
subject: 'plugins::upload.file',
|
subject: 'plugins::users-permissions.user',
|
||||||
conditions: ['isOwner'],
|
conditions: ['isOwner'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -234,10 +234,7 @@
|
|||||||
"strapi::permission",
|
"strapi::permission",
|
||||||
"strapi::role",
|
"strapi::role",
|
||||||
"strapi::user",
|
"strapi::user",
|
||||||
"plugins::users-permissions.permission",
|
"plugins::users-permissions.user"
|
||||||
"plugins::users-permissions.role",
|
|
||||||
"plugins::users-permissions.user",
|
|
||||||
"plugins::upload.file"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -247,10 +244,7 @@
|
|||||||
"strapi::permission",
|
"strapi::permission",
|
||||||
"strapi::role",
|
"strapi::role",
|
||||||
"strapi::user",
|
"strapi::user",
|
||||||
"plugins::users-permissions.permission",
|
"plugins::users-permissions.user"
|
||||||
"plugins::users-permissions.role",
|
|
||||||
"plugins::users-permissions.user",
|
|
||||||
"plugins::upload.file"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -260,10 +254,7 @@
|
|||||||
"strapi::permission",
|
"strapi::permission",
|
||||||
"strapi::role",
|
"strapi::role",
|
||||||
"strapi::user",
|
"strapi::user",
|
||||||
"plugins::users-permissions.permission",
|
"plugins::users-permissions.user"
|
||||||
"plugins::users-permissions.role",
|
|
||||||
"plugins::users-permissions.user",
|
|
||||||
"plugins::upload.file"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -273,10 +264,7 @@
|
|||||||
"strapi::permission",
|
"strapi::permission",
|
||||||
"strapi::role",
|
"strapi::role",
|
||||||
"strapi::user",
|
"strapi::user",
|
||||||
"plugins::users-permissions.permission",
|
"plugins::users-permissions.user"
|
||||||
"plugins::users-permissions.role",
|
|
||||||
"plugins::users-permissions.user",
|
|
||||||
"plugins::upload.file"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -109,7 +109,9 @@ async function syncComponentsSchemas() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function registerPermissions() {
|
function registerPermissions() {
|
||||||
const contentTypesUids = Object.keys(strapi.contentTypes); // TODO: filter to not have internal contentTypes
|
const contentTypesUids = strapi.plugins[
|
||||||
|
'content-manager'
|
||||||
|
].services.contenttypes.getDisplayedContentTypesUids();
|
||||||
|
|
||||||
const actions = [
|
const actions = [
|
||||||
{
|
{
|
||||||
|
@ -128,10 +128,14 @@ const createTimestampsSchema = contentType => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getDisplayedContentTypesUids = () =>
|
||||||
|
Object.keys(strapi.contentTypes).filter(ct => !HIDDEN_CONTENT_TYPES.includes(ct));
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getConfiguration,
|
getConfiguration,
|
||||||
setConfiguration,
|
setConfiguration,
|
||||||
deleteConfiguration,
|
deleteConfiguration,
|
||||||
formatContentType,
|
formatContentType,
|
||||||
formatContentTypeSchema,
|
formatContentTypeSchema,
|
||||||
|
getDisplayedContentTypesUids,
|
||||||
};
|
};
|
||||||
|
@ -7,9 +7,7 @@ describe('Upload plugin bootstrap function', () => {
|
|||||||
|
|
||||||
global.strapi = {
|
global.strapi = {
|
||||||
admin: {
|
admin: {
|
||||||
permissionProvider: {
|
services: { permission: { provider: { register } } },
|
||||||
register,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
log: {
|
log: {
|
||||||
error() {},
|
error() {},
|
||||||
|
@ -30,7 +30,10 @@ function isAPluginName(message) {
|
|||||||
|
|
||||||
function isAContentTypeId(message) {
|
function isAContentTypeId(message) {
|
||||||
return this.test('is not a content-type id', message, function(value) {
|
return this.test('is not a content-type id', message, function(value) {
|
||||||
return Object.keys(strapi.contentTypes).includes(value)
|
const contentTypesUids = strapi.plugins[
|
||||||
|
'content-manager'
|
||||||
|
].services.contenttypes.getDisplayedContentTypesUids();
|
||||||
|
return contentTypesUids.includes(value)
|
||||||
? true
|
? true
|
||||||
: this.createError({
|
: this.createError({
|
||||||
path: this.path,
|
path: this.path,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user