mirror of
https://github.com/strapi/strapi.git
synced 2025-08-09 01:07:27 +00:00
Merge pull request #15222 from strapi/audit-logs/ctb-events
[Audit logs] Emit events for content types and components
This commit is contained in:
commit
6e63a82c75
@ -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) => {
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user