Introduce primary actions (#15826)
- These actions are displayed in the accent color - Added new context store state `contextStoreIsPageInEditModeComponentState` - Reverted the order in which the actions are displayed (the first action should appear to the right of the top bar action menu) https://github.com/user-attachments/assets/3a0769cf-61ed-4619-8c4d-e3a01765b63c
This commit is contained in:
+11
-15
@@ -1,6 +1,5 @@
|
||||
import { SingleRecordActionKeys } from '@/action-menu/actions/record-actions/single-record/types/SingleRecordActionsKey';
|
||||
import { forceRegisteredActionsByKeyState } from '@/action-menu/actions/states/forceRegisteredActionsMapComponentState';
|
||||
import { PageLayoutSingleRecordActionKeys } from '@/page-layout/actions/PageLayoutSingleRecordActionKeys';
|
||||
import { MAIN_CONTEXT_STORE_INSTANCE_ID } from '@/context-store/constants/MainContextStoreInstanceId';
|
||||
import { contextStoreIsPageInEditModeComponentState } from '@/context-store/states/contextStoreIsPageInEditModeComponentState';
|
||||
import { PageLayoutComponentInstanceContext } from '@/page-layout/states/contexts/PageLayoutComponentInstanceContext';
|
||||
import { isPageLayoutInEditModeComponentState } from '@/page-layout/states/isPageLayoutInEditModeComponentState';
|
||||
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
|
||||
@@ -18,23 +17,20 @@ export const useSetIsPageLayoutInEditMode = (pageLayoutIdFromProps: string) => {
|
||||
pageLayoutId,
|
||||
);
|
||||
|
||||
const contextStoreIsFullTabWidgetInEditModeState =
|
||||
useRecoilComponentCallbackState(
|
||||
contextStoreIsPageInEditModeComponentState,
|
||||
MAIN_CONTEXT_STORE_INSTANCE_ID,
|
||||
);
|
||||
|
||||
const setIsPageLayoutInEditMode = useRecoilCallback(
|
||||
({ set }) =>
|
||||
(value: boolean) => {
|
||||
set(isPageLayoutInEditModeState, value);
|
||||
set(forceRegisteredActionsByKeyState, (prev) => ({
|
||||
...prev,
|
||||
[PageLayoutSingleRecordActionKeys.EDIT_LAYOUT]: !value,
|
||||
[PageLayoutSingleRecordActionKeys.SAVE_LAYOUT]: value,
|
||||
[PageLayoutSingleRecordActionKeys.CANCEL_LAYOUT_EDITION]: value,
|
||||
[PageLayoutSingleRecordActionKeys.ADD_TO_FAVORITES_READ_MODE]: !value,
|
||||
[SingleRecordActionKeys.ADD_TO_FAVORITES]: value,
|
||||
[SingleRecordActionKeys.DELETE]: !value,
|
||||
[SingleRecordActionKeys.NAVIGATE_TO_PREVIOUS_RECORD]: !value,
|
||||
[SingleRecordActionKeys.NAVIGATE_TO_NEXT_RECORD]: !value,
|
||||
}));
|
||||
|
||||
set(contextStoreIsFullTabWidgetInEditModeState, value);
|
||||
},
|
||||
[isPageLayoutInEditModeState],
|
||||
[isPageLayoutInEditModeState, contextStoreIsFullTabWidgetInEditModeState],
|
||||
);
|
||||
|
||||
return { setIsPageLayoutInEditMode };
|
||||
|
||||
Reference in New Issue
Block a user