Merge pull request #15222 from strapi/audit-logs/ctb-events

[Audit logs] Emit events for content types and components
This commit is contained in:
Rémi de Juvigny 2022-12-21 11:52:42 +01:00 committed by GitHub
commit 6e63a82c75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View File

@ -13,6 +13,12 @@ const defaultEvents = [
'user.update',
'user.delete',
'admin.auth.success',
'content-type.create',
'content-type.update',
'content-type.delete',
'component.create',
'component.update',
'component.delete',
];
const getEventMap = (defaultEvents) => {

View File

@ -52,6 +52,9 @@ const createComponent = async ({ component, components = [] }) => {
});
await builder.writeFiles();
strapi.eventHub.emit('component.create', { component: newComponent });
return newComponent;
};
@ -81,6 +84,9 @@ const editComponent = async (uid, { component, components = [] }) => {
});
await builder.writeFiles();
strapi.eventHub.emit('component.update', { component: updatedComponent });
return updatedComponent;
};
@ -90,6 +96,9 @@ const deleteComponent = async (uid) => {
const deletedComponent = builder.deleteComponent(uid);
await builder.writeFiles();
strapi.eventHub.emit('component.delete', { component: deletedComponent });
return deletedComponent;
};

View File

@ -120,6 +120,8 @@ const createContentType = async ({ contentType, components = [] }, options = {})
await builder.writeFiles();
}
strapi.eventHub.emit('content-type.create', { contentType: newContentType });
return newContentType;
};
@ -208,6 +210,9 @@ const editContentType = async (uid, { contentType, components = [] }) => {
}
await builder.writeFiles();
strapi.eventHub.emit('content-type.update', { contentType: updatedContentType });
return updatedContentType;
};
@ -252,6 +257,8 @@ const deleteContentType = async (uid, defaultBuilder = undefined) => {
}
}
strapi.eventHub.emit('content-type.delete', { contentType });
return contentType;
};