Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/dashboard/app/boot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import wpcom from 'calypso/lib/wp';
import isDashboardEnv from '../utils/is-dashboard-env';
import { handleOAuthCallback } from './auth/oauth-callback';
import { loadPreferencesHelper } from './dev-tools/preferences';
import { omnibarEvents } from './interim-omnibar/click-handlers';
import { omnibarEvents } from './interim-omnibar/omnibar-events';
import Layout from './layout';
import limitTotalSnackbars from './snackbars/limit-total-snackbars';
import type { AppConfig } from './context';
Expand Down
2 changes: 1 addition & 1 deletion client/dashboard/app/interim-omnibar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { hydrateRoot } from 'react-dom/client';
import type { OmnibarEvents } from './click-handlers';
import type { OmnibarEvents } from './omnibar-events';

export default async function loadOmnibar( events: OmnibarEvents ) {
const container = document.getElementById( 'wpcom-omnibar' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useQuery } from '@tanstack/react-query';
import { useCallback, useEffect, useState } from 'react';
import { AUTH_QUERY_KEY, initializeCurrentUser } from '../auth';
import { InterimOmnibar } from './interim-omnibar';
import type { OmnibarEvents } from './click-handlers';
import type { OmnibarEvents } from './omnibar-events';
import type { Site, User } from '@automattic/api-core';

interface InterimOmnibarContainerProps {
Expand Down
20 changes: 2 additions & 18 deletions client/dashboard/app/interim-omnibar/interim-omnibar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,12 @@ import { MasterbarLoggedIn } from 'calypso/layout/masterbar/logged-in';
import { recordTracksEvent } from 'calypso/lib/analytics/tracks';
import { getSiteDisplayName } from '../../utils/site-name';
import { logout } from '../auth';
import { omnibarEvents } from './click-handlers';
import { omnibarEvents } from './omnibar-events';
import { createOmnibarStore } from './omnibar-store';
import type { User, Site } from '@automattic/api-core';

const noop = () => {};

type StoreType = Parameters< typeof ReduxProvider >[ 0 ][ 'store' ];

// Fake Redux store so child components using connect() (e.g. Notifications) don't crash.
// Intercepts specific actions so the dashboard can handle them.
function createOmnibarStore( onToggleNotifications?: () => void ): StoreType {
return {
getState: () => ( { ui: { section: false, isNotificationsOpen: false } } ),
dispatch: ( action: { type: string } ) => {
if ( action.type === 'NOTIFICATIONS_PANEL_TOGGLE' ) {
onToggleNotifications?.();
}
return action;
},
subscribe: () => () => {},
} as unknown as StoreType;
}

// Separate query client for the legacy masterbar so its internal queries
// (e.g. useGetDomainsQuery in MasterbarLaunchButton) don't pollute the Dashboard cache.
const omnibarQueryClient = new QueryClient();
Expand Down
18 changes: 18 additions & 0 deletions client/dashboard/app/interim-omnibar/omnibar-store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Provider as ReduxProvider } from 'react-redux';

type StoreType = Parameters< typeof ReduxProvider >[ 0 ][ 'store' ];

// Fake Redux store so child components using connect() (e.g. Notifications) don't crash.
// Intercepts specific actions so the dashboard can handle them.
export function createOmnibarStore( onToggleNotifications?: () => void ): StoreType {
return {
getState: () => ( { ui: { section: false, isNotificationsOpen: false } } ),
dispatch: ( action: { type: string } ) => {
if ( action.type === 'NOTIFICATIONS_PANEL_TOGGLE' ) {
onToggleNotifications?.();
}
return action;
},
subscribe: () => () => {},
} as unknown as StoreType;
}
2 changes: 1 addition & 1 deletion client/dashboard/app/notifications/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Suspense, lazy, useCallback, useEffect, useState } from 'react';
import wpcom from 'calypso/lib/wp';
import { useAuth } from '../auth';
import { useHelpCenter } from '../help-center';
import { useOmnibarEvent } from '../interim-omnibar/click-handlers';
import { useOmnibarEvent } from '../interim-omnibar/omnibar-events';
import { useLocale } from '../locale';
import './style.scss';

Expand Down
2 changes: 1 addition & 1 deletion client/dashboard/app/root/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { bumpStat } from '../analytics';
import CommandPalette from '../command-palette';
import { useAppContext } from '../context';
import Header from '../header';
import { useOmnibarEvent } from '../interim-omnibar/click-handlers';
import { useOmnibarEvent } from '../interim-omnibar/omnibar-events';
import OmnibarHelpCenter from '../interim-omnibar/omnibar-help-center';
import { NavigationBlockerRegistry } from '../navigation-blocker';
import Notifications from '../notifications';
Expand Down
Loading