From b7796793f973b67a4daff46f81adbcd7939d57d9 Mon Sep 17 00:00:00 2001 From: "Hanna K (she/her) FE" Date: Fri, 7 May 2021 13:35:25 -0600 Subject: [PATCH 1/6] WIP: Found CLI config object in same object providing info for libraries tab --- app/components/app-config.hbs | 2 ++ app/components/app-config.js | 27 +++++++++++++++++++ app/controllers/app-config.js | 5 ++++ app/router.js | 1 + app/routes/app-config.js | 20 ++++++++++++++ app/routes/libraries.js | 2 ++ app/templates/app-config.hbs | 9 +++++++ app/templates/info.hbs | 5 ++++ ember_debug/general-debug.js | 7 +++++ .../integration/components/app-config-test.js | 26 ++++++++++++++++++ tests/unit/controllers/app-config-test.js | 12 +++++++++ tests/unit/routes/app-config-test.js | 11 ++++++++ 12 files changed, 127 insertions(+) create mode 100644 app/components/app-config.hbs create mode 100644 app/components/app-config.js create mode 100644 app/controllers/app-config.js create mode 100644 app/routes/app-config.js create mode 100644 app/templates/app-config.hbs create mode 100644 tests/integration/components/app-config-test.js create mode 100644 tests/unit/controllers/app-config-test.js create mode 100644 tests/unit/routes/app-config-test.js diff --git a/app/components/app-config.hbs b/app/components/app-config.hbs new file mode 100644 index 0000000000..148188296f --- /dev/null +++ b/app/components/app-config.hbs @@ -0,0 +1,2 @@ +

{{this.selectedAppName}}

+{{!--

hello{{this.selectedAppDetails}}

--}} \ No newline at end of file diff --git a/app/components/app-config.js b/app/components/app-config.js new file mode 100644 index 0000000000..ad5fd35f0e --- /dev/null +++ b/app/components/app-config.js @@ -0,0 +1,27 @@ +import Component from '@glimmer/component'; +import { inject as service } from '@ember/service'; + +export default class AppConfigComponent extends Component { + @service port; + + get apps() { + return this.port.detectedApplications; + } + + get selectedAppId() { + return this.port.applicationId; + } + + get selectedAppName() { + // can you use this to get name instead and erase other 2 or is id/name sometimes different? + console.log('xxx', this.port.applicationName); + return this.apps[this.selectedAppId]; + } + + // get selectedAppDetails() { + // const env = requireModule(`${this.selectedAppName}/config/environment`); + // return env; + // } +} + +// route would be `${this.selectedAppName}/config/environment` diff --git a/app/controllers/app-config.js b/app/controllers/app-config.js new file mode 100644 index 0000000000..5cf96e7d14 --- /dev/null +++ b/app/controllers/app-config.js @@ -0,0 +1,5 @@ +import { computed } from '@ember/object'; +import Controller from '@ember/controller'; + +export default class AppConfigController extends Controller { +} diff --git a/app/router.js b/app/router.js index 2321ce719f..4c92c66c22 100644 --- a/app/router.js +++ b/app/router.js @@ -29,6 +29,7 @@ Router.map(function () { this.route('info', { resetNamespace: true }, function () { this.route('info-index', { path: '/', resetNamespace: true }); this.route('libraries', { resetNamespace: true }); + this.route('app-config', { resetNamespace: true }); this.route('whats-new', { resetNamespace: true }); }); diff --git a/app/routes/app-config.js b/app/routes/app-config.js new file mode 100644 index 0000000000..79b46cf4eb --- /dev/null +++ b/app/routes/app-config.js @@ -0,0 +1,20 @@ +import Route from '@ember/routing/route'; +import TabRoute from 'ember-inspector/routes/tab'; +import { readOnly } from '@ember/object/computed'; + +export default TabRoute.extend({ + version: readOnly('config.VERSION'), + + model() { + const version = this.version; + const port = this.port; + console.log('port', port); + return new Promise((resolve) => { + port.one('general:emberCliConfig', (message) => { + console.log('message', message); + resolve(message); + }); + port.send('general:getEmberCliConfig'); + }); + }, +}); \ No newline at end of file diff --git a/app/routes/libraries.js b/app/routes/libraries.js index 710f535688..fe1b62e1a6 100644 --- a/app/routes/libraries.js +++ b/app/routes/libraries.js @@ -8,8 +8,10 @@ export default TabRoute.extend({ model() { const version = this.version; const port = this.port; + console.log('port', port) return new Promise((resolve) => { port.one('general:libraries', (message) => { + // console.log('m',message) message.libraries.insertAt(0, { name: 'Ember Inspector', version, diff --git a/app/templates/app-config.hbs b/app/templates/app-config.hbs new file mode 100644 index 0000000000..3185a4ecee --- /dev/null +++ b/app/templates/app-config.hbs @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/app/templates/info.hbs b/app/templates/info.hbs index 6484f3ba86..ac00628f24 100644 --- a/app/templates/info.hbs +++ b/app/templates/info.hbs @@ -10,6 +10,11 @@ Libraries + +
  • + + App Config +
  • diff --git a/ember_debug/general-debug.js b/ember_debug/general-debug.js index 4106c63d8f..c2430ccdf6 100644 --- a/ember_debug/general-debug.js +++ b/ember_debug/general-debug.js @@ -27,6 +27,7 @@ export default EmberObject.extend(PortMixin, { try { let config = JSON.parse(unescape(found.getAttribute('content'))); this.set('emberCliConfig', config); + console.log(config); } catch (e) {} } }, @@ -96,6 +97,12 @@ export default EmberObject.extend(PortMixin, { this.sendMessage('libraries', { libraries: libraries._registry }); }, + getEmberCliConfig() { + this.sendMessage('emberCliConfig', { + emberCliConfig: this.emberCliConfig, + }); + }, + /** * Called from the inspector to refresh the inspected app. * Used in case the inspector was opened late and therefore missed capturing diff --git a/tests/integration/components/app-config-test.js b/tests/integration/components/app-config-test.js new file mode 100644 index 0000000000..475a174ddb --- /dev/null +++ b/tests/integration/components/app-config-test.js @@ -0,0 +1,26 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Component | app-config', function(hooks) { + setupRenderingTest(hooks); + + test('it renders', async function(assert) { + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.set('myAction', function(val) { ... }); + + await render(hbs``); + + assert.dom(this.element).hasText(''); + + // Template block usage: + await render(hbs` + + template block text + + `); + + assert.dom(this.element).hasText('template block text'); + }); +}); diff --git a/tests/unit/controllers/app-config-test.js b/tests/unit/controllers/app-config-test.js new file mode 100644 index 0000000000..01bc986d54 --- /dev/null +++ b/tests/unit/controllers/app-config-test.js @@ -0,0 +1,12 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Controller | app-config', function(hooks) { + setupTest(hooks); + + // TODO: Replace this with your real tests. + test('it exists', function(assert) { + let controller = this.owner.lookup('controller:app-config'); + assert.ok(controller); + }); +}); diff --git a/tests/unit/routes/app-config-test.js b/tests/unit/routes/app-config-test.js new file mode 100644 index 0000000000..780c69bcaf --- /dev/null +++ b/tests/unit/routes/app-config-test.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Route | app-config', function(hooks) { + setupTest(hooks); + + test('it exists', function(assert) { + let route = this.owner.lookup('route:app-config'); + assert.ok(route); + }); +}); From f671289604eabfdc799b2322e7132b72665a10ad Mon Sep 17 00:00:00 2001 From: "Hanna K (she/her) FE" Date: Wed, 12 May 2021 09:29:30 -0600 Subject: [PATCH 2/6] Add app config tab to Info --- app/components/app-config.hbs | 2 -- app/components/app-config.js | 27 ---------------- app/controllers/app-config.js | 17 ++++++++++ app/routes/app-config.js | 5 ++- app/routes/libraries.js | 3 +- app/templates/app-config.hbs | 22 ++++++++----- tests/acceptance/info-test.js | 31 +++++++++++++++++++ .../integration/components/app-config-test.js | 26 ---------------- 8 files changed, 66 insertions(+), 67 deletions(-) delete mode 100644 app/components/app-config.hbs delete mode 100644 app/components/app-config.js delete mode 100644 tests/integration/components/app-config-test.js diff --git a/app/components/app-config.hbs b/app/components/app-config.hbs deleted file mode 100644 index 148188296f..0000000000 --- a/app/components/app-config.hbs +++ /dev/null @@ -1,2 +0,0 @@ -

    {{this.selectedAppName}}

    -{{!--

    hello{{this.selectedAppDetails}}

    --}} \ No newline at end of file diff --git a/app/components/app-config.js b/app/components/app-config.js deleted file mode 100644 index ad5fd35f0e..0000000000 --- a/app/components/app-config.js +++ /dev/null @@ -1,27 +0,0 @@ -import Component from '@glimmer/component'; -import { inject as service } from '@ember/service'; - -export default class AppConfigComponent extends Component { - @service port; - - get apps() { - return this.port.detectedApplications; - } - - get selectedAppId() { - return this.port.applicationId; - } - - get selectedAppName() { - // can you use this to get name instead and erase other 2 or is id/name sometimes different? - console.log('xxx', this.port.applicationName); - return this.apps[this.selectedAppId]; - } - - // get selectedAppDetails() { - // const env = requireModule(`${this.selectedAppName}/config/environment`); - // return env; - // } -} - -// route would be `${this.selectedAppName}/config/environment` diff --git a/app/controllers/app-config.js b/app/controllers/app-config.js index 5cf96e7d14..dccea6a9f7 100644 --- a/app/controllers/app-config.js +++ b/app/controllers/app-config.js @@ -2,4 +2,21 @@ import { computed } from '@ember/object'; import Controller from '@ember/controller'; export default class AppConfigController extends Controller { + get columns() { + return [ + { name: 'Key', valuePath: 'key' }, + { name: 'Value', valuePath: 'value' }, + ]; + } + + @computed('model') + get rows() { + return Object.entries(this.get('model')).map(([key, value]) => { + const obj = { key, value }; + if (typeof obj.value === 'object') { + obj.value = JSON.stringify(obj.value, null, 2); + } + return obj; + }); + } } diff --git a/app/routes/app-config.js b/app/routes/app-config.js index 79b46cf4eb..2575311760 100644 --- a/app/routes/app-config.js +++ b/app/routes/app-config.js @@ -6,13 +6,12 @@ export default TabRoute.extend({ version: readOnly('config.VERSION'), model() { - const version = this.version; const port = this.port; console.log('port', port); return new Promise((resolve) => { port.one('general:emberCliConfig', (message) => { - console.log('message', message); - resolve(message); + console.log('message', message.emberCliConfig); + resolve(message.emberCliConfig); }); port.send('general:getEmberCliConfig'); }); diff --git a/app/routes/libraries.js b/app/routes/libraries.js index fe1b62e1a6..5575e62cf0 100644 --- a/app/routes/libraries.js +++ b/app/routes/libraries.js @@ -8,14 +8,13 @@ export default TabRoute.extend({ model() { const version = this.version; const port = this.port; - console.log('port', port) return new Promise((resolve) => { port.one('general:libraries', (message) => { - // console.log('m',message) message.libraries.insertAt(0, { name: 'Ember Inspector', version, }); + console.log('libraries', message.libraries) resolve(message.libraries); }); port.send('general:getLibraries'); diff --git a/app/templates/app-config.hbs b/app/templates/app-config.hbs index 3185a4ecee..8ad9a5119b 100644 --- a/app/templates/app-config.hbs +++ b/app/templates/app-config.hbs @@ -1,9 +1,17 @@ - + + - + + + + {{value}} + + + + - - - \ No newline at end of file +{{!-- view is slightly off - cuts off at max size --}} \ No newline at end of file diff --git a/tests/acceptance/info-test.js b/tests/acceptance/info-test.js index 91fe35d7a4..2cd6af2cc3 100644 --- a/tests/acceptance/info-test.js +++ b/tests/acceptance/info-test.js @@ -38,4 +38,35 @@ module('Info Tab', function (hooks) { .hasText('Handlebars'); assert.dom(libraries[2].querySelector('.js-lib-version')).hasText('2.1'); }); + + test('App config is displayed correctly', async function (assert) { + respondWith('general:getEmberCliConfig', { + type: 'general:emberCliConfig', + emberCliConfig: { + modulePrefix: 'extended', + environment: 'production', + }, + }); + + await visit('/info/app-config'); + + let configs = findAll('.js-config-row'); + assert.equal( + configs.length, + 2, + 'The correct number of configurations is displayed' + ); + assert + .dom(configs[0].querySelector('.js-config-key')) + .hasText('modulePrefix'); + assert + .dom(configs[0].querySelector('.js-config-value')) + .hasText('extended'); + assert + .dom(configs[1].querySelector('.js-config-key')) + .hasText('environment'); + assert + .dom(configs[1].querySelector('.js-config-value')) + .hasText('production'); + }); }); diff --git a/tests/integration/components/app-config-test.js b/tests/integration/components/app-config-test.js deleted file mode 100644 index 475a174ddb..0000000000 --- a/tests/integration/components/app-config-test.js +++ /dev/null @@ -1,26 +0,0 @@ -import { module, test } from 'qunit'; -import { setupRenderingTest } from 'ember-qunit'; -import { render } from '@ember/test-helpers'; -import { hbs } from 'ember-cli-htmlbars'; - -module('Integration | Component | app-config', function(hooks) { - setupRenderingTest(hooks); - - test('it renders', async function(assert) { - // Set any properties with this.set('myProperty', 'value'); - // Handle any actions with this.set('myAction', function(val) { ... }); - - await render(hbs``); - - assert.dom(this.element).hasText(''); - - // Template block usage: - await render(hbs` - - template block text - - `); - - assert.dom(this.element).hasText('template block text'); - }); -}); From 2c16ddd4a7be38bba287a583f7642fa4ebd8563d Mon Sep 17 00:00:00 2001 From: "Hanna K (she/her) FE" Date: Wed, 12 May 2021 15:03:15 -0600 Subject: [PATCH 3/6] Make requested changes from PR comments --- app/routes/app-config.js | 5 +---- app/routes/libraries.js | 1 - app/templates/app-config.hbs | 4 +--- ember_debug/general-debug.js | 1 - tests/unit/controllers/app-config-test.js | 12 ------------ tests/unit/routes/app-config-test.js | 11 ----------- 6 files changed, 2 insertions(+), 32 deletions(-) delete mode 100644 tests/unit/controllers/app-config-test.js delete mode 100644 tests/unit/routes/app-config-test.js diff --git a/app/routes/app-config.js b/app/routes/app-config.js index 2575311760..7ef714030c 100644 --- a/app/routes/app-config.js +++ b/app/routes/app-config.js @@ -1,4 +1,3 @@ -import Route from '@ember/routing/route'; import TabRoute from 'ember-inspector/routes/tab'; import { readOnly } from '@ember/object/computed'; @@ -7,13 +6,11 @@ export default TabRoute.extend({ model() { const port = this.port; - console.log('port', port); return new Promise((resolve) => { port.one('general:emberCliConfig', (message) => { - console.log('message', message.emberCliConfig); resolve(message.emberCliConfig); }); port.send('general:getEmberCliConfig'); }); }, -}); \ No newline at end of file +}); diff --git a/app/routes/libraries.js b/app/routes/libraries.js index 5575e62cf0..710f535688 100644 --- a/app/routes/libraries.js +++ b/app/routes/libraries.js @@ -14,7 +14,6 @@ export default TabRoute.extend({ name: 'Ember Inspector', version, }); - console.log('libraries', message.libraries) resolve(message.libraries); }); port.send('general:getLibraries'); diff --git a/app/templates/app-config.hbs b/app/templates/app-config.hbs index 8ad9a5119b..17d0771768 100644 --- a/app/templates/app-config.hbs +++ b/app/templates/app-config.hbs @@ -12,6 +12,4 @@ - - -{{!-- view is slightly off - cuts off at max size --}} \ No newline at end of file + \ No newline at end of file diff --git a/ember_debug/general-debug.js b/ember_debug/general-debug.js index c2430ccdf6..81745bbc57 100644 --- a/ember_debug/general-debug.js +++ b/ember_debug/general-debug.js @@ -27,7 +27,6 @@ export default EmberObject.extend(PortMixin, { try { let config = JSON.parse(unescape(found.getAttribute('content'))); this.set('emberCliConfig', config); - console.log(config); } catch (e) {} } }, diff --git a/tests/unit/controllers/app-config-test.js b/tests/unit/controllers/app-config-test.js deleted file mode 100644 index 01bc986d54..0000000000 --- a/tests/unit/controllers/app-config-test.js +++ /dev/null @@ -1,12 +0,0 @@ -import { module, test } from 'qunit'; -import { setupTest } from 'ember-qunit'; - -module('Unit | Controller | app-config', function(hooks) { - setupTest(hooks); - - // TODO: Replace this with your real tests. - test('it exists', function(assert) { - let controller = this.owner.lookup('controller:app-config'); - assert.ok(controller); - }); -}); diff --git a/tests/unit/routes/app-config-test.js b/tests/unit/routes/app-config-test.js deleted file mode 100644 index 780c69bcaf..0000000000 --- a/tests/unit/routes/app-config-test.js +++ /dev/null @@ -1,11 +0,0 @@ -import { module, test } from 'qunit'; -import { setupTest } from 'ember-qunit'; - -module('Unit | Route | app-config', function(hooks) { - setupTest(hooks); - - test('it exists', function(assert) { - let route = this.owner.lookup('route:app-config'); - assert.ok(route); - }); -}); From 8eada728416bfcdb9d5c243c39aba48716b0bf9b Mon Sep 17 00:00:00 2001 From: Robert Wagner Date: Wed, 12 May 2021 22:02:01 -0400 Subject: [PATCH 4/6] Update app/routes/app-config.js --- app/routes/app-config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/routes/app-config.js b/app/routes/app-config.js index 7ef714030c..dac2181dca 100644 --- a/app/routes/app-config.js +++ b/app/routes/app-config.js @@ -2,7 +2,6 @@ import TabRoute from 'ember-inspector/routes/tab'; import { readOnly } from '@ember/object/computed'; export default TabRoute.extend({ - version: readOnly('config.VERSION'), model() { const port = this.port; From acc0b705b7656159bca3313275eb90090170967d Mon Sep 17 00:00:00 2001 From: Robert Wagner Date: Wed, 12 May 2021 22:20:18 -0400 Subject: [PATCH 5/6] Update app/routes/app-config.js --- app/routes/app-config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/routes/app-config.js b/app/routes/app-config.js index dac2181dca..316e7fd397 100644 --- a/app/routes/app-config.js +++ b/app/routes/app-config.js @@ -2,7 +2,6 @@ import TabRoute from 'ember-inspector/routes/tab'; import { readOnly } from '@ember/object/computed'; export default TabRoute.extend({ - model() { const port = this.port; return new Promise((resolve) => { From 3a39a6e8b7440c080dbb9489af43b9ba4f6f545b Mon Sep 17 00:00:00 2001 From: Robert Wagner Date: Wed, 12 May 2021 22:20:23 -0400 Subject: [PATCH 6/6] Update app/routes/app-config.js --- app/routes/app-config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/routes/app-config.js b/app/routes/app-config.js index 316e7fd397..dfd797eb59 100644 --- a/app/routes/app-config.js +++ b/app/routes/app-config.js @@ -1,5 +1,4 @@ import TabRoute from 'ember-inspector/routes/tab'; -import { readOnly } from '@ember/object/computed'; export default TabRoute.extend({ model() {