mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-11-05 00:44:28 +00:00
* feat(signatures): Add custom info to system signatures * feat(connections): Add custom info to system connections * feat(Map): Add system signature type * feat(Map): Update wormhole types info * feat(Map): Add undo action for removed systems * feat(Map): Delete systems on Backspace hotkey * feat(Map): Update k-space systems background & styles * feat(Map): Update systems status background styles * feat(Map): add support for new wh type data. add signatures settings modal menu; reworked signatures widget - was added info of wormhole; --------- Co-authored-by: achichenkov <aleksei.chichenkov@telleqt.ai>
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { Node } from 'reactflow';
|
|
import { useCallback, useRef, useState } from 'react';
|
|
import { ContextMenu } from 'primereact/contextmenu';
|
|
import { SolarSystemRawType } from '@/hooks/Mapper/types';
|
|
import { ctxManager } from '@/hooks/Mapper/utils/contextManager.ts';
|
|
import { NodeSelectionMouseHandler } from '@/hooks/Mapper/components/contexts/types.ts';
|
|
import { useDeleteSystems } from '@/hooks/Mapper/components/contexts/hooks';
|
|
|
|
export const useContextMenuSystemMultipleHandlers = () => {
|
|
const contextMenuRef = useRef<ContextMenu | null>(null);
|
|
const [systems, setSystems] = useState<Node<SolarSystemRawType>[]>();
|
|
|
|
const { deleteSystems } = useDeleteSystems();
|
|
|
|
const handleSystemMultipleContext: NodeSelectionMouseHandler = (ev, systems_) => {
|
|
setSystems(systems_);
|
|
ev.preventDefault();
|
|
ctxManager.next('ctxSysMult', contextMenuRef.current);
|
|
contextMenuRef.current?.show(ev);
|
|
};
|
|
|
|
const onDeleteSystems = useCallback(() => {
|
|
if (!systems) {
|
|
return;
|
|
}
|
|
|
|
const sysToDel = systems.filter(x => !x.data.locked).map(x => x.id);
|
|
if (sysToDel.length === 0) {
|
|
return;
|
|
}
|
|
|
|
deleteSystems(sysToDel);
|
|
}, [deleteSystems, systems]);
|
|
|
|
return {
|
|
handleSystemMultipleContext,
|
|
contextMenuRef,
|
|
onDeleteSystems,
|
|
};
|
|
};
|