From: Dominik Csapak <d.csapak@proxmox.com>
To: Proxmox Backup Server development discussion
<pbs-devel@lists.proxmox.com>,
Hannes Laimer <h.laimer@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup v6 6/6] ui: add option to change the maintenance type
Date: Thu, 3 Feb 2022 11:53:34 +0100 [thread overview]
Message-ID: <193782e7-7b6d-9345-4339-23c34dc13027@proxmox.com> (raw)
In-Reply-To: <20220202154927.30572-7-h.laimer@proxmox.com>
comment inline:
On 2/2/22 16:49, Hannes Laimer wrote:
> Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
> ---
> 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 = '<i class="fa fa-check"></i>';
> + const spinnerIcon = '<i class="fa fa-spinner fa-pulse fa-fw"></i>';
> + const conflictingTasksMessage = `<i>${conflictingTasks} conflicting tasks still active</i>`;
> + 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..]
next prev parent reply other threads:[~2022-02-03 10:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-02 15:49 [pbs-devel] [PATCH proxmox-backup v6 0/6] closes #3071: maintenance mode for datastore Hannes Laimer
2022-02-02 15:49 ` [pbs-devel] [PATCH proxmox-backup v6 1/6] api-types: add maintenance type Hannes Laimer
2022-02-02 15:49 ` [pbs-devel] [PATCH proxmox-backup v6 2/6] datastore: add check for maintenance in lookup Hannes Laimer
2022-02-02 15:49 ` [pbs-devel] [PATCH proxmox-backup v6 3/6] pbs-datastore: add active operations tracking Hannes Laimer
2022-02-03 10:53 ` Dominik Csapak
2022-02-02 15:49 ` [pbs-devel] [PATCH proxmox-backup v6 4/6] api: make maintenance_type updatable Hannes Laimer
2022-02-02 15:49 ` [pbs-devel] [PATCH proxmox-backup v6 5/6] api: add get_active_operations endpoint Hannes Laimer
2022-02-02 15:49 ` [pbs-devel] [PATCH proxmox-backup v6 6/6] ui: add option to change the maintenance type Hannes Laimer
2022-02-03 10:53 ` Dominik Csapak [this message]
2022-02-03 10:53 ` [pbs-devel] [PATCH proxmox-backup v6 0/6] closes #3071: maintenance mode for datastore Dominik Csapak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=193782e7-7b6d-9345-4339-23c34dc13027@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=h.laimer@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox