Skip to content

Commit

Permalink
shell: Check types in "shell-modals"
Browse files Browse the repository at this point in the history
  • Loading branch information
mvollmer authored and martinpitt committed Dec 18, 2024
1 parent dcf5f94 commit cb504af
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pkg/shell/shell-modals.jsx → pkg/shell/shell-modals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* along with Cockpit; If not, see <https://www.gnu.org/licenses/>.
*/

// @cockpit-ts-relaxed

import cockpit from "cockpit";
import React, { useState } from "react";
import { AboutModal } from "@patternfly/react-core/dist/esm/components/AboutModal/index.js";
Expand All @@ -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 = [];
Expand Down Expand Up @@ -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 (
<Modal isOpen position="top" variant="small"
Expand All @@ -121,7 +125,7 @@ export const LangModal = ({ dialogResult }) => {
isPlain
isScrollable
className="ct-menu-select-widget"
onSelect={(_, selected) => setSelected(selected)}
onSelect={(_, selected) => setSelected(selected as string)}
activeItemId={selected}
selected={selected}>
<MenuSearch>
Expand All @@ -140,8 +144,9 @@ export const LangModal = ({ dialogResult }) => {
<MenuList>
{
(() => {
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 (
Expand All @@ -153,7 +158,7 @@ export const LangModal = ({ dialogResult }) => {
return filteredLocales.map(key => {
return (
<MenuItem itemId={key} key={key} data-value={key}>
{manifest.locales[key]}
{locales[key]}
</MenuItem>
);
});
Expand Down

0 comments on commit cb504af

Please sign in to comment.