summaryrefslogtreecommitdiffstats
path: root/install/ui
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2012-09-12 13:41:39 +0200
committerPetr Vobornik <pvoborni@redhat.com>2013-01-07 10:53:58 +0100
commit16663cb215fad4e20169a97231d94d3ee9c21adf (patch)
treef91737663c34fbb2a8314e66632ac38593894a3a /install/ui
parentcbb12c7cc56ba8d9ee48d261fc86ddef5e323c34 (diff)
downloadfreeipa-16663cb215fad4e20169a97231d94d3ee9c21adf.tar.gz
freeipa-16663cb215fad4e20169a97231d94d3ee9c21adf.tar.xz
freeipa-16663cb215fad4e20169a97231d94d3ee9c21adf.zip
Make confirm_dialog a base class of revoke and restore certificate dialogs
https://fedorahosted.org/freeipa/ticket/3035
Diffstat (limited to 'install/ui')
-rwxr-xr-xinstall/ui/certificate.js155
-rw-r--r--install/ui/facet.js12
2 files changed, 58 insertions, 109 deletions
diff --git a/install/ui/certificate.js b/install/ui/certificate.js
index 6a6509e7e..782033db1 100755
--- a/install/ui/certificate.js
+++ b/install/ui/certificate.js
@@ -208,34 +208,14 @@ IPA.cert.download_dialog = function(spec) {
IPA.cert.revoke_dialog = function(spec) {
spec = spec || {};
+ spec.width = spec.width || 500;
+ spec.ok_label = spec.ok_label || IPA.messages.buttons.revoke;
- var that = IPA.dialog(spec);
-
- that.width = spec.width || 500;
- that.height = spec.height || 300;
-
- that.revoke = spec.revoke;
-
- that.create_button({
- name: 'revoke',
- label: IPA.messages.buttons.revoke,
- click: function() {
- var values = {};
- values.reason = that.select.val();
- if (that.revoke) {
- that.revoke(values);
- }
- that.close();
- }
- });
+ var that = IPA.confirm_dialog(spec);
- that.create_button({
- name: 'cancel',
- label: IPA.messages.buttons.cancel,
- click: function() {
- that.close();
- }
- });
+ that.get_reason = function() {
+ return that.select.val();
+ };
that.create = function() {
@@ -270,44 +250,6 @@ IPA.cert.revoke_dialog = function(spec) {
return that;
};
-IPA.cert.restore_dialog = function(spec) {
-
- spec = spec || {};
-
- var that = IPA.dialog(spec);
-
- that.width = spec.width || 400;
- that.height = spec.height || 200;
-
- that.restore = spec.restore;
-
- that.create_button({
- name: 'restore',
- label: IPA.messages.buttons.restore,
- click: function() {
- if (that.restore) {
- that.restore();
- }
- that.close();
- }
- });
-
- that.create_button({
- name: 'cancel',
- label: IPA.messages.buttons.cancel,
- click: function() {
- that.close();
- }
- });
-
- that.create = function() {
- that.container.append(
- IPA.messages.objects.cert.restore_confirmation);
- };
-
- return that;
-};
-
IPA.cert.view_dialog = function(spec) {
spec = spec || {};
@@ -716,15 +658,16 @@ IPA.cert.revoke_action = function(spec) {
spec.enable_cond = spec.enable_cond || ['has_certificate'];
spec.disable_cond = spec.disable_cond || ['certificate_revoked'];
spec.hide_cond = spec.hide_cond || ['selfsign'];
+ spec.confirm_dialog = spec.confirm_dialog || IPA.cert.revoke_dialog;
+ spec.needs_confirm = spec.needs_confirm !== undefined ? spec.needs_confirm : true;
var that = IPA.action(spec);
that.entity_label = spec.entity_label;
- that.request_message = spec.request_message;
+ that.confirm_msg = spec.request_message;
- that.execute_action = function(facet) {
+ that.update_confirm_dialog = function(facet) {
var certificate = facet.certificate;
- if (!certificate) facet.refresh();
var entity_label = that.entity_label || facet.entity.metadata.label_singular;
var entity_name = certificate.entity_info.name;
@@ -733,27 +676,26 @@ IPA.cert.revoke_action = function(spec) {
title = title.replace('${entity}', entity_label);
title = title.replace('${primary_key}', entity_name);
- var dialog = IPA.cert.revoke_dialog({
- title: title,
- message: that.request_message,
- revoke: function(values) {
+ that.dialog.title = title;
+ that.dialog.message = that.get_confirm_message(facet);
+ };
- IPA.command({
- entity: 'cert',
- method: 'revoke',
- args: [certificate.serial_number],
- options: {
- 'revocation_reason': values.reason
- },
- on_success: function(data, text_status, xhr) {
- facet.refresh();
- IPA.notify_success(IPA.messages.objects.cert.revoked);
- }
- }).execute();
- }
- });
+ that.execute_action = function(facet) {
- dialog.open();
+ var certificate = facet.certificate;
+
+ IPA.command({
+ entity: 'cert',
+ method: 'revoke',
+ args: [certificate.serial_number],
+ options: {
+ 'revocation_reason': that.dialog.get_reason()
+ },
+ on_success: function(data, text_status, xhr) {
+ facet.refresh();
+ IPA.notify_success(IPA.messages.objects.cert.revoked);
+ }
+ }).execute();
};
return that;
@@ -766,15 +708,19 @@ IPA.cert.restore_action = function(spec) {
spec.label = spec.label || IPA.messages.buttons.restore;
spec.enable_cond = spec.enable_cond || ['has_certificate', 'certificate_hold'];
spec.hide_cond = spec.hide_cond || ['selfsign'];
+ spec.confirm_msg = spec.confirm_msg || IPA.messages.objects.cert.restore_confirmation;
+ spec.confirm_dialog = spec.confirm_dialog || {
+ factory: IPA.confirm_dialog,
+ ok_label: IPA.messages.buttons.restore
+ };
+ spec.needs_confirm = spec.needs_confirm !== undefined ? spec.needs_confirm : true;
var that = IPA.action(spec);
that.entity_label = spec.entity_label;
- that.request_message = spec.request_message;
- that.execute_action = function(facet) {
+ that.update_confirm_dialog = function(facet) {
var certificate = facet.certificate;
- if (!certificate) facet.refresh();
var entity_label = that.entity_label || facet.entity.metadata.label_singular;
var entity_name = certificate.entity_info.name;
@@ -783,24 +729,23 @@ IPA.cert.restore_action = function(spec) {
title = title.replace('${entity}', entity_label);
title = title.replace('${primary_key}', entity_name);
- var dialog = IPA.cert.restore_dialog({
- title: title,
- message: that.request_message,
- restore: function() {
+ that.dialog.title = title;
+ that.dialog.message = that.get_confirm_message(facet);
+ };
- IPA.command({
- entity: 'cert',
- method: 'remove_hold',
- args: [certificate.serial_number],
- on_success: function(data, text_status, xhr) {
- facet.refresh();
- IPA.notify_success(IPA.messages.objects.cert.restored);
- }
- }).execute();
- }
- });
+ that.execute_action = function(facet) {
- dialog.open();
+ var certificate = facet.certificate;
+
+ IPA.command({
+ entity: 'cert',
+ method: 'remove_hold',
+ args: [certificate.serial_number],
+ on_success: function(data, text_status, xhr) {
+ facet.refresh();
+ IPA.notify_success(IPA.messages.objects.cert.restored);
+ }
+ }).execute();
};
return that;
diff --git a/install/ui/facet.js b/install/ui/facet.js
index 372022dbe..25d48bf66 100644
--- a/install/ui/facet.js
+++ b/install/ui/facet.js
@@ -1323,12 +1323,12 @@ IPA.action = function(spec) {
if (that.confirm_dialog) {
- var dialog = IPA.build(that.confirm_dialog);
- dialog.message = that.get_confirm_message(facet);
- dialog.on_ok = function () {
+ that.dialog = IPA.build(that.confirm_dialog);
+ that.update_confirm_dialog(facet);
+ that.dialog.on_ok = function () {
that.execute_action(facet, on_success, on_error);
};
- dialog.open();
+ that.dialog.open();
} else {
var msg = that.get_confirm_message(facet);
confirmed = IPA.confirm(msg);
@@ -1340,6 +1340,10 @@ IPA.action = function(spec) {
that.execute_action(facet, on_success, on_error);
};
+ that.update_confirm_dialog = function(facet) {
+ that.dialog.message = that.get_confirm_message(facet);
+ };
+
that.get_confirm_message = function(facet) {
return that.confirm_msg;
};