This patch modifies the status attributes in users, DNS zones,
HBAC/sudo rules, HBAC test, and SELinux User Map to use the same
label (i.e. Status) and values (i.e. Enabled/Disabled). The method
to change the status will be modified separately.

Ticket #2247

--
Endi S. Dewata
From 188afbf67fdc7c22bbbdadbdaa1149d9a4ff4a46 Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata <edew...@redhat.com>
Date: Wed, 18 Jan 2012 21:54:41 -0600
Subject: [PATCH] Fixed inconsistent status labels.

This patch modifies the status attributes in users, DNS zones,
HBAC/sudo rules, HBAC test, and SELinux User Map to use the same
label (i.e. Status) and values (i.e. Enabled/Disabled). The method
to change the status will be modified separately.

Ticket #2247
---
 install/ui/dns.js                             |   15 ++++++--
 install/ui/hbac.js                            |   10 +++---
 install/ui/hbactest.js                        |   21 ++++-------
 install/ui/selinux.js                         |   10 +++---
 install/ui/sudo.js                            |   10 +++---
 install/ui/test/data/dnszone_find_pkeys.json  |    6 +++
 install/ui/test/data/dnszone_get_records.json |   49 +++++++++++++++++++++++++
 install/ui/test/data/ipa_init.json            |   21 +++++------
 install/ui/user.js                            |   36 ++++++++----------
 install/ui/widget.js                          |   13 +++++++
 ipalib/plugins/internal.py                    |   19 +++++-----
 11 files changed, 138 insertions(+), 72 deletions(-)

diff --git a/install/ui/dns.js b/install/ui/dns.js
index 6383d922770333a7d848541a8645538c46004372..d23eca3a9fef71a0e95befee4f83a419038a545a 100644
--- a/install/ui/dns.js
+++ b/install/ui/dns.js
@@ -43,8 +43,16 @@ IPA.dns.zone_entity = function(spec) {
 
         that.builder.facet_groups([ 'dnsrecord', 'settings' ]).
         search_facet({
+            row_enabled_attribute: 'idnszoneactive',
             title: IPA.metadata.objects.dnszone.label,
-            columns: [ 'idnsname' ]
+            columns: [
+                'idnsname',
+                {
+                    name: 'idnszoneactive',
+                    label: IPA.messages.status.label,
+                    format: IPA.boolean_status_format()
+                }
+            ]
         }).
         details_facet({
             factory: IPA.dnszone_details_facet,
@@ -55,9 +63,10 @@ IPA.dns.zone_entity = function(spec) {
                     {
                         type: 'radio',
                         name: 'idnszoneactive',
+                        label: IPA.messages.status.label,
                         options: [
-                            { value: 'TRUE', label: IPA.get_message('true') },
-                            { value: 'FALSE', label: IPA.get_message('false') }
+                            { value: 'TRUE', label: IPA.messages.status.enabled },
+                            { value: 'FALSE', label: IPA.messages.status.disabled }
                         ]
                     },
                     'idnssoamname',
diff --git a/install/ui/hbac.js b/install/ui/hbac.js
index 5d6de15d303ac60eecf85207ccdfadcf64540af9..bff2af30c82a7ad0cff77dcc024c6ca6144b4c78 100644
--- a/install/ui/hbac.js
+++ b/install/ui/hbac.js
@@ -43,9 +43,8 @@ IPA.hbac.rule_entity = function(spec) {
                 'cn',
                 {
                     name: 'ipaenabledflag',
-                    format: IPA.boolean_format({
-                        show_false: true
-                    })
+                    label: IPA.messages.status.label,
+                    format: IPA.boolean_status_format()
                 },
                 'description'
             ]
@@ -208,6 +207,7 @@ IPA.hbacrule_details_facet = function(spec) {
         {
             type: 'enable',
             name: 'ipaenabledflag',
+            label: IPA.messages.status.label,
             priority: IPA.hbac.enable_priority,
             widget: 'general.ipaenabledflag'
         }
@@ -230,8 +230,8 @@ IPA.hbacrule_details_facet = function(spec) {
                     type: 'enable',
                     name: 'ipaenabledflag',
                     options: [
-                        { value: 'TRUE', label: IPA.get_message('true') },
-                        { value: 'FALSE', label: IPA.get_message('false') }
+                        { value: 'TRUE', label: IPA.messages.status.enabled },
+                        { value: 'FALSE', label: IPA.messages.status.disabled }
                     ]
                 }
             ]
diff --git a/install/ui/hbactest.js b/install/ui/hbactest.js
index b529a1d5ff6bba40883c7eef196ca5d5b339af33..e9b02a14ca0670949f1a7faead70b44f262a3c37 100644
--- a/install/ui/hbactest.js
+++ b/install/ui/hbactest.js
@@ -50,13 +50,10 @@ IPA.hbac.test_entity = function(spec) {
                 'sn',
                 {
                     name: 'nsaccountlock',
-                    format: IPA.boolean_format({
-                        true_value: IPA.messages.objects.user.active,
-                        false_value: IPA.messages.objects.user.inactive,
-                        invert_value: true,
-                        show_false: true
-                    }),
-                    label: IPA.messages.objects.user.account_status
+                    label: IPA.messages.status.label,
+                    format: IPA.boolean_status_format({
+                        invert_value: true
+                    })
                 }
             ]
         }).
@@ -118,9 +115,8 @@ IPA.hbac.test_entity = function(spec) {
                 'cn',
                 {
                     name: 'ipaenabledflag',
-                    format: IPA.boolean_format({
-                        show_false: true
-                    })
+                    label: IPA.messages.status.label,
+                    format: IPA.boolean_status_format()
                 },
                 'description'
             ]
@@ -142,9 +138,8 @@ IPA.hbac.test_entity = function(spec) {
                 },
                 {
                     name: 'ipaenabledflag',
-                    format: IPA.boolean_format({
-                        show_false: true
-                    })
+                    label: IPA.messages.status.label,
+                    format: IPA.boolean_status_format()
                 },
                 'description'
             ]
diff --git a/install/ui/selinux.js b/install/ui/selinux.js
index 1ca11760d3919e49025087b3d69488363e5a2a5b..050659a6773ed901ffb33bcf8710078ba106d84c 100644
--- a/install/ui/selinux.js
+++ b/install/ui/selinux.js
@@ -42,9 +42,8 @@ IPA.selinux.selinuxusermap_entity = function(spec) {
                 'ipaselinuxuser',
                 {
                     name: 'ipaenabledflag',
-                    format: IPA.boolean_format({
-                        show_false: true
-                    })
+                    label: IPA.messages.status.label,
+                    format: IPA.boolean_status_format()
                 },
                 'description'
             ]
@@ -96,6 +95,7 @@ IPA.selinux_details_facet = function(spec) {
         {
             type: 'enable',
             name: 'ipaenabledflag',
+            label: IPA.messages.status.label,
             priority: IPA.selinux.enable_priority,
             widget: 'general.ipaenabledflag'
         }
@@ -128,8 +128,8 @@ IPA.selinux_details_facet = function(spec) {
                     type: 'enable',
                     name: 'ipaenabledflag',
                     options: [
-                        { value: 'TRUE', label: IPA.get_message('true') },
-                        { value: 'FALSE', label: IPA.get_message('false') }
+                        { value: 'TRUE', label: IPA.messages.status.enabled },
+                        { value: 'FALSE', label: IPA.messages.status.disabled }
                     ]
                 }
             ]
diff --git a/install/ui/sudo.js b/install/ui/sudo.js
index f1b64bd55b6cdc2c25ccd23c64d781ac43d9066b..78af5fce1633e8ac73dbe32fc81c929e0dc2f312 100644
--- a/install/ui/sudo.js
+++ b/install/ui/sudo.js
@@ -41,9 +41,8 @@ IPA.sudo.rule_entity = function(spec) {
                 'cn',
                 {
                     name: 'ipaenabledflag',
-                    format: IPA.boolean_format({
-                        show_false: true
-                    })
+                    label: IPA.messages.status.label,
+                    format: IPA.boolean_status_format()
                 },
                 'description'
             ]
@@ -206,6 +205,7 @@ IPA.sudorule_details_facet = function(spec) {
         {
             type: 'enable',
             name: 'ipaenabledflag',
+            label: IPA.messages.status.label,
             priority: IPA.sudo.enable_priority,
             widget: 'general.ipaenabledflag'
         }
@@ -228,8 +228,8 @@ IPA.sudorule_details_facet = function(spec) {
                     type: 'enable',
                     name: 'ipaenabledflag',
                     options: [
-                        { value: 'TRUE', label: IPA.get_message('true') },
-                        { value: 'FALSE', label: IPA.get_message('false') }
+                        { value: 'TRUE', label: IPA.messages.status.enabled },
+                        { value: 'FALSE', label: IPA.messages.status.disabled }
                     ]
                 }
             ]
diff --git a/install/ui/test/data/dnszone_find_pkeys.json b/install/ui/test/data/dnszone_find_pkeys.json
index f40636f434ad963edc62056c51cb0557ef522ba6..8f642cce81b7dbdffa334113c69ca0794a945be7 100644
--- a/install/ui/test/data/dnszone_find_pkeys.json
+++ b/install/ui/test/data/dnszone_find_pkeys.json
@@ -15,6 +15,12 @@
                 "idnsname": [
                     "example.com"
                 ]
+            },
+            {
+                "dn": "idnsname=test.com,cn=dns,dc=example,dc=com",
+                "idnsname": [
+                    "test.com"
+                ]
             }
         ],
         "summary": null,
diff --git a/install/ui/test/data/dnszone_get_records.json b/install/ui/test/data/dnszone_get_records.json
index 2e14716ce5412b58182f5ec45b3f5802e8155119..d1d20bf0323aa94e9938ed3cce8818644bd890a1 100644
--- a/install/ui/test/data/dnszone_get_records.json
+++ b/install/ui/test/data/dnszone_get_records.json
@@ -101,6 +101,55 @@
                 },
                 "summary": null,
                 "value": "example.com"
+            },
+            {
+                "error": null,
+                "result": {
+                    "dn": "idnsname=test.com,cn=dns,dc=example,dc=com",
+                    "idnsallowdynupdate": [
+                        "TRUE"
+                    ],
+                    "idnsname": [
+                        "test.com"
+                    ],
+                    "idnssoaexpire": [
+                        "1209600"
+                    ],
+                    "idnssoaminimum": [
+                        "3600"
+                    ],
+                    "idnssoamname": [
+                        "dev.example.com."
+                    ],
+                    "idnssoarefresh": [
+                        "3600"
+                    ],
+                    "idnssoaretry": [
+                        "900"
+                    ],
+                    "idnssoarname": [
+                        "root.dev.example.com."
+                    ],
+                    "idnssoaserial": [
+                        "2010021201"
+                    ],
+                    "idnsupdatepolicy": [
+                        "grant TEST.COM krb5-self * A;"
+                    ],
+                    "idnszoneactive": [
+                        "FALSE"
+                    ],
+                    "nsrecord": [
+                        "dev.example.com."
+                    ],
+                    "objectclass": [
+                        "top",
+                        "idnsrecord",
+                        "idnszone"
+                    ]
+                },
+                "summary": null,
+                "value": "test.com"
             }
         ]
     }
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index a0738734b51a10a6fdfc6b1d016296ef0eeb723d..b819c30b1ed17b54d16a2410c42adfd422f46bcc 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -202,12 +202,10 @@
                             "posix": "Is this a POSIX group?"
                         },
                         "hbacrule": {
-                            "active": "Active",
                             "any_host": "Any Host",
                             "any_service": "Any Service",
                             "anyone": "Anyone",
                             "host": "Accessing",
-                            "inactive": "Inactive",
                             "ipaenabledflag": "Rule status",
                             "service": "Via Service",
                             "sourcehost": "From",
@@ -310,7 +308,6 @@
                             "commands": "Commands"
                         },
                         "sudorule": {
-                            "active": "Active",
                             "allow": "Allow",
                             "any_command": "Any Command",
                             "any_group": "Any Group",
@@ -320,7 +317,6 @@
                             "deny": "Deny",
                             "external": "External",
                             "host": "Access this host",
-                            "inactive": "Inactive",
                             "ipaenabledflag": "Rule status",
                             "options": "Options",
                             "runas": "As Whom",
@@ -333,17 +329,13 @@
                         "user": {
                             "account": "Account Settings",
                             "account_status": "Account Status",
-                            "activate": "Activate",
-                            "activation_confirmation": "Are you sure you want to ${action} the user?<br/>The change will take effect immediately.",
-                            "activation_link": "Click to ${action}",
-                            "active": "Active",
                             "contact": "Contact Settings",
-                            "deactivate": "Deactivate",
                             "employee": "Employee Information",
                             "error_changing_status": "Error changing account status",
-                            "inactive": "Inactive",
                             "mailing": "Mailing Address",
-                            "misc": "Misc. Information"
+                            "misc": "Misc. Information",
+                            "status_confirmation": "Are you sure you want to ${action} the user?<br/>The change will take effect immediately.",
+                            "status_link": "Click to ${action}"
                         }
                     },
                     "password": {
@@ -363,6 +355,13 @@
                         "truncated": "Query returned more results than the configured size limit. Displaying the first ${counter} results.",
                         "unselect_all": "Unselect All"
                     },
+                    "status": {
+                        "disable": "Disable",
+                        "disabled": "Disabled",
+                        "enable": "Enable",
+                        "enabled": "Enabled",
+                        "label": "Status"
+                    },
                     "tabs": {
                         "audit": "Audit",
                         "automount": "Automount",
diff --git a/install/ui/user.js b/install/ui/user.js
index 92ac86a8380bf47fd19110e599b70a1e07d694b4..2466b8801db97e48eb411c7728c03874e6821d27 100644
--- a/install/ui/user.js
+++ b/install/ui/user.js
@@ -43,13 +43,10 @@ IPA.user.entity = function(spec) {
                 'sn',
                 {
                     name: 'nsaccountlock',
-                    format: IPA.boolean_format({
-                        true_value: IPA.messages.objects.user.active,
-                        false_value: IPA.messages.objects.user.inactive,
-                        invert_value: true,
-                        show_false: true
-                    }),
-                    label: IPA.messages.objects.user.account_status
+                    label: IPA.messages.status.label,
+                    format: IPA.boolean_status_format({
+                        invert_value: true
+                    })
                 },
                 'uidnumber',
                 'mail',
@@ -78,7 +75,7 @@ IPA.user.entity = function(spec) {
                         {
                             factory: IPA.user_status_widget,
                             name: 'nsaccountlock',
-                            label: IPA.messages.objects.user.account_status
+                            label: IPA.messages.status.label
                         },
                         'uid',
                         {
@@ -439,19 +436,19 @@ IPA.user_status_widget = function(spec) {
         var action;
 
         if (locked) {
-            status = IPA.messages.objects.user.inactive;
-            action = 'activate';
+            status = IPA.messages.status.disabled;
+            action = 'enable';
 
         } else {
-            status = IPA.messages.objects.user.active;
-            action = 'deactivate';
+            status = IPA.messages.status.enabled;
+            action = 'disable';
         }
 
         that.status_span.html(status);
         that.status_link.attr('href', action);
 
-        var message = IPA.messages.objects.user.activation_link;
-        var action_label = IPA.messages.objects.user[action];
+        var message = IPA.messages.objects.user.status_link;
+        var action_label = IPA.messages.status[action];
         message = message.replace('${action}', action_label);
 
         that.status_link.html(message);
@@ -473,12 +470,12 @@ IPA.user_status_widget = function(spec) {
 
         var action = that.status_link.attr('href');
 
-        var message = IPA.messages.objects.user.activation_confirmation;
-        var action_label = IPA.messages.objects.user[action];
+        var message = IPA.messages.objects.user.status_confirmation;
+        var action_label = IPA.messages.status[action];
         message = message.replace('${action}', action_label.toLocaleLowerCase());
 
         var dialog = IPA.dialog({
-            'title': IPA.messages.dialogs.confirmation
+            title: IPA.messages.dialogs.confirmation
         });
 
         dialog.create = function() {
@@ -490,7 +487,7 @@ IPA.user_status_widget = function(spec) {
             label: action_label,
             click: function() {
                 that.set_status(
-                    action == 'activate',
+                    action,
                     function(data, textStatus, xhr) {
                         var facet = that.entity.get_facet();
                         facet.refresh();
@@ -511,10 +508,9 @@ IPA.user_status_widget = function(spec) {
         dialog.open(that.container);
     };
 
-    that.set_status = function(enabled, on_success, on_error) {
+    that.set_status = function(method, on_success, on_error) {
 
         var pkey = IPA.nav.get_state('user-pkey');
-        var method = enabled ? 'enable' : 'disable';
 
         IPA.command({
             entity: 'user',
diff --git a/install/ui/widget.js b/install/ui/widget.js
index 85d9282c25cb6b0b65c18825124f3b463944697d..a7dd81e67a91608b960bb1631d8f7d23ab00a8e7 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -1019,6 +1019,19 @@ IPA.boolean_format = function(spec) {
     return that;
 };
 
+IPA.boolean_status_format = function(spec) {
+
+    spec = spec || {};
+
+    var that = IPA.boolean_format(spec);
+
+    that.true_value = spec.true_value || IPA.messages.status.enabled;
+    that.false_value = spec.false_value || IPA.messages.status.disabled;
+    that.show_false = true;
+
+    return that;
+};
+
 /*
   The entity name must be set in the spec either directly or via entity.name
 */
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index 94be9107de2163032a63f3830761d6756e944850..05fb968756078d88902f490690a43b36e9515872 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -339,12 +339,10 @@ class i18n_messages(Command):
                 "posix": _("Is this a POSIX group?"),
             },
             "hbacrule": {
-                "active": _("Active"),
                 "any_host": _("Any Host"),
                 "any_service": _("Any Service"),
                 "anyone": _("Anyone"),
                 "host": _("Accessing"),
-                "inactive": _("Inactive"),
                 "ipaenabledflag": _("Rule status"),
                 "service": _("Via Service"),
                 "sourcehost": _("From"),
@@ -449,7 +447,6 @@ class i18n_messages(Command):
                 "commands": _("Commands"),
             },
             "sudorule": {
-                "active": _("Active"),
                 "allow": _("Allow"),
                 "any_command": _("Any Command"),
                 "any_group": _("Any Group"),
@@ -459,7 +456,6 @@ class i18n_messages(Command):
                 "deny": _("Deny"),
                 "external": _("External"),
                 "host": _("Access this host"),
-                "inactive": _("Inactive"),
                 "ipaenabledflag": _("Rule status"),
                 "options": _("Options"),
                 "runas": _("As Whom"),
@@ -472,17 +468,13 @@ class i18n_messages(Command):
             "user": {
                 "account": _("Account Settings"),
                 "account_status": _("Account Status"),
-                "activate": _("Activate"),
-                "activation_confirmation": _("Are you sure you want to ${action} the user?<br/>The change will take effect immediately."),
-                "activation_link": _("Click to ${action}"),
-                "active": _("Active"),
                 "contact": _("Contact Settings"),
-                "deactivate": _("Deactivate"),
                 "employee": _("Employee Information"),
                 "error_changing_status": _("Error changing account status"),
-                "inactive": _("Inactive"),
                 "mailing": _("Mailing Address"),
                 "misc": _("Misc. Information"),
+                "status_confirmation": _("Are you sure you want to ${action} the user?<br/>The change will take effect immediately."),
+                "status_link": _("Click to ${action}"),
             },
         },
         "password": {
@@ -502,6 +494,13 @@ class i18n_messages(Command):
             "truncated": _("Query returned more results than the configured size limit. Displaying the first ${counter} results."),
             "unselect_all": _("Unselect All"),
         },
+        "status": {
+            "disable": _("Disable"),
+            "disabled": _("Disabled"),
+            "enable": _("Enable"),
+            "enabled": _("Enabled"),
+            "label": _("Status"),
+        },
         "tabs": {
             "audit": _("Audit"),
             "automount": _("Automount"),
-- 
1.7.5.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to