diff --git a/app/components/List/Item.js b/app/components/List/Item.js index d9efc2fe..5491fa2e 100644 --- a/app/components/List/Item.js +++ b/app/components/List/Item.js @@ -37,6 +37,7 @@ const Image = styled(Flex)` max-height: 40px; align-items: center; user-select: none; + flex-shrink: 0; `; const Heading = styled.p` diff --git a/app/models/Event.js b/app/models/Event.js index 369f691c..f493547f 100644 --- a/app/models/Event.js +++ b/app/models/Event.js @@ -13,7 +13,11 @@ class Event extends BaseModel { userId: string; createdAt: string; actor: User; - data: { name: string, email: string }; + data: { + name: string, + email: string, + title: string, + }; get model() { return this.name.split('.')[0]; diff --git a/app/scenes/Settings/components/EventListItem.js b/app/scenes/Settings/components/EventListItem.js index ef97ca7f..49337296 100644 --- a/app/scenes/Settings/components/EventListItem.js +++ b/app/scenes/Settings/components/EventListItem.js @@ -21,8 +21,9 @@ const description = event => { return ( {capitalize(event.verbPastTense)} a{' '} - public link to a{' '} - document + public link to the{' '} + {event.data.name}{' '} + document ); case 'users.create': @@ -61,18 +62,35 @@ const description = event => { } if (event.documentId) { + if (event.name === 'documents.delete') { + return ( + + Deleted the {event.data.title} document + + ); + } return ( - {capitalize(event.verbPastTense)} a{' '} - document + {capitalize(event.verbPastTense)} the{' '} + {event.data.title} document ); } if (event.collectionId) { + if (event.name === 'collections.delete') { + return ( + + Deleted the {event.data.name} collection + + ); + } return ( - {capitalize(event.verbPastTense)} a{' '} - collection + {capitalize(event.verbPastTense)} the{' '} + + {event.data.name} + {' '} + collection ); } @@ -95,7 +113,7 @@ const EventListItem = ({ event }: Props) => { subtitle={ {description(event)} } actions={ diff --git a/server/api/events.js b/server/api/events.js index aa1c5e77..94218aea 100644 --- a/server/api/events.js +++ b/server/api/events.js @@ -12,11 +12,12 @@ const { authorize } = policy; const router = new Router(); 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'; const user = ctx.state.user; - const collectionIds = await user.collectionIds(); + const paranoid = false; + const collectionIds = await user.collectionIds(paranoid); let where = { name: Event.ACTIVITY_EVENTS, diff --git a/server/models/Event.js b/server/models/Event.js index 6f6b2ee9..9211c760 100644 --- a/server/models/Event.js +++ b/server/models/Event.js @@ -8,6 +8,7 @@ const Event = sequelize.define('event', { defaultValue: DataTypes.UUIDV4, primaryKey: true, }, + modelId: DataTypes.UUID, name: DataTypes.STRING, ip: DataTypes.STRING, data: DataTypes.JSONB, diff --git a/server/models/User.js b/server/models/User.js index 159a4a49..5e0277fc 100644 --- a/server/models/User.js +++ b/server/models/User.js @@ -54,7 +54,7 @@ User.associate = models => { }; // Instance methods -User.prototype.collectionIds = async function() { +User.prototype.collectionIds = async function(paranoid: boolean = true) { let models = await Collection.findAll({ attributes: ['id', 'private'], where: { teamId: this.teamId }, @@ -67,6 +67,7 @@ User.prototype.collectionIds = async function() { required: false, }, ], + paranoid, }); // Filter collections that are private and don't have an association