Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/compass-app-stores/src/stores/instance-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}

Expand Down Expand Up @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

/**
Expand All @@ -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 <div className={styles['collection-stats-empty']} />;
}

Expand Down
5 changes: 3 additions & 2 deletions packages/compass-collection-stats/src/stores/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const store = Reflux.createStore({
getInitialState() {
return {
namespace: '',
isEditing: false,
isReadonly: false,
isTimeSeries: false,
documentCount: INVALID,
Expand Down Expand Up @@ -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');
}
Expand All @@ -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);

Expand Down
4 changes: 4 additions & 0 deletions packages/compass-collection-stats/src/stores/store.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions packages/compass-collection/src/modules/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ const createContext = ({
views.push(<UnsafeComponent component={role.component} key={i} store={store} actions={actions} />);
});

// Setup the stats in the collection HUD
const statsRole = globalAppRegistry.getRole('Collection.HUD')[0];
const statsPlugin = statsRole.component;
const statsStore = setupStore({
Expand All @@ -276,7 +275,8 @@ const createContext = ({
isReadonly,
isTimeSeries,
actions: {},
allowWrites: !isDataLake
allowWrites: !isDataLake,
isEditing: Boolean(editViewName)
});

// Setup the scoped modals
Expand Down