Bug 1702064

Summary: Regex validation not working when using dialogs
Product: Red Hat CloudForms Management Engine Reporter: Satoe Imaishi <simaishi>
Component: AutomateAssignee: eclarizi
Status: CLOSED ERRATA QA Contact: Niyaz Akhtar Ansari <nansari>
Severity: high Docs Contact: Red Hat CloudForms Documentation <cloudforms-docs>
Priority: high    
Version: 5.9.0CC: dmetzger, eclarizi, gmccullo, mkanoor, mshriver, myoder, nansari, obarenbo
Target Milestone: GAKeywords: ZStream
Target Release: 5.10.4   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: 5.10.4.2 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1694737 Environment:
Last Closed: 2019-05-21 05:46:54 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: CFME Core Target Upstream Version:
Embargoed:
Bug Depends On: 1694737    
Bug Blocks:    
Attachments:
Description Flags
datastore
none
testing dialog none

Comment 2 Satoe Imaishi 2019-04-24 17:56:23 UTC
The fix is included in ui-components 1.1.23

https://github.com/ManageIQ/manageiq-ui-classic/pull/5479
https://github.com/ManageIQ/manageiq-ui-service/pull/1540

Comment 3 CFME Bot 2019-04-24 19:48:16 UTC
New commit detected on ManageIQ/ui-components/hammer:

https://github.com/ManageIQ/ui-components/commit/fb9f75d35468feb951991a4d3d6424769ed5ea21
commit fb9f75d35468feb951991a4d3d6424769ed5ea21
Author:     Martin Hradil <himdel>
AuthorDate: Tue Apr  2 10:45:01 2019 -0400
Commit:     Martin Hradil <himdel>
CommitDate: Tue Apr  2 10:45:01 2019 -0400

    Merge pull request #378 from eclarizio/add_validator_rule_attribute_to_update

    Allow validator_rule to be updated in case of dynamic text boxes

    (cherry picked from commit 851569e401f83b1fc7d8fca2340ed3fefe1ea3c7)

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

 src/dialog-user/components/dialog-user/dialogField.spec.ts | 2 +-
 src/dialog-user/components/dialog-user/dialogUser.spec.ts | 20 +-
 src/dialog-user/components/dialog-user/dialogUser.ts | 1 +
 src/dialog-user/services/dialogData.spec.ts | 22 +
 src/dialog-user/services/dialogData.ts | 2 +-
 5 files changed, 36 insertions(+), 11 deletions(-)

Comment 6 Niyaz Akhtar Ansari 2019-05-02 18:00:48 UTC
Created attachment 1561884 [details]
datastore

I have tested this BZ with datastore and dialog and refresh works fine, but I am not able figure out regex to be used.

Could you please help.

Comment 7 Niyaz Akhtar Ansari 2019-05-02 18:01:27 UTC
Created attachment 1561885 [details]
testing dialog

Comment 8 eclarizi 2019-05-02 20:02:07 UTC
You'll just have to add something like:

$evm.object['validator_rule'] = "^1234" to the automate method that the text-box dialog field is using, but this just sets a single validator rule and doesn't ensure that it can be changed, so you'll have to do something like:

if ($evm.root['template'] == "Citrix10") {
  $evm.object['validator_rule'] = "^1234"
} else {
  $evm.object['validator_rule'] = "^4321"
}

Then when you pick Citrix10 from the dropdown, the validation should only pass with strings that start with "1234", and if you pick anything else, only strings that start with "4321" should pass validation.

Hopefully that helps!

Comment 9 myoder 2019-05-06 19:36:20 UTC
Niyaz, Iust configured your appliance with the same automate code and catalog/service dialog configurations, but the regex is still not working.

I noticed there is now a yes/no option for validator in the service dialog.  Perhaps this value needs to be explicitly set in the automate method that populates the 2 dynamic service dialog elements.

One thing I noticed, I manually set the validator option to "yes" and inputted a regex validator expression "^MAX[A-Za-z0-9\-\_]{1,40}$" from within the Web UI.  This worked.  However, I disabled the validator option, yet, the regex validator "^MAX[A-Za-z0-9\-\_]{1,40}$" is still being used despite my automate method populating the regex validator with another expression.

The only other thing, once you turn the validator option to "yes" save it, then edit it to "no" and save, any other time you edit it, the option is stuck between "yes" and "no".

The service catalog and service dialog are both named "regex-test".  I created a automate domain "Yoder", with namespace "DynamicDialogs" and class "Dialogs", otherwise, everything else should be the same as before.

Kind Regards,

Comment 12 CFME Bot 2019-05-08 02:05:43 UTC
New commit detected on ManageIQ/manageiq/hammer:

https://github.com/ManageIQ/manageiq/commit/b739a7820ccec248a82111a32c8b095884094443
commit b739a7820ccec248a82111a32c8b095884094443
Author:     Madhu Kanoor <mkanoor>
AuthorDate: Tue May  7 14:40:00 2019 -0400
Commit:     Madhu Kanoor <mkanoor>
CommitDate: Tue May  7 14:40:00 2019 -0400

    Merge pull request #18743 from eclarizio/allow_textarea_dynamic_attributes

    Allow textarea boxes to dynamically set validator type and rule

    (cherry picked from commit 5bd2a9e8f2465282115ce843ce3b6d07e8efd551)

    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1702064

 app/models/dialog_field_text_area_box.rb | 2 +-
 spec/models/dialog_field_text_area_box_spec.rb | 12 +-
 2 files changed, 9 insertions(+), 5 deletions(-)

Comment 13 Niyaz Akhtar Ansari 2019-05-10 11:27:46 UTC
Verified in Version 5.10.4.2.20190508174256_282f74e

Comment 15 errata-xmlrpc 2019-05-21 05:46:54 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2019:1247