Skip to content

Commit 188ece2

Browse files
authored
chore(heureka): heureka old goes to ts (#777)
* chore(heureka): old heureka move to TS * chore(heureka): leftovers * chore(heureka): add changeset * chore(heureka): client types
1 parent 4834d12 commit 188ece2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+438
-274
lines changed

.changeset/wild-islands-accept.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudoperators/juno-app-heureka": patch
3+
---
4+
5+
Heureka move to TS

apps/heureka/eslint.config.mjs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,31 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import junoConfigs from "@cloudoperators/juno-config/eslint/juno.mjs"
6+
import junoConfigs from "@cloudoperators/juno-config/eslint/juno-typescript.mjs"
77

88
export default [
99
...junoConfigs,
1010
{
11-
files: ["**/*.js", "**/*.mjs", "**/*.jsx"],
11+
files: ["**/*.ts", "**/*.mjs", "**/*.tsx"],
1212
languageOptions: { sourceType: "module" },
1313
rules: {
14+
"@typescript-eslint/no-unsafe-assignment": "off",
15+
"@typescript-eslint/no-unsafe-call": "off",
16+
"@typescript-eslint/no-unsafe-argument": "off",
17+
"@typescript-eslint/no-unsafe-return": "off",
18+
"@typescript-eslint/no-unsafe-member-access": "off",
19+
"@typescript-eslint/no-floating-promises": "off",
20+
"@typescript-eslint/require-await": "off",
21+
"@typescript-eslint/unbound-method": "off",
22+
"@typescript-eslint/restrict-template-expressions": "off",
23+
"@typescript-eslint/no-unnecessary-type-assertion": "off",
24+
"@typescript-eslint/no-redundant-type-constituents": "off",
25+
"@typescript-eslint/no-misused-promises": "off",
26+
"@typescript-eslint/no-base-to-string": "off",
27+
"no-empty": "off",
28+
"no-unused-vars": "off",
29+
"prefer-const": "off",
30+
"no-fallthrough": "off",
1431
// disable for now, till we switch to TypeScript
1532
"react/prop-types": "off",
1633
},

apps/heureka/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
},
3535
"scripts": {
3636
"test": "vitest run",
37+
"typecheck": "tsc --project tsconfig.json --noEmit",
3738
"dev": "vite",
3839
"build": "vite build",
3940
"build:static": "vite build --mode static",

apps/heureka/src/App.test.jsx renamed to apps/heureka/src/App.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ describe("App", () => {
1515
render(<App id="123" />)
1616
})
1717
waitFor(() => (loginTitles = screen.queryAllByShadowText(/HEUREKA/i)))
18+
// @ts-expect-error TS(2454): Variable 'loginTitles' is used before being assign... Remove this comment to see the full error message
1819
expect(loginTitles.length).toBeGreaterThan(0)
1920
})
2021
})

apps/heureka/src/App.jsx renamed to apps/heureka/src/App.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function App(props = {}) {
2323
w-full
2424
`
2525

26-
const fallbackRender = ({ error }) => {
26+
const fallbackRender = ({ error }: any) => {
2727
return (
2828
<div className="w-1/2">
2929
<CodeBlock className={preErrorClasses} copy={false}>
@@ -39,6 +39,7 @@ function App(props = {}) {
3939
// global default options that apply to all queries
4040
queries: {
4141
// staleTime: Infinity, // if you wish to keep data from the keys until reload
42+
// @ts-ignore
4243
keepPreviousData: true, // nice when paginating
4344
refetchOnWindowFocus: false, // default: true
4445
},
@@ -50,6 +51,7 @@ function App(props = {}) {
5051
<MessagesProvider>
5152
<CustomAppShell>
5253
<ErrorBoundary fallbackRender={fallbackRender}>
54+
{/* @ts-expect-error TS(2322): Type '{ consumerId: any; }' is not assignable to t... Remove this comment to see the full error message */}
5355
<AsyncWorker consumerId={props.id} />
5456
<PanelManager />
5557
</ErrorBoundary>
@@ -59,8 +61,9 @@ function App(props = {}) {
5961
)
6062
}
6163

62-
const StyledApp = (props) => {
64+
const StyledApp = (props: any) => {
6365
return (
66+
// @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
6467
<AppShellProvider theme={`${props.theme ? props.theme : "theme-dark"}`}>
6568
{/* load styles inside the shadow dom */}
6669
<style>{styles.toString()}</style>

apps/heureka/src/components/CustomAppShell.jsx renamed to apps/heureka/src/components/CustomAppShell.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,34 @@ const VIEW_CONFIG = {
1818
Components: { label: "Images", icon: "autoAwesomeMotion", component: ComponentsView }, // Commented out to remove ComponentsView for MVP version
1919
}
2020

21-
const CustomAppShell = ({ children }) => {
21+
const CustomAppShell = ({ children }: any) => {
22+
// @ts-expect-error TS(2339): Property 'setActiveView' does not exist on type '() => void'. // @ts-expect-error
2223
const { setActiveView, setShowPanel } = useGlobalsActions()
2324
const activeView = useGlobalsActiveView()
2425
const embedded = useGlobalsEmbedded()
2526

26-
const handleNavItemChange = (item) => {
27+
const handleNavItemChange = (item: any) => {
2728
setActiveView(item)
2829
setShowPanel(constants.PANEL_NONE) // Hide the panel when switching
2930
}
3031

3132
// Create topNavigation with NavItems based on VIEW_CONFIG
3233
const topNavigation = (
34+
// @ts-ignore
3335
<TopNavigation activeItem={activeView} onActiveItemChange={handleNavItemChange}>
3436
{Object.entries(VIEW_CONFIG).map(([key, nav]) => (
37+
// @ts-ignore
3538
<TopNavigationItem key={key} icon={nav.icon} value={key} label={nav.label} />
3639
))}
3740
</TopNavigation>
3841
)
3942

4043
// Get the component to render based on activeView
44+
// @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
4145
const ActiveComponent = VIEW_CONFIG[activeView]?.component
4246

4347
return (
48+
// @ts-ignore
4449
<AppShell pageHeader={<PageHeader heading="Heureka" />} topNavigation={topNavigation} embedded={embedded}>
4550
<Container py px>
4651
{ActiveComponent && <ActiveComponent />}

apps/heureka/src/components/StoreProvider.jsx

Lines changed: 0 additions & 99 deletions
This file was deleted.

apps/heureka/src/components/StoreProvider.test.jsx renamed to apps/heureka/src/components/StoreProvider.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe("createGlobalsSlice", () => {
1212
embedded: "false",
1313
}
1414

15-
const wrapper = ({ children }) => <StoreProvider options={mockOptions}>{children}</StoreProvider>
15+
const wrapper = ({ children }: any) => <StoreProvider options={mockOptions}>{children}</StoreProvider>
1616

1717
it("should initialize with correct default values", () => {
1818
const { result } = renderHook(
@@ -35,6 +35,7 @@ describe("createGlobalsSlice", () => {
3535
{ wrapper }
3636
)
3737
act(() => {
38+
// @ts-ignore
3839
result.current.actions.setEmbedded(true)
3940
})
4041

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import React, { createContext, useContext } from "react"
7+
import { createStore, useStore } from "zustand"
8+
import { devtools } from "zustand/middleware"
9+
10+
import createFiltersSlice from "../lib/slices/createFiltersSlice"
11+
import createAuthDataSlice from "../lib/slices/createAuthDataSlice"
12+
import createGlobalsSlice from "../lib/slices/createGlobalsSlice"
13+
import createUserActivitySlice from "../lib/slices/createUserActivitySlice"
14+
15+
// Entity constants
16+
const ISSUEMATCHES = "IssueMatches"
17+
const SERVICES = "Services"
18+
const COMPONENTS = "Components"
19+
20+
// @ts-expect-error TS(2554): Expected 1 arguments, but got 0.
21+
const StoreContext = createContext()
22+
23+
export const StoreProvider = ({ options, children }: any) => {
24+
return (
25+
<StoreContext.Provider
26+
value={createStore(
27+
devtools((set, get) => ({
28+
...createGlobalsSlice(set, get, options),
29+
...createAuthDataSlice(set, get),
30+
// @ts-expect-error TS(2554): Expected 1 arguments, but got 2.
31+
...createUserActivitySlice(set, get),
32+
...createFiltersSlice(set, get),
33+
}))
34+
)}
35+
>
36+
{children}
37+
</StoreContext.Provider>
38+
)
39+
}
40+
// @ts-ignore
41+
const useAppStore = (selector: any) => useStore(useContext(StoreContext), selector)
42+
43+
// Globals exports
44+
export const useGlobalsEmbedded = () => useAppStore((state: any) => state.globals.embedded)
45+
export const useGlobalsQueryClientFnReady = () => useAppStore((state: any) => state.globals.queryClientFnReady)
46+
export const useGlobalsActiveView = () => useAppStore((state: any) => state.globals.activeView)
47+
export const useGlobalsQueryOptions = (viewName: any) =>
48+
useAppStore((state: any) => state.globals.views[viewName].queryOptions)
49+
export const useGlobalsApiEndpoint = () => useAppStore((state: any) => state.globals.apiEndpoint)
50+
export const useGlobalsShowPanel = () => useAppStore((state: any) => state.globals.showPanel)
51+
export const useGlobalsShowServiceDetail = () => useAppStore((state: any) => state.globals.showServiceDetail)
52+
export const useGlobalsShowIssueDetail = () => useAppStore((state: any) => state.globals.showIssueDetail)
53+
export const useGlobalsActions = () => useAppStore((state: any) => state.globals.actions)
54+
55+
// AUTH exports
56+
export const useAuthData = () => useAppStore((state: any) => state.auth.data)
57+
export const useAuthIsProcessing = () => useAppStore((state: any) => state.auth.isProcessing)
58+
export const useAuthLoggedIn = () => useAppStore((state: any) => state.auth.loggedIn)
59+
export const useAuthError = () => useAppStore((state: any) => state.auth.error)
60+
export const useAuthLastAction = () => useAppStore((state: any) => state.auth.lastAction)
61+
export const useAuthAppLoaded = () => useAppStore((state: any) => state.auth.appLoaded)
62+
export const useAuthAppIsLoading = () => useAppStore((state: any) => state.auth.appIsLoading)
63+
export const useAuthActions = () => useAppStore((state: any) => state.auth.actions)
64+
65+
// UserActivity exports
66+
export const useUserIsActive = () => useAppStore((state: any) => state.userActivity.isActive)
67+
68+
export const useUserActivityActions = () => useAppStore((state: any) => state.userActivity.actions)
69+
70+
// Filter exports for Issues
71+
export const useIssueMatchesFilterLabels = () => useAppStore((state: any) => state.filters[ISSUEMATCHES].labels)
72+
export const useIssueMatchesActiveFilters = () => useAppStore((state: any) => state.filters[ISSUEMATCHES].activeFilters)
73+
export const useIssueMatchesSearchTerm = () => useAppStore((state: any) => state.filters[ISSUEMATCHES].search)
74+
export const useIssueMatchesFilterLabelValues = () =>
75+
useAppStore((state: any) => state.filters[ISSUEMATCHES].filterLabelValues)
76+
export const useIssueMatchesPredefinedFilters = () =>
77+
useAppStore((state: any) => state.filters[ISSUEMATCHES].predefinedFilters)
78+
export const useIssueMatchesActivePredefinedFilter = () =>
79+
useAppStore((state: any) => state.filters[ISSUEMATCHES].activePredefinedFilter)
80+
81+
// Filter exports for Services
82+
export const useServiceFilterLabels = () => useAppStore((state: any) => state.filters[SERVICES].labels)
83+
export const useServiceActiveFilters = () => useAppStore((state: any) => state.filters[SERVICES].activeFilters)
84+
export const useServiceSearchTerm = () => useAppStore((state: any) => state.filters[SERVICES].search)
85+
export const useServiceFilterLabelValues = () => useAppStore((state: any) => state.filters[SERVICES].filterLabelValues)
86+
export const useServicePredefinedFilters = () => useAppStore((state: any) => state.filters[SERVICES].predefinedFilters)
87+
export const useServiceActivePredefinedFilter = () =>
88+
useAppStore((state: any) => state.filters[SERVICES].activePredefinedFilter)
89+
90+
// Filter exports for Components
91+
export const useComponentFilterLabels = () => useAppStore((state: any) => state.filters[COMPONENTS].labels)
92+
export const useComponentActiveFilters = () => useAppStore((state: any) => state.filters[COMPONENTS].activeFilters)
93+
export const useComponentSearchTerm = () => useAppStore((state: any) => state.filters[COMPONENTS].search)
94+
export const useComponentFilterLabelValues = () =>
95+
useAppStore((state: any) => state.filters[COMPONENTS].filterLabelValues)
96+
export const useComponentPredefinedFilters = () =>
97+
useAppStore((state: any) => state.filters[COMPONENTS].predefinedFilters)
98+
export const useComponentActivePredefinedFilter = () =>
99+
useAppStore((state: any) => state.filters[COMPONENTS].activePredefinedFilter)
100+
101+
// Filter actions
102+
export const useFilterActions = () => useAppStore((state: any) => state.filters.actions)
103+
104+
export default StoreProvider

apps/heureka/src/components/components/ComponentsList.jsx renamed to apps/heureka/src/components/components/ComponentsList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import HintNotFound from "../shared/HintNotFound"
1818
import HintLoading from "../shared/HintLoading"
1919
import ComponentsListItem from "./ComponentsListItem"
2020

21-
const ComponentsList = ({ items, isLoading }) => {
21+
const ComponentsList = ({ items, isLoading }: any) => {
2222
return (
2323
<DataGrid minContentColumns={[2, 3]} columns={4}>
2424
<DataGridRow>
@@ -52,7 +52,7 @@ const ComponentsList = ({ items, isLoading }) => {
5252
<>
5353
{items?.length > 0 ? (
5454
<>
55-
{items.map((item, index) => (
55+
{items.map((item: any, index: any) => (
5656
<ComponentsListItem key={index} item={item}></ComponentsListItem>
5757
))}
5858
</>

apps/heureka/src/components/components/ComponentsListItem.jsx renamed to apps/heureka/src/components/components/ComponentsListItem.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
import React from "react"
77
import { DataGridRow, DataGridCell } from "@cloudoperators/juno-ui-components"
88

9-
const sumTotalInstances = (versions) => {
9+
const sumTotalInstances = (versions: any) => {
1010
let sum = 0
11-
versions.forEach((v) => (sum += v?.node?.componentInstances?.totalCount))
11+
versions.forEach((v: any) => (sum += v?.node?.componentInstances?.totalCount))
1212
return sum
1313
}
14-
const ComponentsListItem = ({ item }) => {
14+
const ComponentsListItem = ({ item }: any) => {
1515
return (
1616
<DataGridRow>
1717
<DataGridCell>{item?.node?.ccrn}</DataGridCell>

0 commit comments

Comments
 (0)