feat: add moduleType to configurations, introduce DetailPageProvider, and consolidate macOS detection into module provider context
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { BaseEntity } from '@repo/core-api/data-services';
|
||||
import { DetailPageContext } from '../hooks/use-detail-page.context';
|
||||
import { EnterpriseDetailPageConfig } from '../entities/entity';
|
||||
|
||||
export function EnterpriseDetailPageProvider<E extends BaseEntity = BaseEntity>(props: EnterpriseDetailPageConfig<E>) {
|
||||
const {
|
||||
children,
|
||||
showPageHeader,
|
||||
useDefaultPadding,
|
||||
editMode,
|
||||
|
||||
pageHeaderProps,
|
||||
customPageActions,
|
||||
} = props;
|
||||
|
||||
return <DetailPageContext.Provider value={{}}></DetailPageContext.Provider>;
|
||||
}
|
||||
|
||||
@@ -12,23 +12,12 @@ import {
|
||||
} from '../hooks/use-module.context';
|
||||
import { shortcutsData } from '../../../constants';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/** Detect macOS / iOS for displaying platform-specific shortcut labels. */
|
||||
const IS_MAC = typeof navigator !== 'undefined' && /Mac|iPod|iPhone|iPad/.test(navigator.userAgent);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Component
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export function EnterpriseIndexPageProvider<E extends BaseEntity = BaseEntity>(props: EnterpriseIndexPageConfig<E>) {
|
||||
export function EnterpriseIndexPageProvider(props: EnterpriseIndexPageConfig) {
|
||||
const { children, pageHeaderProps, px, py, customPageActions, onClickCreate } = props;
|
||||
|
||||
const { t } = useEnterpriseModuleTranslationContext();
|
||||
const navigation = useEnterpriseModuleNavigationContext();
|
||||
const { config, privileges } = useEnterpriseModuleConfigContext();
|
||||
const { config, privileges, IS_MACOS } = useEnterpriseModuleConfigContext();
|
||||
const { moduleKey } = config;
|
||||
const { ALLOW_CREATE } = privileges;
|
||||
|
||||
@@ -50,8 +39,8 @@ export function EnterpriseIndexPageProvider<E extends BaseEntity = BaseEntity>(p
|
||||
/** Platform-aware shortcut label for the Create action. */
|
||||
const CREATE_SHORTCUT_LABEL = useMemo(() => {
|
||||
const shortcutData = shortcutsData.find((s) => s.key === 'collapse_sidebar');
|
||||
return IS_MAC ? shortcutData?.macKeyIcons.join(' ') : shortcutData?.winKeyIcons.join(' ');
|
||||
}, [IS_MAC]);
|
||||
return IS_MACOS ? shortcutData?.macKeyIcons.join(' ') : shortcutData?.winKeyIcons.join(' ');
|
||||
}, [IS_MACOS]);
|
||||
|
||||
useEffect(() => {
|
||||
function onKeyDown(e: KeyboardEvent) {
|
||||
|
||||
@@ -20,6 +20,9 @@ export interface EnterpriseModuleProviderProps<E extends BaseEntity> {
|
||||
dataServices: BaseRemoteDataServices<E>;
|
||||
}
|
||||
|
||||
/** Detect macOS / iOS for displaying platform-specific shortcut labels. */
|
||||
const IS_MACOS = typeof navigator !== 'undefined' && /Mac|iPod|iPhone|iPad/.test(navigator.userAgent);
|
||||
|
||||
export function EnterpriseModuleProvider<E extends BaseEntity>(props: EnterpriseModuleProviderProps<E>) {
|
||||
const { children, config, dataServices } = props;
|
||||
const navigate = useNavigate();
|
||||
@@ -32,6 +35,7 @@ export function EnterpriseModuleProvider<E extends BaseEntity>(props: Enterprise
|
||||
config,
|
||||
// FIXME => IMPLEMENT PRIVILEGE
|
||||
privileges: defaultPrivileges,
|
||||
IS_MACOS: IS_MACOS,
|
||||
};
|
||||
}, [config]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user