mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Fixed DNS record add handling of 4304 error
Fixed hanling of 4304 error in DNS record add. Code which handled this error in host-add was generalized and moved to IPA. DNS record add both in adder dialog and dns record table are using this generalized version. https://fedorahosted.org/freeipa/ticket/2349
This commit is contained in:
committed by
Petr Vobornik
parent
525bf04da5
commit
cf60e7e71e
@@ -982,11 +982,14 @@ IPA.dns.record_entity = function(spec) {
|
|||||||
IPA.dns.record_adder_dialog = function(spec) {
|
IPA.dns.record_adder_dialog = function(spec) {
|
||||||
|
|
||||||
spec = spec || {};
|
spec = spec || {};
|
||||||
|
spec.retry = spec.retry !== undefined ? spec.retry : false;
|
||||||
|
|
||||||
IPA.dns.record_prepare_spec(spec, IPA.dns.record_prepare_editor_for_type);
|
IPA.dns.record_prepare_spec(spec, IPA.dns.record_prepare_editor_for_type);
|
||||||
|
|
||||||
var that = IPA.entity_adder_dialog(spec);
|
var that = IPA.entity_adder_dialog(spec);
|
||||||
|
|
||||||
|
that.on_error = IPA.create_4304_error_handler(that);
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1621,6 +1624,7 @@ IPA.dns.record_type_table_widget = function(spec) {
|
|||||||
entity: that.entity,
|
entity: that.entity,
|
||||||
fields: [],
|
fields: [],
|
||||||
widgets: [],
|
widgets: [],
|
||||||
|
retry: false,
|
||||||
title: title.replace('${entity}', label)
|
title: title.replace('${entity}', label)
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1635,6 +1639,8 @@ IPA.dns.record_type_table_widget = function(spec) {
|
|||||||
var cancel_button = dialog.buttons.get('cancel');
|
var cancel_button = dialog.buttons.get('cancel');
|
||||||
dialog.buttons.empty();
|
dialog.buttons.empty();
|
||||||
|
|
||||||
|
dialog.on_error = IPA.create_4304_error_handler(dialog);
|
||||||
|
|
||||||
dialog.create_button({
|
dialog.create_button({
|
||||||
name: 'add',
|
name: 'add',
|
||||||
label: IPA.messages.buttons.add,
|
label: IPA.messages.buttons.add,
|
||||||
@@ -1642,7 +1648,12 @@ IPA.dns.record_type_table_widget = function(spec) {
|
|||||||
dialog.hide_message();
|
dialog.hide_message();
|
||||||
dialog.add(
|
dialog.add(
|
||||||
function(data, text_status, xhr) {
|
function(data, text_status, xhr) {
|
||||||
|
|
||||||
|
if (data.result.result.dnsrecords) {
|
||||||
that.reload_facet(data);
|
that.reload_facet(data);
|
||||||
|
} else {
|
||||||
|
that.refresh_facet();
|
||||||
|
}
|
||||||
dialog.close();
|
dialog.close();
|
||||||
},
|
},
|
||||||
dialog.on_error);
|
dialog.on_error);
|
||||||
@@ -1661,7 +1672,11 @@ IPA.dns.record_type_table_widget = function(spec) {
|
|||||||
message = message.replace('${entity}', label);
|
message = message.replace('${entity}', label);
|
||||||
dialog.show_message(message);
|
dialog.show_message(message);
|
||||||
|
|
||||||
|
if (data.result.result.dnsrecords) {
|
||||||
that.reload_facet(data);
|
that.reload_facet(data);
|
||||||
|
} else {
|
||||||
|
that.refresh_facet();
|
||||||
|
}
|
||||||
dialog.reset();
|
dialog.reset();
|
||||||
},
|
},
|
||||||
dialog.on_error);
|
dialog.on_error);
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ IPA.widget_factories['host_fqdn'] = IPA.host_fqdn_widget;
|
|||||||
IPA.host_adder_dialog = function(spec) {
|
IPA.host_adder_dialog = function(spec) {
|
||||||
|
|
||||||
spec = spec || {};
|
spec = spec || {};
|
||||||
spec.retry = typeof spec.retry !== 'undefined' ? spec.retry : false;
|
spec.retry = spec.retry !== undefined ? spec.retry : false;
|
||||||
|
|
||||||
var that = IPA.entity_adder_dialog(spec);
|
var that = IPA.entity_adder_dialog(spec);
|
||||||
|
|
||||||
@@ -356,36 +356,7 @@ IPA.host_adder_dialog = function(spec) {
|
|||||||
that.container.addClass('host-adder-dialog');
|
that.container.addClass('host-adder-dialog');
|
||||||
};
|
};
|
||||||
|
|
||||||
that.on_error = function(xhr, text_status, error_thrown) {
|
that.on_error = IPA.create_4304_error_handler(that);
|
||||||
var ajax = this;
|
|
||||||
var command = that.command;
|
|
||||||
var data = error_thrown.data;
|
|
||||||
var dialog = null;
|
|
||||||
|
|
||||||
if(data && data.error && data.error.code === 4304) {
|
|
||||||
dialog = IPA.message_dialog({
|
|
||||||
message: data.error.message,
|
|
||||||
title: spec.title,
|
|
||||||
on_ok: function() {
|
|
||||||
data.result = {
|
|
||||||
result: {
|
|
||||||
fqdn: command.args[0]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
command.on_success.call(ajax, data, text_status, xhr);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
dialog = IPA.error_dialog({
|
|
||||||
xhr: xhr,
|
|
||||||
text_status: text_status,
|
|
||||||
error_thrown: error_thrown,
|
|
||||||
command: command
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog.open(that.container);
|
|
||||||
};
|
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1178,6 +1178,46 @@ IPA.error_list = function() {
|
|||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
IPA.create_4304_error_handler = function(adder_dialog) {
|
||||||
|
|
||||||
|
var set_pkey = function(result) {
|
||||||
|
|
||||||
|
var pkey_name = adder_dialog.entity.metadata.primary_key;
|
||||||
|
var args = adder_dialog.command.args;
|
||||||
|
var pkey = args[args.length-1];
|
||||||
|
result[pkey_name] = pkey;
|
||||||
|
};
|
||||||
|
|
||||||
|
return function (xhr, text_status, error_thrown) {
|
||||||
|
|
||||||
|
var ajax = this;
|
||||||
|
var command = adder_dialog.command;
|
||||||
|
var data = error_thrown.data;
|
||||||
|
var dialog = null;
|
||||||
|
|
||||||
|
if (data && data.error && data.error.code === 4304) {
|
||||||
|
dialog = IPA.message_dialog({
|
||||||
|
message: data.error.message,
|
||||||
|
title: adder_dialog.title,
|
||||||
|
on_ok: function() {
|
||||||
|
data.result = { result: {} };
|
||||||
|
set_pkey(data.result.result);
|
||||||
|
command.on_success.call(ajax, data, text_status, xhr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
dialog = IPA.error_dialog({
|
||||||
|
xhr: xhr,
|
||||||
|
text_status: text_status,
|
||||||
|
error_thrown: error_thrown,
|
||||||
|
command: command
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog.open(adder_dialog.container);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
IPA.limit_text = function(value, max_length) {
|
IPA.limit_text = function(value, max_length) {
|
||||||
|
|
||||||
if (!value) return '';
|
if (!value) return '';
|
||||||
|
|||||||
Reference in New Issue
Block a user