[pve-devel] [PATCH manager 2/2] ui: cert upload: fix private key field sending empty string
Max Carrara
m.carrara at proxmox.com
Thu Mar 2 11:42:03 CET 2023
On 3/1/23 10:35, Matthias Heiserer wrote:
> On 28.02.2023 17:36, Max Carrara wrote:
>> The private key's field is now excluded from the upload form's
>> JSON data if it's considered empty by Ext.js.
>>
>> Prior to this change, the form still sent an empty string if no
>> private key was provided by the user, even though the private key's
>> field is marked as optional in `pve-manager/PVE/API2/Certificates.pm`,
>> causing the JSONSchema validation to fail.
>>
>> Signed-off-by: Max Carrara <m.carrara at proxmox.com>
>> ---
>> www/manager6/node/Certificates.js | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/www/manager6/node/Certificates.js
>> b/www/manager6/node/Certificates.js
>> index 34013b44..4c0b18d1 100644
>> --- a/www/manager6/node/Certificates.js
>> +++ b/www/manager6/node/Certificates.js
>> @@ -173,6 +173,13 @@ Ext.define('PVE.node.CertUpload', {
>> emptyText: gettext('No change'),
>> name: 'key',
>> xtype: 'textarea',
>> + getSubmitValue: function() {
>> + let value = this.getValue();
>> + if (Ext.isEmpty(value)) {
>> + return null;
>> + }
>> + return value;
> I guess you could save space and write "return this.getValue() || null;"
> The SubmitValue is a string anyways, so behaviour for Ext.isEmpty and
> || should be the same
> (https://docs.sencha.com/extjs/7.0.0/classic/Ext.html#method-isEmpty
> and
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR)
Good point! Will include that in v2.
>> + },
>> },
>> {
>> xtype: 'filebutton',
>
More information about the pve-devel
mailing list