Bug 1737449 - Can not associate a button to the button set when separately created using REST API
Summary: Can not associate a button to the button set when separately created using RE...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: API
Version: 5.10.5
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: GA
: 5.11.0
Assignee: drew uhlmann
QA Contact: Nikhil Dhandre
Red Hat CloudForms Documentation
URL:
Whiteboard:
Depends On:
Blocks: 1745198
TreeView+ depends on / blocked
 
Reported: 2019-08-05 11:35 UTC by Rahul Chincholkar
Modified: 2019-12-13 14:57 UTC (History)
5 users (show)

Fixed In Version: 5.11.0.21
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1745198 (view as bug list)
Environment:
Last Closed: 2019-12-13 14:57:03 UTC
Category: Bug
Cloudforms Team: CFME Core
Target Upstream Version:
Embargoed:
ndhandre: automate_bug+
mfeifer: mirror+


Attachments (Terms of Use)
Separate_Button_and_Button_Set (6.04 KB, image/png)
2019-08-05 11:35 UTC, Rahul Chincholkar
no flags Details

Description Rahul Chincholkar 2019-08-05 11:35:26 UTC
Created attachment 1600635 [details]
Separate_Button_and_Button_Set

Description of problem:

We can create a Button Group and a button separately via the API but we can not associate the button with the button group. 
The API docs [1] only show how to create each one, nothing about associating them. The current behaviour is that the custom button is just placed in the 'unassigned' group.
We create the button set first, then in the custom button. we specify the ID of the button in the button order but this doesn't work. The UI show that the button set doesn't contain any buttons.

Version-Release number of selected component (if applicable):
5.10.5.1

How reproducible:
Always


Steps to Reproduce:

Step 1 : Create a button set using API

POST - https://10.74.131.62/api/custom_button_sets
BODY - 
	{
	  "name"        : "MyGroup1",
	  "description" : "MyGroup1",
	  "set_data"    : {
	    "button_icon"      : "ff ff-manageiq",
	    "button_color"     : "#4727ff",
	    "display"          : true,
	    "applies_to_class" : "Service"
	  }
	}


Step 2 : Create a button using API

POST - https://10.74.131.62/api/custom_buttons
BODY -

	{
	  "name"             : "MyButton",
	  "description"      : "MyButton",
	  "applies_to_class" : "Service",
	  "options"          : {
	    "button_icon"    : "ff ff-manageiq",
	    "button_color"   : "#4727ff",
	    "display"        : true
	  },
	  "resource_action"  : {
	    "ae_namespace"   : "SYSTEM",
	    "ae_class"       : "PROCESS"
	  },
	  "visibility"       : {
	    "roles"          : ["_ALL_"]
	  }
	}


Step 3 : Set the button_order for button_set using button ID (Because we want to assign button to button_set), Under RESPONSE the button_order has been properly assigned.

POST - https://10.74.131.62/api/custom_button_sets/1000000000032
BODY - 

	{
	  "action" : "edit",
	  "resource" : {
	    "set_data" : {
	      "button_order": [ "1000000000003" ],
	      "button_icon": "ff ff-manageiq",
	      "button_color": "#4727ff",
	      "display": true,
	      "applies_to_class": "Service"
	    }
	  }
	}

RESPONSE - 

	{
	    "href": "https://10.74.131.62/api/custom_button_sets/1000000000032",
	    "id": "1000000000032",
	    "set_data": {
	        "button_order": [
	            "1000000000003"
	        ],
	        "button_icon": "ff ff-manageiq",
	        "button_color": "#4727ff",
	        "display": true,
	        "applies_to_class": "Service"
	    },
	    "name": "MyGroup1",
	    "set_type": "CustomButtonSet",
	    "userid": null,
	    "group_id": null,
	    "description": "MyGroup1",
	    "created_on": "2019-08-05T11:06:45Z",
	    "updated_on": "2019-08-05T11:13:53Z",
	    "guid": "807ca229-cb87-454e-8947-4043fc34f4d1",
	    "read_only": null,
	    "mode": null,
	    "owner_type": null,
	    "owner_id": null
	}



Step 4 - Verify the button set

GET - https://10.74.131.62/api/custom_button_sets/1000000000032

RESPONSE - 
	{
	    "href": "https://10.74.131.62/api/custom_button_sets/1000000000032",
	    "id": "1000000000032",
	    "name": "MyGroup1",
	    "description": "MyGroup1",
	    "set_type": "CustomButtonSet",
	    "created_on": "2019-08-05T11:06:45Z",
	    "updated_on": "2019-08-05T11:13:53Z",
	    "guid": "807ca229-cb87-454e-8947-4043fc34f4d1",
	    "read_only": null,
	    "set_data": {
	        "button_order": [
	            "1000000000003"
	        ],
	        "button_icon": "ff ff-manageiq",
	        "button_color": "#4727ff",
	        "display": true,
	        "applies_to_class": "Service"
	    },
	    "mode": null,
	    "owner_type": null,
	    "owner_id": null,
	    "userid": null,
	    "group_id": null,
	    "actions": [
	        {
	            "name": "edit",
	            "method": "post",
	            "href": "https://10.74.131.62/api/custom_button_sets/1000000000032"
	        },
	        {
	            "name": "edit",
	            "method": "patch",
	            "href": "https://10.74.131.62/api/custom_button_sets/1000000000032"
	        },
	        {
	            "name": "edit",
	            "method": "put",
	            "href": "https://10.74.131.62/api/custom_button_sets/1000000000032"
	        },
	        {
	            "name": "delete",
	            "method": "post",
	            "href": "https://10.74.131.62/api/custom_button_sets/1000000000032"
	        },
	        {
	            "name": "delete",
	            "method": "delete",
	            "href": "https://10.74.131.62/api/custom_button_sets/1000000000032"
	        }
	    ]
	}

Step 5 : The assignment of button and button set is not working with above API calls.


Actual results:
In UI, we still see the button and button sets are separate (Screenshot Attached).

Expected results:
Buttons can be assigned to Button Sets using REST API

Additional info:
[1] http://manageiq.org/docs/reference/latest/api/reference/custom_buttons

Comment 2 drew uhlmann 2019-08-12 15:52:02 UTC
By way of https://github.com/ManageIQ/manageiq/pull/18368, this is fixed on master.

Comment 3 drew uhlmann 2019-08-13 13:04:50 UTC
So if we were to backport that to H, we would also need the following: 
https://github.com/ManageIQ/manageiq-ui-classic/pull/5319 and https://github.com/ManageIQ/manageiq-api/pull/563

With those three backported, this should be fixed.

Comment 4 drew uhlmann 2019-08-21 15:03:43 UTC
And https://github.com/ManageIQ/manageiq/pull/19169

Comment 5 CFME Bot 2019-08-21 20:26:25 UTC
New commit detected on ManageIQ/manageiq/ivanchuk:

https://github.com/ManageIQ/manageiq/commit/c4b2d8aa0425fa12649c7b9a1d772e7da596a98e
commit c4b2d8aa0425fa12649c7b9a1d772e7da596a98e
Author:     Brandon Dunne <bdunne>
AuthorDate: Tue Aug 20 13:15:40 2019 -0400
Commit:     Brandon Dunne <bdunne>
CommitDate: Tue Aug 20 13:15:40 2019 -0400

    Merge pull request #19169 from d-m-u/fixing_custom_button_set_copy_children

    Fix the custom button set set_data hash links to the original buttons on copy

    (cherry picked from commit 68f281d47fe19f84f0aacff9e8d764d69e315416)

    https://bugzilla.redhat.com/show_bug.cgi?id=1740556
    https://bugzilla.redhat.com/show_bug.cgi?id=1737449

 app/models/custom_button_set.rb | 8 +-
 spec/models/custom_button_set_spec.rb | 3 +-
 spec/models/service_template/copy_spec.rb | 10 +-
 3 files changed, 18 insertions(+), 3 deletions(-)

Comment 7 Nikhil Dhandre 2019-08-28 08:22:03 UTC
Tested with 5.11.0.21

Now its possible to associate unassigned button with group using REST API.

Verification steps:

1. Create group (tested with service)

POST - https://192.168.122.231/api/custom_button_sets

	{
	  "name"        : "MyGroup1",
	  "description" : "MyGroup1",
	  "set_data"    : {
	    "button_icon"      : "ff ff-manageiq",
	    "button_color"     : "#4727ff",
	    "display"          : true,
	    "applies_to_class" : "Service"
	  }
	}

# response id = 28

2. Create two unassigned buttons

POST - https://192.168.122.231/api/custom_buttons

	{
	  "name"             : "MyButton_1",
	  "description"      : "MyButton_2",
	  "applies_to_class" : "Service",
	  "options"          : {
	    "button_icon"    : "ff ff-manageiq",
	    "button_color"   : "#4727ff",
	    "display"        : true
	  },
	  "resource_action"  : {
	    "ae_namespace"   : "SYSTEM",
	    "ae_class"       : "PROCESS"
	  },
	  "visibility"       : {
	    "roles"          : ["_ALL_"]
	  }
	}
# response id = 5 and 6

Step 3 : Set the button_order for button_set using button ID (Because we want to assign button to button_set), Under RESPONSE the button_order has been properly assigned.

POST - https://192.168.122.231/api/custom_button_sets/28

	{
	  "action" : "edit",
	  "resource" : {
	    "set_data" : {
	      "button_order": [ 6, 5 ],
	      "button_icon": "ff ff-manageiq",
	      "button_color": "#4727ff",
	      "display": true,
	      "applies_to_class": "Service"
	    }
	  }
	}


Verify with UI and REST



It assigned to group.


Note You need to log in before you can comment on or make changes to this bug.