Skip to content

Commit a2f12be

Browse files
committed
Fix array query params serializing
1 parent 0262982 commit a2f12be

File tree

8 files changed

+46
-7
lines changed

8 files changed

+46
-7
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- run: npm ci
3030

3131
- env:
32-
GITHUB_TOKEN: ${{ secrets.CONTENTS_WRITE_PAT }}
32+
GITHUB_TOKEN: ${{ secrets.CONTENTS_WRITE_PAT }} # TODO: fix
3333
run: npm run build:prod:${{ inputs.platform }}
3434

3535
- name: Get artifact name

src/components/Agentic/IncidentTemplate/MCPServerDialog/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ export const MCPServerDialog = ({
166166
onClose();
167167
};
168168

169-
const title = serverData?.uid ? "Set MCP Server" : "Add MCP Server";
169+
const title = serverData?.uid
170+
? `Edit ${serverData.name} MCP Server`
171+
: "Add MCP Server";
170172

171173
return (
172174
<Dialog title={title} onClose={handleDialogClose}>

src/components/Agentic/IncidentTemplate/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ export const IncidentTemplate = () => {
170170
}
171171
}, [mcpServers]);
172172

173+
const mcpServerToDelete = mcpServers?.mcps.find(
174+
(x) => x.uid === mcpServerIdToDelete
175+
);
176+
173177
return (
174178
<s.Container>
175179
<s.Header>
@@ -211,7 +215,7 @@ export const IncidentTemplate = () => {
211215
{mcpServerIdToDelete && (
212216
<s.StyledOverlay>
213217
<CancelConfirmation
214-
header={"Delete MCP server"}
218+
header={`Delete ${mcpServerToDelete?.name ?? " "}MCP server`}
215219
description={"Are you sure you want to delete this MCP server?"}
216220
onClose={handleDeleteMCPServerDialogClose}
217221
onConfirm={handleDeleteMCPServerDialogConfirm}

src/redux/services/auth.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
2+
import { serializeParams } from "./serializeParams";
23

34
export const authApi = createApi({
45
reducerPath: "authApi",
5-
baseQuery: fetchBaseQuery({ baseUrl: "/auth/", credentials: "same-origin" }),
6+
baseQuery: fetchBaseQuery({
7+
baseUrl: "/auth/",
8+
credentials: "same-origin",
9+
paramsSerializer: serializeParams
10+
}),
611
endpoints: (builder) => ({
712
logout: builder.mutation<void, void>({
813
query: () => ({

src/redux/services/digma.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
22
import { isString } from "../../typeGuards/isString";
3+
import { serializeParams } from "./serializeParams";
34
import type {
45
AddMCPServerPayload,
56
AgenticInvestigatePayload,
@@ -137,7 +138,8 @@ export const digmaApi = createApi({
137138
baseUrl: isString(window.digmaApiProxyPrefix)
138139
? window.digmaApiProxyPrefix
139140
: "/api/",
140-
credentials: "same-origin"
141+
credentials: "same-origin",
142+
paramsSerializer: serializeParams
141143
}),
142144
endpoints: (builder) => ({
143145
getAbout: builder.query<GetAboutResponse, void>({

src/redux/services/digmaEmpty.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
22
import { isString } from "../../typeGuards/isString";
3+
import { serializeParams } from "./serializeParams";
34

45
export const digmaEmptyApi = createApi({
56
reducerPath: "digmaApi",
67
baseQuery: fetchBaseQuery({
78
baseUrl: isString(window.digmaApiProxyPrefix)
89
? window.digmaApiProxyPrefix
910
: "/api/",
10-
credentials: "same-origin"
11+
credentials: "same-origin",
12+
paramsSerializer: serializeParams
1113
}),
1214
endpoints: () => ({})
1315
});

src/redux/services/plugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
2+
import { serializeParams } from "./serializeParams";
23

34
export const pluginApi = createApi({
45
reducerPath: "pluginApi",
56
baseQuery: fetchBaseQuery({
67
baseUrl: "/plugin-api",
7-
credentials: "same-origin"
8+
credentials: "same-origin",
9+
paramsSerializer: serializeParams
810
}),
911
endpoints: () => ({})
1012
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Serialize array params as duplicated params
2+
export const serializeParams = (
3+
params: Record<string, string | number | boolean | null | undefined>
4+
) => {
5+
const searchParams = new URLSearchParams();
6+
7+
Object.entries(params).forEach(([key, value]) => {
8+
if (value === undefined || value === null) {
9+
return;
10+
}
11+
12+
if (Array.isArray(value)) {
13+
value.forEach((item) => {
14+
searchParams.append(key, String(item));
15+
});
16+
} else {
17+
searchParams.append(key, String(value));
18+
}
19+
});
20+
21+
return searchParams.toString();
22+
};

0 commit comments

Comments
 (0)