import { Suspense } from 'react'; import { useIntl } from 'react-intl'; import { urls, useConceptNavigation } from '@/app'; import { InfoUsers, SelectUser, useLabelUser, useRoleStore, UserRole } from '@/features/users'; 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 { type EventMouse } from '@/components/props'; import { ValueIcon } from '@/components/View'; import { useDialogsStore } from '@/stores/dialogs'; import { useModificationStore } from '@/stores/modification'; import { prefixes } from '@/utils/constants'; import { promptText } from '@/utils/labels'; import { type ILibraryItemData } from '../backend/types'; import { useMutatingLibrary } from '../backend/useMutatingLibrary'; import { useSetLocation } from '../backend/useSetLocation'; import { useSetOwner } from '../backend/useSetOwner'; import { useLibrarySearchStore } from '../stores/librarySearch'; interface EditorLibraryItemProps { schema: ILibraryItemData; isAttachedToOSS: boolean; } export function EditorLibraryItem({ schema, isAttachedToOSS }: 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 === schema.owner) { return; } if (!window.confirm(promptText.ownerChange)) { return; } void setOwner({ itemID: schema.id, owner: newValue }); }; function handleOpenLibrary(event: EventMouse) { setGlobalLocation(schema.location); router.push(urls.library, event.ctrlKey || event.metaKey); } function handleEditLocation() { showEditLocation({ initial: schema.location, onChangeLocation: newLocation => void setLocation({ itemID: schema.id, location: newLocation }) }); } function handleEditEditors() { showEditEditors({ itemID: schema.id, initialEditors: schema.editors }); } return (