mirror of
https://github.com/strapi/strapi.git
synced 2025-09-16 12:02:41 +00:00
Add model name to entry events
This commit is contained in:
parent
a91a9016ad
commit
3a227b6f1e
@ -48,10 +48,13 @@ const ActionBody = ({ status, data, formattedDate }) => {
|
||||
id: 'Settings.permissions.auditLogs.action',
|
||||
defaultMessage: 'Action',
|
||||
})}
|
||||
actionName={formatMessage({
|
||||
id: `Settings.permissions.auditLogs.${action}`,
|
||||
defaultMessage: getDefaultMessage(action),
|
||||
})}
|
||||
actionName={formatMessage(
|
||||
{
|
||||
id: `Settings.permissions.auditLogs.${action}`,
|
||||
defaultMessage: getDefaultMessage(action),
|
||||
},
|
||||
{ model: payload?.model }
|
||||
)}
|
||||
/>
|
||||
<ActionItem
|
||||
actionLabel={formatMessage({
|
||||
|
@ -14,16 +14,19 @@ const TableRows = ({ headers, rows, onOpenModal }) => {
|
||||
const { formatMessage } = useIntl();
|
||||
const formatTimeStamp = useFormatTimeStamp();
|
||||
|
||||
const getCellValue = ({ type, value }) => {
|
||||
const getCellValue = ({ type, value, model }) => {
|
||||
if (type === 'date') {
|
||||
return formatTimeStamp(value);
|
||||
}
|
||||
|
||||
if (type === 'action') {
|
||||
return formatMessage({
|
||||
id: `Settings.permissions.auditLogs.${value}`,
|
||||
defaultMessage: getDefaultMessage(value),
|
||||
});
|
||||
return formatMessage(
|
||||
{
|
||||
id: `Settings.permissions.auditLogs.${value}`,
|
||||
defaultMessage: getDefaultMessage(value),
|
||||
},
|
||||
{ model }
|
||||
);
|
||||
}
|
||||
|
||||
return value || '-';
|
||||
@ -46,6 +49,7 @@ const TableRows = ({ headers, rows, onOpenModal }) => {
|
||||
{getCellValue({
|
||||
type: key,
|
||||
value: cellFormatter ? cellFormatter(data[name]) : data[name],
|
||||
model: data.payload?.model,
|
||||
})}
|
||||
</Typography>
|
||||
</Td>
|
||||
|
@ -96,7 +96,7 @@ describe('ADMIN | Pages | AUDIT LOGS | ListView', () => {
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Create role')).toBeInTheDocument();
|
||||
expect(screen.getByText('Delete role')).toBeInTheDocument();
|
||||
expect(screen.getByText('Create entry')).toBeInTheDocument();
|
||||
expect(screen.getByText('Create entry (article)')).toBeInTheDocument();
|
||||
expect(screen.getByText('Admin logout')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
@ -8,6 +8,7 @@ const TEST_PAGE_DATA = [
|
||||
fullname: 'test user',
|
||||
email: 'test@test.com',
|
||||
},
|
||||
payload: {},
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
@ -18,12 +19,16 @@ const TEST_PAGE_DATA = [
|
||||
fullname: 'test user',
|
||||
email: 'test@test.com',
|
||||
},
|
||||
payload: {},
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
action: 'entry.create',
|
||||
date: '2022-12-27T17:34:00.673Z',
|
||||
user: null,
|
||||
payload: {
|
||||
model: 'article',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
@ -34,6 +39,7 @@ const TEST_PAGE_DATA = [
|
||||
fullname: 'test user',
|
||||
email: 'test@test.com',
|
||||
},
|
||||
payload: {},
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
const actionTypes = {
|
||||
'entry.create': 'Create entry',
|
||||
'entry.update': 'Update entry',
|
||||
'entry.delete': 'Delete entry',
|
||||
'entry.publish': 'Publish entry',
|
||||
'entry.unpublish': 'Unpublish entry',
|
||||
'entry.create': 'Create entry ({model})',
|
||||
'entry.update': 'Update entry ({model})',
|
||||
'entry.delete': 'Delete entry ({model})',
|
||||
'entry.publish': 'Publish entry ({model})',
|
||||
'entry.unpublish': 'Unpublish entry ({model})',
|
||||
'media.create': 'Create media',
|
||||
'media.update': 'Update media',
|
||||
'media.delete': 'Delete media',
|
||||
|
@ -181,11 +181,11 @@
|
||||
"Settings.permissions.auditLogs.userId": "User ID",
|
||||
"Settings.permissions.auditLogs.details": "Log Details",
|
||||
"Settings.permissions.auditLogs.listview.header.subtitle": "Logs of all the activities that happened in your environment",
|
||||
"Settings.permissions.auditLogs.entry.create": "Create entry",
|
||||
"Settings.permissions.auditLogs.entry.update": "Update entry",
|
||||
"Settings.permissions.auditLogs.entry.delete": "Delete entry",
|
||||
"Settings.permissions.auditLogs.entry.publish": "Publish entry",
|
||||
"Settings.permissions.auditLogs.entry.unpublish": "Unpublish entry",
|
||||
"Settings.permissions.auditLogs.entry.create": "Create entry ({model})",
|
||||
"Settings.permissions.auditLogs.entry.update": "Update entry ({model})",
|
||||
"Settings.permissions.auditLogs.entry.delete": "Delete entry ({model})",
|
||||
"Settings.permissions.auditLogs.entry.publish": "Publish entry ({model})",
|
||||
"Settings.permissions.auditLogs.entry.unpublish": "Unpublish entry ({model})",
|
||||
"Settings.permissions.auditLogs.media.create": "Create media",
|
||||
"Settings.permissions.auditLogs.media.update": "Update media",
|
||||
"Settings.permissions.auditLogs.media.delete": "Delete media",
|
||||
|
@ -24,7 +24,7 @@ const provider = {
|
||||
findMany(query) {
|
||||
return strapi.entityService.findPage('admin::audit-log', {
|
||||
populate: ['user'],
|
||||
fields: ['action', 'date'],
|
||||
fields: ['action', 'date', 'payload'],
|
||||
...query,
|
||||
});
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user