mirror of https://github.com/perkeep/perkeep.git
Add a link in the piggy drop down to importers UI
Change-Id: I4a2ba7127822e85f086ff4155c079a74ee31fae6
This commit is contained in:
parent
90d1df956f
commit
0d923c6207
|
@ -46,7 +46,7 @@ cam.Header = React.createClass({
|
||||||
onNewPermanode: React.PropTypes.func,
|
onNewPermanode: React.PropTypes.func,
|
||||||
onSearch: React.PropTypes.func,
|
onSearch: React.PropTypes.func,
|
||||||
searchRootsURL: React.PropTypes.instanceOf(goog.Uri).isRequired,
|
searchRootsURL: React.PropTypes.instanceOf(goog.Uri).isRequired,
|
||||||
syncStatusURL: React.PropTypes.instanceOf(goog.Uri).isRequired,
|
statusURL: React.PropTypes.instanceOf(goog.Uri).isRequired,
|
||||||
subControls: React.PropTypes.arrayOf(React.PropTypes.renderable),
|
subControls: React.PropTypes.arrayOf(React.PropTypes.renderable),
|
||||||
timer: React.PropTypes.shape({setTimeout:React.PropTypes.func.isRequired, clearTimeout:React.PropTypes.func.isRequired}).isRequired,
|
timer: React.PropTypes.shape({setTimeout:React.PropTypes.func.isRequired, clearTimeout:React.PropTypes.func.isRequired}).isRequired,
|
||||||
width: React.PropTypes.number.isRequired,
|
width: React.PropTypes.number.isRequired,
|
||||||
|
@ -60,10 +60,18 @@ cam.Header = React.createClass({
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return {
|
return {
|
||||||
currentSearch: this.props.currentSearch,
|
currentSearch: this.props.currentSearch,
|
||||||
|
importerRoot: null,
|
||||||
menuVisible: false,
|
menuVisible: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
componentWillMount: function() {
|
||||||
|
var req = new XMLHttpRequest();
|
||||||
|
req.open('GET', this.props.statusURL.resolve(new goog.Uri('status.json')), true);
|
||||||
|
req.onload = this.handleStatusLoad_;
|
||||||
|
req.send(null);
|
||||||
|
},
|
||||||
|
|
||||||
componentWillReceiveProps: function(nextProps) {
|
componentWillReceiveProps: function(nextProps) {
|
||||||
if (nextProps.currentSearch != this.props.currentSearch) {
|
if (nextProps.currentSearch != this.props.currentSearch) {
|
||||||
this.setState({currentSearch: nextProps.currentSearch});
|
this.setState({currentSearch: nextProps.currentSearch});
|
||||||
|
@ -192,12 +200,17 @@ cam.Header = React.createClass({
|
||||||
// TODO(aa): Also I keep going back and forth about whether we should call this 'permanode' or 'set' in the UI. Hrm.
|
// TODO(aa): Also I keep going back and forth about whether we should call this 'permanode' or 'set' in the UI. Hrm.
|
||||||
this.getMenuItemButton_('New set', this.props.onNewPermanode),
|
this.getMenuItemButton_('New set', this.props.onNewPermanode),
|
||||||
|
|
||||||
this.getMenuItemLink_('Search roots', this.props.searchRootsURL),
|
this.getMenuItemLink_('Importers', this.state.importerRoot),
|
||||||
this.getMenuItemLink_('Server status', this.props.syncStatusURL)
|
this.getMenuItemLink_('Server status', this.props.statusURL),
|
||||||
|
this.getMenuItemLink_('Search roots', this.props.searchRootsURL)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
getMenuItemLink_: function(text, link) {
|
getMenuItemLink_: function(text, link) {
|
||||||
|
if (!text || !link) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return React.DOM.a(
|
return React.DOM.a(
|
||||||
{
|
{
|
||||||
className: 'cam-header-menu-item',
|
className: 'cam-header-menu-item',
|
||||||
|
@ -293,4 +306,8 @@ cam.Header = React.createClass({
|
||||||
getSearchNode_: function() {
|
getSearchNode_: function() {
|
||||||
return this.refs['searchbox'].getDOMNode();
|
return this.refs['searchbox'].getDOMNode();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleStatusLoad_: function(e) {
|
||||||
|
this.setState({importerRoot: this.props.homeURL.resolve(new goog.Uri(JSON.parse(e.target.responseText)['importerRoot']))});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -376,7 +376,7 @@ cam.IndexPage = React.createClass({
|
||||||
onNewPermanode: this.handleCreateSetWithSelection_,
|
onNewPermanode: this.handleCreateSetWithSelection_,
|
||||||
onSearch: this.setSearch_,
|
onSearch: this.setSearch_,
|
||||||
searchRootsURL: this.getSearchRootsURL_(),
|
searchRootsURL: this.getSearchRootsURL_(),
|
||||||
syncStatusURL: this.baseURL_.resolve(new goog.Uri(this.props.config.statusRoot)),
|
statusURL: this.baseURL_.resolve(new goog.Uri(this.props.config.statusRoot)),
|
||||||
ref: 'header',
|
ref: 'header',
|
||||||
subControls: [
|
subControls: [
|
||||||
this.getClearSelectionItem_(),
|
this.getClearSelectionItem_(),
|
||||||
|
|
Loading…
Reference in New Issue