Github user robertkowalski commented on a diff in the pull request: https://github.com/apache/couchdb-fauxton/pull/651#discussion_r55555303 --- Diff: app/addons/documents/sidebar/sidebar.react.jsx --- @@ -110,38 +120,92 @@ function (app, FauxtonAPI, React, ReactDOM, Stores, Actions, </ul> ); } - }); + var IndexSection = React.createClass({ propTypes: { urlNamespace: React.PropTypes.string.isRequired, - databaseName: React.PropTypes.string.isRequired, + indexLabel: React.PropTypes.string.isRequired, + database: React.PropTypes.object.isRequired, designDocName: React.PropTypes.string.isRequired, items: React.PropTypes.array.isRequired, isExpanded: React.PropTypes.bool.isRequired, - selectedIndex: React.PropTypes.string.isRequired + selectedIndex: React.PropTypes.string.isRequired, + onDelete: React.PropTypes.func.isRequired, + onClone: React.PropTypes.func.isRequired }, createItems: function () { - return _.map(this.props.items, function (index, key) { - var href = FauxtonAPI.urls(this.props.urlNamespace, 'app', this.props.databaseName, this.props.designDocName); - var className = (this.props.selectedIndex === index) ? 'active' : ''; + + // sort the indexes alphabetically + var sortedItems = this.props.items.sort(); + + return _.map(sortedItems, function (indexName, index) { + var href = FauxtonAPI.urls(this.props.urlNamespace, 'app', this.props.database.id, this.props.designDocName); + var className = (this.props.selectedIndex === indexName) ? 'active' : ''; return ( - <li className={className} key={key}> + <li className={className} key={index}> <a - id={this.props.designDocName + '_' + index} - href={"#/" + href + index} + id={this.props.designDocName + '_' + indexName} + href={"#/" + href + indexName} className="toggle-view"> - {index} + {indexName} </a> + + <OverlayTrigger + ref="indexMenu" + trigger="click" + placement="bottom" + rootClose={true} + overlay={ + <Popover id="index-menu-component-popover"> + <ul> + <li onClick={this.indexAction.bind(this, 'edit', { indexName: indexName, onEdit: this.props.onEdit })}> + <span className="fonticon fonticon-file-code-o"></span> + Edit + </li> + <li onClick={this.indexAction.bind(this, 'clone', { indexName: indexName, onClone: this.props.onClone })}> + <span className="fonticon fonticon-files-o"></span> + Clone + </li> + <li onClick={this.indexAction.bind(this, 'delete', { indexName: indexName, onDelete: this.props.onDelete })}> + <span className="fonticon fonticon-trash"></span> + Delete + </li> + </ul> + </Popover> + }> + <span className="index-menu-toggle fonticon fonticon-wrench2"></span> + </OverlayTrigger> + </li> ); }, this); }, + indexAction: function (action, params, e) { + e.preventDefault(); + + // bah. We need to close the overlay trigger whenever the user clicks on anything inside. The + // component doesn't have that functionality, so we simulate a click outside of it :( + $('body').trigger('click'); --- End diff -- the overlay component has an interface. give it a `ref` and then you can call `hide` and `show` on it, example: https://github.com/apache/couchdb-fauxton/blob/0c07ddc432c12895310592b0c46729feaac958db/app/addons/components/react-components.react.jsx#L198-L206
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---