Multiple categories for catalog

This commit is contained in:
Vincent Fiduccia 2017-02-14 12:46:36 -07:00
parent 55eff3e0b1
commit 76c3193ab3
No known key found for this signature in database
GPG Key ID: 2B29AD6BB2BB2582
5 changed files with 33 additions and 4 deletions

View File

@ -21,7 +21,7 @@
<small><strong>{{t 'newCatalog.catalog'}}</strong> <span class="text-capitalize">{{templateResource.catalogId}}</span></small> <small><strong>{{t 'newCatalog.catalog'}}</strong> <span class="text-capitalize">{{templateResource.catalogId}}</span></small>
</div> </div>
<div> <div>
<small><strong>{{t 'newCatalog.category'}}</strong> {{templateResource.category}}</small> <small><strong>{{t 'newCatalog.category'}}</strong> {{join-array templateResource.categoryArray}}</small>
</div> </div>
{{#if (eq templateResource.certifiedType 'rancher')}} {{#if (eq templateResource.certifiedType 'rancher')}}
<small><strong>{{t 'newCatalog.support'}} </strong>{{t 'newCatalog.official'}}</small> <small><strong>{{t 'newCatalog.support'}} </strong>{{t 'newCatalog.official'}}</small>

View File

@ -0,0 +1,8 @@
import Ember from 'ember';
export default Ember.Helper.extend({
compute(params, options) {
let separator = options.separator || ', ';
return params[0].join(separator);
},
});

View File

@ -62,9 +62,27 @@ export default Resource.extend({
return list.length === 0 || list.includes(orch); return list.length === 0 || list.includes(orch);
}, },
categoryArray: function() {
let out = this.get('categories');
if ( !out || !out.length ) {
let single = this.get('category');
if ( single ) {
out = [single];
} else {
out = [];
}
}
return out;
}.property('category','categories.[]'),
categoryLowerArray: function() {
return this.get('categoryArray').map(x => (x||'').toLowerCase());
}.property('categoryArray.[]'),
supported: function() { supported: function() {
let orch = this.get('projects.current.orchestration')||'cattle'; let orch = this.get('projects.current.orchestration')||'cattle';
if ( (this.get('category')||'').toLowerCase() === 'orchestration' ) { if ( this.get('categoryLowerArray').includes('orchestration') ) {
return orch === 'cattle'; return orch === 'cattle';
} else { } else {
return this.supportsOrchestration(orch); return this.supportsOrchestration(orch);

View File

@ -115,11 +115,13 @@ export default Ember.Service.extend({
bases.push(C.EXTERNAL_ID.KIND_INFRA); bases.push(C.EXTERNAL_ID.KIND_INFRA);
} }
let categories = uniqKeys(data, 'category'); let categories = [];
data.forEach((obj) => { categories.pushObjects(obj.get('categoryArray')); });
categories = uniqKeys(categories);
categories.unshift('all'); categories.unshift('all');
data = data.filter((tpl) => { data = data.filter((tpl) => {
if ( category !== 'all' && (tpl.get('category')||'').toLowerCase() !== category ) { if ( category !== 'all' && !tpl.get('categoryLowerArray').includes(category) ) {
return false; return false;
} }

View File

@ -108,6 +108,7 @@ var C = {
CSRF: 'X-Api-Csrf', CSRF: 'X-Api-Csrf',
NO_CHALLENGE: 'X-Api-No-Challenge', NO_CHALLENGE: 'X-Api-No-Challenge',
NO_CHALLENGE_VALUE: 'true', NO_CHALLENGE_VALUE: 'true',
PROJECT_ID: 'X-Api-Project-Id',
RANCHER_VERSION: 'X-Rancher-Version', RANCHER_VERSION: 'X-Rancher-Version',
}, },