How to use the @jupyterlab/application.Router function in @jupyterlab/application

To help you get started, we’ve selected a few @jupyterlab/application examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyterlab / jupyterlab / packages / application-extension / src / index.ts View on Github external
activate: (app: JupyterLab) => {
    const { commands } = app;
    const base = PageConfig.getOption('pageUrl');
    const router = new Router({ base, commands });

    commands.addCommand(CommandIDs.tree, {
      execute: (args: IRouter.ILocation) => {
        const path = decodeURIComponent((args.path.match(Patterns.tree)[1]));

        // File browser navigation waits for the application to be restored.
        // As a result, this command cannot return a promise because it would
        // create a circular dependency on the restored promise that would
        // cause the application to never restore.
        const opened = commands.execute('filebrowser:navigate-main', { path });

        // Change the URL back to the base application URL without adding the
        // URL change to the browser history.
        opened.then(() => { router.navigate('', { silent: true }); });
      }
    });
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / application-extension / src / index.tsx View on Github external
activate: (app: JupyterFrontEnd, paths: JupyterFrontEnd.IPaths) => {
    const { commands } = app;
    const base = paths.urls.base;
    const router = new Router({ base, commands });

    app.started.then(() => {
      // Route the very first request on load.
      router.route();

      // Route all pop state events.
      window.addEventListener('popstate', () => {
        router.route();
      });
    });

    return router;
  },
  autoStart: true,
github yuvipanda / simplest-notebook / packages / application-extension / src / index.tsx View on Github external
activate: (app: JupyterLab) => {
    const { commands } = app;
    const base = PageConfig.getOption('pageUrl');
    const router = new Router({ base, commands });

    commands.addCommand(CommandIDs.tree, {
      execute: (args: IRouter.ILocation) => {
        const path = decodeURIComponent((args.path.match(Patterns.tree)[1]));

        // File browser navigation waits for the application to be restored.
        // As a result, this command cannot return a promise because it would
        // create a circular dependency on the restored promise that would
        // cause the application to never restore.
        const opened = commands.execute('filebrowser:navigate-main', { path });

        // Change the URL back to the base application URL without adding the
        // URL change to the browser history.
        opened.then(() => { router.navigate('', { silent: true }); });
      }
    });
github jupyterlab / jupyterlab / packages / application-extension / src / index.tsx View on Github external
activate: (app: JupyterLab) => {
    const { commands } = app;
    const base = PageConfig.getOption('baseUrl');
    const router = new Router({ base, commands });

    app.started.then(() => {
      // Route the very first request on load.
      router.route();

      // Route all pop state events.
      window.addEventListener('popstate', () => {
        router.route();
      });
    });

    return router;
  },
  autoStart: true,
github jupyterlab / jupyterlab / packages / application-extension / src / index.tsx View on Github external
activate: (app: JupyterLab) => {
    const { commands } = app;
    const base = PageConfig.getOption('pageUrl');
    const router = new Router({ base, commands });

    commands.addCommand(CommandIDs.tree, {
      execute: (args: IRouter.ILocation) => {
        const path = decodeURIComponent((args.path.match(Patterns.tree)[1]));

        // File browser navigation waits for the application to be restored.
        // As a result, this command cannot return a promise because it would
        // create a circular dependency on the restored promise that would
        // cause the application to never restore.
        const opened = commands.execute('filebrowser:navigate-main', { path });

        // Change the URL back to the base application URL without adding the
        // URL change to the browser history.
        opened.then(() => { router.navigate('', { silent: true }); });
      }
    });
github jupyterlab / jupyterlab / tests / test-application / src / router.spec.ts View on Github external
beforeEach(() => {
      commands = new CommandRegistry();
      router = new Router({ base, commands });
    });