summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2014-09-26 16:41:00 +0200
committerPetr Vobornik <pvoborni@redhat.com>2014-09-30 10:47:03 +0200
commit0e76bc1cb65b3eb81b37b4b45ccb71bf91fe5fbc (patch)
tree7472e5bb720d6af7d8ea292c6e316d67e0e43d49
parent2cc78acf9b45b5f8a2d12e232d53267a31732df6 (diff)
downloadfreeipa-0e76bc1cb65b3eb81b37b4b45ccb71bf91fe5fbc.tar.gz
freeipa-0e76bc1cb65b3eb81b37b4b45ccb71bf91fe5fbc.tar.xz
freeipa-0e76bc1cb65b3eb81b37b4b45ccb71bf91fe5fbc.zip
webui: list only not-applied hosts in "apply to host" dialog
https://fedorahosted.org/freeipa/ticket/4535 Reviewed-By: Endi Sukma Dewata <edewata@redhat.com>
-rw-r--r--install/ui/src/freeipa/idviews.js24
1 files changed, 22 insertions, 2 deletions
diff --git a/install/ui/src/freeipa/idviews.js b/install/ui/src/freeipa/idviews.js
index 2ba1fd681..18f48acb6 100644
--- a/install/ui/src/freeipa/idviews.js
+++ b/install/ui/src/freeipa/idviews.js
@@ -415,11 +415,12 @@ idviews.apply_action = function(spec) {
/**
* Create and open dialog
*/
- that.show_dialog = function(facet, current_pkeys) {
+ that.show_dialog = function(facet) {
var pkey = facet.get_pkey();
var other_entity = reg.entity.get(that.other_entity);
var other_entity_label = other_entity.metadata.label;
+ var exclude = that.get_exclude(facet);
var title = text.get(that.dialog_title);
title = title.replace('${entity}', other_entity_label);
title = title.replace('${primary_key}', pkey);
@@ -430,7 +431,7 @@ idviews.apply_action = function(spec) {
pkey: pkey,
other_entity: other_entity,
attribute_member: that.attribute_member,
- exclude: current_pkeys || [],
+ exclude: exclude,
add_button_label: that.confirm_button_label
});
@@ -478,6 +479,25 @@ idviews.apply_action = function(spec) {
};
/**
+ * Get pkeys which should be excluded from offered pkeys in the dialog
+ *
+ * By default it works only for 'host' of 'appliedtohosts' facet since
+ * other facets might contain completely different values or might have
+ * different API.
+ *
+ * @param {facet.facet} facet
+ * @return {string[]}
+ */
+ that.get_exclude = function(facet) {
+ if (facet && facet.name === 'appliedtohosts' &&
+ that.other_entity === 'host') {
+ var records = facet.get_records_map(facet.data);
+ return records.keys;
+ }
+ return [];
+ };
+
+ /**
* Notify idview.appliedtohosts facet that there were possible changes
* and a refresh is needed.
*/