mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* feat: record and show the identity kind in history and pickers - Snapshot the user type of the actor on row history, workflow history and audit log entries, and return it from their APIs. - Show the identity icon in row and workflow history, list identities in their own section of the audit log actor filter and count them per role in inherited access. - Load every identity in the team and access pickers through the paginated subjects endpoint, which now returns the workspace role. - Give identities premium features from the workspace or instance licence instead of a seat. * feat: record identity management in the audit log Creating, updating and deleting an identity go through registered actions, so the audit log shows who did it, with the identity's name and role before and after an update. The actions are not undoable. * fix: export an identity by its name in created by and last modified by * fix: record the values an identity update replaced from the locked row * fix: check the owner of an imported personal view without a query * fix: show an identity with the avatar and icon of its subject type * fix: audit an identity update by what it changed * feat: include the actor's user type in the audit log export and tool * test: cover a row history actor of an unregistered type * test: name the history migration test after what it checks
157 lines
4.6 KiB
Vue
157 lines
4.6 KiB
Vue
<template>
|
|
<div class="row-history-entry">
|
|
<div class="row-history-entry__header">
|
|
<component
|
|
:is="identityAvatar"
|
|
v-if="identityAvatar"
|
|
:subject="entry.actor"
|
|
size="medium"
|
|
/>
|
|
<span v-else class="row-history-entry__initials">{{ initials }}</span>
|
|
<span class="row-history-entry__name">{{ name }} {{ actionName }}</span>
|
|
<span class="row-history-entry__timestamp" :title="timestampTooltip">{{
|
|
formattedTimestamp
|
|
}}</span>
|
|
</div>
|
|
<template v-if="hasContent">
|
|
<div class="row-history-entry__content">
|
|
<template v-for="fieldIdentifier in entryFields">
|
|
<template
|
|
v-if="
|
|
getFieldName(fieldIdentifier) &&
|
|
getEntryComponent(fieldIdentifier)
|
|
"
|
|
>
|
|
<div :key="fieldIdentifier" class="row-history-entry__field">
|
|
{{ getFieldName(fieldIdentifier) }}
|
|
</div>
|
|
<component
|
|
:is="getEntryComponent(fieldIdentifier)"
|
|
:key="fieldIdentifier + 'content'"
|
|
:entry="entry"
|
|
:workspace-id="workspaceId"
|
|
:field-identifier="fieldIdentifier"
|
|
:field="getField(fieldIdentifier)"
|
|
></component>
|
|
</template>
|
|
</template>
|
|
</div>
|
|
</template>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import _ from 'lodash'
|
|
import moment from '@baserow/modules/core/moment'
|
|
import collaboratorName from '@baserow/modules/database/mixins/collaboratorName'
|
|
|
|
const actioNameMapping = {
|
|
create_rows: 'created',
|
|
create_row: 'created',
|
|
submit_form: 'submitted',
|
|
update_rows: 'updated',
|
|
update_row: 'updated',
|
|
delete_row: 'deleted',
|
|
delete_rows: 'deleted',
|
|
restore_from_trash: 'restored',
|
|
removedCreated: 'removedCreated',
|
|
}
|
|
|
|
export default {
|
|
name: 'RowHistoryEntry',
|
|
mixins: [collaboratorName],
|
|
props: {
|
|
workspaceId: {
|
|
type: Number,
|
|
required: true,
|
|
},
|
|
entry: {
|
|
type: Object,
|
|
required: true,
|
|
},
|
|
fields: {
|
|
type: Array,
|
|
required: true,
|
|
},
|
|
},
|
|
computed: {
|
|
name() {
|
|
if (!this.entry.actor) {
|
|
if (this.entry.user.id === this.$store.getters['auth/getUserId']) {
|
|
return this.$t('rowHistorySidebar.you')
|
|
}
|
|
return this.getCollaboratorName(this.entry.user, this.store)
|
|
}
|
|
|
|
const actor = this.entry.actor
|
|
if (!this.$registry.exists('subject', actor.type)) {
|
|
return actor.name
|
|
}
|
|
return this.$registry.get('subject', actor.type).getDisplayName(actor, {
|
|
currentUserId: this.$store.getters['auth/getUserId'],
|
|
currentUserName: this.$t('rowHistorySidebar.you'),
|
|
anonymousName: this.$t('rowHistorySidebar.anonymousUser'),
|
|
resolveUserName: (user) => this.getCollaboratorName(user, this.store),
|
|
})
|
|
},
|
|
initials() {
|
|
return this.name.slice(0, 1).toUpperCase()
|
|
},
|
|
identityAvatar() {
|
|
const actor = this.entry.actor
|
|
return actor?.user_type === 'identity'
|
|
? this.$registry.get('subject', actor.type).avatarComponent
|
|
: null
|
|
},
|
|
timestampTooltip() {
|
|
return this.getLocalizedMoment(this.entry.timestamp).format('L LT')
|
|
},
|
|
formattedTimestamp() {
|
|
return this.getLocalizedMoment(this.entry.timestamp).format('LT')
|
|
},
|
|
entryFields() {
|
|
return new Set(
|
|
Object.keys(this.entry.before).concat(Object.keys(this.entry.after))
|
|
)
|
|
},
|
|
hasContent() {
|
|
return !_.isEmpty(this.entry.before) || !_.isEmpty(this.entry.after)
|
|
},
|
|
actionName() {
|
|
const actionCommandType = this.entry.action_command_type
|
|
let actionName = actioNameMapping[this.entry.action_type]
|
|
if (actionCommandType === 'UNDO') {
|
|
actionName = `${actionName}Undo`
|
|
}
|
|
return this.$t(`rowHistorySidebar.${actionName}`)
|
|
},
|
|
},
|
|
methods: {
|
|
getLocalizedMoment(timestamp) {
|
|
return moment.utc(timestamp).tz(moment.tz.guess())
|
|
},
|
|
getFieldName(fieldIdentifier) {
|
|
const field = this.getField(fieldIdentifier)
|
|
if (field) {
|
|
return field.name
|
|
}
|
|
return null
|
|
},
|
|
getField(fieldIdentifier) {
|
|
const id = this.entry.fields_metadata[fieldIdentifier].id
|
|
const field = this.fields.find((f) => f.id === id)
|
|
return field
|
|
},
|
|
getEntryComponent(fieldIdentifier) {
|
|
const fieldMetadata = this.entry.fields_metadata[fieldIdentifier]
|
|
const type = fieldMetadata.type
|
|
const fieldType = this.$registry.get('field', type)
|
|
if (fieldType) {
|
|
return fieldType.getRowHistoryEntryComponent(fieldMetadata)
|
|
}
|
|
return null
|
|
},
|
|
},
|
|
}
|
|
</script>
|