URL: https://github.com/freeipa/freeipa/pull/3619
Author: serg-cymbaluk
 Title: #3619: WebUI: Fix changing category on HBAC/Sudo/etc Rule pages
Action: opened

PR body:
"""
No object can be added to a rule when object category is 'all'.
So while editing rule there is needed to save actual category value before 
adding related objects.

Ticket: https://pagure.io/freeipa/issue/7961
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/3619/head:pr3619
git checkout pr3619
From 558ebfd042b4ecd8109166beabb4b56b839ae529 Mon Sep 17 00:00:00 2001
From: Serhii Tsymbaliuk <stsym...@redhat.com>
Date: Wed, 4 Sep 2019 08:30:13 +0200
Subject: [PATCH 1/2] WebUI: Fix changing category on HBAC/Sudo/etc Rule pages

No object can be added to a rule when object category is 'all'.
So while editing rule there is needed to save actual category value
before adding related objects.

Ticket: https://pagure.io/freeipa/issue/7961

Signed-off-by: Serhii Tsymbaliuk <stsym...@redhat.com>
---
 install/ui/src/freeipa/association.js |  2 ++
 install/ui/src/freeipa/rule.js        | 49 +++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)

diff --git a/install/ui/src/freeipa/association.js b/install/ui/src/freeipa/association.js
index 8038e2d41d..f10ccb2a5c 100644
--- a/install/ui/src/freeipa/association.js
+++ b/install/ui/src/freeipa/association.js
@@ -668,6 +668,7 @@ IPA.association_table_widget = function (spec) {
                 dialog.get_selected_values(),
                 function(data) {
                     that.refresh();
+                    that.facet.refresh();
                     dialog.close();
 
                     var succeeded = IPA.get_succeeded(data);
@@ -676,6 +677,7 @@ IPA.association_table_widget = function (spec) {
                 },
                 function() {
                     that.refresh();
+                    that.facet.refresh();
                     dialog.close();
                 }
             );
diff --git a/install/ui/src/freeipa/rule.js b/install/ui/src/freeipa/rule.js
index 7c7e6f1c1a..fbf83cc87a 100644
--- a/install/ui/src/freeipa/rule.js
+++ b/install/ui/src/freeipa/rule.js
@@ -35,6 +35,14 @@ IPA.rule_details_widget = function(spec) {
 
     spec = spec || {};
 
+    // Link association table with category option.
+    for (var i=0; i<spec.widgets.length; i++) {
+        var widget = spec.widgets[i];
+        if (widget.$type == 'rule_association_table') {
+            widget.category_name = spec.radio_name;
+        }
+    }
+
     var that = IPA.composite_widget(spec);
 
     that.radio_name = spec.radio_name;
@@ -126,6 +134,7 @@ IPA.rule_association_table_widget = function(spec) {
     var that = IPA.association_table_widget(spec);
 
     that.external = spec.external;
+    that.category_name = spec.category_name;
 
     that.setup_column = function(column, div, record) {
         var suppress_link = false;
@@ -177,6 +186,46 @@ IPA.rule_association_table_widget = function(spec) {
         });
     };
 
+    that.add = function(values, on_success, on_error) {
+
+        var pkey = that.facet.get_pkey();
+
+        var batch = rpc.batch_command({
+            name: 'add_association',
+            on_success: on_success,
+            on_error: on_error
+        });
+
+        if (that.category_name) {
+            var category_field = that.facet.get_field(that.category_name);
+
+            // Save category option if the field value is changed.
+            if (category_field.dirty) {
+                var options = {};
+                options[that.category_name] = category_field.value[0];
+
+                command = rpc.command({
+                    entity: that.entity.name,
+                    method: 'mod',
+                    args: [pkey],
+                    options: options
+                });
+                batch.add_command(command);
+            }
+        }
+
+        command = rpc.command({
+            entity: that.entity.name,
+            method: that.add_method,
+            args: [pkey]
+        });
+        that.join_additional_option(command);
+        that.handle_entity_option(command, values);
+        batch.add_command(command);
+
+        batch.execute();
+    };
+
     return that;
 };
 

From d06b4ad71cd48d23ced58a847174deca11e6655c Mon Sep 17 00:00:00 2001
From: Serhii Tsymbaliuk <stsym...@redhat.com>
Date: Wed, 4 Sep 2019 08:56:43 +0200
Subject: [PATCH 2/2] Temp commit

---
 .freeipa-pr-ci.yaml                        |  2 +-
 ipatests/prci_definitions/temp_commit.yaml | 14 +++++++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/.freeipa-pr-ci.yaml b/.freeipa-pr-ci.yaml
index abcf8c5b63..8065669008 120000
--- a/.freeipa-pr-ci.yaml
+++ b/.freeipa-pr-ci.yaml
@@ -1 +1 @@
-ipatests/prci_definitions/gating.yaml
\ No newline at end of file
+ipatests/prci_definitions/temp_commit.yaml
\ No newline at end of file
diff --git a/ipatests/prci_definitions/temp_commit.yaml b/ipatests/prci_definitions/temp_commit.yaml
index 295b272d2b..71b3c7eca8 100644
--- a/ipatests/prci_definitions/temp_commit.yaml
+++ b/ipatests/prci_definitions/temp_commit.yaml
@@ -49,14 +49,18 @@ jobs:
         timeout: 1800
         topology: *build
 
-  fedora-30/temp_commit:
+  fedora-30/test_webui_rules:
     requires: [fedora-30/build]
     priority: 50
     job:
-      class: RunPytest
+      class: RunWebuiTests
       args:
         build_url: '{fedora-30/build_url}'
-        test_suite: test_integration/test_REPLACEME.py
+        test_suite: >-
+          test_webui/test_hbac.py
+          test_webui/test_netgroup.py
+          test_webui/test_selinuxusermap.py
+          test_webui/test_sudo.py
         template: *ci-master-f30
-        timeout: 3600
-        topology: *master_1repl_1client
+        timeout: 4800
+        topology: *ipaserver
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/freeipa-devel@lists.fedorahosted.org

Reply via email to