How to use the @jupyterlab/filebrowser.FileBrowserModel function in @jupyterlab/filebrowser

To help you get started, we’ve selected a few @jupyterlab/filebrowser 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-data-explorer / tests / test-filebrowser / src / model.spec.ts View on Github external
it('should be resilient to a slow initial fetch', async () => {
        let delayedServiceManager = new ServiceManager({ standby: 'never' });
        (delayedServiceManager as any).contents = new DelayedContentsManager();
        let manager = new DocumentManager({
          registry,
          opener,
          manager: delayedServiceManager
        });
        model = new FileBrowserModel({ manager, state }); // Should delay 1000ms

        // An initial refresh is called in the constructor.
        // If it is too slow, it can come in after the directory change,
        // causing a directory set by, e.g., the tree handler to be wrong.
        // This checks to make sure we are handling that case correctly.
        await model.cd('src'); // should delay 500ms
        await sleep(2000);
        expect(model.path).to.equal('src');

        manager.dispose();
        delayedServiceManager.contents.dispose();
        delayedServiceManager.dispose();
        model.dispose();
      });
    });
github jupyterlab / jupyterlab-data-explorer / jupyterlab / examples / filebrowser / src / index.ts View on Github external
let wFactory = new FileEditorFactory({
    editorServices,
    factoryOptions: {
      name: 'Editor',
      modelName: 'text',
      fileTypes: ['*'],
      defaultFor: ['*'],
      preferKernel: false,
      canStartKernel: true
    }
  });
  docRegistry.addWidgetFactory(wFactory);

  let commands = new CommandRegistry();

  let fbModel = new FileBrowserModel({ manager: docManager });
  let fbWidget = new FileBrowser({
    id: 'filebrowser',
    model: fbModel
  });

  // Add a creator toolbar item.
  let creator = new ToolbarButton({
    iconClassName: 'jp-AddIcon jp-Icon jp-Icon-16',
    onClick: () => {
      docManager
        .newUntitled({
          type: 'file',
          path: fbModel.path
        })
        .then(model => {
          docManager.open(model.path);
github yuvipanda / simplest-notebook / packages / filebrowser-extension / src / index.ts View on Github external
createFileBrowser(id: string, options: IFileBrowserFactory.IOptions = {}): FileBrowser {
      const model = new FileBrowserModel({
        manager: docManager,
        driveName: options.driveName || '',
        state: options.state === null ? null : options.state || state
      });
      const widget = new FileBrowser({
        id, model, commands: options.commands || commands
      });
      const { registry } = docManager;

      // Add a launcher toolbar item.
      let launcher = new ToolbarButton({
        className: 'jp-AddIcon',
        onClick: () => {
          return commands.execute('launcher:create', {
            cwd: widget.model.path
          });
github jupyterlab / jupyterlab / examples / filebrowser / src / index.ts View on Github external
let wFactory = new FileEditorFactory({
    editorServices,
    factoryOptions: {
      name: 'Editor',
      modelName: 'text',
      fileTypes: ['*'],
      defaultFor: ['*'],
      preferKernel: false,
      canStartKernel: true
    }
  });
  docRegistry.addWidgetFactory(wFactory);

  let commands = new CommandRegistry();

  let fbModel = new FileBrowserModel({
    manager: docManager,
    iconRegistry: defaultIconRegistry
  });
  let fbWidget = new FileBrowser({
    id: 'filebrowser',
    model: fbModel
  });

  // Add a creator toolbar item.
  let creator = new ToolbarButton({
    iconClassName: 'jp-AddIcon jp-Icon jp-Icon-16',
    onClick: () => {
      void docManager
        .newUntitled({
          type: 'file',
          path: fbModel.path
github jupyterlab / jupyterlab / packages / filebrowser-extension / src / index.ts View on Github external
const createFileBrowser = (
    id: string,
    options: IFileBrowserFactory.IOptions = {}
  ) => {
    const model = new FileBrowserModel({
      manager: docManager,
      driveName: options.driveName || '',
      refreshInterval: options.refreshInterval,
      state: options.state === null ? null : options.state || state
    });
    const widget = new FileBrowser({
      id,
      model
    });

    // Add a launcher toolbar item.
    let launcher = new ToolbarButton({
      iconClassName: 'jp-AddIcon',
      onClick: () => {
        return Private.createLauncher(commands, widget);
      },
github jupyterlab / jupyterlab-data-explorer / packages / filebrowser-extension / src / index.ts View on Github external
const createFileBrowser = (
    id: string,
    options: IFileBrowserFactory.IOptions = {}
  ) => {
    const model = new FileBrowserModel({
      manager: docManager,
      driveName: options.driveName || '',
      refreshInterval: options.refreshInterval,
      state: options.state === null ? null : options.state || state
    });
    const widget = new FileBrowser({
      id,
      model
    });

    // Add a launcher toolbar item.
    let launcher = new ToolbarButton({
      iconClassName: 'jp-AddIcon',
      onClick: () => {
        return Private.createLauncher(commands, widget);
      },
github jupyterlab / jupyterlab / tests / test-filebrowser / src / crumbs.spec.ts View on Github external
it('should be called when the model updates', async () => {
        const model = new FileBrowserModel({ iconRegistry, manager });
        await model.cd(path);
        crumbs = new LogCrumbs({ model });
        await model.cd('..');
        await framePromise();

        expect(crumbs.methods).to.contain('onUpdateRequest');
        const items = crumbs.node.querySelectorAll(ITEM_QUERY);
        expect(items.length).to.equal(3);
        model.dispose();
      });
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-filebrowser / src / model.spec.ts View on Github external
beforeEach(async () => {
    await state.clear();
    model = new FileBrowserModel({ manager, state });
    const contents = await manager.newUntitled({ type: 'file' });
    name = contents.name;
    return model.cd();
  });
github yuvipanda / simplest-notebook / src / filebrowser / page.tsx View on Github external
currentPath: this.props.startingPath
    };

    let opener = {
      open: (widget: Widget) => {
        console.log(widget);
      }
    }
    let docRegistry = new DocumentRegistry();
    this.docManager = new DocumentManager({
      registry: docRegistry,
      manager: this.props.serviceManager,
      opener
    });

    let fbModel = new FileBrowserModel({
      manager: this.docManager,
    });
    fbModel.cd(this.state.currentPath);
    this.fileBrowser = new FileBrowser({
      id: 'filebrowser',
      model: fbModel
    });

    fbModel.pathChanged.connect(this.pathChanged);
  }