mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +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',
|
||||
};
|
||||
|
||||
await actionProviderService.register([action1, action2]);
|
||||
|
||||
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.',
|
||||
})
|
||||
expect(() => actionProviderService.register([action1, action2])).toThrow(
|
||||
'Duplicated action id: plugins::aPlugin.marketplace.delete. You may want to change the actions name.'
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -25,7 +25,7 @@ describe('Permission Service', () => {
|
||||
const getAll = jest.fn(() => []);
|
||||
|
||||
global.strapi = {
|
||||
admin: { permissionProvider: { getAll } },
|
||||
admin: { services: { permission: { provider: { getAll } } } },
|
||||
query() {
|
||||
return { delete: deleteFn, create };
|
||||
},
|
||||
@ -42,11 +42,11 @@ describe('Permission Service', () => {
|
||||
const getAll = jest.fn(() =>
|
||||
Array(5)
|
||||
.fill(0)
|
||||
.map((v, i) => ({ permissionId: `action-${i}` }))
|
||||
.map((v, i) => ({ actionId: `action-${i}` }))
|
||||
);
|
||||
|
||||
global.strapi = {
|
||||
admin: { permissionProvider: { getAll } },
|
||||
admin: { services: { permission: { provider: { getAll } } } },
|
||||
query() {
|
||||
return { delete: deleteFn, create };
|
||||
},
|
||||
|
@ -9,7 +9,7 @@ const actionProviderFactory = () => {
|
||||
return {
|
||||
get(uid, pluginName) {
|
||||
const actionId = getActionId({ pluginName, uid });
|
||||
const action = actions.find(p => p.actionId === actionId);
|
||||
const action = actions.get(actionId);
|
||||
return _.cloneDeep(action);
|
||||
},
|
||||
getAll() {
|
||||
|
@ -359,7 +359,7 @@ describe('Role CRUD End to End', () => {
|
||||
},
|
||||
{
|
||||
action: 'plugins::content-manager.create',
|
||||
subject: 'plugins::upload.file',
|
||||
subject: 'plugins::users-permissions.user',
|
||||
conditions: ['isOwner'],
|
||||
},
|
||||
],
|
||||
|
@ -234,10 +234,7 @@
|
||||
"strapi::permission",
|
||||
"strapi::role",
|
||||
"strapi::user",
|
||||
"plugins::users-permissions.permission",
|
||||
"plugins::users-permissions.role",
|
||||
"plugins::users-permissions.user",
|
||||
"plugins::upload.file"
|
||||
"plugins::users-permissions.user"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -247,10 +244,7 @@
|
||||
"strapi::permission",
|
||||
"strapi::role",
|
||||
"strapi::user",
|
||||
"plugins::users-permissions.permission",
|
||||
"plugins::users-permissions.role",
|
||||
"plugins::users-permissions.user",
|
||||
"plugins::upload.file"
|
||||
"plugins::users-permissions.user"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -260,10 +254,7 @@
|
||||
"strapi::permission",
|
||||
"strapi::role",
|
||||
"strapi::user",
|
||||
"plugins::users-permissions.permission",
|
||||
"plugins::users-permissions.role",
|
||||
"plugins::users-permissions.user",
|
||||
"plugins::upload.file"
|
||||
"plugins::users-permissions.user"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -273,10 +264,7 @@
|
||||
"strapi::permission",
|
||||
"strapi::role",
|
||||
"strapi::user",
|
||||
"plugins::users-permissions.permission",
|
||||
"plugins::users-permissions.role",
|
||||
"plugins::users-permissions.user",
|
||||
"plugins::upload.file"
|
||||
"plugins::users-permissions.user"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -109,7 +109,9 @@ async function syncComponentsSchemas() {
|
||||
}
|
||||
|
||||
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 = [
|
||||
{
|
||||
|
@ -128,10 +128,14 @@ const createTimestampsSchema = contentType => {
|
||||
};
|
||||
};
|
||||
|
||||
const getDisplayedContentTypesUids = () =>
|
||||
Object.keys(strapi.contentTypes).filter(ct => !HIDDEN_CONTENT_TYPES.includes(ct));
|
||||
|
||||
module.exports = {
|
||||
getConfiguration,
|
||||
setConfiguration,
|
||||
deleteConfiguration,
|
||||
formatContentType,
|
||||
formatContentTypeSchema,
|
||||
getDisplayedContentTypesUids,
|
||||
};
|
||||
|
@ -7,9 +7,7 @@ describe('Upload plugin bootstrap function', () => {
|
||||
|
||||
global.strapi = {
|
||||
admin: {
|
||||
permissionProvider: {
|
||||
register,
|
||||
},
|
||||
services: { permission: { provider: { register } } },
|
||||
},
|
||||
log: {
|
||||
error() {},
|
||||
|
@ -30,7 +30,10 @@ function isAPluginName(message) {
|
||||
|
||||
function isAContentTypeId(message) {
|
||||
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
|
||||
: this.createError({
|
||||
path: this.path,
|
||||
|
Loading…
x
Reference in New Issue
Block a user