From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 40AEF60C73 for ; Thu, 3 Feb 2022 11:54:06 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3695025179 for ; Thu, 3 Feb 2022 11:53:36 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id A577B2516E for ; Thu, 3 Feb 2022 11:53:35 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 7E72B46D43; Thu, 3 Feb 2022 11:53:35 +0100 (CET) Message-ID: <193782e7-7b6d-9345-4339-23c34dc13027@proxmox.com> Date: Thu, 3 Feb 2022 11:53:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Thunderbird/97.0 Content-Language: en-US To: Proxmox Backup Server development discussion , Hannes Laimer References: <20220202154927.30572-1-h.laimer@proxmox.com> <20220202154927.30572-7-h.laimer@proxmox.com> From: Dominik Csapak In-Reply-To: <20220202154927.30572-7-h.laimer@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.161 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.001 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [activetasks.read] Subject: Re: [pbs-devel] [PATCH proxmox-backup v6 6/6] ui: add option to change the maintenance type X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Feb 2022 10:54:06 -0000 comment inline: On 2/2/22 16:49, Hannes Laimer wrote: > Signed-off-by: Hannes Laimer > --- > www/Makefile | 1 + > www/Utils.js | 23 ++++++++++ > www/datastore/OptionView.js | 30 +++++++++++++ > www/window/MaintenanceOptions.js | 72 ++++++++++++++++++++++++++++++++ > 4 files changed, 126 insertions(+) > create mode 100644 www/window/MaintenanceOptions.js > > diff --git a/www/Makefile b/www/Makefile > index 455fbeec..0952fb82 100644 > --- a/www/Makefile > +++ b/www/Makefile > @@ -61,6 +61,7 @@ JSSRC= \ > window/BackupGroupChangeOwner.js \ > window/CreateDirectory.js \ > window/DataStoreEdit.js \ > + window/MaintenanceOptions.js \ > window/NotesEdit.js \ > window/RemoteEdit.js \ > window/TrafficControlEdit.js \ > diff --git a/www/Utils.js b/www/Utils.js > index 36a94211..db23645a 100644 > --- a/www/Utils.js > +++ b/www/Utils.js > @@ -640,4 +640,27 @@ Ext.define('PBS.Utils', { > return `${icon} ${value}`; > }, > > + renderMaintenance: function(type, activeTasks) { > + if (!type) return gettext('None'); > + let at = 0; > + for (let x of ['read-only-', 'offline-']) { > + if (type.startsWith(x)) { > + at = x.length; > + } > + } > + > + const conflictingTasks = activeTasks.write + (type.startsWith('offline') ? activeTasks.read : 0); > + const checkmarkIcon = ''; > + const spinnerIcon = ''; > + const conflictingTasksMessage = `${conflictingTasks} conflicting tasks still active`; > + const extra = conflictingTasks > 0 ? `| ${spinnerIcon} ${conflictingTasksMessage}` : checkmarkIcon; > + > + const mode = type.substring(0, at-1); > + let msg = type.substring(at); > + if (msg.length > 0) { > + msg = `"${msg}"`; > + } > + return Ext.String.capitalize(`${gettext(mode)} ${msg} ${extra}`) || gettext('None'); two small issues here: i don't think using 'capitalize' is good here because 1. may not work in all translations like you intended 2. the gettext should already be capitalized second issue is that you use a variable in gettext. while it'll "work" the actual values you pass will never be picked up by our script in proxmox-i18n. instead something like this would work better (untested): --- let modeText = Proxmox.Utils.unknownText; switch (mode) { case 'read-only: modeText = gettext("Read-only"); break; case 'offline': modeText = gettext("Offline"); break; } --- with that, the gettexts are properly picked up and you don't need to use 'capitalize' > + }, > + > }); > [..snip..]