findUsingIndex: function()

in app/addons/documents/routes-mango.js [54:93]


  findUsingIndex: function (database, partitionKey) {
    const encodedPartitionKey = partitionKey ? encodeURIComponent(partitionKey) : '';
    const url = FauxtonAPI.urls(
      'allDocs', 'app', encodeURIComponent(this.databaseName), encodedPartitionKey
    );

    const partKeyUrlComponent = partitionKey ? `/${encodedPartitionKey}` : '';
    const fetchUrl = '/' + encodeURIComponent(this.databaseName) + partKeyUrlComponent + '/_find';

    const crumbs = [
      {name: database, link: url},
      {name: app.i18n.en_US['mango-title-editor']}
    ];

    const endpoint = FauxtonAPI.urls('mango', 'query-apiurl', encodeURIComponent(this.databaseName), encodedPartitionKey);

    const navigateToPartitionedView = (partKey) => {
      const baseUrl = FauxtonAPI.urls('mango', 'query-app', encodeURIComponent(database),
        encodeURIComponent(partKey));
      FauxtonAPI.navigate('#/' + baseUrl);
    };
    const navigateToGlobalView = () => {
      const baseUrl = FauxtonAPI.urls('mango', 'query-app', encodeURIComponent(database));
      FauxtonAPI.navigate('#/' + baseUrl);
    };

    return <MangoLayoutContainer
      database={database}
      crumbs={crumbs}
      docURL={FauxtonAPI.constants.DOC_URLS.MANGO_SEARCH}
      endpoint={endpoint}
      edit={false}
      databaseName={this.databaseName}
      fetchUrl={fetchUrl}
      partitionKey={partitionKey}
      onPartitionKeySelected={navigateToPartitionedView}
      onGlobalModeSelected={navigateToGlobalView}
      globalMode={partitionKey === ''}
    />;
  },