Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added custom buttons to VM details page #750

Merged
merged 2 commits into from
May 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions client/app/services/vm-details/vm-details.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function ComponentController($stateParams, VmsService, ServicesState, sprintf, l
function activate() {
vm.permissions = ServicesState.getPermissions();
angular.extend(vm, {
hasCustomButtons: hasCustomButtons,
loading: true,
neverText: __('Never'),
noneText: __('None'),
Expand Down Expand Up @@ -85,6 +86,7 @@ function ComponentController($stateParams, VmsService, ServicesState, sprintf, l
EventNotifications.warn(sprintf(__("%s is a retired resource"), vm.vmDetails.name), {persistent: true, unread: false});
}
getListActions();
hasCustomButtons();
vm.loading = false;
}

Expand All @@ -93,6 +95,14 @@ function ComponentController($stateParams, VmsService, ServicesState, sprintf, l
}
}

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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export function VmsService(CollectionsApi, RBAC) {
'compliances',
'cpu_affinity',
'created_on',
'custom_actions',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I belieeeeeeve adding these new attributes will break mock api get requests... probably should update that 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, they will. I have an update for mock api that I will submit that should fix these

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

'custom_action_buttons',
'disks',
'disks_aligned',
'drift_states',
Expand Down