SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
import { FolderInput } from '@signozhq/icons';
import type {
DropdownActionItemType,
DropdownSubmenuItemType,
} from '@signozhq/ui/dropdown';
import { findRootSection, type DashboardSection } from '../../../utils';
import type { MovePanelArgs } from '../hooks/useMovePanelToSection';
// Matches the root option label in the New Panel picker (AddPanelSplitButton).
const ROOT_LABEL = 'Dashboard (root)';
interface MoveItemsArgs {
sections: DashboardSection[];
currentLayoutIndex: number;
panelId: string;
movePanel: (args: MovePanelArgs) => Promise<void>;
}
/**
* "Move to section" submenu listing every section the panel can move to — the
* dashboard root (untitled top level, labelled "Dashboard (root)") plus every
* titled section, minus the one the panel already sits in. Hidden entirely when
* there is nowhere to move: an ungrouped board with no titled sections, or a
* panel that is alone in the only section.
*/
export function buildMoveItems({
sections,
currentLayoutIndex,
panelId,
movePanel,
}: MoveItemsArgs): DropdownSubmenuItemType[] {
const rootSection = findRootSection(sections);
// Sections are already in layout order, so the root (index 0, when present)
// naturally leads. Untitled non-root layouts are never a move target.
const targets = sections.filter(
(section) =>
section.layoutIndex !== currentLayoutIndex &&
(section === rootSection || Boolean(section.title)),
);
if (targets.length === 0) {
return [];
}
return [
{
type: 'submenu',
value: 'move',
label: 'Move to section',
prefix: <FolderInput size={14} />,
items: targets.map((section): DropdownActionItemType => {
const isRoot = section === rootSection;
return {
type: 'item',
value: isRoot ? 'move-to-root' : `move-${section.layoutIndex}`,
label: isRoot ? ROOT_LABEL : (section.title as string),
onClick: (): void =>
void movePanel({
panelId,
fromLayoutIndex: currentLayoutIndex,
toLayoutIndex: section.layoutIndex,
}),
};
}),
},
];
}