import { Suspense } from 'react'; import { useIntl } from 'react-intl'; import { urls, useConceptNavigation } from '@/app'; import { Overlay, Tooltip } from '@/components/Container'; import { MiniButton } from '@/components/Control'; import { useDropdown } from '@/components/Dropdown'; import { IconDateCreate, IconDateUpdate, IconEditor, IconFolderEdit, IconFolderOpened, IconOwner } from '@/components/Icons'; import { Loader } from '@/components/Loader'; import { CProps } from '@/components/props'; import { ValueIcon } from '@/components/View'; import { InfoUsers, SelectUser, useLabelUser, useRoleStore } from '@/features/users'; import { UserRole } from '@/features/users/models/user'; import { useDialogsStore } from '@/stores/dialogs'; import { useModificationStore } from '@/stores/modification'; import { prefixes } from '@/utils/constants'; import { promptText } from '@/utils/labels'; import { useMutatingLibrary } from '../backend/useMutatingLibrary'; import { useSetLocation } from '../backend/useSetLocation'; import { useSetOwner } from '../backend/useSetOwner'; import { ILibraryItemEditor } from '../models/library'; import { useLibrarySearchStore } from '../stores/librarySearch'; interface EditorLibraryItemProps { controller: ILibraryItemEditor; } export function EditorLibraryItem({ controller }: EditorLibraryItemProps) { const getUserLabel = useLabelUser(); const role = useRoleStore(state => state.role); const intl = useIntl(); const router = useConceptNavigation(); const setGlobalLocation = useLibrarySearchStore(state => state.setLocation); const isProcessing = useMutatingLibrary(); const { isModified } = useModificationStore(); const { setOwner } = useSetOwner(); const { setLocation } = useSetLocation(); const showEditEditors = useDialogsStore(state => state.showEditEditors); const showEditLocation = useDialogsStore(state => state.showChangeLocation); const ownerSelector = useDropdown(); const onSelectUser = function (newValue: number) { ownerSelector.hide(); if (newValue === controller.schema.owner) { return; } if (!window.confirm(promptText.ownerChange)) { return; } void setOwner({ itemID: controller.schema.id, owner: newValue }); }; function handleOpenLibrary(event: CProps.EventMouse) { setGlobalLocation(controller.schema.location); router.push(urls.library, event.ctrlKey || event.metaKey); } function handleEditLocation() { showEditLocation({ initial: controller.schema.location, onChangeLocation: newLocation => void setLocation({ itemID: controller.schema.id, location: newLocation }) }); } function handleEditEditors() { showEditEditors({ itemID: controller.schema.id, initialEditors: controller.schema.editors }); } return (