Commit 9fdd66b0 authored by Lyza Danger Gardner's avatar Lyza Danger Gardner Committed by Lyza Gardner

Add support for `notebook` routing in sidebar

parent 33067d0d
...@@ -194,6 +194,7 @@ function HypothesisApp({ ...@@ -194,6 +194,7 @@ function HypothesisApp({
{route === 'annotation' && ( {route === 'annotation' && (
<AnnotationViewerContent onLogin={login} /> <AnnotationViewerContent onLogin={login} />
)} )}
{route === 'notebook' && <StreamContent />}
{route === 'stream' && <StreamContent />} {route === 'stream' && <StreamContent />}
{route === 'sidebar' && ( {route === 'sidebar' && (
<SidebarContent onLogin={login} onSignUp={signUp} /> <SidebarContent onLogin={login} onSignUp={signUp} />
......
...@@ -115,6 +115,10 @@ describe('HypothesisApp', () => { ...@@ -115,6 +115,10 @@ describe('HypothesisApp', () => {
route: 'sidebar', route: 'sidebar',
contentComponent: 'SidebarContent', contentComponent: 'SidebarContent',
}, },
{
route: 'notebook',
contentComponent: 'StreamContent',
},
{ {
route: 'stream', route: 'stream',
contentComponent: 'StreamContent', contentComponent: 'StreamContent',
......
...@@ -38,11 +38,6 @@ if (appConfig.googleAnalytics) { ...@@ -38,11 +38,6 @@ if (appConfig.googleAnalytics) {
addAnalytics(appConfig.googleAnalytics); addAnalytics(appConfig.googleAnalytics);
} }
const isSidebar = !(
window.location.pathname.startsWith('/stream') ||
window.location.pathname.startsWith('/a/')
);
// Install Preact renderer options to work around browser quirks // Install Preact renderer options to work around browser quirks
rendererOptions.setupBrowserFixes(); rendererOptions.setupBrowserFixes();
...@@ -91,9 +86,9 @@ function autosave(autosaveService) { ...@@ -91,9 +86,9 @@ function autosave(autosaveService) {
} }
// @inject // @inject
function setupFrameSync(frameSync) { function setupFrameSync(frameSync, isSidebar) {
if (isSidebar) { if (isSidebar) {
frameSync.connect(); frameSync.connect(true);
} }
} }
...@@ -140,6 +135,12 @@ import { Injector } from '../shared/injector'; ...@@ -140,6 +135,12 @@ import { Injector } from '../shared/injector';
function startApp(config) { function startApp(config) {
const container = new Injector(); const container = new Injector();
const isSidebar = !(
window.location.pathname.startsWith('/stream') ||
window.location.pathname.startsWith('/a/') ||
window.location.pathname.startsWith('/notebook')
);
// Register services. // Register services.
container container
.register('analytics', analyticsService) .register('analytics', analyticsService)
......
...@@ -15,11 +15,15 @@ export default function router($window, store) { ...@@ -15,11 +15,15 @@ export default function router($window, store) {
const params = queryString.parse($window.location.search); const params = queryString.parse($window.location.search);
let route; let route;
switch (pathSegments[0]) { switch (pathSegments[0]) {
case 'a': case 'a':
route = 'annotation'; route = 'annotation';
params.id = pathSegments[1] || ''; params.id = pathSegments[1] || '';
break; break;
case 'notebook':
route = 'notebook';
break;
case 'stream': case 'stream':
route = 'stream'; route = 'stream';
break; break;
...@@ -47,6 +51,9 @@ export default function router($window, store) { ...@@ -47,6 +51,9 @@ export default function router($window, store) {
url = `/a/${id}`; url = `/a/${id}`;
} }
break; break;
case 'notebook':
url = '/notebook';
break;
case 'stream': case 'stream':
url = '/stream'; url = '/stream';
break; break;
......
...@@ -7,6 +7,11 @@ const fixtures = [ ...@@ -7,6 +7,11 @@ const fixtures = [
route: 'sidebar', route: 'sidebar',
params: {}, params: {},
}, },
{
path: '/notebook',
route: 'notebook',
params: {},
},
{ {
path: '/a/foo', path: '/a/foo',
route: 'annotation', route: 'annotation',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment