Remove duplicate page-id bridge API
- keep getCurrentPageId off the legacy shell bridge surface - leave page-id lookup on the router side where it is actually used - align the bridge tests and type definitions with the slimmer API
This commit is contained in:
parent
ed2b8d0e3d
commit
82115011b2
6 changed files with 0 additions and 12 deletions
|
|
@ -54,7 +54,6 @@ function mockIssuesFetch() {
|
||||||
|
|
||||||
function createShellBridge(overrides: Partial<ShellBridge> = {}): ShellBridge {
|
function createShellBridge(overrides: Partial<ShellBridge> = {}): ShellBridge {
|
||||||
return {
|
return {
|
||||||
getCurrentPageId: vi.fn<() => ShellPageId>(() => 'dashboard'),
|
|
||||||
getCurrentProfileContext: vi.fn(() => ({ profileId: 1, isAdmin: false })),
|
getCurrentProfileContext: vi.fn(() => ({ profileId: 1, isAdmin: false })),
|
||||||
isPageAllowed: vi.fn(() => true),
|
isPageAllowed: vi.fn(() => true),
|
||||||
getProfileHomePage: vi.fn<() => ShellPageId>(() => 'discover'),
|
getProfileHomePage: vi.fn<() => ShellPageId>(() => 'discover'),
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ describe('waitForShellContext', () => {
|
||||||
getProfileHomePage: vi.fn(() => 'discover'),
|
getProfileHomePage: vi.fn(() => 'discover'),
|
||||||
isPageAllowed: vi.fn(() => true),
|
isPageAllowed: vi.fn(() => true),
|
||||||
activateLegacyPath: vi.fn(),
|
activateLegacyPath: vi.fn(),
|
||||||
getCurrentPageId: vi.fn(() => 'issues'),
|
|
||||||
getCurrentProfileContext: vi.fn(() => ({ profileId: 2, isAdmin: true })),
|
getCurrentProfileContext: vi.fn(() => ({ profileId: 2, isAdmin: true })),
|
||||||
resolveLegacyPath: vi.fn(() => 'issues'),
|
resolveLegacyPath: vi.fn(() => 'issues'),
|
||||||
setActivePageChrome: vi.fn(),
|
setActivePageChrome: vi.fn(),
|
||||||
|
|
@ -36,7 +35,6 @@ describe('waitForShellContext', () => {
|
||||||
getProfileHomePage: vi.fn(() => 'discover'),
|
getProfileHomePage: vi.fn(() => 'discover'),
|
||||||
isPageAllowed: vi.fn(() => true),
|
isPageAllowed: vi.fn(() => true),
|
||||||
activateLegacyPath: vi.fn(),
|
activateLegacyPath: vi.fn(),
|
||||||
getCurrentPageId: vi.fn(() => 'issues'),
|
|
||||||
getCurrentProfileContext,
|
getCurrentProfileContext,
|
||||||
resolveLegacyPath: vi.fn(() => 'issues'),
|
resolveLegacyPath: vi.fn(() => 'issues'),
|
||||||
setActivePageChrome: vi.fn(),
|
setActivePageChrome: vi.fn(),
|
||||||
|
|
|
||||||
|
|
@ -79,9 +79,6 @@ export async function waitForShellContext(): Promise<ShellContext> {
|
||||||
export function bindWindowWebRouter(router: AnyRouter) {
|
export function bindWindowWebRouter(router: AnyRouter) {
|
||||||
window.SoulSyncWebRouter = {
|
window.SoulSyncWebRouter = {
|
||||||
routeManifest: [...shellRouteManifest],
|
routeManifest: [...shellRouteManifest],
|
||||||
getCurrentPageId() {
|
|
||||||
return resolveShellPageFromPath(window.location.pathname);
|
|
||||||
},
|
|
||||||
getCurrentPath() {
|
getCurrentPath() {
|
||||||
return normalizeShellPath(window.location.pathname);
|
return normalizeShellPath(window.location.pathname);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
2
webui/src/platform/shell/globals.d.ts
vendored
2
webui/src/platform/shell/globals.d.ts
vendored
|
|
@ -17,7 +17,6 @@ declare global {
|
||||||
};
|
};
|
||||||
SoulSyncWebRouter?: {
|
SoulSyncWebRouter?: {
|
||||||
routeManifest: ShellRouteDefinition[];
|
routeManifest: ShellRouteDefinition[];
|
||||||
getCurrentPageId: () => ShellPageId | null;
|
|
||||||
getCurrentPath: () => string;
|
getCurrentPath: () => string;
|
||||||
resolvePageId: (pathname: string) => ShellPageId | null;
|
resolvePageId: (pathname: string) => ShellPageId | null;
|
||||||
navigateToPage: (
|
navigateToPage: (
|
||||||
|
|
@ -28,7 +27,6 @@ declare global {
|
||||||
) => Promise<boolean>;
|
) => Promise<boolean>;
|
||||||
};
|
};
|
||||||
SoulSyncWebShellBridge?: {
|
SoulSyncWebShellBridge?: {
|
||||||
getCurrentPageId: () => ShellPageId;
|
|
||||||
getCurrentProfileContext: () => ShellProfileContext | null;
|
getCurrentProfileContext: () => ShellProfileContext | null;
|
||||||
isPageAllowed: (pageId: ShellPageId) => boolean;
|
isPageAllowed: (pageId: ShellPageId) => boolean;
|
||||||
getProfileHomePage: () => ShellPageId;
|
getProfileHomePage: () => ShellPageId;
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ function createResponse(body: unknown, ok = true, status = 200) {
|
||||||
|
|
||||||
function createShellBridge(overrides: Partial<ShellBridge> = {}): ShellBridge {
|
function createShellBridge(overrides: Partial<ShellBridge> = {}): ShellBridge {
|
||||||
return {
|
return {
|
||||||
getCurrentPageId: vi.fn<() => ShellPageId>(() => 'issues'),
|
|
||||||
getCurrentProfileContext: vi.fn(() => ({ profileId: 2, isAdmin: true })),
|
getCurrentProfileContext: vi.fn(() => ({ profileId: 2, isAdmin: true })),
|
||||||
isPageAllowed: vi.fn(() => true),
|
isPageAllowed: vi.fn(() => true),
|
||||||
getProfileHomePage: vi.fn<() => ShellPageId>(() => 'discover'),
|
getProfileHomePage: vi.fn<() => ShellPageId>(() => 'discover'),
|
||||||
|
|
|
||||||
|
|
@ -124,9 +124,6 @@ window.SoulSyncWorkflowActions = {
|
||||||
};
|
};
|
||||||
|
|
||||||
window.SoulSyncWebShellBridge = {
|
window.SoulSyncWebShellBridge = {
|
||||||
getCurrentPageId() {
|
|
||||||
return currentPage || getWebRouter()?.resolvePageId?.(window.location.pathname) || _getPageFromPath();
|
|
||||||
},
|
|
||||||
getCurrentProfileContext() {
|
getCurrentProfileContext() {
|
||||||
if (!currentProfile) return null;
|
if (!currentProfile) return null;
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue