Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/nine-cougars-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@cloudoperators/juno-app-doop": patch
"@cloudoperators/juno-app-heureka": patch
"@cloudoperators/juno-app-supernova": patch
---

fix(heureka): correct numeric searchTerm URL param to string in search box
9 changes: 9 additions & 0 deletions apps/doop/src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { z } from "zod"

/** Zod schema for optional URL search params that may be parsed as numbers by TanStack Router. */
export const optionalStringSchema = z.preprocess(
(val) =>
val === undefined || val === null ? undefined : typeof val === "string" ? val : String(val as number | boolean),
z.string().optional()
)

export const parseError = (error: any) => {
if (!error || (typeof error === "object" && Object.keys(error).length === 0))
return "An error occurred. There is no further information"
Expand Down
4 changes: 2 additions & 2 deletions apps/doop/src/routes/violations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import {
} from "../components/StoreProvider"
import { parseInitialFilters } from "../lib/store/createFiltersSlice"
import { isObjectWithKeys } from "../lib/helpers"
import { filterSearchParamsByPrefix } from "../lib/helpers"
import { filterSearchParamsByPrefix, optionalStringSchema } from "../lib/helpers"

const filterValueSchema = z.union([z.string(), z.array(z.string()), z.undefined()])

const searchSchema = z
.object({
searchTerm: z.string().optional(),
searchTerm: optionalStringSchema,
violationGroup: z.string().optional(),
})
.catchall(filterValueSchema)
Expand Down
4 changes: 2 additions & 2 deletions apps/heureka/src/routes/services/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import { SELECTED_FILTER_PREFIX } from "../../constants"
import { fetchServices } from "../../api/fetchServices"
import { fetchServicesFilters } from "../../api/fetchServicesFilters"
import { extractFilterSettingsFromSearchParams } from "../../components/Services/utils"
import { filterSearchParamsByPrefix } from "../../utils"
import { filterSearchParamsByPrefix, optionalStringSchema } from "../../utils"

const filterValueSchema = z.union([z.string(), z.array(z.string()), z.undefined()])

const servicesSearchSchema = z
.object({
service: z.string().optional(),
searchTerm: z.string().optional(),
searchTerm: optionalStringSchema,
})
.catchall(filterValueSchema)

Expand Down
4 changes: 2 additions & 2 deletions apps/heureka/src/routes/vulnerabilities/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import { SELECTED_FILTER_PREFIX } from "../../constants"
import { fetchVulnerabilities } from "../../api/fetchVulnerabilities"
import { fetchVulnerabilityFilters } from "../../api/fetchVulnerabilityFilters"
import { extractFilterSettingsFromSearchParams } from "../../components/Vulnerabilities/utils"
import { filterSearchParamsByPrefix } from "../../utils"
import { filterSearchParamsByPrefix, optionalStringSchema } from "../../utils"

const filterValueSchema = z.union([z.string(), z.array(z.string()), z.undefined()])

const vulnerabilitiesSearchSchema = z
.object({
vulnerability: z.string().optional(),
searchTerm: z.preprocess((val) => (typeof val === "number" ? val.toString() : val), z.string().optional()),
searchTerm: optionalStringSchema,
})
.catchall(filterValueSchema)

Expand Down
8 changes: 8 additions & 0 deletions apps/heureka/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@

import { useState, useRef, useEffect, Dispatch, SetStateAction } from "react"
import { KnownIcons } from "@cloudoperators/juno-ui-components"
import { z } from "zod"

/** Zod schema for optional URL search params that may be parsed as numbers by TanStack Router. */
export const optionalStringSchema = z.preprocess(
(val) =>
val === undefined || val === null ? undefined : typeof val === "string" ? val : String(val as number | boolean),
z.string().optional()
)

export const capitalizeFirstLetter = (str: string): string => {
return str.charAt(0).toUpperCase() + str.slice(1)
Expand Down
9 changes: 9 additions & 0 deletions apps/supernova/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { z } from "zod"

/** Zod schema for optional URL search params that may be parsed as numbers by TanStack Router. */
export const optionalStringSchema = z.preprocess(
(val) =>
val === undefined || val === null ? undefined : typeof val === "string" ? val : String(val as number | boolean),
z.string().optional()
)

import { AlertItem, SeverityCounts } from "./createAlertsSlice"

export const severityToSemanticName = (severity: any) => {
Expand Down
5 changes: 2 additions & 3 deletions apps/supernova/src/routes/alerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ import AlertsTab from "../components/alerts/AlertsTab"
import { ACTIVE_FILTERS_PREFIX, PAUSED_FILTERS_PREFIX } from "../constants"
import { convertUrlStateToAppState, getFiltersForUrl } from "../lib/urlStateUtils"
import { useGlobalsActions, useFilterActions, useGlobalsInitialFiltersApplied } from "../components/StoreProvider"
import { isObjectWithKeys } from "../lib/utils"
import { filterSearchParamsByPrefix } from "../lib/utils"
import { isObjectWithKeys, filterSearchParamsByPrefix, optionalStringSchema } from "../lib/utils"

const filterValueSchema = z.union([z.string(), z.array(z.string()), z.undefined()])

const searchSchema = z
.object({
searchTerm: z.string().optional(),
searchTerm: optionalStringSchema,
showDetailsFor: z.string().optional(),
predefinedFilter: z.string().optional(),
})
Expand Down
Loading