From bbcdd8d3fd72a7b306b47a953ae73c3f25bdd0b3 Mon Sep 17 00:00:00 2001 From: Thomas Rueckstiess Date: Mon, 28 Nov 2016 14:18:19 +1100 Subject: [PATCH 1/2] COMPASS-334 active state for sidebar entries --- .../sidebar/lib/components/sidebar-collection.jsx | 13 +++++++++++-- .../sidebar/lib/components/sidebar-database.jsx | 10 ++++++++-- .../lib/components/sidebar-instance-properties.jsx | 10 ++++++++-- .../sidebar/lib/components/sidebar.jsx | 14 +++++++++++--- src/internal-packages/sidebar/lib/stores/index.js | 14 ++++++++++++-- 5 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/internal-packages/sidebar/lib/components/sidebar-collection.jsx b/src/internal-packages/sidebar/lib/components/sidebar-collection.jsx index 51ad342553c..e887cffa0af 100644 --- a/src/internal-packages/sidebar/lib/components/sidebar-collection.jsx +++ b/src/internal-packages/sidebar/lib/components/sidebar-collection.jsx @@ -1,11 +1,15 @@ const app = require('ampersand-app'); const React = require('react'); +// const debug = require('debug')('mongodb-compass:sidebar:sidebar-collection'); const { NamespaceStore } = require('hadron-reflux-store'); class SidebarCollection extends React.Component { constructor() { super(); + this.state = { + active: false + }; this.handleClick = this.handleClick.bind(this); this.CollectionStore = app.appRegistry.getStore('App.CollectionStore'); } @@ -33,10 +37,14 @@ class SidebarCollection extends React.Component { render() { const collectionName = this.getCollectionName(); + let className = 'compass-sidebar-title compass-sidebar-title-is-actionable'; + if (this.props.activeNamespace === this.props._id) { + className += ' compass-sidebar-title-is-active'; + } return (
{collectionName}  {this.renderReadonly()} @@ -51,7 +59,8 @@ SidebarCollection.propTypes = { database: React.PropTypes.string, capped: React.PropTypes.bool, power_of_two: React.PropTypes.bool, - readonly: React.PropTypes.bool + readonly: React.PropTypes.bool, + activeNamespace: React.PropTypes.string.isRequired }; module.exports = SidebarCollection; diff --git a/src/internal-packages/sidebar/lib/components/sidebar-database.jsx b/src/internal-packages/sidebar/lib/components/sidebar-database.jsx index 74a48e881e0..8f193297a6f 100644 --- a/src/internal-packages/sidebar/lib/components/sidebar-database.jsx +++ b/src/internal-packages/sidebar/lib/components/sidebar-database.jsx @@ -19,7 +19,8 @@ class SidebarDatabase extends React.Component { database: c.database, capped: c.capped, power_of_two: c.power_of_two, - readonly: c.readonly + readonly: c.readonly, + activeNamespace: this.props.activeNamespace }; return ( @@ -46,9 +47,13 @@ class SidebarDatabase extends React.Component { } render() { + let className = 'compass-sidebar-item-header compass-sidebar-item-header-is-expandable compass-sidebar-item-header-is-actionable'; + if (this.props.activeNamespace === this.props._id) { + className += ' compass-sidebar-item-header-is-active'; + } return (
-
+
@@ -65,6 +70,7 @@ class SidebarDatabase extends React.Component { SidebarDatabase.propTypes = { _id: React.PropTypes.string, + activeNamespace: React.PropTypes.string.isRequired, collections: React.PropTypes.array }; diff --git a/src/internal-packages/sidebar/lib/components/sidebar-instance-properties.jsx b/src/internal-packages/sidebar/lib/components/sidebar-instance-properties.jsx index 8a4d474c4a7..11d5fa54429 100644 --- a/src/internal-packages/sidebar/lib/components/sidebar-instance-properties.jsx +++ b/src/internal-packages/sidebar/lib/components/sidebar-instance-properties.jsx @@ -58,9 +58,14 @@ class SidebarInstanceProperties extends React.Component { const hostnameAndPort = this.getHostnameAndPort(); const sshTunnelViaPort = this.getSshTunnelViaPort(); const versionName = this.getVersionName(); + let className = 'compass-sidebar-instance'; + // empty string for active namespace means instance level + if (this.props.activeNamespace === '') { + className += ' compass-sidebar-instance-is-active'; + } return (
-
+
{hostnameAndPort}
{sshTunnelViaPort} @@ -85,7 +90,8 @@ class SidebarInstanceProperties extends React.Component { SidebarInstanceProperties.propTypes = { connection: React.PropTypes.object, instance: React.PropTypes.object, - fetching: React.PropTypes.bool + fetching: React.PropTypes.bool, + activeNamespace: React.PropTypes.string.isRequired }; module.exports = SidebarInstanceProperties; diff --git a/src/internal-packages/sidebar/lib/components/sidebar.jsx b/src/internal-packages/sidebar/lib/components/sidebar.jsx index 63a65915804..d85f25eac52 100644 --- a/src/internal-packages/sidebar/lib/components/sidebar.jsx +++ b/src/internal-packages/sidebar/lib/components/sidebar.jsx @@ -7,6 +7,9 @@ const SidebarActions = require('../actions'); const SidebarDatabase = require('./sidebar-database'); const SidebarInstanceProperties = require('./sidebar-instance-properties'); +// const debug = require('debug')('mongodb-compass:sidebar:sidebar'); + + class Sidebar extends React.Component { handleFilter(event) { @@ -26,7 +29,10 @@ class Sidebar extends React.Component { return (
- +
@@ -37,7 +43,8 @@ class Sidebar extends React.Component { this.props.databases.map(db => { const props = { _id: db._id, - collections: db.collections + collections: db.collections, + activeNamespace: this.props.activeNamespace }; return ( @@ -52,7 +59,8 @@ class Sidebar extends React.Component { Sidebar.propTypes = { instance: React.PropTypes.object, - databases: React.PropTypes.array + databases: React.PropTypes.array, + activeNamespace: React.PropTypes.string }; module.exports = Sidebar; diff --git a/src/internal-packages/sidebar/lib/stores/index.js b/src/internal-packages/sidebar/lib/stores/index.js index a46f10a9a30..80e6801bda4 100644 --- a/src/internal-packages/sidebar/lib/stores/index.js +++ b/src/internal-packages/sidebar/lib/stores/index.js @@ -4,6 +4,7 @@ const StateMixin = require('reflux-state-mixin'); const SidebarActions = require('../actions'); const InstanceActions = app.appRegistry.getAction('App.InstanceActions'); +const { NamespaceStore } = require('hadron-reflux-store'); const debug = require('debug')('mongodb-compass:stores:sidebar'); @@ -26,7 +27,9 @@ const SidebarStore = Reflux.createStore({ /** * Initialize everything that is not part of the store's state. */ - init() {}, + init() { + NamespaceStore.listen(this.onNamespaceChanged.bind(this)); + }, /** * Initialize the Compass Sidebar store state. @@ -37,10 +40,17 @@ const SidebarStore = Reflux.createStore({ return { instance: {}, databases: [], - filterRegex: /.*/ + filterRegex: /.*/, + activeNamespace: '' }; }, + onNamespaceChanged() { + this.setState({ + activeNamespace: NamespaceStore.ns || '' + }); + }, + setInstance(instance) { this.setState({ instance, From 3c9b93a5819291616ca1c5f78791c05afd63cc75 Mon Sep 17 00:00:00 2001 From: Thomas Rueckstiess Date: Mon, 28 Nov 2016 14:20:14 +1100 Subject: [PATCH 2/2] make refresh icon white as well --- src/internal-packages/sidebar/styles/index.less | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/internal-packages/sidebar/styles/index.less b/src/internal-packages/sidebar/styles/index.less index 0d2cf2b35f3..4213a1912ac 100644 --- a/src/internal-packages/sidebar/styles/index.less +++ b/src/internal-packages/sidebar/styles/index.less @@ -107,6 +107,10 @@ color: #9DA4AA; } + &.fa-rotate-90 { + color: #fff; + } + &-database-icon { position: absolute; top: 6px;