Regular rows for special catalogs

This commit is contained in:
Vincent Fiduccia 2019-09-19 04:31:50 -07:00
parent ecf852e21e
commit 466f699c9b
No known key found for this signature in database
GPG Key ID: 2B29AD6BB2BB2582
5 changed files with 76 additions and 300 deletions

View File

@ -12,6 +12,12 @@ export default Resource.extend({
return ucFirst(get(this, 'kind'));
}),
combinedState: computed('id', function() {
if ( !get(this, 'id') ) {
return 'disabled';
}
}),
canClone: computed('actions.clone', function() {
const name = get(this, 'name');
const catalogNames = get(C, 'CATALOG');
@ -23,15 +29,27 @@ export default Resource.extend({
availableActions: computed('actionLinks.{refresh}', function() {
let a = get(this, 'actionLinks') || {};
return [{
enabled: !!a.refresh,
label: 'catalogPage.index.refreshBtn',
icon: 'icon icon-refresh',
action: 'refresh'
}];
return [
{
action: 'enable',
icon: 'icon icon-plus-circle',
enabled: !this.id,
label: 'generic.enable',
},
{
enabled: !!a.refresh,
label: 'catalogPage.index.refreshBtn',
icon: 'icon icon-refresh',
action: 'refresh'
}
];
}),
actions: {
enable() {
this.save();
},
edit() {
get(this, 'modalService').toggleModal('modal-edit-catalog', {
model: this,

View File

@ -15,130 +15,6 @@ export default Controller.extend({
togglingLibrary: false,
actions: {
disableLibrary() {
if ( get(this, 'togglingLibrary') ) {
return;
}
set(this, 'togglingLibrary', true);
get(this, 'library').delete().catch((err) => {
get(this, 'growl').fromError('Error removing Library', err);
}).finally(() => {
set(this, 'togglingLibrary', false);
this.send('refresh');
});
},
enableLibrary() {
if ( get(this, 'togglingLibrary') ) {
return;
}
set(this, 'togglingLibrary', true);
get(this, 'globalStore').createRecord({
type: 'catalog',
name: C.CATALOG.LIBRARY_KEY,
url: C.CATALOG.LIBRARY_VALUE,
branch: C.CATALOG.DEFAULT_BRANCH,
kind: 'helm',
}).save().catch((err) => {
get(this, 'growl').fromError('Error saving Library', err);
})
.finally(() => {
set(this, 'togglingLibrary', false);
this.send('refresh');
});
},
disableHelmIncubator() {
if ( get(this, 'togglingHelmIncubator') ) {
return;
}
set(this, 'togglingHelmIncubator', true);
get(this, 'helmIncubator').delete().catch((err) => {
get(this, 'growl').fromError('Error removing Incubator', err);
}).finally(() => {
set(this, 'togglingHelmIncubator', false);
this.send('refresh');
});
},
enableHelmIncubator() {
if ( get(this, 'togglingHelmIncubator') ) {
return;
}
set(this, 'togglingHelmIncubator', true);
get(this, 'globalStore').createRecord({
type: 'catalog',
name: C.CATALOG.HELM_INCUBATOR_KEY,
url: C.CATALOG.HELM_INCUBATOR_VALUE,
branch: C.CATALOG.DEFAULT_BRANCH,
kind: 'helm',
}).save().catch((err) => {
get(this, 'growl').fromError('Error saving Incubator', err);
})
.finally(() => {
set(this, 'togglingHelmIncubator', false);
this.send('refresh');
});
},
disableHelmStable() {
if ( get(this, 'togglingHelmStable') ) {
return;
}
set(this, 'togglingHelmStable', true);
get(this, 'helmStable').delete().catch((err) => {
get(this, 'growl').fromError('Error removing Stable', err);
}).finally(() => {
set(this, 'togglingHelmStable', false);
this.send('refresh');
});
},
enableHelmStable() {
if ( get(this, 'togglingHelmStable') ) {
return;
}
set(this, 'togglingHelmStable', true);
get(this, 'globalStore').createRecord({
type: 'catalog',
name: C.CATALOG.HELM_STABLE_KEY,
url: C.CATALOG.HELM_STABLE_VALUE,
branch: C.CATALOG.DEFAULT_BRANCH,
kind: 'helm',
}).save().catch((err) => {
get(this, 'growl').fromError('Error saving Stable', err);
})
.finally(() => {
set(this, 'togglingHelmStable', false);
this.send('refresh');
});
},
enableCommunity() {
get(this, 'globalStore').createRecord({
type: 'catalog',
name: C.CATALOG.COMMUNITY_KEY,
url: C.CATALOG.COMMUNITY_VALUE,
branch: C.CATALOG.COMMUNITY_BRANCH,
}).save().catch((err) => {
get(this, 'growl').fromError('Error saving Community', err);
})
.finally(() => {
this.send('refresh', this)
});
},
disableCommunity() {
get(this, 'stdCommunity').delete().catch((err) => {
get(this, 'growl').fromError('Error removing Community', err);
}).finally(() => {
this.send('refresh', this)
});
},
add() {
const record = get(this, 'globalStore').createRecord({
type: 'catalog',
@ -152,62 +28,4 @@ export default Controller.extend({
});
},
},
library: computed('model.@each.{name,url,branch}', function() {
return this.findMatch(
C.CATALOG.LIBRARY_KEY,
C.CATALOG.LIBRARY_VALUE
);
}),
helmStable: computed('model.@each.{name,url,branch}', function() {
return this.findMatch(
C.CATALOG.HELM_STABLE_KEY,
C.CATALOG.HELM_STABLE_VALUE,
);
}),
helmIncubator: computed('model.@each.{name,url,branch}', function() {
return this.findMatch(
C.CATALOG.HELM_INCUBATOR_KEY,
C.CATALOG.HELM_INCUBATOR_VALUE,
);
}),
custom: computed('library', 'helmStable', 'helmIncubator', function() {
const hide = [
get(this, 'library'),
get(this, 'helmStable'),
get(this, 'helmIncubator'),
];
return get(this, 'model').filter((x) => !hide.includes(x));
}),
customLibrary: computed('custom.@each.{name}', function() {
return get(this, 'custom').findBy('name', 'library')
}),
customHelmStable: computed('custom.@each.{name}', function() {
return get(this, 'custom').findBy('name', 'helm')
}),
customHelmIncubator: computed('custom.@each.{name}', function() {
return get(this, 'custom').findBy('name', 'helm-incubator')
}),
findMatch(name, url, branch) {
const entry = get(this, 'model').findBy('name', name);
if ( !entry ) {
return null;
}
if ( get(entry, 'url') === url &&
(!branch || get(entry, 'branch') === branch)
) {
return entry;
}
},
});

View File

@ -8,92 +8,6 @@
<h1>{{t 'catalogSettings.header'}}</h1>
</section>
<div class="row row-same-height">
<div class="col span-4">
<h2>{{t 'catalogSettings.library.label'}}</h2>
<div>
{{#if library}}
<div class="btn-group no-inline-space">
<button class="btn btn-link btn-sm bg-default" {{action "disableLibrary"}} disabled={{togglingLibrary}}>{{#if togglingLibrary}}<i class="icon icon-spinner icon-spin"></i> {{/if}}{{t 'generic.disable'}}</button>
<button class="btn btn-link btn-sm bg-success">{{t "generic.enabled"}}</button>
</div>
{{else}}
<div class="btn-group no-inline-space">
<button class="btn btn-link btn-sm bg-primary">{{t 'generic.disabled'}}</button>
<button class="btn btn-link btn-sm bg-defualt" {{action "enableLibrary"}} disabled={{togglingLibrary}}>{{#if togglingLibrary}}<i class="icon icon-spinner icon-spin"></i> {{/if}}{{t 'generic.enable'}}</button>
</div>
{{/if}}
{{#if customLibrary}}
{{#banner-message color='bg-warning'}}
{{t 'catalogSettings.errors.nameInExists' key='library' }}
{{/banner-message}}
{{/if}}
</div>
<p class="text-info">
{{t 'catalogSettings.library.detail' appName=settings.appName}}
</p>
{{#if library.showTransitioningMessage}}
<div class="{{library.stateColor}}"><p>{{uc-first library.transitioningMessage}}</p></div>
{{/if}}
</div>
<div class="col span-4">
<h2>{{t 'catalogSettings.helm.stable.label'}}</h2>
<div>
{{#if helmStable}}
<div class="btn-group no-inline-space">
<button class="btn btn-link btn-sm bg-default" {{action "disableHelmStable"}} disabled={{togglingHelmStable}}>{{#if togglingHelmStable}}<i class="icon icon-spinner icon-spin"></i> {{/if}}{{t 'generic.disable'}}</button>
<button class="btn btn-link btn-sm bg-success">{{t "generic.enabled"}}</button>
</div>
{{else}}
<div class="btn-group no-inline-space">
<button class="btn btn-link btn-sm bg-primary">{{t 'generic.disabled'}}</button>
<button class="btn btn-link btn-sm bg-defualt" {{action "enableHelmStable"}} disabled={{togglingHelmStable}}>{{#if togglingHelmStable}}<i class="icon icon-spinner icon-spin"></i> {{/if}}{{t 'generic.enable'}}</button>
</div>
{{/if}}
{{#if customHelmStable}}
{{#banner-message color='bg-warning'}}
{{t 'catalogSettings.errors.nameInExists' key='helm' }}
{{/banner-message}}
{{/if}}
</div>
<p class="text-info">
{{t 'catalogSettings.helm.stable.detail'}}
</p>
{{#if helmStable.showTransitioningMessage}}
<div class="{{helmStable.stateColor}}"><p>{{uc-first helmStable.transitioningMessage}}</p></div>
{{/if}}
</div>
<div class="col span-4">
<h2>{{t 'catalogSettings.helm.incubator.label'}}</h2>
<div>
{{#if helmIncubator}}
<div class="btn-group no-inline-space">
<button class="btn btn-link btn-sm bg-default" {{action "disableHelmIncubator"}} disabled={{togglingHelmIncubator}}>{{#if togglingHelmIncubator}}<i class="icon icon-spinner icon-spin"></i> {{/if}}{{t 'generic.disable'}}</button>
<button class="btn btn-link btn-sm bg-success">{{t "generic.enabled"}}</button>
</div>
{{else}}
<div class="btn-group no-inline-space">
<button class="btn btn-link btn-sm bg-primary">{{t 'generic.disabled'}}</button>
<button class="btn btn-link btn-sm bg-defualt" {{action "enableHelmIncubator"}} disabled={{togglingHelmIncubator}}>{{#if togglingHelmIncubator}}<i class="icon icon-spinner icon-spin"></i> {{/if}}{{t 'generic.enable'}}</button>
</div>
{{/if}}
{{#if customHelmIncubator}}
{{#banner-message color='bg-warning'}}
{{t 'catalogSettings.errors.nameInExists' key='helm-incubator' }}
{{/banner-message}}
{{/if}}
</div>
<p class="text-info">
{{t 'catalogSettings.helm.incubator.detail'}}
</p>
{{#if helmIncubator.showTransitioningMessage}}
<div class="{{helmIncubator.stateColor}}"><p>{{uc-first helmIncubator.transitioningMessage}}</p></div>
{{/if}}
</div>
</div>
{{custom-catalog
catalogs=custom
}}
catalogs=model
}}

View File

@ -40,6 +40,7 @@ const headers = [
];
export default Component.extend({
globalStore: service(),
settings: service(),
layout,
headers,
@ -50,9 +51,51 @@ export default Component.extend({
paging: true,
rightActions: true,
filtered: computed('catalogs.@each.{name,url}', function() {
return get(this, 'catalogs').filter((catalog) => {
return !(get(catalog, 'name') === C.CATALOG.SYSTEM_LIBRARY_KEY && get(catalog, 'url') === C.CATALOG.SYSTEM_LIBRARY_VALUE);
});
library: computed('catalogs.@each.{name}', function() {
return get(this, 'catalogs').findBy('name', C.CATALOG.LIBRARY_KEY);
}),
helmStable: computed('catalogs.@each.{name}', function() {
return get(this, 'catalogs').findBy('name', C.CATALOG.HELM_STABLE_KEY)
}),
helmIncubator: computed('catalogs.@each.{name}', function() {
return get(this, 'catalogs').findBy('name', C.CATALOG.HELM_INCUBATOR_KEY)
}),
rows: computed('catalogs.@each.{id,name,url}', function() {
const out = get(this, 'catalogs').slice();
if ( !this.library ) {
out.push(get(this, 'globalStore').createRecord({
type: 'catalog',
name: C.CATALOG.LIBRARY_KEY,
url: C.CATALOG.LIBRARY_VALUE,
branch: C.CATALOG.DEFAULT_BRANCH,
kind: 'helm',
}));
}
if ( !this.helmStable ) {
out.push(get(this, 'globalStore').createRecord({
type: 'catalog',
name: C.CATALOG.HELM_STABLE_KEY,
url: C.CATALOG.HELM_STABLE_VALUE,
branch: C.CATALOG.DEFAULT_BRANCH,
kind: 'helm',
}));
}
if ( !this.helmIncubator ) {
out.push(get(this, 'globalStore').createRecord({
type: 'catalog',
name: C.CATALOG.HELM_INCUBATOR_KEY,
url: C.CATALOG.HELM_INCUBATOR_VALUE,
branch: C.CATALOG.DEFAULT_BRANCH,
kind: 'helm',
}));
}
return out;
})
});

View File

@ -1,22 +1,5 @@
<section class="header clearfix">
<h1>{{t 'catalogSettings.more.header'}}</h1>
<div>
<p>{{t 'catalogSettings.more.helpText.header' htmlSafe=true}}</p>
<ul class="">
<li>{{t 'catalogSettings.more.helpText.help-name' htmlSafe=true}}</li>
<li>
<span>{{t 'catalogSettings.more.helpText.help-repo' htmlSafe=true}}</span>
<ul>
<li>{{t 'catalogSettings.more.helpText.help-git' appName=settings.appName htmlSafe=true}}</li>
<li>{{t 'catalogSettings.more.helpText.help-chart' htmlSafe=true}}</li>
</ul>
</li>
</ul>
</div>
</section>
{{#sortable-table
body=filtered
body=rows
descending=descending
headers=headers
paging=paging
@ -47,7 +30,7 @@
{{row.name}}
</td>
<td data-title="{{dt.url}}">
<a href="{{row.url}}" target="_blank" rel="nofollow noopener">{{row.url}}</a>
{{row.url}}
</td>
<td data-title="{{dt.branch}}">
{{row.branch}}
@ -64,4 +47,4 @@
{{else if (eq kind "norows")}}
<tr><td colspan="{{sortable.fullColspan}}" class="text-center text-muted pt-20 pb-20">{{t 'catalogSettings.more.noData'}}</td></tr>
{{/if}}
{{/sortable-table}}
{{/sortable-table}}