Skip to content

Loading…

Add support for grouping promulgated bundles as recommended #160

Merged
merged 1 commit into from

3 participants

@mitechie
Juju member

Search should show promulgated bundles as recommended.

To QA:

Load the gui and search for "bundle" as the keyword. There should be one result that comes back as recommended and the charm token shows it as a recommended bundle.

@jujugui
Juju member

Test FAILed.
Refer to this link for build results: http://ci.jujugui.org:8080/job/juju-gui/506/

@jujugui
Juju member

Test PASSed.
Refer to this link for build results: http://ci.jujugui.org:8080/job/juju-gui/507/

@hatched hatched commented on an outdated diff
app/models/bundle.js
@@ -125,6 +125,26 @@ YUI.add('juju-bundle-models', function(Y) {
id: {},
name: {},
description: {},
+ /**
+ For charms the api returns is_approved and we want to share that
+ across our templates. This maps to the promulgated api data from the
+ bundle results.
+
+ @attribute is_approved
+ @default false
+ @type {Boolean}
+
@hatched Juju member
hatched added a note

extra space

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@hatched hatched commented on the diff
app/models/bundle.js
((5 lines not shown))
+ For charms the api returns is_approved and we want to share that
+ across our templates. This maps to the promulgated api data from the
+ bundle results.
+
+ @attribute is_approved
+ @default false
+ @type {Boolean}
+
+ */
+ is_approved: {
+ /**
+ Reach into the promulgated attr
+
+ @method getter
+ */
+ getter: function() {
@hatched Juju member
hatched added a note

If you didn't want to doc this you can quote the method name 'getter'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@hatched hatched commented on an outdated diff
app/subapps/browser/views/search.js
@@ -169,13 +169,24 @@ YUI.add('subapp-browser-searchview', function(Y) {
series = DEFAULT_SEARCH_SERIES;
}
results.map(function(charm) {
@hatched Juju member
hatched added a note

charm should probably be entity

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

Thanks for adding this!
:+1: with trivials
QA OK!

@mitechie
Juju member

Thanks for the review. Updated :shipit:

@jujugui
Juju member

Status: merge request accepted. Url: http://ci.jujugui.org:8080/job/juju-gui-merge

@jujugui jujugui merged commit 895aa48 into juju:develop

1 check failed

Details default Merged build finished.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 53 additions and 6 deletions.
  1. +19 −0 app/models/bundle.js
  2. +16 −5 app/subapps/browser/views/search.js
  3. +13 −1 test/test_browser_search_view.js
  4. +5 −0 test/test_model_bundle.js
View
19 app/models/bundle.js
@@ -125,6 +125,25 @@ YUI.add('juju-bundle-models', function(Y) {
id: {},
name: {},
description: {},
+ /**
+ For charms the api returns is_approved and we want to share that
+ across our templates. This maps to the promulgated api data from the
+ bundle results.
+
+ @attribute is_approved
+ @default false
+ @type {Boolean}
+ */
+ is_approved: {
+ /**
+ Reach into the promulgated attr
+
+ @method getter
+ */
+ getter: function() {
@hatched Juju member
hatched added a note

If you didn't want to doc this you can quote the method name 'getter'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ return this.get('promulgated');
+ }
+ },
owner: {},
permanent_url: {},
promulgated: false,
View
21 app/subapps/browser/views/search.js
@@ -168,14 +168,25 @@ YUI.add('subapp-browser-searchview', function(Y) {
if (!series) {
series = DEFAULT_SEARCH_SERIES;
}
- results.map(function(charm) {
- if (charm.get('is_approved') &&
- charm.get('series') === series) {
- recommended.push(charm);
+ results.map(function(entity) {
+ // If this is a charm, make sure it's approved and is of the
+ // correct series to be recommended.
+ if (entity.entityType === 'bundle') {
+ if (entity.get('is_approved')) {
+ recommended.push(entity);
+ } else {
+ more.push(entity);
+ }
} else {
- more.push(charm);
+ if (entity.get('is_approved') &&
+ entity.get('series') === series) {
+ recommended.push(entity);
+ } else {
+ more.push(entity);
+ }
}
}, this);
+
this._renderSearchResults({
recommended: recommended,
more: more
View
14 test/test_browser_search_view.js
@@ -179,8 +179,9 @@ describe('search view', function() {
it('organizes results by approval status', function(done) {
view._renderSearchResults = function(results) {
- assert.equal(results.recommended.length, 1);
+ assert.equal(results.recommended.length, 2);
assert.equal(results.recommended[0].get('id'), 'precise/bar-2');
+ assert.equal(results.recommended[1].get('id'), '~charmers/bar/2/bar');
assert.equal(results.more.length, 1);
done();
};
@@ -201,6 +202,17 @@ describe('search view', function() {
files: [],
is_approved: false
}
+ }, {
+ bundle: {
+ id: '~charmers/bar/2/bar',
+ name: 'bar bundle',
+ description: '',
+ files: [],
+ promulgated: true,
+ data: {
+ series: 'precise'
+ }
+ }
}]
};
var fakeStore = new Y.juju.charmworld.APIv3({});
View
5 test/test_model_bundle.js
@@ -98,6 +98,11 @@ describe('The bundle model', function() {
assert.equal(expected, instance.get('promulgated'));
});
+ it('must support is_approved as a proxy to promulgated', function() {
+ instance = new models.Bundle({promulgated: true});
+ assert.equal(instance.get('is_approved'), true);
+ });
+
it('must store the title', function() {
expected = 'My Bountiful Bundle';
data.title = expected;
Something went wrong with that request. Please try again.