From cb504afb62666570ed97ffefb096bb289ea3fbac Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Wed, 11 Dec 2024 20:38:33 +0200 Subject: [PATCH] shell: Check types in "shell-modals" --- .../{shell-modals.jsx => shell-modals.tsx} | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) rename pkg/shell/{shell-modals.jsx => shell-modals.tsx} (94%) diff --git a/pkg/shell/shell-modals.jsx b/pkg/shell/shell-modals.tsx similarity index 94% rename from pkg/shell/shell-modals.jsx rename to pkg/shell/shell-modals.tsx index ea9b4b67e44d..19560cc2d2be 100644 --- a/pkg/shell/shell-modals.jsx +++ b/pkg/shell/shell-modals.tsx @@ -17,6 +17,8 @@ * along with Cockpit; If not, see . */ +// @cockpit-ts-relaxed + import cockpit from "cockpit"; import React, { useState } from "react"; import { AboutModal } from "@patternfly/react-core/dist/esm/components/AboutModal/index.js"; @@ -31,12 +33,14 @@ import { SearchIcon } from '@patternfly/react-icons'; import { useInit } from "hooks"; +import { import_ShellManifest } from "./manifests"; + import "menu-select-widget.scss"; const _ = cockpit.gettext; export const AboutCockpitModal = ({ dialogResult }) => { - const [packages, setPackages] = useState(null); + const [packages, setPackages] = useState<{ name: string, version: string }[]>([]); useInit(() => { const packages = []; @@ -102,7 +106,7 @@ export const LangModal = ({ dialogResult }) => { window.location.reload(true); } - const manifest = cockpit.manifests.shell || { }; + const manifest = import_ShellManifest(cockpit.manifests.shell || { }); return ( { isPlain isScrollable className="ct-menu-select-widget" - onSelect={(_, selected) => setSelected(selected)} + onSelect={(_, selected) => setSelected(selected as string)} activeItemId={selected} selected={selected}> @@ -140,8 +144,9 @@ export const LangModal = ({ dialogResult }) => { { (() => { - const filteredLocales = Object.keys(manifest.locales || {}) - .filter(key => !searchInput || manifest.locales[key].toLowerCase().includes(searchInput.toString().toLowerCase())); + const locales = manifest.locales || {}; + const filteredLocales = Object.keys(locales) + .filter(key => !searchInput || locales[key].toLowerCase().includes(searchInput.toString().toLowerCase())); if (filteredLocales.length === 0) { return ( @@ -153,7 +158,7 @@ export const LangModal = ({ dialogResult }) => { return filteredLocales.map(key => { return ( - {manifest.locales[key]} + {locales[key]} ); });