From adbd4de2b4d9e340273bad677b006439716ec6ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Fri, 1 Sep 2023 18:14:09 +0200 Subject: [PATCH] Use the sprintf-js library instead of format-util It also supports more formatting attributes like %2$s --- web/package-lock.json | 40 ++++++++++--------- web/package.json | 2 +- web/src/components/core/About.jsx | 4 +- web/src/components/core/ValidationErrors.jsx | 4 +- web/src/components/layout/Icon.jsx | 4 +- .../components/network/ConnectionsTable.jsx | 8 ++-- web/src/components/network/IpSettingsForm.jsx | 4 +- .../network/WifiNetworkListItem.jsx | 4 +- .../components/overview/NetworkSection.jsx | 4 +- web/src/components/storage/DeviceSelector.jsx | 16 ++++---- .../storage/ProposalActionsSection.jsx | 6 +-- .../components/storage/ProposalVolumes.jsx | 6 +-- web/src/components/storage/VolumeForm.jsx | 14 +++---- .../components/storage/iscsi/EditNodeForm.jsx | 4 +- .../components/storage/iscsi/LoginForm.jsx | 4 +- .../storage/iscsi/NodesPresenter.jsx | 4 +- 16 files changed, 65 insertions(+), 63 deletions(-) diff --git a/web/package-lock.json b/web/package-lock.json index 79139409e..e2312c0d1 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -14,13 +14,13 @@ "@patternfly/react-table": "^4.113.0", "core-js": "^3.21.1", "fast-sort": "^3.2.1", - "format-util": "^1.0.5", "ipaddr.js": "^2.0.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.3.0", "react-teleporter": "^3.1.0", "regenerator-runtime": "^0.13.9", + "sprintf-js": "^1.1.2", "xbytes": "^1.8.0" }, "devDependencies": { @@ -5190,6 +5190,12 @@ "sprintf-js": "~1.0.2" } }, + "node_modules/argparse/node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "dev": true + }, "node_modules/aria-query": { "version": "5.1.3", "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.1.3.tgz", @@ -9189,11 +9195,6 @@ "node": ">= 6" } }, - "node_modules/format-util": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/format-util/-/format-util-1.0.5.tgz", - "integrity": "sha512-varLbTj0e0yVyRpqQhuWV+8hlePAgaoFRhNFj50BNjEIrw1/DphHSObtqwskVCPWNgzwPoQrZAbfa/SBiicNeg==" - }, "node_modules/forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", @@ -16094,10 +16095,9 @@ } }, "node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", - "dev": true + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", + "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==" }, "node_modules/stack-utils": { "version": "2.0.6", @@ -22009,6 +22009,14 @@ "dev": true, "requires": { "sprintf-js": "~1.0.2" + }, + "dependencies": { + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "dev": true + } } }, "aria-query": { @@ -24978,11 +24986,6 @@ "mime-types": "^2.1.12" } }, - "format-util": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/format-util/-/format-util-1.0.5.tgz", - "integrity": "sha512-varLbTj0e0yVyRpqQhuWV+8hlePAgaoFRhNFj50BNjEIrw1/DphHSObtqwskVCPWNgzwPoQrZAbfa/SBiicNeg==" - }, "forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", @@ -30040,10 +30043,9 @@ } }, "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", - "dev": true + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", + "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==" }, "stack-utils": { "version": "2.0.6", diff --git a/web/package.json b/web/package.json index 7ffb78a8c..fe25c2126 100644 --- a/web/package.json +++ b/web/package.json @@ -103,13 +103,13 @@ "@patternfly/react-table": "^4.113.0", "core-js": "^3.21.1", "fast-sort": "^3.2.1", - "format-util": "^1.0.5", "ipaddr.js": "^2.0.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.3.0", "react-teleporter": "^3.1.0", "regenerator-runtime": "^0.13.9", + "sprintf-js": "^1.1.2", "xbytes": "^1.8.0" } } diff --git a/web/src/components/core/About.jsx b/web/src/components/core/About.jsx index 3f48059b8..6e1f68f8e 100644 --- a/web/src/components/core/About.jsx +++ b/web/src/components/core/About.jsx @@ -21,7 +21,7 @@ import React, { useState } from "react"; import { Button, Text } from "@patternfly/react-core"; -import format from "format-util"; +import { sprintf } from "sprintf-js"; import { Icon } from "~/components/layout"; import { Popup } from "~/components/core"; @@ -59,7 +59,7 @@ data loss.") { - format( + sprintf( // TRANSLATORS: content of the "About" popup (2/2) // %s is replaced by the project URL _("For more information, please visit the project's repository at %s."), diff --git a/web/src/components/core/ValidationErrors.jsx b/web/src/components/core/ValidationErrors.jsx index c34aba1be..b5f00ac1e 100644 --- a/web/src/components/core/ValidationErrors.jsx +++ b/web/src/components/core/ValidationErrors.jsx @@ -29,7 +29,7 @@ import { ListItem, Popover } from "@patternfly/react-core"; -import format from "format-util"; +import { sprintf } from "sprintf-js"; import { Icon } from '~/components/layout'; import { _, n_ } from "~/i18n"; @@ -81,7 +81,7 @@ const ValidationErrors = ({ title = _("Errors"), errors }) => { onClick={() => setPopoverVisible(true)} > { warningIcon } { - format( + sprintf( // TRANSLATORS: %d is replaced with the number of errors found n_("%d error found", "%d errors found", errors.length), errors.length diff --git a/web/src/components/layout/Icon.jsx b/web/src/components/layout/Icon.jsx index f903001b5..462783015 100644 --- a/web/src/components/layout/Icon.jsx +++ b/web/src/components/layout/Icon.jsx @@ -20,7 +20,7 @@ */ import React from 'react'; -import format from "format-util"; +import { sprintf } from "sprintf-js"; import { _ } from "~/i18n"; @@ -152,5 +152,5 @@ export default function Icon({ name, className = "", size = 32, ...otherProps }) return (IconComponent) ?