allDocs: function()

in app/addons/documents/routes-documents.js [102:152]


  allDocs: function (databaseName, partitionKey, options) {
    const params = this.createParams(options);
    const docParams = params.docParams;

    const url = partitionKey ?
      FauxtonAPI.urls('partitioned_allDocs', 'server', encodeURIComponent(databaseName), encodeURIComponent(partitionKey)) :
      FauxtonAPI.urls('allDocsSanitized', 'server', databaseName);

    // this is used for the header and sidebar
    this.database.buildAllDocs(docParams);

    const onlyShowDdocs = !!(docParams.startkey && docParams.startkey.indexOf("_design") > -1);
    let tab = 'all-docs';
    if (onlyShowDdocs) {
      tab = 'design-docs';
    }

    const selectedNavItem = new SidebarItemSelection(tab);
    ComponentsActions.showDeleteDatabaseModal({showDeleteModal: false, dbId: ''});

    const endpoint = partitionKey ?
      FauxtonAPI.urls('partitioned_allDocs', 'apiurl', encodeURIComponent(databaseName), encodeURIComponent(partitionKey)) :
      this.database.allDocs.urlRef("apiurl", {});
    const docURL = FauxtonAPI.constants.DOC_URLS.GENERAL;
    const navigateToPartitionedAllDocs = (partKey) => {
      const baseUrl = FauxtonAPI.urls('partitioned_allDocs', 'app', encodeURIComponent(databaseName),
        encodeURIComponent(partKey));
      FauxtonAPI.navigate('#/' + baseUrl);
    };
    const navigateToGlobalAllDocs = () => {
      const baseUrl = FauxtonAPI.urls('allDocs', 'app', encodeURIComponent(databaseName));
      FauxtonAPI.navigate('#/' + baseUrl);
    };
    const dropDownLinks = this.getCrumbs(this.database);
    DatabaseActions.fetchSelectedDatabaseInfo(databaseName);
    return <DocsTabsSidebarLayout
      docURL={docURL}
      endpoint={endpoint}
      dbName={this.database.id}
      dropDownLinks={dropDownLinks}
      database={this.database}
      designDocs={this.designDocs}
      fetchUrl={url}
      ddocsOnly={onlyShowDdocs}
      selectedNavItem={selectedNavItem}
      partitionKey={partitionKey}
      onPartitionKeySelected={navigateToPartitionedAllDocs}
      onGlobalModeSelected={navigateToGlobalAllDocs}
      globalMode={partitionKey === ''}
    />;
  },