Skip to content

Commit

Permalink
collections view mounts properly
Browse files Browse the repository at this point in the history
  • Loading branch information
KeyboardTsundoku committed Dec 13, 2016
1 parent 92d8973 commit 89cbce4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
28 changes: 15 additions & 13 deletions src/internal-packages/collection/lib/components/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const React = require('react');
const app = require('ampersand-app');
const semver = require('semver');
const toNS = require('mongodb-ns');
const NamespaceStore = require('hadron-reflux-store').NamespaceStore;
// const NamespaceStore = require('hadron-reflux-store').NamespaceStore;

class Collection extends React.Component {
constructor(props) {
Expand All @@ -24,18 +24,19 @@ class Collection extends React.Component {
this.Validation = app.appRegistry.getComponent('Validation.Validation');

this.CollectionStore = app.appRegistry.getStore('App.CollectionStore');
}

NamespaceStore.listen((ns) => {
if (ns && toNS(ns).collection) {
this.setState({
name: ns,
showView: true,
activeTab: this.CollectionStore && this.CollectionStore.getActiveTab()
});
} else {
this.setState({name: '', showView: false, activeTab: 0});
}
});
componentWillMount() {
const ns = this.props.namespace;
if (ns && toNS(ns).collection) {
this.setState({
name: ns,
showView: true,
activeTab: this.CollectionStore && this.CollectionStore.getActiveTab()
});
} else {
this.setState({name: '', showView: false, activeTab: 0});
}
}

onTabClicked(idx) {
Expand Down Expand Up @@ -98,7 +99,8 @@ class Collection extends React.Component {
}

Collection.propTypes = {
showView: React.PropTypes.bool
showView: React.PropTypes.bool,
namespace: React.PropTypes.string
};

Collection.displayName = 'Collection';
Expand Down
8 changes: 5 additions & 3 deletions src/internal-packages/home/lib/components/home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ class Home extends React.Component {

renderContent() {
let view;
console.log('collectionview', this.props.namespace);
switch (this.props.mode) {
case 'database':
view = (<this.collectionsTable />);
break;
case 'collection':
view = (<this.collectionView />);
view = (<this.collectionView namespace={this.props.namespace} />);
break;
default:
view = (<this.serverStatsView interval={1000}/>);
}

return view; // ; // (<div>Hello world</div>);
return view;
}

render() {
Expand All @@ -66,7 +67,8 @@ class Home extends React.Component {

Home.propTypes = {
hasContent: React.PropTypes.bool,
mode: React.PropTypes.oneOf(['instance', 'database', 'collection'])
mode: React.PropTypes.oneOf(['instance', 'database', 'collection']),
namespace: React.PropTypes.string
};

Home.displayName = 'Home';
Expand Down
9 changes: 5 additions & 4 deletions src/internal-packages/home/lib/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const HomeStore = Reflux.createStore({
return {
// mode can be one of instance, database, collection
mode: 'instance',
hasContent: false
hasContent: false,
namespace: ''
};
},

Expand All @@ -51,13 +52,13 @@ const HomeStore = Reflux.createStore({
const ns = toNS(namespace);
if (ns.database === '') {
// top of the side bar was clicked, render server stats
this.setState({mode: 'instance'});
this.setState({mode: 'instance', namespace: namespace});
} else if (ns.collection === '') {
// a database was clicked, render collections table
this.setState({mode: 'database'});
this.setState({mode: 'database', namespace: namespace});
} else {
// show collection view
this.setState({mode: 'collection'});
this.setState({mode: 'collection', namespace: namespace});
}
this.updateTitle(ns);
},
Expand Down

0 comments on commit 89cbce4

Please sign in to comment.