f2fa958f20
Introduces a progress indicator for command menu items (both engine commands and front components). When a command is running, the menu item now displays a percentage alongside the loader spinner instead of just a spinner. - Added `commandMenuItemProgressFamilyState` to track per-item progress and `CommandListItemLoader` to render it - Exposed `updateProgress` in the twenty-sdk public API so front components can report execution progress back to the host - Wired progress reporting into `ExportMultipleRecordsCommand` as the first consumer, showing CSV export progress - Progress state is cleaned up on unmount for both engine commands and headless front components - Refactor
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { useCallback } from 'react';
|
|
|
|
import { commandMenuItemProgressFamilyState } from '@/command-menu-item/states/commandMenuItemProgressFamilyState';
|
|
import { mountedHeadlessFrontComponentMapsState } from '@/front-components/states/mountedHeadlessFrontComponentMapsState';
|
|
import { useStore } from 'jotai';
|
|
|
|
export const useUnmountHeadlessFrontComponent = () => {
|
|
const store = useStore();
|
|
const unmountHeadlessFrontComponent = useCallback(
|
|
(frontComponentId: string) => {
|
|
const currentMap = store.get(mountedHeadlessFrontComponentMapsState.atom);
|
|
const mountContext = currentMap.get(frontComponentId);
|
|
|
|
store.set(mountedHeadlessFrontComponentMapsState.atom, (previousMap) => {
|
|
const next = new Map(previousMap);
|
|
next.delete(frontComponentId);
|
|
return next;
|
|
});
|
|
|
|
if (mountContext) {
|
|
store.set(
|
|
commandMenuItemProgressFamilyState.atomFamily(
|
|
mountContext.commandMenuItemId,
|
|
),
|
|
undefined,
|
|
);
|
|
}
|
|
},
|
|
[store],
|
|
);
|
|
|
|
return unmountHeadlessFrontComponent;
|
|
};
|