mirror of https://github.com/rancher/ui.git
Merge pull request #2547 from westlywright/catalog-fixes
filter catalog categories by cluster and project
This commit is contained in:
commit
1ad58aaeac
|
|
@ -1,6 +1,6 @@
|
|||
import { inject as service } from '@ember/service';
|
||||
import Route from '@ember/routing/route';
|
||||
import { get } from '@ember/object';
|
||||
import { get, set } from '@ember/object';
|
||||
|
||||
export default Route.extend({
|
||||
access: service(),
|
||||
|
|
@ -18,6 +18,8 @@ export default Route.extend({
|
|||
model(params) {
|
||||
const project = this.modelFor('authenticated.project').get('project');
|
||||
|
||||
set(params, 'project', project);
|
||||
|
||||
return get(this, 'catalog').fetchTemplates(params)
|
||||
.then((res) => {
|
||||
res.catalog.forEach((tpl) => {
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ export default Service.extend({
|
|||
const store = get(this, 'globalStore');
|
||||
|
||||
return this.fetchUnScopedCatalogs().then(() => {
|
||||
this.set('templateCache', null);
|
||||
set(this, 'templateCache', null);
|
||||
|
||||
return hash({
|
||||
projectCatalogs: store.request({
|
||||
|
|
@ -148,6 +148,9 @@ export default Service.extend({
|
|||
let cache = get(this, 'templateCache');
|
||||
let catalogId = null;
|
||||
let qp = { 'category_ne': 'system', };
|
||||
let project = params.project ? params.project : null;
|
||||
let currentProjectId = project ? project.id.split(':')[1] : null;
|
||||
let currentClusterId = project ? project.clusterId : null;
|
||||
|
||||
if (params.catalogId) {
|
||||
catalogId = params.catalogId;
|
||||
|
|
@ -186,7 +189,25 @@ export default Service.extend({
|
|||
|
||||
return get(this, 'globalStore').request({ url, }).then((res) => {
|
||||
res.catalogId = catalogId;
|
||||
this.set('templateCache', res);
|
||||
|
||||
if (catalogId === 'all' || !catalogId) {
|
||||
set(this, 'templateCache', res.filter((t) => {
|
||||
this;
|
||||
if (t.clusterId && currentClusterId) {
|
||||
if (t.clusterId === currentClusterId) {
|
||||
return t;
|
||||
}
|
||||
} else if (t.projectId && currentProjectId) {
|
||||
if (t.projectId === currentProjectId) {
|
||||
return t;
|
||||
}
|
||||
} else {
|
||||
return t;
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
set(this, 'templateCache', res);
|
||||
}
|
||||
|
||||
return this.filter(res, params.category);
|
||||
}).catch((err) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue