Bug 1434865

Summary: Cannot copy a built in OpenSCAP policy
Product: Red Hat CloudForms Management Engine Reporter: Pavel Zagalsky <pzagalsk>
Component: UI - OPSAssignee: Robin Knaur <rknaur>
Status: CLOSED CURRENTRELEASE QA Contact: Einat Pacifici <epacific>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 5.8.0CC: dclarizi, fsimonce, hkataria, jhardy, mpovolny, mtayer, obarenbo, rknaur, simaishi
Target Milestone: GAKeywords: TestOnly
Target Release: 5.9.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: container:ui
Fixed In Version: 5.9.0.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1445376 (view as bug list) Environment:
Last Closed: 2018-03-06 14:50:32 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: Bug
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: Container Management Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1445376    
Attachments:
Description Flags
CopyOpenSCAP policy none

Description Pavel Zagalsky 2017-03-22 14:00:29 UTC
Created attachment 1265407 [details]
CopyOpenSCAP policy

Description of problem:
There's a built in OpenSCAP Container Image Compliance Policy. It cannot be copied in GUI

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

How reproducible:
Always

Steps to Reproduce:
1. Go to Control --> Explorer
2. Go to Policies --> Container Image Compliance Policies
3. Select the OpenSCAP policy and press Configuration

Actual results:
The OpenSCAP policy options are all greyed out, hence denying ability to copy the policy which should be available for the user

Expected results:
At least the copying option should bee available for the user. Not sure about the other options in Configuration menu

Additional info:
Screenshot attached

Comment 2 Chris Kacerguis 2017-03-22 15:08:33 UTC
This is not part of the Service UI, this is the Ops UI.  Sending to them.

Comment 4 zakiva 2017-03-23 13:15:41 UTC
I see that all of the policy toolbar buttons in the system including the Copy button are defined as ReadOnly buttons, meaning that they are disabled for a read-only policy. Do we want to change that?

Comment 5 Federico Simoncelli 2017-03-24 14:55:11 UTC
Mooli any specific reason for not being able to copy the OOTB OpenSCAP policy?

Comment 6 Mooli Tayer 2017-03-26 10:41:20 UTC
This is due to a change[1] that made all policy buttons readonly (while copy should not be readonly). 

Robin can you please take a look? 
I'm not sure what the fix would be due to inheritance, maybe we should replace that with mixins?

PS I think there is another potential problem: you can delete policies if they do not belong to a profile but that can allow deleting a readonly policy (should be cannot delete if belong to policy OR is read only))[2]


[1] https://github.com/manageiq/manageiq-ui-classic/commit/cf71d7d43bf9a2589f20bc07f6ee31516947c350#diff-abbe3a37fb8d3ef2e0ec7869dda7eff5R1

The policy button was first introduced in https://github.com/manageiq/manageiq-ui-classic/commit/f1c580b79283bb677cd61ca5537b9a52f6d18a6c#diff-f27ddda7803ce55e5da6a7711c51d419L15

[2] https://github.com/manageiq/manageiq-ui-classic/commit/f1c580b79283bb677cd61ca5537b9a52f6d18a6c#diff-d60ef6310f95c62767cef5969da88b86R4

Comment 7 Robin Knaur 2017-03-27 14:56:26 UTC
Hey,
because of other refactoring these classes look now little bit different, but i think that both of your points are still valid. When i look at it, this class hierarchy for policy buttons could be little bit confusing and I am open to changes.

1. This could be fixed by adding this into class ApplicationHelper::Button::PolicyButton: 
  def disabled?
    false
  end

It's not pretty but it should work.

2. This also could be an issue and could be fixed by changing disabled method in ApplicationHelper::Button::PolicyDelete

  def disabled?
    @error_message = super
    @error_message ||= _('Policies that belong to Profiles can not be deleted') unless @policy.memberof.empty?
    @error_message.present?
  end

This is how changes could look if you don't want to change class hierarchy, but if you want to change it, please do it. I hope, hat i answered your questions, but if you have more questions fell free to ask.

Comment 11 CFME Bot 2017-04-22 04:53:11 UTC
New commit detected on ManageIQ/manageiq-ui-classic/master:
https://github.com/ManageIQ/manageiq-ui-classic/commit/5713886f19409111a6302ab6989e7560a22adc48

commit 5713886f19409111a6302ab6989e7560a22adc48
Author:     PanSpagetka <rknaur>
AuthorDate: Tue Apr 18 11:20:13 2017 +0200
Commit:     PanSpagetka <rknaur>
CommitDate: Fri Apr 21 13:28:36 2017 +0200

    Fix policy delete/copy buttons
    https://bugzilla.redhat.com/show_bug.cgi?id=1434865

 app/helpers/application_helper/button/policy_copy.rb        | 3 ++-
 app/helpers/application_helper/button/policy_delete.rb      | 3 ++-
 app/helpers/application_helper/toolbar/miq_policy_center.rb | 3 +--
 3 files changed, 5 insertions(+), 4 deletions(-)

Comment 12 Mooli Tayer 2017-04-23 13:46:18 UTC
Robin thanks for the fix.
Should this be on POST?

Comment 14 Pavel Zagalsky 2017-10-29 16:49:10 UTC
Verified