refactor(command-menu-item): rename Actions to CommandMenuItem (#18489)
actions are being renamed to command menu item, they will be migrated to server and will be served as headless front components --------- Co-authored-by: Raphaël Bosi <71827178+bosiraphael@users.noreply.github.com>
This commit is contained in:
+16
-15
@@ -1,18 +1,18 @@
|
||||
import { ThreadWebWorker, release, retain } from '@quilted/threads';
|
||||
import { RemoteReceiver } from '@remote-dom/core/receivers';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { type ActionConfirmationModalResult } from '../../../sdk/front-component-api/globals/frontComponentHostCommunicationApi';
|
||||
import { type CommandConfirmationModalResult } from '../../../sdk/front-component-api/globals/frontComponentHostCommunicationApi';
|
||||
import { type FrontComponentHostCommunicationApi } from '../../types/FrontComponentHostCommunicationApi';
|
||||
import { type WorkerExports } from '../../types/WorkerExports';
|
||||
import { createRemoteWorker } from '../worker/utils/createRemoteWorker';
|
||||
|
||||
// Must match ACTION_MENU_CONFIRMATION_MODAL_RESULT_BROWSER_EVENT_NAME in twenty-front
|
||||
const ACTION_MENU_CONFIRMATION_MODAL_RESULT_BROWSER_EVENT_NAME =
|
||||
'action-menu-confirmation-modal-result';
|
||||
// Must match COMMAND_MENU_ITEM_CONFIRMATION_MODAL_RESULT_BROWSER_EVENT_NAME in twenty-front
|
||||
const COMMAND_MENU_ITEM_CONFIRMATION_MODAL_RESULT_BROWSER_EVENT_NAME =
|
||||
'command-menu-item-confirmation-modal-result';
|
||||
|
||||
type ActionMenuConfirmationModalResultBrowserEventDetail = {
|
||||
type CommandMenuItemConfirmationModalResultBrowserEventDetail = {
|
||||
frontComponentId: string;
|
||||
confirmationResult: ActionConfirmationModalResult;
|
||||
confirmationResult: CommandConfirmationModalResult;
|
||||
};
|
||||
|
||||
type FrontComponentWorkerEffectProps = {
|
||||
@@ -67,13 +67,14 @@ export const FrontComponentWorkerEffect = ({
|
||||
exports: frontComponentHostCommunicationApi,
|
||||
});
|
||||
|
||||
const handleActionMenuConfirmationModalResultBrowserEvent = (
|
||||
event: CustomEvent<ActionMenuConfirmationModalResultBrowserEventDetail>,
|
||||
const handleCommandMenuItemConfirmationModalResultBrowserEvent = (
|
||||
event: CustomEvent<CommandMenuItemConfirmationModalResultBrowserEventDetail>,
|
||||
) => {
|
||||
const actionMenuConfirmationModalResultBrowserEventDetail = event.detail;
|
||||
const commandMenuItemConfirmationModalResultBrowserEventDetail =
|
||||
event.detail;
|
||||
|
||||
if (
|
||||
actionMenuConfirmationModalResultBrowserEventDetail.frontComponentId !==
|
||||
commandMenuItemConfirmationModalResultBrowserEventDetail.frontComponentId !==
|
||||
frontComponentId
|
||||
) {
|
||||
return;
|
||||
@@ -81,7 +82,7 @@ export const FrontComponentWorkerEffect = ({
|
||||
|
||||
thread.imports
|
||||
.onConfirmationModalResult(
|
||||
actionMenuConfirmationModalResultBrowserEventDetail.confirmationResult,
|
||||
commandMenuItemConfirmationModalResultBrowserEventDetail.confirmationResult,
|
||||
)
|
||||
.catch((error: Error) => {
|
||||
setError(error);
|
||||
@@ -89,8 +90,8 @@ export const FrontComponentWorkerEffect = ({
|
||||
};
|
||||
|
||||
window.addEventListener(
|
||||
ACTION_MENU_CONFIRMATION_MODAL_RESULT_BROWSER_EVENT_NAME,
|
||||
handleActionMenuConfirmationModalResultBrowserEvent as EventListener,
|
||||
COMMAND_MENU_ITEM_CONFIRMATION_MODAL_RESULT_BROWSER_EVENT_NAME,
|
||||
handleCommandMenuItemConfirmationModalResultBrowserEvent as EventListener,
|
||||
);
|
||||
|
||||
setThread(thread);
|
||||
@@ -110,8 +111,8 @@ export const FrontComponentWorkerEffect = ({
|
||||
|
||||
return () => {
|
||||
window.removeEventListener(
|
||||
ACTION_MENU_CONFIRMATION_MODAL_RESULT_BROWSER_EVENT_NAME,
|
||||
handleActionMenuConfirmationModalResultBrowserEvent as EventListener,
|
||||
COMMAND_MENU_ITEM_CONFIRMATION_MODAL_RESULT_BROWSER_EVENT_NAME,
|
||||
handleCommandMenuItemConfirmationModalResultBrowserEvent as EventListener,
|
||||
);
|
||||
setThread(null);
|
||||
worker.terminate();
|
||||
|
||||
Reference in New Issue
Block a user