diff --git a/packages/compass-app-stores/src/stores/instance-store.js b/packages/compass-app-stores/src/stores/instance-store.js index 75428e14b31..0d243e00703 100644 --- a/packages/compass-app-stores/src/stores/instance-store.js +++ b/packages/compass-app-stores/src/stores/instance-store.js @@ -60,7 +60,7 @@ store.fetchDatabaseDetails = async(dbName, { nameOnly = false } = {}) => { const { instance, dataService } = store.getState(); const db = instance.databases.get(dbName); - if (db && db.collectionsStatus === 'initial') { + if (db.collectionsStatus === 'initial') { await db.fetchCollections({ dataService, fetchInfo: !nameOnly }); } @@ -162,6 +162,14 @@ store.onActivated = (appRegistry) => { store.fetchDatabaseDetails(dbName, { nameOnly: true }); }); + appRegistry.on('select-namespace', ({ namespace }) => { + store.fetchCollectionDetails(namespace); + }); + + appRegistry.on('open-namespace-in-new-tab', ({ namespace }) => { + store.fetchCollectionDetails(namespace); + }); + appRegistry.on('refresh-data', () => { store.refreshInstance(appRegistry); }); diff --git a/packages/compass-collection-stats/src/components/collection-stats/collection-stats.jsx b/packages/compass-collection-stats/src/components/collection-stats/collection-stats.jsx index 39011da24f9..f9ac87c35e9 100644 --- a/packages/compass-collection-stats/src/components/collection-stats/collection-stats.jsx +++ b/packages/compass-collection-stats/src/components/collection-stats/collection-stats.jsx @@ -17,7 +17,8 @@ class CollectionStats extends Component { totalIndexSize: PropTypes.string, avgIndexSize: PropTypes.string, isReadonly: PropTypes.bool, - isTimeSeries: PropTypes.bool + isTimeSeries: PropTypes.bool, + isEditing: PropTypes.bool }; /** @@ -26,7 +27,7 @@ class CollectionStats extends Component { * @returns {React.Component} The rendered component. */ render() { - if (this.props.isReadonly === true) { + if (this.props.isReadonly === true || this.props.isEditing === true) { return
; } diff --git a/packages/compass-collection-stats/src/stores/store.js b/packages/compass-collection-stats/src/stores/store.js index 0456f1c6e61..4cc0cf9bd0f 100644 --- a/packages/compass-collection-stats/src/stores/store.js +++ b/packages/compass-collection-stats/src/stores/store.js @@ -44,6 +44,7 @@ const store = Reflux.createStore({ getInitialState() { return { namespace: '', + isEditing: false, isReadonly: false, isTimeSeries: false, documentCount: INVALID, @@ -125,7 +126,7 @@ function onInstanceDestroyed() { /** * Collection Stats store. */ -const configureStore = ({ namespace, globalAppRegistry } = {}) => { +const configureStore = ({ namespace, globalAppRegistry, isEditing = false } = {}) => { if (!namespace) { throw new Error('Trying to render collection stats without namespace'); } @@ -151,7 +152,7 @@ const configureStore = ({ namespace, globalAppRegistry } = {}) => { instance.on('change:collections.status', onCollectionStatusChange); } - store.setState({ namespace }); + store.setState({ namespace, isEditing }); const { database, ns } = toNS(namespace); diff --git a/packages/compass-collection-stats/src/stores/store.spec.js b/packages/compass-collection-stats/src/stores/store.spec.js index e87bfe2749b..b646aed7a95 100644 --- a/packages/compass-collection-stats/src/stores/store.spec.js +++ b/packages/compass-collection-stats/src/stores/store.spec.js @@ -53,6 +53,7 @@ describe('CollectionStats [store]', function() { const store = configureStore({ globalAppRegistry, namespace: 'foo.bar' }); expect(store.state).to.deep.eq({ namespace: 'foo.bar', + isEditing: false, isReadonly: false, isTimeSeries: false, documentCount: 'N/A', @@ -71,6 +72,7 @@ describe('CollectionStats [store]', function() { }); expect(store.state).to.deep.eq({ namespace: 'bar.woof', + isEditing: false, isReadonly: false, isTimeSeries: false, documentCount: '100', @@ -90,6 +92,7 @@ describe('CollectionStats [store]', function() { expect(store.state).to.deep.eq({ namespace: 'baz.meow', + isEditing: false, isReadonly: false, isTimeSeries: false, documentCount: 'N/A', @@ -110,6 +113,7 @@ describe('CollectionStats [store]', function() { expect(store.state).to.deep.eq({ namespace: 'baz.meow', + isEditing: false, isReadonly: false, isTimeSeries: false, documentCount: '5', diff --git a/packages/compass-collection/src/modules/context.js b/packages/compass-collection/src/modules/context.js index 5f33cad90a0..e67fb4c689a 100644 --- a/packages/compass-collection/src/modules/context.js +++ b/packages/compass-collection/src/modules/context.js @@ -263,7 +263,6 @@ const createContext = ({ views.push(); }); - // Setup the stats in the collection HUD const statsRole = globalAppRegistry.getRole('Collection.HUD')[0]; const statsPlugin = statsRole.component; const statsStore = setupStore({ @@ -276,7 +275,8 @@ const createContext = ({ isReadonly, isTimeSeries, actions: {}, - allowWrites: !isDataLake + allowWrites: !isDataLake, + isEditing: Boolean(editViewName) }); // Setup the scoped modals