diff --git a/.changeset/wild-islands-accept.md b/.changeset/wild-islands-accept.md
new file mode 100644
index 000000000..d73acaff7
--- /dev/null
+++ b/.changeset/wild-islands-accept.md
@@ -0,0 +1,5 @@
+---
+"@cloudoperators/juno-app-heureka": patch
+---
+
+Heureka move to TS
diff --git a/apps/heureka/eslint.config.mjs b/apps/heureka/eslint.config.mjs
index 15fecd06d..8d155833e 100644
--- a/apps/heureka/eslint.config.mjs
+++ b/apps/heureka/eslint.config.mjs
@@ -3,14 +3,31 @@
* SPDX-License-Identifier: Apache-2.0
*/
-import junoConfigs from "@cloudoperators/juno-config/eslint/juno.mjs"
+import junoConfigs from "@cloudoperators/juno-config/eslint/juno-typescript.mjs"
export default [
...junoConfigs,
{
- files: ["**/*.js", "**/*.mjs", "**/*.jsx"],
+ files: ["**/*.ts", "**/*.mjs", "**/*.tsx"],
languageOptions: { sourceType: "module" },
rules: {
+ "@typescript-eslint/no-unsafe-assignment": "off",
+ "@typescript-eslint/no-unsafe-call": "off",
+ "@typescript-eslint/no-unsafe-argument": "off",
+ "@typescript-eslint/no-unsafe-return": "off",
+ "@typescript-eslint/no-unsafe-member-access": "off",
+ "@typescript-eslint/no-floating-promises": "off",
+ "@typescript-eslint/require-await": "off",
+ "@typescript-eslint/unbound-method": "off",
+ "@typescript-eslint/restrict-template-expressions": "off",
+ "@typescript-eslint/no-unnecessary-type-assertion": "off",
+ "@typescript-eslint/no-redundant-type-constituents": "off",
+ "@typescript-eslint/no-misused-promises": "off",
+ "@typescript-eslint/no-base-to-string": "off",
+ "no-empty": "off",
+ "no-unused-vars": "off",
+ "prefer-const": "off",
+ "no-fallthrough": "off",
// disable for now, till we switch to TypeScript
"react/prop-types": "off",
},
diff --git a/apps/heureka/package.json b/apps/heureka/package.json
index 6db9e8f4b..b5658441c 100644
--- a/apps/heureka/package.json
+++ b/apps/heureka/package.json
@@ -34,6 +34,7 @@
},
"scripts": {
"test": "vitest run",
+ "typecheck": "tsc --project tsconfig.json --noEmit",
"dev": "vite",
"build": "vite build",
"build:static": "vite build --mode static",
diff --git a/apps/heureka/src/App.test.jsx b/apps/heureka/src/App.test.tsx
similarity index 81%
rename from apps/heureka/src/App.test.jsx
rename to apps/heureka/src/App.test.tsx
index 076f36a11..896b76249 100644
--- a/apps/heureka/src/App.test.jsx
+++ b/apps/heureka/src/App.test.tsx
@@ -15,6 +15,7 @@ describe("App", () => {
render()
})
waitFor(() => (loginTitles = screen.queryAllByShadowText(/HEUREKA/i)))
+ // @ts-expect-error TS(2454): Variable 'loginTitles' is used before being assign... Remove this comment to see the full error message
expect(loginTitles.length).toBeGreaterThan(0)
})
})
diff --git a/apps/heureka/src/App.jsx b/apps/heureka/src/App.tsx
similarity index 80%
rename from apps/heureka/src/App.jsx
rename to apps/heureka/src/App.tsx
index 60e94249f..3aa1b172e 100644
--- a/apps/heureka/src/App.jsx
+++ b/apps/heureka/src/App.tsx
@@ -23,7 +23,7 @@ function App(props = {}) {
w-full
`
- const fallbackRender = ({ error }) => {
+ const fallbackRender = ({ error }: any) => {
return (
@@ -39,6 +39,7 @@ function App(props = {}) {
// global default options that apply to all queries
queries: {
// staleTime: Infinity, // if you wish to keep data from the keys until reload
+ // @ts-ignore
keepPreviousData: true, // nice when paginating
refetchOnWindowFocus: false, // default: true
},
@@ -50,6 +51,7 @@ function App(props = {}) {
+ {/* @ts-expect-error TS(2322): Type '{ consumerId: any; }' is not assignable to t... Remove this comment to see the full error message */}
@@ -59,8 +61,9 @@ function App(props = {}) {
)
}
-const StyledApp = (props) => {
+const StyledApp = (props: any) => {
return (
+ // @ts-expect-error TS(2322): Type '{ theme: string; }' is not assignable to type 'IntrinsicAttributes & { children?: ReactNode; }'. Property 'theme' does not exist on type 'IntrinsicAttributes & { children?: ReactNode; }'. Remove this comment to see the full error message
{/* load styles inside the shadow dom */}
diff --git a/apps/heureka/src/components/AsyncWorker.jsx b/apps/heureka/src/components/AsyncWorker.tsx
similarity index 100%
rename from apps/heureka/src/components/AsyncWorker.jsx
rename to apps/heureka/src/components/AsyncWorker.tsx
diff --git a/apps/heureka/src/components/CustomAppShell.jsx b/apps/heureka/src/components/CustomAppShell.tsx
similarity index 83%
rename from apps/heureka/src/components/CustomAppShell.jsx
rename to apps/heureka/src/components/CustomAppShell.tsx
index feb9d1962..0fd63585c 100644
--- a/apps/heureka/src/components/CustomAppShell.jsx
+++ b/apps/heureka/src/components/CustomAppShell.tsx
@@ -18,29 +18,34 @@ const VIEW_CONFIG = {
Components: { label: "Images", icon: "autoAwesomeMotion", component: ComponentsView }, // Commented out to remove ComponentsView for MVP version
}
-const CustomAppShell = ({ children }) => {
+const CustomAppShell = ({ children }: any) => {
+ // @ts-expect-error TS(2339): Property 'setActiveView' does not exist on type '() => void'. // @ts-expect-error
const { setActiveView, setShowPanel } = useGlobalsActions()
const activeView = useGlobalsActiveView()
const embedded = useGlobalsEmbedded()
- const handleNavItemChange = (item) => {
+ const handleNavItemChange = (item: any) => {
setActiveView(item)
setShowPanel(constants.PANEL_NONE) // Hide the panel when switching
}
// Create topNavigation with NavItems based on VIEW_CONFIG
const topNavigation = (
+ // @ts-ignore
{Object.entries(VIEW_CONFIG).map(([key, nav]) => (
+ // @ts-ignore
))}
)
// Get the component to render based on activeView
+ // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
const ActiveComponent = VIEW_CONFIG[activeView]?.component
return (
+ // @ts-ignore
} topNavigation={topNavigation} embedded={embedded}>
{ActiveComponent && }
diff --git a/apps/heureka/src/components/StoreProvider.jsx b/apps/heureka/src/components/StoreProvider.jsx
deleted file mode 100644
index 83c1c1863..000000000
--- a/apps/heureka/src/components/StoreProvider.jsx
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React, { createContext, useContext } from "react"
-import { createStore, useStore } from "zustand"
-import { devtools } from "zustand/middleware"
-
-import createFiltersSlice from "../lib/slices/createFiltersSlice"
-import createAuthDataSlice from "../lib/slices/createAuthDataSlice"
-import createGlobalsSlice from "../lib/slices/createGlobalsSlice"
-import createUserActivitySlice from "../lib/slices/createUserActivitySlice"
-
-// Entity constants
-const ISSUEMATCHES = "IssueMatches"
-const SERVICES = "Services"
-const COMPONENTS = "Components"
-
-const StoreContext = createContext()
-
-export const StoreProvider = ({ options, children }) => {
- return (
- ({
- ...createGlobalsSlice(set, get, options),
- ...createAuthDataSlice(set, get),
- ...createUserActivitySlice(set, get),
- ...createFiltersSlice(set, get),
- }))
- )}
- >
- {children}
-
- )
-}
-
-const useAppStore = (selector) => useStore(useContext(StoreContext), selector)
-
-// Globals exports
-export const useGlobalsEmbedded = () => useAppStore((state) => state.globals.embedded)
-export const useGlobalsQueryClientFnReady = () => useAppStore((state) => state.globals.queryClientFnReady)
-export const useGlobalsActiveView = () => useAppStore((state) => state.globals.activeView)
-export const useGlobalsQueryOptions = (viewName) => useAppStore((state) => state.globals.views[viewName].queryOptions)
-export const useGlobalsApiEndpoint = () => useAppStore((state) => state.globals.apiEndpoint)
-export const useGlobalsShowPanel = () => useAppStore((state) => state.globals.showPanel)
-export const useGlobalsShowServiceDetail = () => useAppStore((state) => state.globals.showServiceDetail)
-export const useGlobalsShowIssueDetail = () => useAppStore((state) => state.globals.showIssueDetail)
-export const useGlobalsActions = () => useAppStore((state) => state.globals.actions)
-
-// AUTH exports
-export const useAuthData = () => useAppStore((state) => state.auth.data)
-export const useAuthIsProcessing = () => useAppStore((state) => state.auth.isProcessing)
-export const useAuthLoggedIn = () => useAppStore((state) => state.auth.loggedIn)
-export const useAuthError = () => useAppStore((state) => state.auth.error)
-export const useAuthLastAction = () => useAppStore((state) => state.auth.lastAction)
-export const useAuthAppLoaded = () => useAppStore((state) => state.auth.appLoaded)
-export const useAuthAppIsLoading = () => useAppStore((state) => state.auth.appIsLoading)
-export const useAuthActions = () => useAppStore((state) => state.auth.actions)
-
-// UserActivity exports
-export const useUserIsActive = () => useAppStore((state) => state.userActivity.isActive)
-
-export const useUserActivityActions = () => useAppStore((state) => state.userActivity.actions)
-
-// Filter exports for Issues
-export const useIssueMatchesFilterLabels = () => useAppStore((state) => state.filters[ISSUEMATCHES].labels)
-export const useIssueMatchesActiveFilters = () => useAppStore((state) => state.filters[ISSUEMATCHES].activeFilters)
-export const useIssueMatchesSearchTerm = () => useAppStore((state) => state.filters[ISSUEMATCHES].search)
-export const useIssueMatchesFilterLabelValues = () =>
- useAppStore((state) => state.filters[ISSUEMATCHES].filterLabelValues)
-export const useIssueMatchesPredefinedFilters = () =>
- useAppStore((state) => state.filters[ISSUEMATCHES].predefinedFilters)
-export const useIssueMatchesActivePredefinedFilter = () =>
- useAppStore((state) => state.filters[ISSUEMATCHES].activePredefinedFilter)
-
-// Filter exports for Services
-export const useServiceFilterLabels = () => useAppStore((state) => state.filters[SERVICES].labels)
-export const useServiceActiveFilters = () => useAppStore((state) => state.filters[SERVICES].activeFilters)
-export const useServiceSearchTerm = () => useAppStore((state) => state.filters[SERVICES].search)
-export const useServiceFilterLabelValues = () => useAppStore((state) => state.filters[SERVICES].filterLabelValues)
-export const useServicePredefinedFilters = () => useAppStore((state) => state.filters[SERVICES].predefinedFilters)
-export const useServiceActivePredefinedFilter = () =>
- useAppStore((state) => state.filters[SERVICES].activePredefinedFilter)
-
-// Filter exports for Components
-export const useComponentFilterLabels = () => useAppStore((state) => state.filters[COMPONENTS].labels)
-export const useComponentActiveFilters = () => useAppStore((state) => state.filters[COMPONENTS].activeFilters)
-export const useComponentSearchTerm = () => useAppStore((state) => state.filters[COMPONENTS].search)
-export const useComponentFilterLabelValues = () => useAppStore((state) => state.filters[COMPONENTS].filterLabelValues)
-export const useComponentPredefinedFilters = () => useAppStore((state) => state.filters[COMPONENTS].predefinedFilters)
-export const useComponentActivePredefinedFilter = () =>
- useAppStore((state) => state.filters[COMPONENTS].activePredefinedFilter)
-
-// Filter actions
-export const useFilterActions = () => useAppStore((state) => state.filters.actions)
-
-export default StoreProvider
diff --git a/apps/heureka/src/components/StoreProvider.test.jsx b/apps/heureka/src/components/StoreProvider.test.tsx
similarity index 88%
rename from apps/heureka/src/components/StoreProvider.test.jsx
rename to apps/heureka/src/components/StoreProvider.test.tsx
index 9e9c5986c..e1e590ba6 100644
--- a/apps/heureka/src/components/StoreProvider.test.jsx
+++ b/apps/heureka/src/components/StoreProvider.test.tsx
@@ -12,7 +12,7 @@ describe("createGlobalsSlice", () => {
embedded: "false",
}
- const wrapper = ({ children }) => {children}
+ const wrapper = ({ children }: any) => {children}
it("should initialize with correct default values", () => {
const { result } = renderHook(
@@ -35,6 +35,7 @@ describe("createGlobalsSlice", () => {
{ wrapper }
)
act(() => {
+ // @ts-ignore
result.current.actions.setEmbedded(true)
})
diff --git a/apps/heureka/src/components/StoreProvider.tsx b/apps/heureka/src/components/StoreProvider.tsx
new file mode 100644
index 000000000..3617da4ba
--- /dev/null
+++ b/apps/heureka/src/components/StoreProvider.tsx
@@ -0,0 +1,104 @@
+/*
+ * SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import React, { createContext, useContext } from "react"
+import { createStore, useStore } from "zustand"
+import { devtools } from "zustand/middleware"
+
+import createFiltersSlice from "../lib/slices/createFiltersSlice"
+import createAuthDataSlice from "../lib/slices/createAuthDataSlice"
+import createGlobalsSlice from "../lib/slices/createGlobalsSlice"
+import createUserActivitySlice from "../lib/slices/createUserActivitySlice"
+
+// Entity constants
+const ISSUEMATCHES = "IssueMatches"
+const SERVICES = "Services"
+const COMPONENTS = "Components"
+
+// @ts-expect-error TS(2554): Expected 1 arguments, but got 0.
+const StoreContext = createContext()
+
+export const StoreProvider = ({ options, children }: any) => {
+ return (
+ ({
+ ...createGlobalsSlice(set, get, options),
+ ...createAuthDataSlice(set, get),
+ // @ts-expect-error TS(2554): Expected 1 arguments, but got 2.
+ ...createUserActivitySlice(set, get),
+ ...createFiltersSlice(set, get),
+ }))
+ )}
+ >
+ {children}
+
+ )
+}
+// @ts-ignore
+const useAppStore = (selector: any) => useStore(useContext(StoreContext), selector)
+
+// Globals exports
+export const useGlobalsEmbedded = () => useAppStore((state: any) => state.globals.embedded)
+export const useGlobalsQueryClientFnReady = () => useAppStore((state: any) => state.globals.queryClientFnReady)
+export const useGlobalsActiveView = () => useAppStore((state: any) => state.globals.activeView)
+export const useGlobalsQueryOptions = (viewName: any) =>
+ useAppStore((state: any) => state.globals.views[viewName].queryOptions)
+export const useGlobalsApiEndpoint = () => useAppStore((state: any) => state.globals.apiEndpoint)
+export const useGlobalsShowPanel = () => useAppStore((state: any) => state.globals.showPanel)
+export const useGlobalsShowServiceDetail = () => useAppStore((state: any) => state.globals.showServiceDetail)
+export const useGlobalsShowIssueDetail = () => useAppStore((state: any) => state.globals.showIssueDetail)
+export const useGlobalsActions = () => useAppStore((state: any) => state.globals.actions)
+
+// AUTH exports
+export const useAuthData = () => useAppStore((state: any) => state.auth.data)
+export const useAuthIsProcessing = () => useAppStore((state: any) => state.auth.isProcessing)
+export const useAuthLoggedIn = () => useAppStore((state: any) => state.auth.loggedIn)
+export const useAuthError = () => useAppStore((state: any) => state.auth.error)
+export const useAuthLastAction = () => useAppStore((state: any) => state.auth.lastAction)
+export const useAuthAppLoaded = () => useAppStore((state: any) => state.auth.appLoaded)
+export const useAuthAppIsLoading = () => useAppStore((state: any) => state.auth.appIsLoading)
+export const useAuthActions = () => useAppStore((state: any) => state.auth.actions)
+
+// UserActivity exports
+export const useUserIsActive = () => useAppStore((state: any) => state.userActivity.isActive)
+
+export const useUserActivityActions = () => useAppStore((state: any) => state.userActivity.actions)
+
+// Filter exports for Issues
+export const useIssueMatchesFilterLabels = () => useAppStore((state: any) => state.filters[ISSUEMATCHES].labels)
+export const useIssueMatchesActiveFilters = () => useAppStore((state: any) => state.filters[ISSUEMATCHES].activeFilters)
+export const useIssueMatchesSearchTerm = () => useAppStore((state: any) => state.filters[ISSUEMATCHES].search)
+export const useIssueMatchesFilterLabelValues = () =>
+ useAppStore((state: any) => state.filters[ISSUEMATCHES].filterLabelValues)
+export const useIssueMatchesPredefinedFilters = () =>
+ useAppStore((state: any) => state.filters[ISSUEMATCHES].predefinedFilters)
+export const useIssueMatchesActivePredefinedFilter = () =>
+ useAppStore((state: any) => state.filters[ISSUEMATCHES].activePredefinedFilter)
+
+// Filter exports for Services
+export const useServiceFilterLabels = () => useAppStore((state: any) => state.filters[SERVICES].labels)
+export const useServiceActiveFilters = () => useAppStore((state: any) => state.filters[SERVICES].activeFilters)
+export const useServiceSearchTerm = () => useAppStore((state: any) => state.filters[SERVICES].search)
+export const useServiceFilterLabelValues = () => useAppStore((state: any) => state.filters[SERVICES].filterLabelValues)
+export const useServicePredefinedFilters = () => useAppStore((state: any) => state.filters[SERVICES].predefinedFilters)
+export const useServiceActivePredefinedFilter = () =>
+ useAppStore((state: any) => state.filters[SERVICES].activePredefinedFilter)
+
+// Filter exports for Components
+export const useComponentFilterLabels = () => useAppStore((state: any) => state.filters[COMPONENTS].labels)
+export const useComponentActiveFilters = () => useAppStore((state: any) => state.filters[COMPONENTS].activeFilters)
+export const useComponentSearchTerm = () => useAppStore((state: any) => state.filters[COMPONENTS].search)
+export const useComponentFilterLabelValues = () =>
+ useAppStore((state: any) => state.filters[COMPONENTS].filterLabelValues)
+export const useComponentPredefinedFilters = () =>
+ useAppStore((state: any) => state.filters[COMPONENTS].predefinedFilters)
+export const useComponentActivePredefinedFilter = () =>
+ useAppStore((state: any) => state.filters[COMPONENTS].activePredefinedFilter)
+
+// Filter actions
+export const useFilterActions = () => useAppStore((state: any) => state.filters.actions)
+
+export default StoreProvider
diff --git a/apps/heureka/src/components/components/ComponentsList.jsx b/apps/heureka/src/components/components/ComponentsList.tsx
similarity index 94%
rename from apps/heureka/src/components/components/ComponentsList.jsx
rename to apps/heureka/src/components/components/ComponentsList.tsx
index 751ca73ad..02a11a3b2 100644
--- a/apps/heureka/src/components/components/ComponentsList.jsx
+++ b/apps/heureka/src/components/components/ComponentsList.tsx
@@ -18,7 +18,7 @@ import HintNotFound from "../shared/HintNotFound"
import HintLoading from "../shared/HintLoading"
import ComponentsListItem from "./ComponentsListItem"
-const ComponentsList = ({ items, isLoading }) => {
+const ComponentsList = ({ items, isLoading }: any) => {
return (
@@ -52,7 +52,7 @@ const ComponentsList = ({ items, isLoading }) => {
<>
{items?.length > 0 ? (
<>
- {items.map((item, index) => (
+ {items.map((item: any, index: any) => (
))}
>
diff --git a/apps/heureka/src/components/components/ComponentsListItem.jsx b/apps/heureka/src/components/components/ComponentsListItem.tsx
similarity index 78%
rename from apps/heureka/src/components/components/ComponentsListItem.jsx
rename to apps/heureka/src/components/components/ComponentsListItem.tsx
index f98d8c5d8..359d31fc8 100644
--- a/apps/heureka/src/components/components/ComponentsListItem.jsx
+++ b/apps/heureka/src/components/components/ComponentsListItem.tsx
@@ -6,12 +6,12 @@
import React from "react"
import { DataGridRow, DataGridCell } from "@cloudoperators/juno-ui-components"
-const sumTotalInstances = (versions) => {
+const sumTotalInstances = (versions: any) => {
let sum = 0
- versions.forEach((v) => (sum += v?.node?.componentInstances?.totalCount))
+ versions.forEach((v: any) => (sum += v?.node?.componentInstances?.totalCount))
return sum
}
-const ComponentsListItem = ({ item }) => {
+const ComponentsListItem = ({ item }: any) => {
return (
{item?.node?.ccrn}
diff --git a/apps/heureka/src/components/components/ComponentsView.jsx b/apps/heureka/src/components/components/ComponentsView.tsx
similarity index 81%
rename from apps/heureka/src/components/components/ComponentsView.jsx
rename to apps/heureka/src/components/components/ComponentsView.tsx
index baee3a0e8..d587f9b51 100644
--- a/apps/heureka/src/components/components/ComponentsView.jsx
+++ b/apps/heureka/src/components/components/ComponentsView.tsx
@@ -6,7 +6,6 @@
import React from "react"
import ComponentsList from "./ComponentsList"
import ListController from "../shared/ListController"
-// import Filters from "../filters/Filters"
import { Messages, MessagesProvider } from "@cloudoperators/juno-messages-provider"
const ComponentsView = () => {
@@ -14,7 +13,6 @@ const ComponentsView = () => {
<>
- {/* // Should be activated after BE respective implementation*/}
{
+const FilterPills = ({ entityName, activeFilters }: any) => {
+ // @ts-ignore
const { removeActiveFilter } = useFilterActions()
return (
{Object.entries(activeFilters || {}).map(([key, values]) =>
- values.map((value) => (
+ // @ts-ignore
+ values.map((value: any) => (
{
+}: any) => {
const [filterLabel, setFilterLabel] = useState("")
const [filterValue, setFilterValue] = useState("")
-
+ // @ts-ignore
const { addActiveFilter, clearActiveFilters, setSearchTerm } = useFilterActions()
- const handleFilterAdd = (value) => {
+ const handleFilterAdd = (value: any) => {
if (filterLabel && (filterValue || value)) {
addActiveFilter(entityName, filterLabel, filterValue || value)
setFilterValue("")
}
}
- const handleFilterLabelChange = (label) => setFilterLabel(label)
+ const handleFilterLabelChange = (label: any) => setFilterLabel(label)
- const handleFilterValueChange = (value) => {
+ const handleFilterValueChange = (value: any) => {
setFilterValue(value)
handleFilterAdd(value)
}
// Define filter options by filtering out already selected values
const filterOptions = filterLabelValues?.[filterLabel]?.filter(
- (value) => !activeFilters?.[filterLabel]?.includes(value)
+ (value: any) => !activeFilters?.[filterLabel]?.includes(value)
)
return (
@@ -51,7 +51,7 @@ const FilterSelect = ({
onChange={handleFilterLabelChange}
disabled={isLoading}
>
- {filterLabels?.map(({ displayName, filterName }) => (
+ {filterLabels?.map(({ displayName, filterName }: any) => (
))}
@@ -62,9 +62,7 @@ const FilterSelect = ({
disabled={!filterLabelValues?.[filterLabel]?.length}
className="filter-value-select w-96 bg-theme-background-lvl-0"
>
- {filterOptions?.map((value) => (
-
- ))}
+ {filterOptions?.map((value: any) => )}
@@ -75,7 +73,7 @@ const FilterSelect = ({
placeholder={`search term for ${searchTargets}`}
className="w-96 ml-auto"
value={searchTerm || ""}
- onSearch={(value) => setSearchTerm(entityName, value)}
+ onSearch={(value: any) => setSearchTerm(entityName, value)}
onClear={() => setSearchTerm(entityName, "")}
/>
diff --git a/apps/heureka/src/components/filters/Filters.jsx b/apps/heureka/src/components/filters/Filters.tsx
similarity index 94%
rename from apps/heureka/src/components/filters/Filters.jsx
rename to apps/heureka/src/components/filters/Filters.tsx
index 351ba2a8a..77d880e3f 100644
--- a/apps/heureka/src/components/filters/Filters.jsx
+++ b/apps/heureka/src/components/filters/Filters.tsx
@@ -25,8 +25,9 @@ const Filters = ({
activeFilters,
searchTerm,
searchTargets,
-}) => {
+}: any) => {
const queryClientFnReady = useGlobalsQueryClientFnReady()
+ // @ts-expect-error - This is a custom hook
const { setLabels, setFilterLabelValues } = useFilterActions()
const { isLoading, data } = useQuery({
@@ -38,9 +39,11 @@ const Filters = ({
//Since there is a custom query to fetch filter labels, names and values for each entity in API
//We need to map the data to the format that the FilterSelect component expects
//You can check the response structure of custom query e.g in /lib/queries/serviceFilterValues.js
+ // @ts-ignore
if (!data || !data[queryKey]) return []
-
+ // @ts-expect-error - This is a custom hook
return Object.keys(data[queryKey]).map((key) => {
+ // @ts-ignore
const field = data[queryKey][key]
return {
displayName: field.displayName, // Display name of the filter
diff --git a/apps/heureka/src/components/issueMatches/IssueMatchesDetails.jsx b/apps/heureka/src/components/issueMatches/IssueMatchesDetails.tsx
similarity index 98%
rename from apps/heureka/src/components/issueMatches/IssueMatchesDetails.jsx
rename to apps/heureka/src/components/issueMatches/IssueMatchesDetails.tsx
index 2e4948935..08b7cc55c 100644
--- a/apps/heureka/src/components/issueMatches/IssueMatchesDetails.jsx
+++ b/apps/heureka/src/components/issueMatches/IssueMatchesDetails.tsx
@@ -21,6 +21,7 @@ const IssueMatchesDetails = () => {
})
const issue = useMemo(() => {
if (!issueElem) return null
+ // @ts-expect-error - data is not defined
return issueElem?.data?.IssueMatches?.edges[0]?.node
}, [issueElem])
@@ -111,7 +112,7 @@ const IssueMatchesDetails = () => {
{issue?.componentInstance?.service?.owners?.edges ? (
- {issue?.componentInstance?.service?.owners?.edges?.map((owner, i) => (
+ {issue?.componentInstance?.service?.owners?.edges?.map((owner: any, i: any) => (
{
+const IssueMatchesList = ({ items, isLoading }: any) => {
return (
<>
{/* clickableTable Table allow changes the background by css when hovering or active*/}
@@ -33,7 +33,7 @@ const IssueMatchesList = ({ items, isLoading }) => {
<>
{items?.length > 0 ? (
<>
- {items.map((item, index) => (
+ {items.map((item: any, index: any) => (
))}
>
diff --git a/apps/heureka/src/components/issueMatches/IssueMatchesListItem.jsx b/apps/heureka/src/components/issueMatches/IssueMatchesListItem.tsx
similarity index 93%
rename from apps/heureka/src/components/issueMatches/IssueMatchesListItem.jsx
rename to apps/heureka/src/components/issueMatches/IssueMatchesListItem.tsx
index 54ea9e2fa..e28a62eb7 100644
--- a/apps/heureka/src/components/issueMatches/IssueMatchesListItem.jsx
+++ b/apps/heureka/src/components/issueMatches/IssueMatchesListItem.tsx
@@ -10,13 +10,14 @@ import constants from "../shared/constants"
import { useGlobalsActions, useGlobalsShowPanel, useGlobalsShowIssueDetail } from "../StoreProvider"
// Helper function to extract the last four parts of a URL - used for displaying ccrn as resource column
-export const extractResourceInfo = (url) => {
+export const extractResourceInfo = (url: any) => {
if (!url) return ""
const parts = url.split("/")
return parts.slice(-4).join("/")
}
-const IssueMatchesListItem = ({ item }) => {
+const IssueMatchesListItem = ({ item }: any) => {
+ // @ts-expect-error - data is not defined
const { setShowPanel, setShowIssueDetail } = useGlobalsActions()
const showPanel = useGlobalsShowPanel()
const showIssueDetail = useGlobalsShowIssueDetail()
diff --git a/apps/heureka/src/components/issueMatches/IssueMatchesView.jsx b/apps/heureka/src/components/issueMatches/IssueMatchesView.tsx
similarity index 97%
rename from apps/heureka/src/components/issueMatches/IssueMatchesView.jsx
rename to apps/heureka/src/components/issueMatches/IssueMatchesView.tsx
index 2e5f3f334..39ade891c 100644
--- a/apps/heureka/src/components/issueMatches/IssueMatchesView.jsx
+++ b/apps/heureka/src/components/issueMatches/IssueMatchesView.tsx
@@ -24,6 +24,7 @@ const IssueMatchesView = () => {
const searchTerm = useIssueMatchesSearchTerm()
// Access filter actions
+ // @ts-expect-error - This is a custom hook
const { setQueryOptions } = useGlobalsActions()
setQueryOptions("IssueMatches", { filter: { issueType: ["Vulnerability"] } })
diff --git a/apps/heureka/src/components/services/ComponentInstancesList.jsx b/apps/heureka/src/components/services/ComponentInstancesList.tsx
similarity index 91%
rename from apps/heureka/src/components/services/ComponentInstancesList.jsx
rename to apps/heureka/src/components/services/ComponentInstancesList.tsx
index 8dd532aa5..2ba6a9802 100644
--- a/apps/heureka/src/components/services/ComponentInstancesList.jsx
+++ b/apps/heureka/src/components/services/ComponentInstancesList.tsx
@@ -19,8 +19,9 @@ import { severityString, highestSeverity } from "../shared/Helper"
import PaginationComponent from "../shared/PaginationComponent"
import HintNotFound from "../shared/HintNotFound"
-const ComponentInstancesList = ({ serviceCcrn }) => {
+const ComponentInstancesList = ({ serviceCcrn }: any) => {
const queryOptions = useGlobalsQueryOptions("ComponentInstancesOfService")
+ // @ts-expect-error - setQueryOptions is not defined
const { setQueryOptions } = useGlobalsActions()
const queryClientFnReady = useGlobalsQueryClientFnReady()
@@ -28,13 +29,14 @@ const ComponentInstancesList = ({ serviceCcrn }) => {
queryKey: [
"ComponentInstancesOfService",
{
+ // @ts-expect-error - filter is not defined
...queryOptions,
filter: { serviceCcrn: [serviceCcrn] },
},
],
enabled: !!queryClientFnReady && !!serviceCcrn,
})
-
+ // @ts-expect-error - data is not defined
const items = data?.ComponentInstances?.edges || []
return (
@@ -58,7 +60,7 @@ const ComponentInstancesList = ({ serviceCcrn }) => {
) : items.length === 0 ? (
) : (
- items.map((componentInstance, i) => (
+ items.map((componentInstance: any, i: any) => (
{componentInstance?.node?.ccrn}
diff --git a/apps/heureka/src/components/services/ServicesDetails.jsx b/apps/heureka/src/components/services/ServicesDetails.tsx
similarity index 75%
rename from apps/heureka/src/components/services/ServicesDetails.jsx
rename to apps/heureka/src/components/services/ServicesDetails.tsx
index cc4534f4d..0a3aaf077 100644
--- a/apps/heureka/src/components/services/ServicesDetails.jsx
+++ b/apps/heureka/src/components/services/ServicesDetails.tsx
@@ -44,6 +44,7 @@ const ServicesDetail = () => {
const service = useMemo(() => {
if (!serviceElem) return null
+ // @ts-expect-error TS(2339): Property 'data' does not exist on type 'never'.
return serviceElem?.data?.Services?.edges[0]?.node
}, [serviceElem])
@@ -56,7 +57,7 @@ const ServicesDetail = () => {
// Pre-populate selected owners
useEffect(() => {
if (service && service.owners?.edges) {
- const preSelectedOwners = service.owners.edges.map((owner) => owner.node)
+ const preSelectedOwners = service.owners.edges.map((owner: any) => owner.node)
setSelectedOwners(preSelectedOwners)
}
}, [service])
@@ -72,12 +73,14 @@ const ServicesDetail = () => {
// Mutation for adding an owner
const addOwnerMutation = useMutation({
mutationKey: ["addOwnerToService"],
+ // @ts-expect-error TS(2339): Property 'enabled' does not exist on type 'never'.
enabled: !!queryClientFnReady,
})
// Mutation for removing an owner
const removeOwnerMutation = useMutation({
mutationKey: ["removeOwnerFromService"],
+ // @ts-expect-error TS(2339): Property 'enabled' does not exist on type 'never'.
enabled: !!queryClientFnReady,
})
@@ -85,21 +88,24 @@ const ServicesDetail = () => {
const handleAddOwner = () => {
if (newOwner) {
addOwnerMutation.mutate(
+ // @ts-ignore
{
serviceId: service.id,
+ // @ts-ignore
userId: newOwner.id,
},
{
onSuccess: () => {
addMessage({
variant: "success",
+ // @ts-expect-error TS(2339): Property 'name' does not exist on type 'never'.
text: `${newOwner.name} added as owner.`,
})
setSelectedOwners((prev) => [...prev, newOwner])
setShowComboBox(false)
setNewOwner(null)
},
- onError: (error) => {
+ onError: (error: any) => {
addMessage({
variant: "error",
text: parseError(error),
@@ -111,30 +117,31 @@ const ServicesDetail = () => {
}
// Remove an owner from the service
- const handleRemoveOwner = (userId) => {
- removeOwnerMutation.mutate(
- {
- serviceId: service.id,
- userId: userId,
+ const handleRemoveOwner = (userId: any) => {
+ const variables = {
+ serviceId: service.id,
+ userId: userId,
+ }
+ // @ts-ignore
+ removeOwnerMutation.mutate(variables, {
+ onSuccess: () => {
+ const removedUser = selectedOwners.find((owner: any) => owner.id === userId)
+ addMessage({
+ variant: "success",
+ // @ts-ignore
+ text: `${removedUser.name} removed as owner.`,
+ })
+ // @ts-expect-error TS(2339): Property 'id' does not exist on type 'never'.
+ setSelectedOwners((prev) => prev.filter((owner) => owner.id !== userId))
+ setConfirmRemoveOwner(null) // Close the modal
},
- {
- onSuccess: () => {
- const removedUser = selectedOwners.find((owner) => owner.id === userId)
- addMessage({
- variant: "success",
- text: `${removedUser.name} removed as owner.`,
- })
- setSelectedOwners((prev) => prev.filter((owner) => owner.id !== userId))
- setConfirmRemoveOwner(null) // Close the modal
- },
- onError: (error) => {
- addMessage({
- variant: "error",
- text: parseError(error),
- })
- },
- }
- )
+ onError: (error: any) => {
+ addMessage({
+ variant: "error",
+ text: parseError(error),
+ })
+ },
+ })
}
const handleCancelAdd = () => {
@@ -143,7 +150,7 @@ const ServicesDetail = () => {
}
// Set owner to remove and show confirmation modal
- const handleConfirmRemoveOwner = (owner) => {
+ const handleConfirmRemoveOwner = (owner: any) => {
setConfirmRemoveOwner(owner?.id)
setOwnerToRemove(owner?.name)
}
@@ -162,7 +169,9 @@ const ServicesDetail = () => {
selectedOwners.map((owner, i) => (
handleConfirmRemoveOwner(owner)}
@@ -175,16 +184,21 @@ const ServicesDetail = () => {
{showComboBox && (
{
+ onChange={(selectedUniqueUserId: any) => {
+ // @ts-ignore
const selectedUser = users?.data?.Users?.edges?.find(
- (user) => user.node.uniqueUserId === selectedUniqueUserId
+ (user: any) => user.node.uniqueUserId === selectedUniqueUserId
)?.node
setNewOwner(selectedUser)
}}
>
+ {/* @ts-ignore */}
{users?.data?.Users?.edges
- ?.filter((user) => !selectedOwners.some((owner) => owner.uniqueUserId === user.node.uniqueUserId))
- .map((user, i) => (
+ ?.filter(
+ // @ts-ignore
+ (user: any) => !selectedOwners.some((owner) => owner.uniqueUserId === user.node.uniqueUserId)
+ )
+ .map((user: any, i: any) => (
{user?.node?.name}
diff --git a/apps/heureka/src/components/services/ServicesList.jsx b/apps/heureka/src/components/services/ServicesList.tsx
similarity index 95%
rename from apps/heureka/src/components/services/ServicesList.jsx
rename to apps/heureka/src/components/services/ServicesList.tsx
index 826548166..dda071b77 100644
--- a/apps/heureka/src/components/services/ServicesList.jsx
+++ b/apps/heureka/src/components/services/ServicesList.tsx
@@ -18,7 +18,7 @@ import HintNotFound from "../shared/HintNotFound"
import ServicesListItem from "./ServicesListItem"
import HintLoading from "../shared/HintLoading"
-const ServicesList = ({ items, isLoading }) => {
+const ServicesList = ({ items, isLoading }: any) => {
return (
<>
{/* clickableTable Table allow changes the background by css when hovering or active*/}
@@ -54,7 +54,7 @@ const ServicesList = ({ items, isLoading }) => {
<>
{items?.length > 0 ? (
<>
- {items.map((item, i) => (
+ {items.map((item: any, i: any) => (
))}
>
diff --git a/apps/heureka/src/components/services/ServicesListItem.jsx b/apps/heureka/src/components/services/ServicesListItem.tsx
similarity index 96%
rename from apps/heureka/src/components/services/ServicesListItem.jsx
rename to apps/heureka/src/components/services/ServicesListItem.tsx
index 6199bc7aa..9047fe450 100644
--- a/apps/heureka/src/components/services/ServicesListItem.jsx
+++ b/apps/heureka/src/components/services/ServicesListItem.tsx
@@ -9,7 +9,8 @@ import { listOfCommaSeparatedObjs } from "../shared/Helper"
import constants from "../shared/constants"
import { useGlobalsActions, useGlobalsShowPanel, useGlobalsShowServiceDetail } from "../StoreProvider"
-const ServicesListItem = ({ item }) => {
+const ServicesListItem = ({ item }: any) => {
+ // @ts-ignore
const { setShowServiceDetail, setShowPanel } = useGlobalsActions()
const showServiceDetail = useGlobalsShowServiceDetail()
const showPanel = useGlobalsShowPanel()
diff --git a/apps/heureka/src/components/services/ServicesView.jsx b/apps/heureka/src/components/services/ServicesView.tsx
similarity index 100%
rename from apps/heureka/src/components/services/ServicesView.jsx
rename to apps/heureka/src/components/services/ServicesView.tsx
diff --git a/apps/heureka/src/components/shared/Helper.test.jsx b/apps/heureka/src/components/shared/Helper.test.tsx
similarity index 98%
rename from apps/heureka/src/components/shared/Helper.test.jsx
rename to apps/heureka/src/components/shared/Helper.test.tsx
index 390339dc5..28f2d2034 100644
--- a/apps/heureka/src/components/shared/Helper.test.jsx
+++ b/apps/heureka/src/components/shared/Helper.test.tsx
@@ -44,7 +44,7 @@ describe("highestSeverity", () => {
})
it("should return undefined if vulnerabilities array is empty", () => {
- const vulnerabilities = []
+ const vulnerabilities: any = []
const result = highestSeverity(vulnerabilities)
expect(result).toBeUndefined()
})
diff --git a/apps/heureka/src/components/shared/Helper.jsx b/apps/heureka/src/components/shared/Helper.tsx
similarity index 72%
rename from apps/heureka/src/components/shared/Helper.jsx
rename to apps/heureka/src/components/shared/Helper.tsx
index 46f1ffc9d..ac113f955 100644
--- a/apps/heureka/src/components/shared/Helper.jsx
+++ b/apps/heureka/src/components/shared/Helper.tsx
@@ -2,24 +2,25 @@
* SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
* SPDX-License-Identifier: Apache-2.0
*/
+// @ts-expect-error TS(2792): Cannot find module 'luxon'. Did you mean to set th... Remove this comment to see the full error message
import { DateTime } from "luxon"
-export const listOfCommaSeparatedObjs = (objs, prop) => {
+export const listOfCommaSeparatedObjs = (objs: any, prop: any) => {
objs = objs?.edges || []
return objs
- .filter((obj) => obj?.node?.[prop])
- .map((obj) => obj?.node?.[prop])
+ .filter((obj: any) => obj?.node?.[prop])
+ .map((obj: any) => obj?.node?.[prop])
.join(", ")
}
-export const formatDate = (dateStr) => {
+export const formatDate = (dateStr: any) => {
const dateObj = DateTime.fromISO(dateStr)
const dateFormat = { ...DateTime.DATE_MED } // Use the predefined DATE_MED format
return dateObj.toLocaleString(dateFormat) // Format the date using the predefined format
}
-export const highestSeverity = (vulnerablities) => {
- const highest = vulnerablities.reduce((max, vulnerability) => {
+export const highestSeverity = (vulnerablities: any) => {
+ const highest = vulnerablities.reduce((max: any, vulnerability: any) => {
const currentScore = vulnerability?.node?.severity?.score
const maxScore = max?.node?.severity?.score
@@ -39,14 +40,14 @@ export const highestSeverity = (vulnerablities) => {
return highest?.node?.severity
}
-export const severityString = (severity) => {
+export const severityString = (severity: any) => {
// return - if there is no value to show nothing.
if (!severity?.value) return "—"
return severity?.value + " (" + severity?.score + ")"
}
-export const cellSeverityClasses = (severity) => {
+export const cellSeverityClasses = (severity: any) => {
let borderColor = "border-text-theme-default"
switch (severity) {
case "Critical":
diff --git a/apps/heureka/src/components/shared/HintLoading.jsx b/apps/heureka/src/components/shared/HintLoading.tsx
similarity index 89%
rename from apps/heureka/src/components/shared/HintLoading.jsx
rename to apps/heureka/src/components/shared/HintLoading.tsx
index 27ff9bc3f..ab1cc0c00 100644
--- a/apps/heureka/src/components/shared/HintLoading.jsx
+++ b/apps/heureka/src/components/shared/HintLoading.tsx
@@ -6,7 +6,7 @@
import React from "react"
import { Stack, Spinner } from "@cloudoperators/juno-ui-components"
-const HintLoading = ({ text, ...props }) => {
+const HintLoading = ({ text, ...props }: any) => {
return (
diff --git a/apps/heureka/src/components/shared/HintNotFound.jsx b/apps/heureka/src/components/shared/HintNotFound.tsx
similarity index 85%
rename from apps/heureka/src/components/shared/HintNotFound.jsx
rename to apps/heureka/src/components/shared/HintNotFound.tsx
index d97a7288b..b50e44abf 100644
--- a/apps/heureka/src/components/shared/HintNotFound.jsx
+++ b/apps/heureka/src/components/shared/HintNotFound.tsx
@@ -6,8 +6,9 @@
import React from "react"
import { Container } from "@cloudoperators/juno-ui-components"
-const HintNotFound = ({ text }) => {
+const HintNotFound = ({ text }: any) => {
return (
+ // @ts-ignore
{text}
diff --git a/apps/heureka/src/components/shared/ListController.jsx b/apps/heureka/src/components/shared/ListController.tsx
similarity index 91%
rename from apps/heureka/src/components/shared/ListController.jsx
rename to apps/heureka/src/components/shared/ListController.tsx
index 26f88300a..fea1c2667 100644
--- a/apps/heureka/src/components/shared/ListController.jsx
+++ b/apps/heureka/src/components/shared/ListController.tsx
@@ -15,9 +15,17 @@ import { useActions as messageActions } from "@cloudoperators/juno-messages-prov
import { parseError } from "../../helpers"
import PaginationComponent from "./PaginationComponent"
-const ListController = ({ queryKey, entityName, ListComponent, activeFilters, searchTerm, enableSearchAndFilter }) => {
+const ListController = ({
+ queryKey,
+ entityName,
+ ListComponent,
+ activeFilters,
+ searchTerm,
+ enableSearchAndFilter,
+}: any) => {
const queryClientFnReady = useGlobalsQueryClientFnReady()
const queryOptions = useGlobalsQueryOptions(queryKey)
+ // @ts-ignore
const { setQueryOptions } = useGlobalsActions()
const { addMessage, resetMessages } = messageActions()
const activeView = useGlobalsActiveView()
@@ -31,6 +39,7 @@ const ListController = ({ queryKey, entityName, ListComponent, activeFilters, se
queryKey: [
`${queryKey}Main`,
{
+ // @ts-ignore
...queryOptions,
filter: {
...activeFilters,
@@ -50,6 +59,7 @@ const ListController = ({ queryKey, entityName, ListComponent, activeFilters, se
queryKey: [
`${queryKey}Count`,
{
+ // @ts-ignore
...queryOptions,
filter: {
...activeFilters,
@@ -59,7 +69,7 @@ const ListController = ({ queryKey, entityName, ListComponent, activeFilters, se
],
enabled: !!queryClientFnReady && queryKey === activeView,
})
-
+ // @ts-ignore
const items = mainData?.[entityName]?.edges || []
useEffect(() => {
diff --git a/apps/heureka/src/components/shared/LoadElement.jsx b/apps/heureka/src/components/shared/LoadElement.tsx
similarity index 92%
rename from apps/heureka/src/components/shared/LoadElement.jsx
rename to apps/heureka/src/components/shared/LoadElement.tsx
index 5af41ed09..0835872e5 100644
--- a/apps/heureka/src/components/shared/LoadElement.jsx
+++ b/apps/heureka/src/components/shared/LoadElement.tsx
@@ -6,7 +6,7 @@
import React from "react"
import { Spinner, Stack } from "@cloudoperators/juno-ui-components"
-const LoadElement = (prop) => {
+const LoadElement = (prop: any) => {
const elem = prop?.elem
return (
<>
diff --git a/apps/heureka/src/components/shared/PaginationComponent.test.jsx b/apps/heureka/src/components/shared/PaginationComponent.test.tsx
similarity index 97%
rename from apps/heureka/src/components/shared/PaginationComponent.test.jsx
rename to apps/heureka/src/components/shared/PaginationComponent.test.tsx
index 22af4742e..78a3b9027 100644
--- a/apps/heureka/src/components/shared/PaginationComponent.test.jsx
+++ b/apps/heureka/src/components/shared/PaginationComponent.test.tsx
@@ -35,12 +35,14 @@ test('should update currentPage when "Next Page" button is clicked', async () =>
)
// Initial value should be "1"
+ // @ts-ignore
expect(screen.getByRole("textbox").value).toBe("1")
// Simulate click on "Next Page"
fireEvent.click(screen.getByText(/Next Page/i))
// Wait for the currentPage to update to "2"
+ // @ts-ignore
await waitFor(() => expect(screen.getByRole("textbox").value).toBe("2"))
// Verify that the `setQueryOptions` function was called with the correct after value for the next page
@@ -63,12 +65,14 @@ test('should update currentPage when "Previous Page" button is clicked', async (
// Simulate click on "Next Page" to go to page 2
fireEvent.click(screen.getByText(/Next Page/i))
+ // @ts-ignore
expect(screen.getByRole("textbox").value).toBe("2")
// Simulate click on "Previous Page"
fireEvent.click(screen.getByText(/Previous Page/i))
// Wait for the currentPage to update to "1"
+ // @ts-ignore
await waitFor(() => expect(screen.getByRole("textbox").value).toBe("1"))
// Verify that the `setQueryOptions` function was called with the correct after value for the previous page
diff --git a/apps/heureka/src/components/shared/PaginationComponent.jsx b/apps/heureka/src/components/shared/PaginationComponent.tsx
similarity index 86%
rename from apps/heureka/src/components/shared/PaginationComponent.jsx
rename to apps/heureka/src/components/shared/PaginationComponent.tsx
index 376af67c7..1f7440b8b 100644
--- a/apps/heureka/src/components/shared/PaginationComponent.jsx
+++ b/apps/heureka/src/components/shared/PaginationComponent.tsx
@@ -6,17 +6,17 @@
import React, { useState } from "react"
import { Pagination, Stack, Container } from "@cloudoperators/juno-ui-components"
-const PaginationComponent = ({ queryKey, queryOptions, entityName, setQueryOptions, countData }) => {
+const PaginationComponent = ({ queryKey, queryOptions, entityName, setQueryOptions, countData }: any) => {
const [currentPage, setCurrentPage] = useState(1)
const pageInfo = countData?.[entityName]?.pageInfo || null
const totalPages = pageInfo?.pages?.length || 0
- const onPaginationChanged = (newPage) => {
+ const onPaginationChanged = (newPage: any) => {
setCurrentPage(newPage)
if (!pageInfo?.pages) return
const pages = pageInfo.pages
- const currentPageIndex = pages?.findIndex((page) => page?.pageNumber === parseInt(newPage))
+ const currentPageIndex = pages?.findIndex((page: any) => page?.pageNumber === parseInt(newPage))
if (currentPageIndex > -1) {
const after = pages[currentPageIndex]?.after
setQueryOptions(queryKey, {
@@ -26,7 +26,7 @@ const PaginationComponent = ({ queryKey, queryOptions, entityName, setQueryOptio
}
}
- const onKeyPress = (event) => {
+ const onKeyPress = (event: any) => {
if (event.code === "Enter") {
onPaginationChanged(event.currentTarget.value)
}
diff --git a/apps/heureka/src/components/shared/PanelManager.jsx b/apps/heureka/src/components/shared/PanelManager.tsx
similarity index 94%
rename from apps/heureka/src/components/shared/PanelManager.jsx
rename to apps/heureka/src/components/shared/PanelManager.tsx
index 92b807973..5e564d553 100644
--- a/apps/heureka/src/components/shared/PanelManager.jsx
+++ b/apps/heureka/src/components/shared/PanelManager.tsx
@@ -12,9 +12,10 @@ import IssueMatchesDetails from "../issueMatches/IssueMatchesDetails"
import { Messages, MessagesProvider } from "@cloudoperators/juno-messages-provider"
const PanelManger = () => {
+ // @ts-ignore
const { setShowPanel, setShowServiceDetail, setShowIssueDetail } = useGlobalsActions()
const showPanel = useGlobalsShowPanel()
- const showServiceDetail = useGlobalsShowServiceDetail()
+ const showServiceDetail = useGlobalsShowServiceDetail() as React.ReactNode
const onPanelClose = () => {
setShowPanel(null)
diff --git a/apps/heureka/src/components/shared/constants.js b/apps/heureka/src/components/shared/constants.ts
similarity index 100%
rename from apps/heureka/src/components/shared/constants.js
rename to apps/heureka/src/components/shared/constants.ts
diff --git a/apps/heureka/src/helpers.test.js b/apps/heureka/src/helpers.test.ts
similarity index 82%
rename from apps/heureka/src/helpers.test.js
rename to apps/heureka/src/helpers.test.ts
index 6b126c35c..3f1d301dc 100644
--- a/apps/heureka/src/helpers.test.js
+++ b/apps/heureka/src/helpers.test.ts
@@ -29,6 +29,7 @@ describe("Helpers", () => {
describe("classifyVulnerabilities", () => {
test("return empty results if no components provided", () => {
+ // @ts-expect-error TS(2345): Argument of type '(components?: never[]) => { low:... Remove this comment to see the full error message
expect(classifyVulnerabilities(classifyVulnerabilities)).toEqual({
low: 0,
medium: 0,
@@ -37,6 +38,7 @@ describe("Helpers", () => {
})
})
test("return empty results if null provided", () => {
+ // @ts-expect-error TS(2345): Argument of type 'null' is not assignable to param... Remove this comment to see the full error message
expect(classifyVulnerabilities(null)).toEqual({
low: 0,
medium: 0,
@@ -47,6 +49,7 @@ describe("Helpers", () => {
test("map to array if object instead of array provided", () => {
expect(
classifyVulnerabilities({
+ // @ts-expect-error TS(2345): Argument of type '{ Vulnerabilities: { ThreatLevel... Remove this comment to see the full error message
Vulnerabilities: [{ ThreatLevelOverall: "Medium" }],
})
).toEqual({
@@ -66,6 +69,7 @@ describe("Helpers", () => {
const component3 = {
Vulnerabilities: [{ ThreatLevelOverall: "medium" }],
}
+ // @ts-expect-error TS(2322): Type '{ Vulnerabilities: { ThreatLevelOverall: str... Remove this comment to see the full error message
expect(classifyVulnerabilities([component1, component2, component3])).toEqual({
low: 1,
medium: 2,
diff --git a/apps/heureka/src/helpers.js b/apps/heureka/src/helpers.ts
similarity index 83%
rename from apps/heureka/src/helpers.js
rename to apps/heureka/src/helpers.ts
index 02c37e474..e689765cf 100644
--- a/apps/heureka/src/helpers.js
+++ b/apps/heureka/src/helpers.ts
@@ -3,9 +3,10 @@
* SPDX-License-Identifier: Apache-2.0
*/
+// @ts-expect-error TS(2792): Cannot find module 'luxon'. Did you mean to set th... Remove this comment to see the full error message
import { DateTime } from "luxon"
-export const parseError = (error) => {
+export const parseError = (error: any) => {
if (!error || (typeof error === "object" && Object.keys(error).length === 0))
return "An error occurred. There is no further information"
let errMsg = JSON.stringify(error)
@@ -20,11 +21,11 @@ export const parseError = (error) => {
return errMsg
}
-export const usersListToString = (users) => {
+export const usersListToString = (users: any) => {
if (!users) users = []
if (!Array.isArray(users)) users = [users]
- return users.map((user) => `${user.Name} (${user.SapID})`).join(", ")
+ return users.map((user: any) => `${user.Name} (${user.SapID})`).join(", ")
}
export const THREAD_LEVEL_LOW = "low"
@@ -32,7 +33,7 @@ export const THREAD_LEVEL_MEDIUM = "medium"
export const THREAD_LEVEL_HIGH = "high"
export const THREAD_LEVEL_CRITICAL = "critical"
-export const threadLevelToWeight = (level) => {
+export const threadLevelToWeight = (level: any) => {
switch (level?.toLowerCase()) {
case THREAD_LEVEL_LOW:
return 3
@@ -51,6 +52,7 @@ export const classifyVulnerabilitiesV2 = (vulnerabilites = []) => {
let severities = { low: 0, medium: 0, high: 0, critical: 0 }
vulnerabilites.forEach((vulnerability) => {
// use of ThreatLevelOverall to get the index
+ // @ts-expect-error TS(2339): Property 'ThreatLevelOverall' does not exist on ty... Remove this comment to see the full error message
switch (vulnerability?.ThreatLevelOverall?.toLowerCase()) {
case THREAD_LEVEL_LOW:
return (severities.low += 1)
@@ -72,9 +74,11 @@ export const classifyVulnerabilities = (components = []) => {
let severities = { low: 0, medium: 0, high: 0, critical: 0 }
components.forEach((component) => {
// collect vulnerabilities from one component
+ // @ts-expect-error TS(2339): Property 'Vulnerabilities' does not exist on type ... Remove this comment to see the full error message
if (component?.Vulnerabilities) {
+ // @ts-expect-error TS(2339): Property 'Vulnerabilities' does not exist on type ... Remove this comment to see the full error message
const vulnerabilites = component?.Vulnerabilities
- vulnerabilites.forEach((vulnerability) => {
+ vulnerabilites.forEach((vulnerability: any) => {
// use of ThreatLevelOverall to get the index
switch (vulnerability?.ThreatLevelOverall?.toLowerCase()) {
case THREAD_LEVEL_LOW:
@@ -98,8 +102,8 @@ export const componentTypes = () => {
return [COMPONENT_TYPE_KEPPEL]
}
-export const componentDetailsByType = (component) => {
- let detailKeys = []
+export const componentDetailsByType = (component: any) => {
+ let detailKeys: any = []
switch (component.Type) {
case COMPONENT_TYPE_KEPPEL:
detailKeys = [
@@ -125,7 +129,7 @@ export const componentDetailsByType = (component) => {
return detailKeys
}
-export const componentVersionByType = (component) => {
+export const componentVersionByType = (component: any) => {
let version = ""
switch (component.Type) {
case COMPONENT_TYPE_KEPPEL:
diff --git a/apps/heureka/src/hooks/useCommunication.js b/apps/heureka/src/hooks/useCommunication.ts
similarity index 69%
rename from apps/heureka/src/hooks/useCommunication.js
rename to apps/heureka/src/hooks/useCommunication.ts
index 301def21b..9c7e4153a 100644
--- a/apps/heureka/src/hooks/useCommunication.js
+++ b/apps/heureka/src/hooks/useCommunication.ts
@@ -9,14 +9,18 @@ import { get, watch } from "@cloudoperators/juno-communicator"
const useCommunication = () => {
useEffect(() => {
// Fetch and watch for auth data updates
+ // @ts-expect-error TS(2304): Cannot find name 'setAuthData'.
if (!setAuthData) return
+ // @ts-expect-error TS(2304): Cannot find name 'setAuthData'.
get("AUTH_GET_DATA", setAuthData)
+ // @ts-expect-error TS(2304): Cannot find name 'setAuthData'.
const unwatchUpdate = watch("AUTH_UPDATE_DATA", setAuthData)
return () => {
if (unwatchUpdate) unwatchUpdate()
}
+ // @ts-expect-error TS(2304): Cannot find name 'setAuthData'.
}, [setAuthData])
}
diff --git a/apps/heureka/src/hooks/useQueryClientFn.js b/apps/heureka/src/hooks/useQueryClientFn.ts
similarity index 83%
rename from apps/heureka/src/hooks/useQueryClientFn.js
rename to apps/heureka/src/hooks/useQueryClientFn.ts
index 9b1d4411d..08bddf30a 100644
--- a/apps/heureka/src/hooks/useQueryClientFn.js
+++ b/apps/heureka/src/hooks/useQueryClientFn.ts
@@ -24,6 +24,7 @@ import usersQuery from "../lib/queries/users"
const useQueryClientFn = () => {
const queryClient = useQueryClient()
const endpoint = useGlobalsApiEndpoint()
+ // @ts-ignore
const { setQueryClientFnReady } = useGlobalsActions()
/*
As stated in getQueryDefaults, the order of registration of query defaults does matter. Since the first matching defaults are returned by getQueryDefaults, the registration should be made in the following order: from the least generic key to the most generic one. This way, in case of specific key, the first matching one would be the expected one.
@@ -33,130 +34,146 @@ const useQueryClientFn = () => {
// Services main query
queryClient.setQueryDefaults(["ServicesMain"], {
- queryFn: async ({ queryKey }) => {
+ queryFn: async ({ queryKey }: any) => {
const [_key, options] = queryKey
+ // @ts-ignore
return await request(endpoint, servicesMainQuery(), options)
},
})
// Services details query
queryClient.setQueryDefaults(["ServicesDetails"], {
- queryFn: async ({ queryKey }) => {
+ queryFn: async ({ queryKey }: any) => {
const [_key, options] = queryKey
+ // @ts-ignore
return await request(endpoint, servicesDetailsQuery(), options)
},
})
// ComponentInstances of a service query both for main and count info - for the service details page
queryClient.setQueryDefaults(["ComponentInstancesOfService"], {
- queryFn: async ({ queryKey }) => {
+ queryFn: async ({ queryKey }: any) => {
const [_key, options] = queryKey
+ // @ts-ignore
return await request(endpoint, componentInstancesOfServiceQuery(), options)
},
})
// Services count query (for totalCount and pageInfo)
queryClient.setQueryDefaults(["ServicesCount"], {
- queryFn: async ({ queryKey }) => {
+ queryFn: async ({ queryKey }: any) => {
const [_key, options] = queryKey
+ // @ts-ignore
return await request(endpoint, servicesCountQuery(), options)
},
})
// Components main query
queryClient.setQueryDefaults(["ComponentsMain"], {
- queryFn: async ({ queryKey }) => {
+ queryFn: async ({ queryKey }: any) => {
const [_key, options] = queryKey
+ // @ts-ignore
return await request(endpoint, componentsMainQuery(), options)
},
})
// Components count query (for totalCount and pageInfo)
queryClient.setQueryDefaults(["ComponentsCount"], {
- queryFn: async ({ queryKey }) => {
+ queryFn: async ({ queryKey }: any) => {
const [_key, options] = queryKey
+ // @ts-ignore
return await request(endpoint, componentsCountQuery(), options)
},
})
// IssueMatches main query
queryClient.setQueryDefaults(["IssueMatchesMain"], {
- queryFn: async ({ queryKey }) => {
+ queryFn: async ({ queryKey }: any) => {
const [_key, options] = queryKey
+ // @ts-ignore
return await request(endpoint, issueMatchesMainQuery(), options)
},
})
// IssueMatches details query
queryClient.setQueryDefaults(["IssueMatchesDetails"], {
- queryFn: async ({ queryKey }) => {
+ queryFn: async ({ queryKey }: any) => {
const [_key, options] = queryKey
+ // @ts-ignore
return await request(endpoint, issueMatchesDetailsQuery(), options)
},
})
// IssueMatches count query (for totalCount and pageInfo)
queryClient.setQueryDefaults(["IssueMatchesCount"], {
- queryFn: async ({ queryKey }) => {
+ queryFn: async ({ queryKey }: any) => {
const [_key, options] = queryKey
+ // @ts-ignore
return await request(endpoint, issueMatchesCountQuery(), options)
},
})
queryClient.setQueryDefaults(["ServiceFilterValues"], {
- queryFn: async ({ queryKey }) => {
+ queryFn: async ({ queryKey }: any) => {
const [_key, variables] = queryKey
+ // @ts-ignore
return await request(endpoint, serviceFilterValuesQuery(), variables)
},
staleTime: Infinity, // this do not change often keep it until reload
})
queryClient.setQueryDefaults(["IssueMatchFilterValues"], {
- queryFn: async ({ queryKey }) => {
+ queryFn: async ({ queryKey }: any) => {
const [_key, variables] = queryKey
+ // @ts-ignore
return await request(endpoint, issueMatchesFilterValuesQuery(), variables)
},
staleTime: Infinity, // this do not change often keep it until reload
})
queryClient.setQueryDefaults(["Users"], {
- queryFn: async ({ queryKey }) => {
+ queryFn: async ({ queryKey }: any) => {
const [_key, options] = queryKey
+ // @ts-ignore
return await request(endpoint, usersQuery(), options)
},
})
// Set mutation defaults for addOwnerToService
queryClient.setMutationDefaults(["addOwnerToService"], {
- mutationFn: async ({ serviceId, userId }) => {
+ mutationFn: async ({ serviceId, userId }: any) => {
const { mutation, variables } = addRemoveServiceOwners(
serviceId,
userId,
"add" // Specify "add" action for adding a user
)
+ // @ts-ignore
await request(endpoint, mutation, variables)
},
onSuccess: () => {
+ // @ts-ignore
queryClient.invalidateQueries(["Services"])
},
- onError: (error) => {
+ onError: (error: any) => {
console.error("Failed to add owner to the service:", error)
},
})
// Set mutation defaults for removeOwnerFromService
queryClient.setMutationDefaults(["removeOwnerFromService"], {
- mutationFn: async ({ serviceId, userId }) => {
+ mutationFn: async ({ serviceId, userId }: any) => {
const { mutation, variables } = addRemoveServiceOwners(
serviceId,
userId,
"remove" // Specify "remove" action for removing a user
)
+ // @ts-ignore
await request(endpoint, mutation, variables)
},
onSuccess: () => {
+ // @ts-ignore
queryClient.invalidateQueries(["Services"])
},
- onError: (error) => {
+ onError: (error: any) => {
console.error("Failed to remove owner from the service:", error)
},
})
diff --git a/apps/heureka/src/hooks/useUrlState.js b/apps/heureka/src/hooks/useUrlState.ts
similarity index 92%
rename from apps/heureka/src/hooks/useUrlState.js
rename to apps/heureka/src/hooks/useUrlState.ts
index 565e1cb32..4522f13cb 100644
--- a/apps/heureka/src/hooks/useUrlState.js
+++ b/apps/heureka/src/hooks/useUrlState.ts
@@ -4,6 +4,7 @@
*/
import { useLayoutEffect, useEffect, useState } from "react"
+// @ts-expect-error TS(2792): Cannot find module '@cloudoperators/juno-url-state... Remove this comment to see the full error message
import { registerConsumer } from "@cloudoperators/juno-url-state-provider-v1"
import {
useGlobalsShowPanel,
@@ -22,12 +23,14 @@ const urlStateManager = registerConsumer("heureka")
const useUrlState = () => {
const [isURLRead, setIsURLRead] = useState(false)
+ // @ts-ignore
const { setFiltersFromURL, syncFiltersWithURL } = useFilterActions()
const activeView = useGlobalsActiveView()
const detailsFor = useGlobalsShowPanel()
const showServiceDetail = useGlobalsShowServiceDetail()
const showIssueDetail = useGlobalsShowIssueDetail()
+ // @ts-ignore
const { setShowPanel, setActiveView, setServiceDetail, setIssueDetail, syncDetailsWithURL } = useGlobalsActions()
const serviceActiveFilters = useServiceActiveFilters()
const issueMatchesActiveFilters = useIssueMatchesActiveFilters()
@@ -97,7 +100,7 @@ const useUrlState = () => {
// Support for back button
useEffect(() => {
- const unregisterStateListener = urlStateManager.onChange((state) => {
+ const unregisterStateListener = urlStateManager.onChange((state: any) => {
setActiveView(state?.[constants.ACTIVE_VIEW])
setFiltersFromURL(state?.[constants.ACTIVE_FILTERS], state?.[constants.SEARCH_TERM])
setShowPanel(state?.[constants.DETAILS_FOR])
@@ -107,9 +110,11 @@ const useUrlState = () => {
if (currentDetailFor) {
switch (currentDetailFor) {
case constants.PANEL_SERVICE:
+ // @ts-expect-error TS(2304): Cannot find name 'urlState'.
setServiceDetail(urlState[constants.SERVICE_NAME]) // Show service details panel
break
case constants.PANEL_ISSUE:
+ // @ts-expect-error TS(2304): Cannot find name 'urlState'.
setIssueDetail(urlState[constants.ISSUE_ID]) // Show issue details panel
break
}
diff --git a/apps/heureka/src/index.js b/apps/heureka/src/index.ts
similarity index 50%
rename from apps/heureka/src/index.js
rename to apps/heureka/src/index.ts
index 13ed4b7b3..35ed0867a 100644
--- a/apps/heureka/src/index.js
+++ b/apps/heureka/src/index.ts
@@ -7,11 +7,14 @@ import { createRoot } from "react-dom/client"
import React from "react"
// export mount and unmount functions
-export const mount = (container, options = {}) => {
+export const mount = (container: any, options = {}) => {
import("./App").then((App) => {
+ // @ts-expect-error TS(2339): Property 'root' does not exist on type '(container... Remove this comment to see the full error message
mount.root = createRoot(container)
+ // @ts-expect-error TS(2339): Property 'root' does not exist on type '(container... Remove this comment to see the full error message
mount.root.render(React.createElement(App.default, options?.props))
})
}
+// @ts-expect-error TS(2339): Property 'root' does not exist on type '(container... Remove this comment to see the full error message
export const unmount = () => mount.root && mount.root.unmount()
diff --git a/apps/heureka/src/lib/queries/addRemoveServiceOwners.js b/apps/heureka/src/lib/queries/addRemoveServiceOwners.ts
similarity index 93%
rename from apps/heureka/src/lib/queries/addRemoveServiceOwners.js
rename to apps/heureka/src/lib/queries/addRemoveServiceOwners.ts
index 732ac079e..4db4c06f5 100644
--- a/apps/heureka/src/lib/queries/addRemoveServiceOwners.js
+++ b/apps/heureka/src/lib/queries/addRemoveServiceOwners.ts
@@ -6,7 +6,7 @@
import { gql } from "graphql-request"
// A function that dynamically generates a GraphQL mutation for adding or removing a user from a service
-export default (serviceId, userId, action) => {
+export default (serviceId: any, userId: any, action: any) => {
// Determine the mutation based on the action (add or remove)
const mutationName = action === "add" ? "addOwnerToService" : "removeOwnerFromService"
diff --git a/apps/heureka/src/lib/queries/components.js b/apps/heureka/src/lib/queries/components.ts
similarity index 100%
rename from apps/heureka/src/lib/queries/components.js
rename to apps/heureka/src/lib/queries/components.ts
diff --git a/apps/heureka/src/lib/queries/issueMatches.js b/apps/heureka/src/lib/queries/issueMatches.ts
similarity index 100%
rename from apps/heureka/src/lib/queries/issueMatches.js
rename to apps/heureka/src/lib/queries/issueMatches.ts
diff --git a/apps/heureka/src/lib/queries/issueMatchesFilterValues.js b/apps/heureka/src/lib/queries/issueMatchesFilterValues.ts
similarity index 100%
rename from apps/heureka/src/lib/queries/issueMatchesFilterValues.js
rename to apps/heureka/src/lib/queries/issueMatchesFilterValues.ts
diff --git a/apps/heureka/src/lib/queries/serviceFilterValues.js b/apps/heureka/src/lib/queries/serviceFilterValues.ts
similarity index 100%
rename from apps/heureka/src/lib/queries/serviceFilterValues.js
rename to apps/heureka/src/lib/queries/serviceFilterValues.ts
diff --git a/apps/heureka/src/lib/queries/services.js b/apps/heureka/src/lib/queries/services.ts
similarity index 100%
rename from apps/heureka/src/lib/queries/services.js
rename to apps/heureka/src/lib/queries/services.ts
diff --git a/apps/heureka/src/lib/queries/users.js b/apps/heureka/src/lib/queries/users.ts
similarity index 100%
rename from apps/heureka/src/lib/queries/users.js
rename to apps/heureka/src/lib/queries/users.ts
diff --git a/apps/heureka/src/lib/slices/createAuthDataSlice.js b/apps/heureka/src/lib/slices/createAuthDataSlice.ts
similarity index 78%
rename from apps/heureka/src/lib/slices/createAuthDataSlice.js
rename to apps/heureka/src/lib/slices/createAuthDataSlice.ts
index a24a6f641..e251e4a8b 100644
--- a/apps/heureka/src/lib/slices/createAuthDataSlice.js
+++ b/apps/heureka/src/lib/slices/createAuthDataSlice.ts
@@ -8,6 +8,7 @@ export const AUTH_ACTIONS = {
SIGN_OUT: "signOut",
}
+// @ts-expect-error TS(7006): Parameter 'set' implicitly has an 'any' type.
const createAuthDataSlice = (set, get) => ({
auth: {
data: null,
@@ -19,10 +20,16 @@ const createAuthDataSlice = (set, get) => ({
appIsLoading: false,
actions: {
- setAppLoaded: (appLoaded) => {
- set((state) => ({ auth: { ...state.auth, appLoaded } }), false, "auth/setAppLoaded")
+ setAppLoaded: (appLoaded: any) => {
+ set(
+ (state: any) => ({
+ auth: { ...state.auth, appLoaded },
+ }),
+ false,
+ "auth/setAppLoaded"
+ )
},
- setData: (data) => {
+ setData: (data: any) => {
if (!data) return
// check if data has changed before updating the state
if (
@@ -34,7 +41,7 @@ const createAuthDataSlice = (set, get) => ({
return
set(
- (state) => ({
+ (state: any) => ({
auth: {
...state.auth,
isProcessing: data?.isProcessing,
@@ -47,9 +54,9 @@ const createAuthDataSlice = (set, get) => ({
"auth/setData"
)
},
- setAction: (name) =>
+ setAction: (name: any) =>
set(
- (state) => ({
+ (state: any) => ({
auth: {
...state.auth,
lastAction: { name: name, updatedAt: Date.now() },
diff --git a/apps/heureka/src/lib/slices/createFiltersSlice.test.js b/apps/heureka/src/lib/slices/createFiltersSlice.test.ts
similarity index 99%
rename from apps/heureka/src/lib/slices/createFiltersSlice.test.js
rename to apps/heureka/src/lib/slices/createFiltersSlice.test.ts
index 3ab1c99dd..87dc25318 100644
--- a/apps/heureka/src/lib/slices/createFiltersSlice.test.js
+++ b/apps/heureka/src/lib/slices/createFiltersSlice.test.ts
@@ -11,7 +11,7 @@ const SERVICES = "Services"
const COMPONENTS = "Components"
describe("createFiltersSlice", () => {
- let store
+ let store: any
beforeEach(() => {
store = createStore((set, get) => ({
diff --git a/apps/heureka/src/lib/slices/createFiltersSlice.js b/apps/heureka/src/lib/slices/createFiltersSlice.ts
similarity index 78%
rename from apps/heureka/src/lib/slices/createFiltersSlice.js
rename to apps/heureka/src/lib/slices/createFiltersSlice.ts
index e2ff49972..4f5723fd2 100644
--- a/apps/heureka/src/lib/slices/createFiltersSlice.js
+++ b/apps/heureka/src/lib/slices/createFiltersSlice.ts
@@ -28,27 +28,28 @@ const initialFiltersState = {
[COMPONENTS]: createFilterState(),
}
+// @ts-expect-error TS(7006): Parameter 'set' implicitly has an 'any' type.
const createFiltersSlice = (set, get) => ({
filters: {
...initialFiltersState,
actions: {
- setLabels: (entity, labelPairs) =>
+ setLabels: (entity: any, labelPairs: any) =>
set(
- produce((state) => {
- state.filters[entity].labels = labelPairs.map(({ displayName, filterName }) => ({
+ produce((state: any) => {
+ state.filters[entity].labels = labelPairs.map(({ displayName, filterName }: any) => ({
displayName,
filterName,
}))
- state.filters[entity].filterNames = labelPairs.map(({ filterName }) => filterName) // update filterNames accordingly
+ state.filters[entity].filterNames = labelPairs.map(({ filterName }: any) => filterName) // update filterNames accordingly
}),
false,
`filters.setLabels.${entity}`
),
- setFilterLabelValues: (entity, filters) =>
+ setFilterLabelValues: (entity: any, filters: any) =>
set(
- produce((state) => {
- state.filters[entity].filterLabelValues = filters.reduce((acc, filter) => {
+ produce((state: any) => {
+ state.filters[entity].filterLabelValues = filters.reduce((acc: any, filter: any) => {
acc[filter.filterName] = filter.values
return acc
}, {})
@@ -57,9 +58,9 @@ const createFiltersSlice = (set, get) => ({
`filters.setFilterLabelValues.${entity}`
),
- setActiveFilters: (entity, activeFilters) => {
+ setActiveFilters: (entity: any, activeFilters: any) => {
set(
- produce((state) => {
+ produce((state: any) => {
state.filters[entity].activeFilters = activeFilters
}),
false,
@@ -67,9 +68,9 @@ const createFiltersSlice = (set, get) => ({
)
},
- clearActiveFilters: (entity) => {
+ clearActiveFilters: (entity: any) => {
set(
- produce((state) => {
+ produce((state: any) => {
state.filters[entity].activeFilters = {}
}),
false,
@@ -77,15 +78,16 @@ const createFiltersSlice = (set, get) => ({
)
},
- addActiveFilter: (entity, filterName, filterValue) => {
+ addActiveFilter: (entity: any, filterName: any, filterValue: any) => {
set(
- produce((state) => {
+ produce((state: any) => {
if (!state.filters[entity].activeFilters[filterName]) {
state.filters[entity].activeFilters[filterName] = []
}
// Add the filter value if it doesn't already exist
state.filters[entity].activeFilters[filterName] = [
+ // @ts-expect-error TS(2552): Cannot find name 'Set'. Did you mean 'set'?
...new Set([...state.filters[entity].activeFilters[filterName], filterValue]),
]
}),
@@ -94,15 +96,16 @@ const createFiltersSlice = (set, get) => ({
)
},
- addActiveFilters: (entity, filterName, filterValues) => {
+ addActiveFilters: (entity: any, filterName: any, filterValues: any) => {
set(
- produce((state) => {
+ produce((state: any) => {
if (!state.filters[entity].activeFilters[filterName]) {
state.filters[entity].activeFilters[filterName] = []
}
// Add the filter values and ensure uniqueness
state.filters[entity].activeFilters[filterName] = [
+ // @ts-expect-error TS(2552): Cannot find name 'Set'. Did you mean 'set'?
...new Set([...state.filters[entity].activeFilters[filterName], ...filterValues]),
]
}),
@@ -111,11 +114,11 @@ const createFiltersSlice = (set, get) => ({
)
},
- removeActiveFilter: (entity, filterName, filterValue) => {
+ removeActiveFilter: (entity: any, filterName: any, filterValue: any) => {
set(
- produce((state) => {
+ produce((state: any) => {
const updatedFilters = state.filters[entity].activeFilters[filterName].filter(
- (value) => value !== filterValue
+ (value: any) => value !== filterValue
)
if (updatedFilters.length === 0) {
@@ -129,18 +132,18 @@ const createFiltersSlice = (set, get) => ({
)
},
- setSearchTerm: (entity, searchTerm) =>
+ setSearchTerm: (entity: any, searchTerm: any) =>
set(
- produce((state) => {
+ produce((state: any) => {
state.filters[entity].search = searchTerm
}),
false,
`filters.setSearchTerm.${entity}`
),
- setFiltersFromURL: (activeFilters, searchTerm) =>
+ setFiltersFromURL: (activeFilters: any, searchTerm: any) =>
set(
- produce((state) => {
+ produce((state: any) => {
if (activeFilters) {
state.filters[ISSUEMATCHES].activeFilters = activeFilters[ISSUEMATCHES] || {}
state.filters[SERVICES].activeFilters = activeFilters[SERVICES] || {}
@@ -157,7 +160,7 @@ const createFiltersSlice = (set, get) => ({
`filters.setFiltersFromURL`
),
- syncFiltersWithURL: (issueFilters, serviceFilters, componentFilters) => {
+ syncFiltersWithURL: (issueFilters: any, serviceFilters: any, componentFilters: any) => {
const encodedSearchTerm = btoa(
JSON.stringify({
[ISSUEMATCHES]: get().filters[ISSUEMATCHES].search,
diff --git a/apps/heureka/src/lib/slices/createGlobalsSlice.test.js b/apps/heureka/src/lib/slices/createGlobalsSlice.test.ts
similarity index 97%
rename from apps/heureka/src/lib/slices/createGlobalsSlice.test.js
rename to apps/heureka/src/lib/slices/createGlobalsSlice.test.ts
index bd9fafb84..244620d79 100644
--- a/apps/heureka/src/lib/slices/createGlobalsSlice.test.js
+++ b/apps/heureka/src/lib/slices/createGlobalsSlice.test.ts
@@ -9,10 +9,11 @@ import createGlobalsSlice from "./createGlobalsSlice"
import constants from "../../components/shared/constants"
describe("createGlobalsSlice", () => {
- let useStore
- let initialState
+ let useStore: any
+ let initialState: any
beforeEach(() => {
+ // @ts-expect-error TS(7006): Parameter 'set' implicitly has an 'any' type.
useStore = create((set, get) => ({
...createGlobalsSlice(set, get, { apiEndpoint: "https://api.example.com" }),
}))
diff --git a/apps/heureka/src/lib/slices/createGlobalsSlice.js b/apps/heureka/src/lib/slices/createGlobalsSlice.ts
similarity index 79%
rename from apps/heureka/src/lib/slices/createGlobalsSlice.js
rename to apps/heureka/src/lib/slices/createGlobalsSlice.ts
index be4dd6969..dc4cfdfb6 100644
--- a/apps/heureka/src/lib/slices/createGlobalsSlice.js
+++ b/apps/heureka/src/lib/slices/createGlobalsSlice.ts
@@ -5,7 +5,7 @@
import { produce } from "immer"
import constants from "../../components/shared/constants"
-
+// @ts-ignore
const createGlobalsSlice = (set, get, options) => ({
globals: {
embedded: options?.embedded === true || options?.embedded === "true", //Set to true if app is to be embedded in another existing app or page.
@@ -41,18 +41,18 @@ const createGlobalsSlice = (set, get, options) => ({
},
actions: {
- setQueryClientFnReady: (readiness) =>
+ setQueryClientFnReady: (readiness: any) =>
set(
- produce((state) => {
+ produce((state: any) => {
state.globals.queryClientFnReady = readiness
}),
false,
"globals/setQueryClientFnReady"
),
- setQueryOptions: (viewName, options) =>
+ setQueryOptions: (viewName: any, options: any) =>
set(
- produce((state) => {
+ produce((state: any) => {
state.globals.views[viewName].queryOptions = {
...state.globals.views[viewName].queryOptions,
...options,
@@ -61,53 +61,59 @@ const createGlobalsSlice = (set, get, options) => ({
false,
"globals/setQueryOptions"
),
- setEmbedded: (embedded) =>
- set((state) => ({ globals: { ...state.globals, embedded: embedded } }), false, "globals/setEmbedded"),
- setApiEndpoint: (apiEndpoint) =>
+ setEmbedded: (embedded: any) =>
+ set(
+ (state: any) => ({
+ globals: { ...state.globals, embedded: embedded },
+ }),
+ false,
+ "globals/setEmbedded"
+ ),
+ setApiEndpoint: (apiEndpoint: any) =>
set(
- (state) => ({
+ (state: any) => ({
globals: { ...state.globals, apiEndpoint: apiEndpoint },
}),
false,
"globals/setApiEndpoint"
),
- setActiveView: (activeView) =>
+ setActiveView: (activeView: any) =>
set(
- (state) => ({
+ (state: any) => ({
globals: { ...state.globals, activeView: activeView },
}),
false,
"globals/setActiveView"
),
- setShowPanel: (panel) =>
+ setShowPanel: (panel: any) =>
set(
- (state) => ({
+ (state: any) => ({
globals: { ...state.globals, showPanel: panel },
}),
false,
"globals/setShowPanel"
),
- setShowServiceDetail: (serviceId) =>
+ setShowServiceDetail: (serviceId: any) =>
set(
- (state) => ({
+ (state: any) => ({
globals: { ...state.globals, showServiceDetail: serviceId },
}),
false,
"globals/setShowServiceDetail"
),
- setShowIssueDetail: (issueName) =>
+ setShowIssueDetail: (issueName: any) =>
set(
- (state) => ({
+ (state: any) => ({
globals: { ...state.globals, showIssueDetail: issueName },
}),
false,
"globals/setShowIssueDetail"
),
// Helper function to set the service detail for deep linking
- setServiceDetail: (serviceId) =>
+ setServiceDetail: (serviceId: any) =>
set(
- produce((state) => {
+ produce((state: any) => {
state.globals.showPanel = constants.PANEL_SERVICE
state.globals.showServiceDetail = serviceId
}),
@@ -116,9 +122,9 @@ const createGlobalsSlice = (set, get, options) => ({
),
// Helper function to set the issue detail for deep linking
- setIssueDetail: (issueId) =>
+ setIssueDetail: (issueId: any) =>
set(
- produce((state) => {
+ produce((state: any) => {
state.globals.showPanel = constants.PANEL_ISSUE
state.globals.showIssueDetail = issueId
}),
@@ -127,7 +133,7 @@ const createGlobalsSlice = (set, get, options) => ({
),
// Sync details state with the URL
- syncDetailsWithURL: (serviceDetail, issueDetail, panelType) => {
+ syncDetailsWithURL: (serviceDetail: any, issueDetail: any, panelType: any) => {
if (panelType === undefined || panelType === null) {
return {
[constants.DETAILS_FOR]: panelType,
diff --git a/apps/heureka/src/lib/slices/createUserActivitySlice.js b/apps/heureka/src/lib/slices/createUserActivitySlice.ts
similarity index 78%
rename from apps/heureka/src/lib/slices/createUserActivitySlice.js
rename to apps/heureka/src/lib/slices/createUserActivitySlice.ts
index c28251ee9..b13fbed33 100644
--- a/apps/heureka/src/lib/slices/createUserActivitySlice.js
+++ b/apps/heureka/src/lib/slices/createUserActivitySlice.ts
@@ -3,14 +3,14 @@
* SPDX-License-Identifier: Apache-2.0
*/
-const createUserActivitySlice = (set) => ({
+const createUserActivitySlice = (set: any) => ({
userActivity: {
isActive: true,
actions: {
- setIsActive: (activity) => {
+ setIsActive: (activity: any) => {
set(
- (state) => ({
+ (state: any) => ({
userActivity: { ...state.userActivity, isActive: activity },
}),
false,
diff --git a/apps/heureka/src/lib/utils.js b/apps/heureka/src/lib/utils.ts
similarity index 93%
rename from apps/heureka/src/lib/utils.js
rename to apps/heureka/src/lib/utils.ts
index 0f566ea32..8b0f669f5 100644
--- a/apps/heureka/src/lib/utils.js
+++ b/apps/heureka/src/lib/utils.ts
@@ -4,7 +4,7 @@
*/
// Capitalize first char, underscores to spaces, camel case to spaces, all words except the first to lower case
-export const humanizeString = (value) => {
+export const humanizeString = (value: any) => {
if (!value) {
return value
}
diff --git a/apps/heureka/src/styles.js b/apps/heureka/src/styles.ts
similarity index 100%
rename from apps/heureka/src/styles.js
rename to apps/heureka/src/styles.ts
diff --git a/apps/heureka/src/types/index.d.ts b/apps/heureka/src/types/index.d.ts
new file mode 100644
index 000000000..5420e67c3
--- /dev/null
+++ b/apps/heureka/src/types/index.d.ts
@@ -0,0 +1,6 @@
+/*
+ * SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Juno contributors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+///
diff --git a/apps/heureka/tailwind.config.js b/apps/heureka/tailwind.config.ts
similarity index 100%
rename from apps/heureka/tailwind.config.js
rename to apps/heureka/tailwind.config.ts
diff --git a/apps/heureka/tsconfig.json b/apps/heureka/tsconfig.json
new file mode 100644
index 000000000..887668988
--- /dev/null
+++ b/apps/heureka/tsconfig.json
@@ -0,0 +1,21 @@
+{
+ "extends": "@cloudoperators/juno-config/typescript/base.json",
+ "compilerOptions": {
+ "target": "ES5",
+ "module": "ESNext",
+ "jsx": "react",
+ "strict": true,
+ "esModuleInterop": true,
+ "skipLibCheck": true,
+ "forceConsistentCasingInFileNames": true,
+ "outDir": "build",
+ "allowJs": true,
+ "resolveJsonModule": true,
+ "isolatedModules": true,
+ "noEmit": true,
+ "allowSyntheticDefaultImports": true,
+ "types": ["vitest/globals", "@testing-library/jest-dom", "@types/react"]
+ },
+ "include": ["./src/**/*.ts", "./types/**/*.ts", "./src/**/*.tsx", "vitest.setup.ts", "public/appProps.js"],
+ "exclude": ["node_modules", "build"]
+}
diff --git a/apps/heureka/turbo.json b/apps/heureka/turbo.json
index 097306e7c..9c298c300 100644
--- a/apps/heureka/turbo.json
+++ b/apps/heureka/turbo.json
@@ -21,6 +21,13 @@
"@cloudoperators/juno-messages-provider#build",
"@cloudoperators/juno-communicator#build"
]
+ },
+ "typecheck": {
+ "dependsOn": [
+ "@cloudoperators/juno-ui-components#build",
+ "@cloudoperators/juno-messages-provider#build",
+ "@cloudoperators/juno-communicator#build"
+ ]
}
}
}
diff --git a/apps/heureka/vite.config.ts b/apps/heureka/vite.config.ts
index 5e81710aa..03690f6e0 100644
--- a/apps/heureka/vite.config.ts
+++ b/apps/heureka/vite.config.ts
@@ -43,7 +43,7 @@ export default defineConfig(({ mode }) => {
outDir: "build",
lib: {
- entry: "src/index.js",
+ entry: "src/index.ts",
formats: ["es"],
fileName: (format) => `index.js`,
},