diff options
author | Endi S. Dewata <edewata@redhat.com> | 2011-08-29 17:34:10 -0500 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2011-08-31 16:29:45 +0000 |
commit | 6c6748748bca8dba6e8af55917e92839734bbc7b (patch) | |
tree | 8fb460f0874cc173a2f0086f12722831f3d79cb8 /install | |
parent | 6a2dfde086bdda62964a9737a300818d2ab24a4b (diff) | |
download | freeipa-6c6748748bca8dba6e8af55917e92839734bbc7b.tar.gz freeipa-6c6748748bca8dba6e8af55917e92839734bbc7b.tar.xz freeipa-6c6748748bca8dba6e8af55917e92839734bbc7b.zip |
Fixed hard-coded UI messages.
Some hard-coded messages in ipa.js have been moved into internal.py.
The messages in internal.py have been rearranged to match the output
(ipa_init.json).
A new method IPA.get_message() has been added to take a message ID and
return the translated message or a default message if not found.
Ticket #1701
Diffstat (limited to 'install')
-rw-r--r-- | install/ui/entity.js | 5 | ||||
-rw-r--r-- | install/ui/hbac.js | 4 | ||||
-rw-r--r-- | install/ui/ipa.js | 87 | ||||
-rw-r--r-- | install/ui/test/data/ipa_init.json | 38 |
4 files changed, 83 insertions, 51 deletions
diff --git a/install/ui/entity.js b/install/ui/entity.js index ce028a2eb..bba51f79f 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -138,8 +138,7 @@ IPA.facet = function (spec) { that.entity.redirect_facet); }; - var redirect_errors = - ["IPA Error 4001"]; + var redirect_errors = [4001]; that.on_error = function(xhr, text_status, error_thrown) { @@ -147,7 +146,7 @@ IPA.facet = function (spec) { as there is nothing any other facet can do either. */ if (that.entity.redirect_facet) { for (var i=0; i<redirect_errors.length; i++) { - if (error_thrown.name === redirect_errors[i]) { + if (error_thrown.code === redirect_errors[i]) { that.redirect(); return; } diff --git a/install/ui/hbac.js b/install/ui/hbac.js index 3223e0f31..7f445b91f 100644 --- a/install/ui/hbac.js +++ b/install/ui/hbac.js @@ -156,8 +156,8 @@ IPA.hbacrule_details_facet = function(spec) { section.radio({ name: 'ipaenabledflag', options:[ - {'value': 'TRUE',label: IPA.messages['true']}, - {'value': 'FALSE',label:IPA.messages['false']} + { value: 'TRUE', label: IPA.get_message('true') }, + { value: 'FALSE', label: IPA.get_message('false') } ] }); return section; diff --git a/install/ui/ipa.js b/install/ui/ipa.js index decf93f34..f71de82a5 100644 --- a/install/ui/ipa.js +++ b/install/ui/ipa.js @@ -76,7 +76,7 @@ var IPA = ( function () { // On IE the request is missing after authentication, // so the request needs to be resent. - if (error_thrown.name == 'IPA Error 909') { + if (error_thrown.code === 909) { batch.execute(); } else { @@ -208,6 +208,35 @@ var IPA = ( function () { } }; + that.get_message = function(id, default_message) { + var messages = IPA.messages; + var keys = id.split(/\./); + + for (var i=0; messages && i<keys.length; i++) { + var key = keys[i]; + var value = messages[key]; + + // undefined key => not found + if (!value) return default_message; + + // if value is string + if (typeof value === 'string') { + + // and it's the last key => found + if (i === keys.length-1) return value; + + // otherwise value should have been a container => not found + return default_message; + } + + // value is container => check next key + messages = value; + } + + // no more keys/messages => not found + return default_message; + }; + return that; }()); @@ -242,8 +271,7 @@ IPA.command = function(spec) { that.retry = typeof spec.retry == 'undefined' ? true : spec.retry; - that.error_message = spec.error_message || (IPA.messages.dialogs ? - IPA.messages.dialogs.batch_error_message : 'Some operations failed.'); + that.error_message = spec.error_message || IPA.get_message('dialogs.batch_error_message', 'Some operations failed.'); that.get_command = function() { return (that.entity ? that.entity+'_' : '') + that.method; @@ -299,22 +327,19 @@ IPA.command = function(spec) { if (xhr.status === 401) { error_thrown = {}; // error_thrown is string - error_thrown.name = 'Kerberos ticket no longer valid.'; - if (IPA.messages && IPA.messages.ajax) { - error_thrown.message = IPA.messages.ajax["401"]; - } else { - error_thrown.message = - "Your kerberos ticket is no longer valid. "+ - "Please run kinit and then click 'Retry'. "+ - "If this is your first time running the IPA Web UI "+ - "<a href='/ipa/config/unauthorized.html'>"+ - "follow these directions</a> to configure your browser."; - } + error_thrown.name = IPA.get_message('ajax.401.title', + 'Kerberos ticket no longer valid.'); + error_thrown.message = IPA.get_message('ajax.401.message', + "Your kerberos ticket is no longer valid. "+ + "Please run kinit and then click 'Retry'. "+ + "If this is your first time running the IPA Web UI "+ + "<a href='/ipa/config/unauthorized.html'>"+ + "follow these directions</a> to configure your browser."); } else if (!error_thrown) { error_thrown = { - name: xhr.responseText || 'Unknown Error', - message: xhr.statusText || 'Unknown Error' + name: xhr.responseText || IPA.get_message('errors.unknown_error', 'Unknown Error'), + message: xhr.statusText || IPA.get_message('errors.unknown_error', 'Unknown Error') }; } else if (typeof error_thrown == 'string') { @@ -338,15 +363,16 @@ IPA.command = function(spec) { if (!data) { // error_handler() calls IPA.hide_activity_icon() error_handler.call(this, xhr, text_status, /* error_thrown */ { - name: 'HTTP Error '+xhr.status, + name: IPA.get_message('errors.http_error', 'HTTP Error')+' '+xhr.status, url: this.url, - message: data ? xhr.statusText : 'No response' + message: data ? xhr.statusText : IPA.get_message('errors.no_response', 'No response') }); } else if (data.error) { // error_handler() calls IPA.hide_activity_icon() error_handler.call(this, xhr, text_status, /* error_thrown */ { - name: 'IPA Error '+data.error.code, + name: IPA.get_message('errors.ipa_error', 'IPA Error')+' '+data.error.code, + code: data.error.code, message: data.error.message, data: data }); @@ -361,8 +387,7 @@ IPA.command = function(spec) { xhr: xhr, text_status: text_status, error_thrown: { - name: IPA.messages.dialogs ? IPA.messages.dialogs.batch_error_title : - 'Operations Error', + name: IPA.get_message('dialogs.batch_error_title', 'Operations Error'), message: that.error_message }, command: that, @@ -416,7 +441,7 @@ IPA.command = function(spec) { var member = result.failed[association][member_name]; for(var i = 0; i < member.length; i++) { if(member[i].length > 1) { - var name = 'IPA Error'; + var name = IPA.get_message('errors.ipa_error', 'IPA Error'); var message = member[i][1]; if(member[i][0]) message = member[i][0] + ': ' + message; @@ -502,8 +527,8 @@ IPA.batch_command = function (spec) { var message = ''; if (!result) { - name = 'Internal Error '+xhr.status; - message = result ? xhr.statusText : "Internal error"; + name = IPA.get_message('errors.internal_error', 'Internal Error')+' '+xhr.status; + message = result ? xhr.statusText : IPA.get_message('errors.internal_error', 'Internal Error'); that.errors.add(command, name, message, text_status); @@ -518,7 +543,7 @@ IPA.batch_command = function (spec) { ); } else if (result.error) { - name = 'IPA Error ' + (result.error.code || ''); + name = IPA.get_message('errors.ipa_error', 'IPA Error')+(result.error.code ? ' '+result.error.code : ''); message = result.error.message || result.error; that.errors.add(command, name, message, text_status); @@ -529,6 +554,7 @@ IPA.batch_command = function (spec) { text_status, { name: name, + code: result.error.code, message: message, data: result } @@ -548,8 +574,7 @@ IPA.batch_command = function (spec) { xhr: xhr, text_status: text_status, error_thrown: { - name: IPA.messages.dialogs ? IPA.messages.dialogs.batch_error_title : - 'Operations Error', + name: IPA.get_message('dialogs.batch_error_title', 'Operations Error'), message: that.error_message }, command: that, @@ -728,7 +753,7 @@ IPA.error_dialog = function(spec) { that.create = function() { if (that.error_thrown.url) { $('<p/>', { - text: 'URL: '+that.error_thrown.url + text: IPA.get_message('errors.url', 'URL')+': '+that.error_thrown.url }).appendTo(that.container); } @@ -794,21 +819,21 @@ IPA.error_dialog = function(spec) { var label; if(that.visible_buttons.indexOf('retry') > -1) { - label = IPA.messages.buttons ? IPA.messages.buttons.retry : 'Retry'; + label = IPA.get_message('buttons.retry', 'Retry'); that.add_button(label, function() { that.on_retry(); }); } if(that.visible_buttons.indexOf('ok') > -1) { - label = IPA.messages.buttons ? IPA.messages.buttons.ok : 'OK'; + label = IPA.get_message('buttons.ok', 'OK'); that.add_button(label, function() { that.on_ok(); }); } if(that.visible_buttons.indexOf('cancel') > -1) { - label = IPA.messages.buttons ? IPA.messages.buttons.cancel : 'Cancel'; + label = IPA.get_message('buttons.cancel', 'Cancel'); that.add_button(label, function() { that.on_cancel(); }); diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json index 8c4a78077..3de974e43 100644 --- a/install/ui/test/data/ipa_init.json +++ b/install/ui/test/data/ipa_init.json @@ -2578,6 +2578,7 @@ "class": "Password", "cli_name": "password", "cli_short_name": null, + "confirm": false, "default": null, "doc": "Registration password", "exclude": null, @@ -9057,6 +9058,7 @@ "ipadefaultprimarygroup", "ipaenabledflag", "ipaentitlementid", + "ipaexternalmember", "ipagroupobjectclasses", "ipagroupsearchfields", "ipahomesrootdir", @@ -15474,6 +15476,7 @@ "class": "Password", "cli_name": "password", "cli_short_name": null, + "confirm": true, "default": null, "doc": "Prompt to set the user password", "exclude": [ @@ -15912,7 +15915,10 @@ "error": null, "messages": { "ajax": { - "401": "Your Kerberos ticket is no longer valid. Please run kinit and then click 'Retry'. If this is your first time running the IPA Web UI <a href='/ipa/config/unauthorized.html'>follow these directions</a> to configure your browser." + "401": { + "message": "Your Kerberos ticket is no longer valid. Please run kinit and then click 'Retry'. If this is your first time running the IPA Web UI <a href='/ipa/config/unauthorized.html'>follow these directions</a> to configure your browser.", + "title": "Kerberos ticket no longer valid." + } }, "association": { "add": { @@ -15984,8 +15990,16 @@ "remove_empty": "Select entries to be removed.", "remove_title": "Remove ${entity}", "show_details": "Show details", - "validation_title": "Validation error", - "validation_message": "Input form contains invalid or missing values." + "validation_message": "Input form contains invalid or missing values.", + "validation_title": "Validation error" + }, + "errors": { + "http_error": "HTTP Error", + "internal_error": "Internal Error", + "ipa_error": "IPA Error", + "no_response": "No response", + "unknown_error": "Unknown Error", + "url": "URL" }, "facet_groups": { "managedby": "${primary_key} is managed by:", @@ -16278,7 +16292,7 @@ "Administrator" ], "gidnumber": [ - "166000000" + "1890800000" ], "has_keytab": true, "has_password": true, @@ -16286,24 +16300,18 @@ "/home/admin" ], "ipauniqueid": [ - "a632c9f6-cdf7-11e0-89ce-525400e135d8" + "dcc874a0-d2d1-11e0-83f8-525400e135d8" ], "krbextradata": [ { - "__base64__": "AAJyYFROcm9vdC9hZG1pbkBJRE0uTEFCLkJPUy5SRURIQVQuQ09NAA==" - }, - { - "__base64__": "AAgBAA==" + "__base64__": "AAJ/hFxOcm9vdC9hZG1pbkBJRE0uTEFCLkJPUy5SRURIQVQuQ09NAA==" } ], "krblastpwdchange": [ - "20110824022242Z" - ], - "krblastsuccessfulauth": [ - "20110824023056Z" + "20110830063439Z" ], "krbpasswordexpiration": [ - "20111122022242Z" + "20111128063439Z" ], "krbprincipalname": [ "admin@IDM.LAB.BOS.REDHAT.COM" @@ -16331,7 +16339,7 @@ "admin" ], "uidnumber": [ - "166000000" + "1890800000" ] } ], |