fix: Deleted collections not showing in audit log
feat: Show titles of objects in audit log fix: modelId not saved with share events fix: List item squashes avatar at small screen sizes
This commit is contained in:
@ -37,6 +37,7 @@ const Image = styled(Flex)`
|
|||||||
max-height: 40px;
|
max-height: 40px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
flex-shrink: 0;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Heading = styled.p`
|
const Heading = styled.p`
|
||||||
|
@ -13,7 +13,11 @@ class Event extends BaseModel {
|
|||||||
userId: string;
|
userId: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
actor: User;
|
actor: User;
|
||||||
data: { name: string, email: string };
|
data: {
|
||||||
|
name: string,
|
||||||
|
email: string,
|
||||||
|
title: string,
|
||||||
|
};
|
||||||
|
|
||||||
get model() {
|
get model() {
|
||||||
return this.name.split('.')[0];
|
return this.name.split('.')[0];
|
||||||
|
@ -21,8 +21,9 @@ const description = event => {
|
|||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{capitalize(event.verbPastTense)} a{' '}
|
{capitalize(event.verbPastTense)} a{' '}
|
||||||
<Link to={`/share/${event.modelId || ''}`}>public link</Link> to a{' '}
|
<Link to={`/share/${event.modelId || ''}`}>public link</Link> to the{' '}
|
||||||
<Link to={`/doc/${event.documentId}`}>document</Link>
|
<Link to={`/doc/${event.documentId}`}>{event.data.name}</Link>{' '}
|
||||||
|
document
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
case 'users.create':
|
case 'users.create':
|
||||||
@ -61,18 +62,35 @@ const description = event => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.documentId) {
|
if (event.documentId) {
|
||||||
|
if (event.name === 'documents.delete') {
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{capitalize(event.verbPastTense)} a{' '}
|
Deleted the <strong>{event.data.title}</strong> document
|
||||||
<Link to={`/doc/${event.documentId}`}>document</Link>
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
{capitalize(event.verbPastTense)} the{' '}
|
||||||
|
<Link to={`/doc/${event.documentId}`}>{event.data.title}</Link> document
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (event.collectionId) {
|
if (event.collectionId) {
|
||||||
|
if (event.name === 'collections.delete') {
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{capitalize(event.verbPastTense)} a{' '}
|
Deleted the <strong>{event.data.name}</strong> collection
|
||||||
<Link to={`/collections/${event.collectionId || ''}`}>collection</Link>
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
{capitalize(event.verbPastTense)} the{' '}
|
||||||
|
<Link to={`/collections/${event.collectionId || ''}`}>
|
||||||
|
{event.data.name}
|
||||||
|
</Link>{' '}
|
||||||
|
collection
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -95,7 +113,7 @@ const EventListItem = ({ event }: Props) => {
|
|||||||
subtitle={
|
subtitle={
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{description(event)} <Time dateTime={event.createdAt} /> ago ·{' '}
|
{description(event)} <Time dateTime={event.createdAt} /> ago ·{' '}
|
||||||
{event.name}
|
<strong>{event.name}</strong>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
}
|
}
|
||||||
actions={
|
actions={
|
||||||
|
@ -12,11 +12,12 @@ const { authorize } = policy;
|
|||||||
const router = new Router();
|
const router = new Router();
|
||||||
|
|
||||||
router.post('events.list', auth(), pagination(), async ctx => {
|
router.post('events.list', auth(), pagination(), async ctx => {
|
||||||
let { sort = 'updatedAt', direction, auditLog = false } = ctx.body;
|
let { sort = 'createdAt', direction, auditLog = false } = ctx.body;
|
||||||
if (direction !== 'ASC') direction = 'DESC';
|
if (direction !== 'ASC') direction = 'DESC';
|
||||||
|
|
||||||
const user = ctx.state.user;
|
const user = ctx.state.user;
|
||||||
const collectionIds = await user.collectionIds();
|
const paranoid = false;
|
||||||
|
const collectionIds = await user.collectionIds(paranoid);
|
||||||
|
|
||||||
let where = {
|
let where = {
|
||||||
name: Event.ACTIVITY_EVENTS,
|
name: Event.ACTIVITY_EVENTS,
|
||||||
|
@ -8,6 +8,7 @@ const Event = sequelize.define('event', {
|
|||||||
defaultValue: DataTypes.UUIDV4,
|
defaultValue: DataTypes.UUIDV4,
|
||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
},
|
},
|
||||||
|
modelId: DataTypes.UUID,
|
||||||
name: DataTypes.STRING,
|
name: DataTypes.STRING,
|
||||||
ip: DataTypes.STRING,
|
ip: DataTypes.STRING,
|
||||||
data: DataTypes.JSONB,
|
data: DataTypes.JSONB,
|
||||||
|
@ -54,7 +54,7 @@ User.associate = models => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Instance methods
|
// Instance methods
|
||||||
User.prototype.collectionIds = async function() {
|
User.prototype.collectionIds = async function(paranoid: boolean = true) {
|
||||||
let models = await Collection.findAll({
|
let models = await Collection.findAll({
|
||||||
attributes: ['id', 'private'],
|
attributes: ['id', 'private'],
|
||||||
where: { teamId: this.teamId },
|
where: { teamId: this.teamId },
|
||||||
@ -67,6 +67,7 @@ User.prototype.collectionIds = async function() {
|
|||||||
required: false,
|
required: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
paranoid,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Filter collections that are private and don't have an association
|
// Filter collections that are private and don't have an association
|
||||||
|
Reference in New Issue
Block a user