Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FE: Escape cluster name in API #113

Merged
merged 4 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 14 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"fetch-mock": "^9.11.0",
"jest": "^29.4.3",
"jest-watch-typeahead": "^2.2.2",
"json-schema-faker": "^0.5.0-rcv.44",
"json-schema-faker": "^0.5.5",
"jsonpath-plus": "^7.2.0",
"lodash": "^4.17.21",
"lossless-json": "^2.0.8",
Expand Down Expand Up @@ -108,5 +108,18 @@
"engines": {
"node": "v18.17.1",
"pnpm": "^8.6.12"
},
"pnpm": {
Mgrdich marked this conversation as resolved.
Show resolved Hide resolved
"overrides": {
"postcss@<8.4.31": ">=8.4.31",
"axios@>=0.8.1 <1.6.0": ">=1.6.0",
"@adobe/css-tools@<4.3.1": ">=4.3.1",
"@babel/traverse@<7.23.2": ">=7.23.2",
"@adobe/css-tools@<4.3.2": ">=4.3.2",
"semver@>=7.0.0 <7.5.2": ">=7.5.2",
"vite@>=4.0.0 <=4.5.1": ">=4.5.2",
"json5@>=2.0.0 <2.2.2": ">=2.2.2",
"follow-redirects@<1.15.4": ">=1.15.4"
}
}
}
10 changes: 9 additions & 1 deletion frontend/src/lib/hooks/useAppParams.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { Params, useParams } from 'react-router-dom';
import { ClusterNameRoute } from 'lib/paths';

export default function useAppParams<
T extends { [K in keyof Params]?: string }
>() {
return useParams<T>() as T;
const params = useParams<T>() as T;

const hasClusterName = (params: T): params is T & ClusterNameRoute => typeof params.clusterName !== "undefined"
if (hasClusterName(params)) {
params.clusterName = decodeURIComponent(params.clusterName)
}

return params
}
2 changes: 1 addition & 1 deletion frontend/src/lib/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const accessErrorPage = '/403';

export const clusterPath = (
clusterName: ClusterName = RouteParams.clusterName
) => `/ui/clusters/${clusterName}`;
) => `/ui/clusters/${clusterName === RouteParams.clusterName ? clusterName : encodeURIComponent(clusterName)}`;

export type ClusterNameRoute = { clusterName: ClusterName };

Expand Down
Loading