[Freeipa-devel] [freeipa PR#400][synchronized] WebUI: Certificate Mapping
URL: https://github.com/freeipa/freeipa/pull/400 Author: pvomacka Title: #400: WebUI: Certificate Mapping Action: synchronized To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/400/head:pr400 git checkout pr400 From 4ec6844bec472e6a54352e0694cf1655d1df5a71 Mon Sep 17 00:00:00 2001 From: Pavel VomackaDate: Mon, 16 Jan 2017 13:59:16 +0100 Subject: [PATCH 1/4] WebUI: Add possibility to set field always writable If field will have set attribute 'always_writable' to true, then 'no_update' flag will be ingored. Used in command user-{add,remove}-certmap which needs to be writable in WebUI and also needs to be omitted from user-mod command. Part of: https://fedorahosted.org/freeipa/ticket/6601 --- install/ui/src/freeipa/field.js | 43 +++- install/ui/src/freeipa/widget.js | 35 ++-- 2 files changed, 52 insertions(+), 26 deletions(-) diff --git a/install/ui/src/freeipa/field.js b/install/ui/src/freeipa/field.js index d70a778..9f287dd 100644 --- a/install/ui/src/freeipa/field.js +++ b/install/ui/src/freeipa/field.js @@ -484,7 +484,16 @@ field.field = IPA.field = function(spec) { writable = false; } -if (that.metadata.flags && array.indexOf(that.metadata.flags, 'no_update') > -1) { +// In case that field has set always_writable attribute, then +// 'no_update' flag is ignored in WebUI. It is done because of +// commands like user-{add,remove}-certmap. They operate with user's +// attribute, which cannot be changed using user-mod, but only +// using command user-{add,remove}-certmap. Therefore it has set +// 'no_update' flag, but we need to show 'Add', 'Remove' buttons in +// WebUI. +if (that.metadata.flags && +array.indexOf(that.metadata.flags, 'no_update') > -1 && +!that.always_writable) { writable = false; } } @@ -1259,6 +1268,37 @@ field.certs_field = IPA.certs_field = function(spec) { return that; }; + +/** + * Used along with custom_command_multivalued widget + * + * - by default has `w_if_no_aci` to workaround missing object class + * - by default has always_writable=true to workaround aci rights + * + * @class + * @alternateClassName IPA.custom_command_multivalued_field + * @extends IPA.field + */ +field.certmap_command_multivalued_field = function(spec) { + +spec = spec || {}; +spec.flags = spec.flags || ['w_if_no_aci']; + +var that = IPA.field(spec); + +/** + * Set field always writable in case that it is set to true + * @param Boolean always_writable + */ +that.always_writable = spec.always_writable === undefined ? true : +spec.always_writable; + +return that; +}; + + +IPA.custom_command_multivalued_field = field.custom_command_multivalued_field; + /** * SSH Keys Adapter * @class @@ -1652,6 +1692,7 @@ field.register = function() { f.register('checkbox', field.checkbox_field); f.register('checkboxes', field.field); f.register('combobox', field.field); +f.register('certmap_multivalued', field.certmap_command_multivalued_field); f.register('datetime', field.datetime_field); f.register('enable', field.enable_field); f.register('entity_select', field.field); diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js index 15f0126..b7028a9 100644 --- a/install/ui/src/freeipa/widget.js +++ b/install/ui/src/freeipa/widget.js @@ -1534,12 +1534,8 @@ IPA.custom_command_multivalued_widget = function(spec) { * Called on error of add command. Override point. */ that.on_error_add = function(xhr, text_status, error_thrown) { -that.adder_dialog.focus_first_element(); - -if (error_thrown.message) { -var msg = error_thrown.message; -IPA.notify(msg, 'error'); -} +that.adder_dialog.show(); +exp.focus_invalid(that.adder_dialog); }; /** @@ -1599,27 +1595,16 @@ IPA.custom_command_multivalued_widget = function(spec) { name: 'custom-add-dialog' }; -that.adder_dialog = IPA.dialog(spec); -that.adder_dialog.create_button({ -name: 'add', -label: '@i18n:buttons.add', -click: function() { -if (!that.adder_dialog.validate()) { -exp.focus_invalid(that.adder_dialog); -} -else { -that.add(that.adder_dialog); -} +spec.on_ok = function() { +if (!that.adder_dialog.validate()) { +exp.focus_invalid(that.adder_dialog); } -}); - -that.adder_dialog.create_button({ -name: 'cancel', -label: '@i18n:buttons.cancel', -
[Freeipa-devel] [freeipa PR#400][synchronized] WebUI: Certificate Mapping
URL: https://github.com/freeipa/freeipa/pull/400 Author: pvomacka Title: #400: WebUI: Certificate Mapping Action: synchronized To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/400/head:pr400 git checkout pr400 From 740a6ed90575051107bae7c0987c62f981308fc9 Mon Sep 17 00:00:00 2001 From: Pavel VomackaDate: Mon, 16 Jan 2017 13:59:16 +0100 Subject: [PATCH 1/4] WebUI: Add possibility to set field always writable If field will have set attribute 'always_writable' to true, then 'no_update' flag will be ingored. Used in command user-{add,remove}-certmap which needs to be writable in WebUI and also needs to be omitted from user-mod command. Part of: https://fedorahosted.org/freeipa/ticket/6601 --- install/ui/src/freeipa/field.js | 43 +++- install/ui/src/freeipa/widget.js | 35 ++-- 2 files changed, 52 insertions(+), 26 deletions(-) diff --git a/install/ui/src/freeipa/field.js b/install/ui/src/freeipa/field.js index d70a778..9f287dd 100644 --- a/install/ui/src/freeipa/field.js +++ b/install/ui/src/freeipa/field.js @@ -484,7 +484,16 @@ field.field = IPA.field = function(spec) { writable = false; } -if (that.metadata.flags && array.indexOf(that.metadata.flags, 'no_update') > -1) { +// In case that field has set always_writable attribute, then +// 'no_update' flag is ignored in WebUI. It is done because of +// commands like user-{add,remove}-certmap. They operate with user's +// attribute, which cannot be changed using user-mod, but only +// using command user-{add,remove}-certmap. Therefore it has set +// 'no_update' flag, but we need to show 'Add', 'Remove' buttons in +// WebUI. +if (that.metadata.flags && +array.indexOf(that.metadata.flags, 'no_update') > -1 && +!that.always_writable) { writable = false; } } @@ -1259,6 +1268,37 @@ field.certs_field = IPA.certs_field = function(spec) { return that; }; + +/** + * Used along with custom_command_multivalued widget + * + * - by default has `w_if_no_aci` to workaround missing object class + * - by default has always_writable=true to workaround aci rights + * + * @class + * @alternateClassName IPA.custom_command_multivalued_field + * @extends IPA.field + */ +field.certmap_command_multivalued_field = function(spec) { + +spec = spec || {}; +spec.flags = spec.flags || ['w_if_no_aci']; + +var that = IPA.field(spec); + +/** + * Set field always writable in case that it is set to true + * @param Boolean always_writable + */ +that.always_writable = spec.always_writable === undefined ? true : +spec.always_writable; + +return that; +}; + + +IPA.custom_command_multivalued_field = field.custom_command_multivalued_field; + /** * SSH Keys Adapter * @class @@ -1652,6 +1692,7 @@ field.register = function() { f.register('checkbox', field.checkbox_field); f.register('checkboxes', field.field); f.register('combobox', field.field); +f.register('certmap_multivalued', field.certmap_command_multivalued_field); f.register('datetime', field.datetime_field); f.register('enable', field.enable_field); f.register('entity_select', field.field); diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js index 15f0126..b7028a9 100644 --- a/install/ui/src/freeipa/widget.js +++ b/install/ui/src/freeipa/widget.js @@ -1534,12 +1534,8 @@ IPA.custom_command_multivalued_widget = function(spec) { * Called on error of add command. Override point. */ that.on_error_add = function(xhr, text_status, error_thrown) { -that.adder_dialog.focus_first_element(); - -if (error_thrown.message) { -var msg = error_thrown.message; -IPA.notify(msg, 'error'); -} +that.adder_dialog.show(); +exp.focus_invalid(that.adder_dialog); }; /** @@ -1599,27 +1595,16 @@ IPA.custom_command_multivalued_widget = function(spec) { name: 'custom-add-dialog' }; -that.adder_dialog = IPA.dialog(spec); -that.adder_dialog.create_button({ -name: 'add', -label: '@i18n:buttons.add', -click: function() { -if (!that.adder_dialog.validate()) { -exp.focus_invalid(that.adder_dialog); -} -else { -that.add(that.adder_dialog); -} +spec.on_ok = function() { +if (!that.adder_dialog.validate()) { +exp.focus_invalid(that.adder_dialog); } -}); - -that.adder_dialog.create_button({ -name: 'cancel', -label: '@i18n:buttons.cancel', -
[Freeipa-devel] [freeipa PR#400][synchronized] WebUI: Certificate Mapping
URL: https://github.com/freeipa/freeipa/pull/400 Author: pvomacka Title: #400: WebUI: Certificate Mapping Action: synchronized To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/400/head:pr400 git checkout pr400 From c2a6ce41c54cc976221ee6c83c7c1286b21e7ff3 Mon Sep 17 00:00:00 2001 From: Pavel VomackaDate: Mon, 16 Jan 2017 13:59:16 +0100 Subject: [PATCH 1/4] WebUI: Add possibility to set field always writable If field will have set attribute 'always_writable' to true, then 'no_update' flag will be ingored. Used in command user-{add,remove}-certmap which needs to be writable in WebUI and also needs to be omitted from user-mod command. Part of: https://fedorahosted.org/freeipa/ticket/6601 --- install/ui/src/freeipa/field.js | 43 +++- install/ui/src/freeipa/widget.js | 35 ++-- 2 files changed, 52 insertions(+), 26 deletions(-) diff --git a/install/ui/src/freeipa/field.js b/install/ui/src/freeipa/field.js index d70a778..9f287dd 100644 --- a/install/ui/src/freeipa/field.js +++ b/install/ui/src/freeipa/field.js @@ -484,7 +484,16 @@ field.field = IPA.field = function(spec) { writable = false; } -if (that.metadata.flags && array.indexOf(that.metadata.flags, 'no_update') > -1) { +// In case that field has set always_writable attribute, then +// 'no_update' flag is ignored in WebUI. It is done because of +// commands like user-{add,remove}-certmap. They operate with user's +// attribute, which cannot be changed using user-mod, but only +// using command user-{add,remove}-certmap. Therefore it has set +// 'no_update' flag, but we need to show 'Add', 'Remove' buttons in +// WebUI. +if (that.metadata.flags && +array.indexOf(that.metadata.flags, 'no_update') > -1 && +!that.always_writable) { writable = false; } } @@ -1259,6 +1268,37 @@ field.certs_field = IPA.certs_field = function(spec) { return that; }; + +/** + * Used along with custom_command_multivalued widget + * + * - by default has `w_if_no_aci` to workaround missing object class + * - by default has always_writable=true to workaround aci rights + * + * @class + * @alternateClassName IPA.custom_command_multivalued_field + * @extends IPA.field + */ +field.certmap_command_multivalued_field = function(spec) { + +spec = spec || {}; +spec.flags = spec.flags || ['w_if_no_aci']; + +var that = IPA.field(spec); + +/** + * Set field always writable in case that it is set to true + * @param Boolean always_writable + */ +that.always_writable = spec.always_writable === undefined ? true : +spec.always_writable; + +return that; +}; + + +IPA.custom_command_multivalued_field = field.custom_command_multivalued_field; + /** * SSH Keys Adapter * @class @@ -1652,6 +1692,7 @@ field.register = function() { f.register('checkbox', field.checkbox_field); f.register('checkboxes', field.field); f.register('combobox', field.field); +f.register('certmap_multivalued', field.certmap_command_multivalued_field); f.register('datetime', field.datetime_field); f.register('enable', field.enable_field); f.register('entity_select', field.field); diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js index 15f0126..b7028a9 100644 --- a/install/ui/src/freeipa/widget.js +++ b/install/ui/src/freeipa/widget.js @@ -1534,12 +1534,8 @@ IPA.custom_command_multivalued_widget = function(spec) { * Called on error of add command. Override point. */ that.on_error_add = function(xhr, text_status, error_thrown) { -that.adder_dialog.focus_first_element(); - -if (error_thrown.message) { -var msg = error_thrown.message; -IPA.notify(msg, 'error'); -} +that.adder_dialog.show(); +exp.focus_invalid(that.adder_dialog); }; /** @@ -1599,27 +1595,16 @@ IPA.custom_command_multivalued_widget = function(spec) { name: 'custom-add-dialog' }; -that.adder_dialog = IPA.dialog(spec); -that.adder_dialog.create_button({ -name: 'add', -label: '@i18n:buttons.add', -click: function() { -if (!that.adder_dialog.validate()) { -exp.focus_invalid(that.adder_dialog); -} -else { -that.add(that.adder_dialog); -} +spec.on_ok = function() { +if (!that.adder_dialog.validate()) { +exp.focus_invalid(that.adder_dialog); } -}); - -that.adder_dialog.create_button({ -name: 'cancel', -label: '@i18n:buttons.cancel', -
[Freeipa-devel] [freeipa PR#400][synchronized] WebUI: Certificate Mapping
URL: https://github.com/freeipa/freeipa/pull/400 Author: pvomacka Title: #400: WebUI: Certificate Mapping Action: synchronized To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/400/head:pr400 git checkout pr400 From f93be59c887ee313ae6c8a5e0e963ee857fee2fb Mon Sep 17 00:00:00 2001 From: Pavel VomackaDate: Mon, 16 Jan 2017 13:59:16 +0100 Subject: [PATCH 1/3] WebUI: Add possibility to set widget always writable If widget will have set attribute 'always_writable' to true, then 'no_update' flag will be ingored. Used in command user-{add,remove}-certmap which needs to be writable in WebUI and also needs to be omitted from user-mod command. Part of: https://fedorahosted.org/freeipa/ticket/6601 --- install/ui/src/freeipa/field.js | 11 ++- install/ui/src/freeipa/widget.js | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/install/ui/src/freeipa/field.js b/install/ui/src/freeipa/field.js index d70a778..2d05ab1 100644 --- a/install/ui/src/freeipa/field.js +++ b/install/ui/src/freeipa/field.js @@ -484,7 +484,16 @@ field.field = IPA.field = function(spec) { writable = false; } -if (that.metadata.flags && array.indexOf(that.metadata.flags, 'no_update') > -1) { +// In case that widget has set always_writable attribute, then +// 'no_update' flag is ignored in WebUI. It is done because of +// commands like user-{add,remove}-certmap. They operate with user's +// attribute, which cannot be changed using user-mod, but only +// using command user-{add,remove}-certmap. Therefore it has set +// 'no_update' flag, but we need to show 'Add', 'Remove' buttons in +// WebUI. +if (that.metadata.flags && +array.indexOf(that.metadata.flags, 'no_update') > -1 && +that.widget && !that.widget.always_writable) { writable = false; } } diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js index 6ad8aad..e6dfef9 100644 --- a/install/ui/src/freeipa/widget.js +++ b/install/ui/src/freeipa/widget.js @@ -1516,6 +1516,8 @@ IPA.custom_command_multivalued_widget = function(spec) { var that = IPA.multivalued_widget(spec); +that.always_writable = spec.always_writable || true; + that.item_name = spec.item_name || ''; that.adder_dialog_spec = spec.adder_dialog_spec; From 751c6ff6cf1118e1f1794e0f7b680809ecd2fe77 Mon Sep 17 00:00:00 2001 From: Pavel Vomacka Date: Mon, 16 Jan 2017 14:13:42 +0100 Subject: [PATCH 2/3] WebUI: Create non editable row widget for mutlivalued widget Old krb-principal widget is changed to general one. And used also for ipacertmapdata in user. This widget make every line non-editable. Part of: https://fedorahosted.org/freeipa/ticket/6601 --- install/ui/src/freeipa/host.js| 3 ++- install/ui/src/freeipa/service.js | 3 ++- install/ui/src/freeipa/user.js| 3 ++- install/ui/src/freeipa/widget.js | 29 +++-- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/install/ui/src/freeipa/host.js b/install/ui/src/freeipa/host.js index 87cf264..023530a 100644 --- a/install/ui/src/freeipa/host.js +++ b/install/ui/src/freeipa/host.js @@ -93,7 +93,8 @@ return { name: 'krbprincipalname', item_name: 'principal', child_spec: { -$type: 'krb_principal' +$type: 'non_editable_row', +data_name: 'krb-principal' } }, { diff --git a/install/ui/src/freeipa/service.js b/install/ui/src/freeipa/service.js index a6607d2..adae347 100644 --- a/install/ui/src/freeipa/service.js +++ b/install/ui/src/freeipa/service.js @@ -81,7 +81,8 @@ return { name: 'krbprincipalname', item_name: 'principal', child_spec: { -$type: 'krb_principal' +$type: 'non_editable_row', +data_name: 'krb-principal' } }, { diff --git a/install/ui/src/freeipa/user.js b/install/ui/src/freeipa/user.js index 7a08151..a36b65a 100644 --- a/install/ui/src/freeipa/user.js +++ b/install/ui/src/freeipa/user.js @@ -192,7 +192,8 @@ return { name: 'krbprincipalname', item_name: 'principal', child_spec: { -$type: 'krb_principal' +$type: 'non_editable_row', +