From c95d66335caa1737996f5d24f24814d14d7a892e Mon Sep 17 00:00:00 2001 From: cgombauld Date: Wed, 4 Jun 2025 08:52:34 +0200 Subject: [PATCH 1/2] feat(setttings) added dynamic warnings --- public/components/views/settings/settings.js | 15 ++++++ views/index.html | 54 +------------------- 2 files changed, 16 insertions(+), 53 deletions(-) diff --git a/public/components/views/settings/settings.js b/public/components/views/settings/settings.js index f9881523..f7ac434d 100644 --- a/public/components/views/settings/settings.js +++ b/public/components/views/settings/settings.js @@ -1,5 +1,6 @@ // Import Third-party Dependencies import { getJSON } from "@nodesecure/vis-network"; +import { warnings } from "@nodesecure/js-x-ray/warnings"; // CONSTANTS const kAllowedHotKeys = new Set([ @@ -17,10 +18,24 @@ const kDefaultHotKeys = { }; const kShortcutInputTargetIds = new Set(Object.keys(kDefaultHotKeys)); +const kWarningsIdToWarningsLabelExceptions = { + "zero-semver": "zero semver (0.x.x)" +}; + export class Settings { static defaultMenuName = "info"; constructor() { + const warningsCheckBoxes = Object.keys(warnings) + .map((id) => `
+ + +
`).join(""); + + const warningsSettings = document.getElementById("warnings-settings"); + warningsSettings.insertAdjacentHTML("beforeend", warningsCheckBoxes); + this.saveEnabled = false; this.dom = { /** @type {HTMLSelectElement} */ diff --git a/views/index.html b/views/index.html index 8771c75d..8e007f52 100644 --- a/views/index.html +++ b/views/index.html @@ -122,60 +122,8 @@

[[=z.token('settings.general.title')]]

-
+

[[=z.token('settings.general.warnings')]]:

-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -

[[=z.token('settings.general.flags')]]:

From f86416213c8e44e7e63753bf444eae021f2178ef Mon Sep 17 00:00:00 2001 From: cgombauld Date: Tue, 10 Jun 2025 10:21:00 +0200 Subject: [PATCH 2/2] feat(settings) added dynamic warning checkbox --- package.json | 2 +- public/components/views/settings/settings.js | 43 +++++++++++++------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index e20593bb..485f2943 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "@nodesecure/documentation-ui": "^1.3.0", "@nodesecure/flags": "^3.0.3", "@nodesecure/i18n": "^4.0.1", - "@nodesecure/js-x-ray": "^8.2.0", + "@nodesecure/js-x-ray": "^9.0.0", "@nodesecure/licenses-conformance": "^2.1.0", "@nodesecure/npm-registry-sdk": "^3.0.0", "@nodesecure/ossf-scorecard-sdk": "^3.2.1", diff --git a/public/components/views/settings/settings.js b/public/components/views/settings/settings.js index f7ac434d..7cbec4b0 100644 --- a/public/components/views/settings/settings.js +++ b/public/components/views/settings/settings.js @@ -2,6 +2,9 @@ import { getJSON } from "@nodesecure/vis-network"; import { warnings } from "@nodesecure/js-x-ray/warnings"; +// Import Internal Dependencies +import * as utils from "../../../common/utils.js"; + // CONSTANTS const kAllowedHotKeys = new Set([ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", @@ -18,24 +21,11 @@ const kDefaultHotKeys = { }; const kShortcutInputTargetIds = new Set(Object.keys(kDefaultHotKeys)); -const kWarningsIdToWarningsLabelExceptions = { - "zero-semver": "zero semver (0.x.x)" -}; - export class Settings { static defaultMenuName = "info"; constructor() { - const warningsCheckBoxes = Object.keys(warnings) - .map((id) => `
- - -
`).join(""); - - const warningsSettings = document.getElementById("warnings-settings"); - warningsSettings.insertAdjacentHTML("beforeend", warningsCheckBoxes); - + this.#generateWarningCheckboxes(); this.saveEnabled = false; this.dom = { /** @type {HTMLSelectElement} */ @@ -110,6 +100,31 @@ export class Settings { this.updateFormHotKeys(hotkeys); } + #generateWarningCheckboxes() { + const warningsSettings = document.getElementById("warnings-settings"); + const checkboxes = Object.keys(warnings).map((id) => utils.createDOMElement("div", { + childs: [ + utils.createDOMElement("input", { + attributes: { + id, + value: id, + type: "checkbox", + checked: true, + name: "warnings" + } + }), + utils.createDOMElement("label", { + attributes: { + for: id + }, + text: id.replaceAll("-", " ") + }) + ] + }) + ); + warningsSettings.append(...checkboxes); + } + updateNavigationHotKey(hotkeys) { const navigationElement = document.getElementById("view-navigation"); navigationElement.querySelectorAll("span").forEach((span) => {