Skip to content

Commit

Permalink
Merge pull request #750 from chalettu/vm-custom-buttons
Browse files Browse the repository at this point in the history
Added custom buttons to VM details page
(cherry picked from commit 4918c1a)

https://bugzilla.redhat.com/show_bug.cgi?id=1450502
  • Loading branch information
chriskacerguis authored and simaishi committed May 12, 2017
1 parent fc1ea66 commit 223c3c1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions client/app/services/vm-details/vm-details.component.js
Expand Up @@ -21,6 +21,7 @@ function ComponentController($stateParams, VmsService, ServicesState, sprintf, E
function activate() {
vm.permissions = ServicesState.getPermissions();
angular.extend(vm, {
hasCustomButtons: hasCustomButtons,
loading: true,
neverText: __('Never'),
noneText: __('None'),
Expand Down Expand Up @@ -84,6 +85,7 @@ function ComponentController($stateParams, VmsService, ServicesState, sprintf, E
EventNotifications.warn(sprintf(__("%s is a retired resource"), vm.vmDetails.name), {persistent: true, unread: false});
}
getListActions();
hasCustomButtons();
vm.loading = false;
}

Expand All @@ -92,6 +94,14 @@ function ComponentController($stateParams, VmsService, ServicesState, sprintf, E
}
}

function hasCustomButtons() {
const actions = vm.vmDetails.custom_actions || {};
const groups = actions.button_groups || [];
const buttons = [].concat(actions.buttons, ...groups.map((g) => g.buttons));

return lodash.compact(buttons).length > 0;
}

function getListActions() {
vm.listActions = [];
const powerOptionsMenu = {
Expand Down
4 changes: 4 additions & 0 deletions client/app/services/vm-details/vm-details.html
Expand Up @@ -18,6 +18,10 @@
<actions>
<div class="ss-details-header__actions">
<div uib-dropdown class="ss-details-header__actions__inner dropdown-kebab-pf">
<custom-button ng-if="vm.hasCustomButtons()"
service-id="vm.vmDetails.service.id"
custom-actions="vm.vmDetails.custom_actions">
</custom-button>
<custom-dropdown class="custom-dropdown pull-left"
config="item"
ng-repeat="item in vm.listActions"
Expand Down
2 changes: 2 additions & 0 deletions client/app/services/vms.service.js
Expand Up @@ -46,6 +46,8 @@ export function VmsService(CollectionsApi, RBAC) {
'compliances',
'cpu_affinity',
'created_on',
'custom_actions',
'custom_action_buttons',
'disks',
'disks_aligned',
'drift_states',
Expand Down

0 comments on commit 223c3c1

Please sign in to comment.