Skip to content

Commit 2e3d059

Browse files
committed
Merge pull request #96 from vincent99/upgrade-ember
Show host.api only to admins
2 parents 5d1cda0 + 7aa0856 commit 2e3d059

26 files changed

Lines changed: 196 additions & 92 deletions

File tree

app/pods/apikey/controller.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ var ApikeyController = Cattle.TransitioningResourceController.extend({
3535
var a = this.get('actions');
3636

3737
return [
38-
{ label: 'Edit', icon: 'ss-write', action: 'edit', enabled: !!a.update },
3938
{ label: 'Activate', icon: 'ss-play', action: 'activate', enabled: !!a.activate },
4039
{ label: 'Deactivate', icon: 'ss-pause', action: 'deactivate', enabled: !!a.deactivate },
41-
{ label: 'Restore', icon: 'ss-medicalcross', action: 'restore', enabled: !!a.restore },
4240
{ label: 'Delete', icon: 'ss-trash', action: 'promptDelete', enabled: !!a.remove, altAction: 'delete' },
43-
{ label: 'Purge', icon: 'ss-tornado', action: 'purge', enabled: !!a.purge },
41+
{ divider: true },
42+
{ label: 'Purge', icon: '', action: 'purge', enabled: !!a.purge },
43+
{ label: 'Restore', icon: '', action: 'restore', enabled: !!a.restore },
44+
{ divider: true },
45+
{ label: 'Edit', icon: '', action: 'edit', enabled: !!a.update },
4446
];
4547
}.property('actions.{update,activate,deactivate,restore,remove,purge}'),
4648
});

app/pods/application/controller.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@ export default Ember.Controller.extend({
1818

1919
return url;
2020
}.property('app.endpoint'),
21+
22+
endpointHost: function() {
23+
var a = document.createElement('a');
24+
a.href = this.get('absoluteEndpoint');
25+
return a.host;
26+
}.property('absoluteEndpoint')
2127
});

app/pods/components/host-widget/template.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="host-header">
22
{{resource-actions-menu model=model choices=model.availableActions}}
33

4-
<div {{bind-attr class=":host-state stateBackground"}}>{{model.displayState}}</div>
4+
<div {{bind-attr class=":host-state stateBackground"}}><span>{{model.displayState}}</span></div>
55
<div class="host-icon"><i {{bind-attr class=":fa-lg model.stateIcon iconColor"}}></i></div>
66
<div class="host-name">
77
{{#if isMachine}}

app/pods/components/page-nav/component.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ export default Ember.Component.extend({
44
activeTab: null,
55

66
tagName: 'nav',
7+
hasRegistries: function() {
8+
var store = this.get('store');
9+
return store && store.hasRecordFor('schema','registry');
10+
}.property(),
711
});

app/pods/components/page-nav/template.hbs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
<label>Volumes</label>
1616
{{/link-to}}
1717

18-
{{#link-to "registries" title="API" classNames="nav-api"}}
19-
<i class="ss-bookmark fa-lg"></i>
20-
<label>Registries</label>
21-
{{/link-to}}
18+
{{#if hasRegistries}}
19+
{{#link-to "registries" title="API" classNames="nav-api"}}
20+
<i class="ss-bookmark fa-lg"></i>
21+
<label>Registries</label>
22+
{{/link-to}}
23+
{{/if}}
2224

2325
{{#link-to "apikeys" title="API" classNames="nav-api"}}
2426
<i class="fa fa-code fa-lg"></i>

app/pods/components/resource-actions-menu/component.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,32 @@ export default Ember.Component.extend({
88
classNames: ['resource-actions'],
99

1010
activeActions: function() {
11-
return (this.get('choices')||[]).filter(function(act) {
12-
return Ember.get(act,'enabled');
11+
var list = (this.get('choices')||[]).filter(function(act) {
12+
return Ember.get(act,'enabled') || Ember.get(act,'divider');
1313
});
14+
15+
// Remove dividers at the beginning
16+
while ( list.get('firstObject.divider') === true )
17+
{
18+
list.shiftObject();
19+
}
20+
21+
// Remove dividers at the end
22+
while ( list.get('lastObject.divider') === true )
23+
{
24+
list.popObject();
25+
}
26+
27+
// Remove consecutive dividers
28+
var last = null;
29+
list = list.filter(function(act) {
30+
var cur = (act.divider === true);
31+
var ok = !cur || (cur && !last);
32+
last = cur;
33+
return ok;
34+
});
35+
36+
return list;
1437
}.property('choices.[]','choices.@each.enabled'),
1538

1639
actions: {

app/pods/components/resource-actions-menu/template.hbs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@
66
<button type="button" class="btn-circle-menu dropdown-toggle" data-toggle="dropdown" aria-expanded="false"></button>
77
<ul class="dropdown-menu dropdown-menu-right" role="menu">
88
{{#each item in activeActions}}
9-
<li>
10-
{{action-menu-item
11-
label=item.label
12-
icon=item.icon
13-
action="clicked"
14-
actionArg=item.action
15-
altActionArg=item.altAction
16-
}}
17-
</li>
9+
{{#if item.divider}}
10+
<li class="divider"></li>
11+
{{else}}
12+
<li>
13+
{{action-menu-item
14+
label=item.label
15+
icon=item.icon
16+
action="clicked"
17+
actionArg=item.action
18+
altActionArg=item.altAction
19+
}}
20+
</li>
21+
{{/if}}
1822
{{/each}}
1923
</ul>

app/pods/container/controller.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,18 @@ var ContainerController = Cattle.TransitioningResourceController.extend({
6565
var a = this.get('actions');
6666

6767
var choices = [
68-
{ label: 'Edit', icon: 'ss-write', action: 'edit', enabled: !!a.update },
69-
{ label: 'View in API', icon: 'fa fa-external-link', action: 'goToApi', enabled: true, detail: true },
70-
{ label: 'Execute Shell', icon: 'fa fa-terminal', action: 'shell', enabled: !!a.execute },
71-
{ label: 'View Logs', icon: 'ss-file', action: 'logs', enabled: !!a.logs },
72-
{ label: 'Restart', icon: 'ss-refresh', action: 'restart', enabled: !!a.restart },
73-
{ label: 'Start', icon: 'ss-play', action: 'start', enabled: !!a.start },
74-
{ label: 'Stop', icon: 'ss-stop', action: 'stop', enabled: !!a.stop },
75-
{ label: 'Restore', icon: 'ss-medicalcross', action: 'restore', enabled: !!a.restore },
76-
{ label: 'Delete', icon: 'ss-trash', action: 'promptDelete', enabled: this.get('canDelete'), altAction: 'delete' },
77-
{ label: 'Purge', icon: 'ss-tornado', action: 'purge', enabled: !!a.purge },
68+
{ label: 'Restart', icon: 'ss-refresh', action: 'restart', enabled: !!a.restart },
69+
{ label: 'Start', icon: 'ss-play', action: 'start', enabled: !!a.start },
70+
{ label: 'Stop', icon: 'ss-stop', action: 'stop', enabled: !!a.stop },
71+
{ label: 'Delete', icon: 'ss-trash', action: 'promptDelete', enabled: this.get('canDelete'), altAction: 'delete' },
72+
{ divider: true },
73+
{ label: 'View in API', icon: '', action: 'goToApi', enabled: true, detail: true },
74+
{ label: 'Execute Shell', icon: '', action: 'shell', enabled: !!a.execute },
75+
{ label: 'View Logs', icon: '', action: 'logs', enabled: !!a.logs },
76+
{ label: 'Restore', icon: '', action: 'restore', enabled: !!a.restore },
77+
{ label: 'Purge', icon: '', action: 'purge', enabled: !!a.purge },
78+
{ divider: true },
79+
{ label: 'Edit', icon: '', action: 'edit', enabled: !!a.update },
7880
];
7981

8082
return choices;

app/pods/containers/new/route.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,25 @@ export default Ember.Route.extend({
2020
var dependencies = [
2121
this.get('store').find('network'),
2222
this.get('store').find('host'),
23-
this.get('store').find('registry'),
2423
];
2524

25+
if ( this.get('store').hasRecordFor('schema','registry') )
26+
{
27+
dependencies.push(this.get('store').find('registry'));
28+
}
29+
2630
return Ember.RSVP.all(dependencies, 'Load container dependencies').then(function(results) {
2731
var networks = results[0].sortBy('name','id').filter((network) => {
2832
return network.get('state') === 'active';
2933
});
3034

31-
var registries = results[2].sortBy('serverAddress').filter((registry) => {
32-
return registry.get('state') === 'active';
33-
});
35+
var registries = [];
36+
if ( results[2] )
37+
{
38+
registries = results[2].sortBy('serverAddress').filter((registry) => {
39+
return registry.get('state') === 'active';
40+
});
41+
}
3442

3543
self.set('networkChoices', networks);
3644
self.set('registryChoices', registries);

app/pods/host/controller.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ var HostController = Cattle.TransitioningResourceController.extend({
4545

4646
return [
4747
// { label: 'Add Container', icon: 'ss-plus', action: 'newContainer', enabled: true, color: 'text-primary' },
48-
{ label: 'View in API', icon: 'fa fa-external-link', action: 'goToApi', enabled: true},
4948
{ label: 'Activate', icon: 'ss-play', action: 'activate', enabled: !!a.activate, color: 'text-success'},
5049
{ label: 'Deactivate', icon: 'ss-pause', action: 'deactivate', enabled: !!a.deactivate, color: 'text-danger'},
5150
{ label: 'Delete', icon: 'ss-trash', action: 'promptDelete', enabled: !!a.remove, altAction: 'delete', color: 'text-warning' },
52-
{ label: 'Purge', icon: 'ss-tornado', action: 'purge', enabled: !!a.purge, color: 'text-danger' },
51+
{ divider: true },
52+
{ label: 'View in API', icon: '', action: 'goToApi', enabled: true},
53+
{ label: 'Purge', icon: '', action: 'purge', enabled: !!a.purge, color: 'text-danger' },
5354
];
5455
}.property('actions.{activate,deactivate,remove,purge}'),
5556

@@ -138,9 +139,9 @@ HostController.reopenClass({
138139
'requested': {icon: 'ss-tag', color: 'text-danger'},
139140
'registering': {icon: 'ss-tag', color: 'text-danger'},
140141
'activating': {icon: 'ss-tag', color: 'text-danger'},
141-
'active': {icon: 'ss-desktop', color: 'text-success'},
142+
'active': {icon: 'ss-database', color: 'text-success'},
142143
'reconnecting': {icon: 'fa fa-cog fa-spin', color: 'text-danger'},
143-
'updating-active': {icon: 'ss-desktop', color: 'text-success'},
144+
'updating-active': {icon: 'ss-database', color: 'text-success'},
144145
'updating-inactive':{icon: 'ss-alert', color: 'text-danger'},
145146
'deactivating': {icon: 'ss-down', color: 'text-danger'},
146147
'inactive': {icon: 'fa fa-circle', color: 'text-danger'},

0 commit comments

Comments
 (0)