From 7ceb961eeadb777c08e3a2d205dbf735f9a0b4ce Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Thu, 28 Jul 2016 15:23:25 +0200 Subject: [PATCH 1/2] INT-1686: Use new app registry --- package.json | 4 ++-- src/app/documents/document-list.js | 2 +- src/app/index.js | 4 ++-- src/internal-packages/crud/index.js | 9 +++++++-- .../crud/lib/component/binary-value.jsx | 2 +- src/internal-packages/crud/lib/component/code-value.jsx | 2 +- src/internal-packages/crud/lib/component/document.jsx | 2 +- .../crud/lib/component/editable-value.jsx | 2 +- 8 files changed, 16 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 8665d2c2545..560d41a37b7 100644 --- a/package.json +++ b/package.json @@ -100,10 +100,10 @@ "electron-squirrel-startup": "^0.1.4", "font-awesome": "https://github.com/FortAwesome/Font-Awesome/archive/v4.4.0.tar.gz", "get-object-path": "azer/get-object-path#74eb42de0cfd02c14ffdd18552f295aba723d394", - "hadron-action": "^0.0.4", + "hadron-action": "^0.1.0", "hadron-auto-update-manager": "^0.0.12", "hadron-compile-cache": "^0.3.0", - "hadron-component-registry": "^0.4.0", + "hadron-app-registry": "^1.0.0", "hadron-document": "^0.16.0", "hadron-ipc": "^0.0.7", "hadron-module-cache": "^0.0.3", diff --git a/src/app/documents/document-list.js b/src/app/documents/document-list.js index a4cb8ba0351..f386e1a4fe1 100644 --- a/src/app/documents/document-list.js +++ b/src/app/documents/document-list.js @@ -18,7 +18,7 @@ var DocumentListView = View.extend({ } }, initialize: function() { - this.documentList = app.componentRegistry.findByRole('Collection:DocumentList')[0]; + this.documentList = app.appRegistry.getComponent('Component::CRUD::DocumentList'); this.listenTo(app.queryOptions, 'change:query', this.onQueryChanged.bind(this)); }, onQueryChanged: function() { diff --git a/src/app/index.js b/src/app/index.js index afbbe1154de..42572b3d4e3 100644 --- a/src/app/index.js +++ b/src/app/index.js @@ -11,7 +11,7 @@ var ModuleCache = require('hadron-module-cache'); ModuleCache.register(resourcePath); ModuleCache.add(resourcePath); -var ComponentRegistry = require('hadron-component-registry'); +var AppRegistry = require('hadron-app-registry'); var PackageManager = require('hadron-package-manager').PackageManager; var pkg = require('../../package.json'); @@ -73,7 +73,7 @@ var debug = require('debug')('mongodb-compass:app'); // order to ensure that the compile cache has already been loaded and // hooked into require.extensions. Otherwise, packages will not have // use of the compile cache. -app.componentRegistry = new ComponentRegistry(); +app.appRegistry = new AppRegistry(); app.packageManager = new PackageManager(path.join(__dirname, '..', 'internal-packages')); app.packageManager.activate(); diff --git a/src/internal-packages/crud/index.js b/src/internal-packages/crud/index.js index dae892c9027..7a4c1da82ea 100644 --- a/src/internal-packages/crud/index.js +++ b/src/internal-packages/crud/index.js @@ -2,19 +2,24 @@ const app = require('ampersand-app'); const DocumentList = require('./lib/component/document-list'); +const Actions = require('./lib/actions'); /** * Activate all the components in the CRUD package. */ function activate() { - app.componentRegistry.register(DocumentList, { role: 'Collection:DocumentList' }); + app.appRegistry.registerComponent('Component::CRUD::DocumentList', DocumentList); + app.appRegistry.registerAction('Action::CRUD::DocumentRemoved', Actions.documentRemoved); + app.appRegistry.registerAction('Action::CRUD::InsertDocument', Actions.insertDocument); } /** * Deactivate all the components in the CRUD package. */ function deactivate() { - app.componentRegistry.deregister(DocumentList); + app.appRegistry.deregisterComponent('Component::CRUD::DocumentList'); + app.appRegistry.deregisterAction('Action::CRUD::DocumentRemoved'); + app.appRegistry.deregisterAction('Action::CRUD::InsertDocument'); } module.exports.activate = activate; diff --git a/src/internal-packages/crud/lib/component/binary-value.jsx b/src/internal-packages/crud/lib/component/binary-value.jsx index 2513b27b835..2249b89a344 100644 --- a/src/internal-packages/crud/lib/component/binary-value.jsx +++ b/src/internal-packages/crud/lib/component/binary-value.jsx @@ -1,7 +1,7 @@ 'use strict'; const React = require('react'); -const truncate = require('hadron-component-registry').truncate; +const truncate = require('hadron-app-registry').truncate; /** * Base 64 constant. diff --git a/src/internal-packages/crud/lib/component/code-value.jsx b/src/internal-packages/crud/lib/component/code-value.jsx index 48c7c1f0538..7463aab1536 100644 --- a/src/internal-packages/crud/lib/component/code-value.jsx +++ b/src/internal-packages/crud/lib/component/code-value.jsx @@ -1,7 +1,7 @@ 'use strict'; const React = require('react'); -const truncate = require('hadron-component-registry').truncate; +const truncate = require('hadron-app-registry').truncate; /** * The document value class. diff --git a/src/internal-packages/crud/lib/component/document.jsx b/src/internal-packages/crud/lib/component/document.jsx index 7a9881a5b23..2b16e5195cc 100644 --- a/src/internal-packages/crud/lib/component/document.jsx +++ b/src/internal-packages/crud/lib/component/document.jsx @@ -3,7 +3,7 @@ const app = require('ampersand-app'); const React = require('react'); const Reflux = require('reflux'); -const ElementFactory = require('hadron-component-registry').ElementFactory; +const ElementFactory = require('hadron-app-registry').ElementFactory; const NamespaceStore = require('hadron-reflux-store').NamespaceStore; const HadronDocument = require('hadron-document'); const Element = require('hadron-document').Element; diff --git a/src/internal-packages/crud/lib/component/editable-value.jsx b/src/internal-packages/crud/lib/component/editable-value.jsx index d177412d391..940f404858c 100644 --- a/src/internal-packages/crud/lib/component/editable-value.jsx +++ b/src/internal-packages/crud/lib/component/editable-value.jsx @@ -3,7 +3,7 @@ const _ = require('lodash'); const React = require('react'); const inputSize = require('./utils').inputSize; -const ElementFactory = require('hadron-component-registry').ElementFactory; +const ElementFactory = require('hadron-app-registry').ElementFactory; const TypeChecker = require('hadron-type-checker'); /** From 54b1aefdc5f47dacee0453faae2b809aa818f100 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Thu, 28 Jul 2016 15:52:07 +0200 Subject: [PATCH 2/2] INT-1686: Register stores from CRUD --- src/internal-packages/crud/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/internal-packages/crud/index.js b/src/internal-packages/crud/index.js index 7a4c1da82ea..6412a88b019 100644 --- a/src/internal-packages/crud/index.js +++ b/src/internal-packages/crud/index.js @@ -3,6 +3,7 @@ const app = require('ampersand-app'); const DocumentList = require('./lib/component/document-list'); const Actions = require('./lib/actions'); +const InsertDocumentStore = require('./lib/store/insert-document-store'); /** * Activate all the components in the CRUD package. @@ -10,7 +11,7 @@ const Actions = require('./lib/actions'); function activate() { app.appRegistry.registerComponent('Component::CRUD::DocumentList', DocumentList); app.appRegistry.registerAction('Action::CRUD::DocumentRemoved', Actions.documentRemoved); - app.appRegistry.registerAction('Action::CRUD::InsertDocument', Actions.insertDocument); + app.appRegistry.registerStore('Store::CRUD::InsertDocumentStore', InsertDocumentStore); } /** @@ -19,7 +20,7 @@ function activate() { function deactivate() { app.appRegistry.deregisterComponent('Component::CRUD::DocumentList'); app.appRegistry.deregisterAction('Action::CRUD::DocumentRemoved'); - app.appRegistry.deregisterAction('Action::CRUD::InsertDocument'); + app.appRegistry.deregisterStore('Store::CRUD::InsertDocumentStore'); } module.exports.activate = activate;