Files
Davide Silvestri 23f328cb19 feat(database): assign identities to rows and mention them in comments (#6619)
* feat(database): assign and mention identities behind a field option

- Collaborator fields get `include_identities` and long text fields
  `long_text_include_identities`, both off by default.
- With the option on, active identities of the workspace can be assigned
  or suggested as mentions; they are shown with their icon and renamed
  in realtime, and they never receive notifications.
- Turning the collaborator option off backs up the column, deletes the
  identity assignments and strips identities from the view defaults, so
  the update can be undone.
- Identities can author row comments and be mentioned in them.
- Exports write an identity as `Name <identity>`.

* refactor: hide internal emails in collaborator exports through one check

* fix: import a personal view only for a person, without a query per owner

* fix: show collaborator identities with the icon of the user subject type

* refactor: drop a redundant local import of the core handler

* fix: unify identity icons and space field options

* fix: keep identity field menus and saved mentions readable

* fix: limit identity mention suggestions to row comments

* perf: prefetch available collaborators once per workspace

* fix: use workspace members as authors of generated rows

* fix: resolve linked collaborator values by member email

* fix: use workspace collaborators for field pickers and paste

* refactor: move identity avatar styles to the avatar stylesheet

* fix: address review feedback on identity collaborators
2026-11-18 22:53:44 +01:00

81 lines
1.8 KiB
JavaScript

import { VueRenderer } from '@tiptap/vue-3'
import { watch } from 'vue'
import tippy from 'tippy.js'
import RichTextEditorMentionsList from '@baserow/modules/core/components/editor/RichTextEditorMentionsList'
export default ({ users }) => ({
render: () => {
let popup
let component
let stopWatchingUsers
const getUsers = () => (typeof users === 'function' ? users() : users) || []
return {
onStart: (props) => {
component = new VueRenderer(RichTextEditorMentionsList, {
editor: props.editor,
props: {
...props,
users: getUsers(),
},
})
stopWatchingUsers = watch(
getUsers,
(users) => component.updateProps({ users }),
{ deep: true }
)
if (!props.clientRect) {
return
}
popup = tippy('body', {
getReferenceClientRect: props.clientRect,
appendTo: () => document.body,
content: component.element,
showOnCreate: true,
interactive: true,
trigger: 'manual',
placement: 'top-start',
offset: [0, 5],
})
},
onUpdate(props) {
component.updateProps({
...props,
users: getUsers(),
})
if (!props.clientRect) {
return
}
popup[0].setProps({
getReferenceClientRect: props.clientRect,
})
},
onKeyDown(props) {
if (props.event.key === 'Escape') {
popup[0].hide()
return true
}
return component.ref?.onKeyDown(props)
},
onExit() {
stopWatchingUsers?.()
if (component) {
popup[0].destroy()
component.destroy()
}
},
}
},
})