import React, { useSyncExternalStore } from 'react'; import { Avatar, Box, Text } from 'folds'; import { UILocation } from '@paarrot/plugin-manager'; import { NavItem, NavButton, NavItemContent } from '../../../components/nav'; import { pluginRegistry } from './PluginAPI'; import { subscribeToButtons, getStoreVersion } from './PluginButtonSlot'; interface PluginNavSlotProps { /** The UI location to render nav list entries for. */ location: UILocation; } /** * Renders plugin buttons as `NavItem` list entries, matching the style of * built-in sidebar items like "Create Room" and "Message Search". * Intended for locations that live inside the channel / room list, not toolbars. */ export function PluginNavSlot({ location }: PluginNavSlotProps): React.ReactElement | null { useSyncExternalStore(subscribeToButtons, getStoreVersion); const buttons = pluginRegistry.getButtonsForLocation(location); if (buttons.length === 0) return null; return ( <> {buttons.map((button) => ( button.onClick?.()}> {button.icon ?? '🔌'} {button.label} ))} ); }