Skip to content

Conversation

satyasinha
Copy link

Needs testing and reviewing.

Have noticed a bug where building a query on one collection, applying and switching to another collection leads to the schema store to constantly run.

@satyasinha satyasinha force-pushed the COMPASS-98-React-Convert-Collection branch from 97103ce to 71d4658 Compare November 15, 2016 04:39
@satyasinha
Copy link
Author

the document and explain plan is still running twice when both query and namespace changes are taking place. Still working on this.

@satyasinha satyasinha force-pushed the COMPASS-98-React-Convert-Collection branch from 71d4658 to d6442a6 Compare November 16, 2016 05:54
Copy link
Contributor

@rueckstiess rueckstiess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change also breaks the functional tests again (was expected). Let's try to fix them. It's probably just some new css selectors for the tabs that need to be changed to the new elements.

@@ -1,5 +1,5 @@
var View = require('ampersand-view');
var Action = require('hadron-action');
// var Action = require('hadron-action');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is ./src/app/home/collection.js still used? If not, you can delete the entire file.

.page
.content.with-sidebar
div(data-hook='collection-subview')
div(data-hook='collection-new-view')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you rename it back to collection-view or collection-subview and remove the comment? (and also change it accordingly in ./src/app/home/index.js? We don't want the word new in there because after we merge, old is the new new :-)


NamespaceStore.listen((ns) => {
if (ns && toNS(ns).collection) {
this.setState({name: toNS(ns).collection, showView: true, activeTab: this.CollectionStore.getActiveTab()});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not directly call functions on a store. The store passes all the required information down to the component as props. If something you need is missing, you should add it to the store state, and retrieve it as this.props.activeTab.

}

onTabClicked(idx) {
this.setState({activeTab: idx});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two issues here:

  • again, never call store functions directly. Everything needs to go via an action. There should be a setActiveTab(idx) action that the store listens to, and then passes down it's state.
  • subtlety with setState and props: calling setState() will trigger a render(). But the action (see above) will cause a store change and also trigger a render(), so you render twice. The right way to do this is to use the componentWillReceiveProps() hook and change the state internally there. Let's discuss this one in person.

* Fetch the state when the component mounts.
*/
componentDidMount() {
debug('is doc list being mounted');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove debug.

if (filter === null) {
return;
}
debug('reset is called....');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove debug.

const options = { limit: 20, sort: [[ '_id', 1 ]], readPreference: READ };
app.dataService.find(NamespaceStore.ns, filter, options, (error, documents) => {
if (!error) {
debug('reset is called.... 2');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this one :)

<div className="compass-explain header-margin">
<div className="flexbox-fix"></div>
<this.queryBar />
{this.CollectionStore.isReadonly() ? this.renderReadonly() : this.renderComponent()}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. I realize now that Durran also calls store functions directly. This goes against the flux pattern. So I guess you were just following his example. I'd like to use the flux pattern as closely as possible, and will also talk to Durran about it so we are on the same page.

const IndexModel = require('mongodb-index-model');
const NamespaceStore = require('hadron-reflux-store').NamespaceStore;
const Action = require('../action/index-actions');
// const Action = require('../action/index-actions');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove all lines that are commented out and no longer needed.

init: function() {
this.CollectionStore = app.appRegistry.getStore('App.CollectionStore');
this.listenTo(Action.loadIndexes, this.loadIndexes);
// this.listenTo(Action.loadIndexes, this.loadIndexes);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one too.

@satyasinha
Copy link
Author

This push fixes most of the above, working on realigning functional tests now

@satyasinha satyasinha force-pushed the COMPASS-98-React-Convert-Collection branch from ba1fcb1 to a7af8c9 Compare November 19, 2016 11:56
@satyasinha
Copy link
Author

satyasinha commented Nov 19, 2016

For some bizarre reason I can't select the query bar reset button in the functional tests. Otherwise the tests seem mostly fine. This should now be reviewed by a few.

@pzrq
Copy link
Contributor

pzrq commented Nov 20, 2016

@KeyboardTsundoku

screen shot 2016-11-21 at 10 41 15 am

@satyasinha
Copy link
Author

@pzrq good catch, not sure how that disappeared since we wouldn't have touched that

@durran
Copy link
Member

durran commented Nov 21, 2016

Just a heads up - the create collection button is visible only if the server is writable. This means only a mongos, standalone, or replica set primary connection would have the button visible. Not sure if that was the case with @pzrq 's comment but something to note.

@satyasinha
Copy link
Author

It's more the light theme of the top navbar, it has top css property of 60 but the dark theme doesn't.
The database view uses light theme but if a dark theme was used it'll fix it. Seems sort of inconsistent.....

@rueckstiess
Copy link
Contributor

oh, yes there should be no difference other than color between light and dark theme.

@rueckstiess rueckstiess force-pushed the COMPASS-98-React-Convert-Collection branch from 66318c9 to 969b76e Compare November 21, 2016 05:36
@rueckstiess rueckstiess merged commit d0f5642 into master Nov 21, 2016
@rueckstiess rueckstiess deleted the COMPASS-98-React-Convert-Collection branch November 21, 2016 05:42
pzrq pushed a commit that referenced this pull request Nov 22, 2016
* COMPASS-98 added query bar to schema

* COMPASS-98 added collection component

* COMPASS-98 added query bar to CRUD and Explain

* COMPASS-98 cleaned up collection package

* COMPASS-98 fixing index

* COMPASS-98 add options to QueryStore and add QueryChangedStore (#590)

* COMPASS-98 add options to QueryStore and add QueryChangedStore

* fix typo

* comments

* pass all other query options to QueryChangedStore. (#592)

* COMPASS-98 listening to namespace for crud and indexes init

* COMPASS-98 crud, schema and explain listens to query changes + removed x from schema action/store files

* COMPASS-98 added fix to Explain plan not resetting on collection change

* COMPASS-98 tests working and schema sample bug fixed

* COMPASS-98 CRUD and explain working

* COMPASS-98 switching between collection and db view

* COMPASS-98 set name of collection

* COMPASS-98 document & indexes loading on mount

* COMPASS-98 made no difference on styling :(

* COMPASS-98 removed hanging console.log

* COMPASS-98 a slightly safer way of preventing double resets for crud

* Header repositioning fix

* COMPASS-98 fix bug where minicharts don’t rerender...

...when updating namespace and schema view was active.

* COMPASS-98 fix bug where minicharts don’t rerender...

...when updating namespace and schema view was active.

cherry-picking deb2133

* fix linter issue.

* fix linter issue.

* COMPASS-98 minor changes to remove comments

* COMPASS-98 removed unused files

* COMPASS-98 removed useless flexbox-fixed class

* using collection 'store' method instead

* removed debugs

* full namespace as title instead of just collection name

* COMPASS-98 adding id to tabs

* 5 passing functional tests!

* splitting functional test of query refine and apply

* supporting more test cases!

* COMPASS-98 most functional tests working

* added extra margin top to show the create button

* skip reset test instead of commenting out.
@pzrq
Copy link
Contributor

pzrq commented Nov 22, 2016

Backported to 1.5-releases, see also #611, #558, #600

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants