Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix: use pathname to get channel id (#8298)

Yunus M4f7d84aa374b
diff --git a/frontend/src/AppRoutes/pageComponents.ts b/frontend/src/AppRoutes/pageComponents.ts
index 3d12cc998e..c2833547f4 100644
--- a/frontend/src/AppRoutes/pageComponents.ts
+++ b/frontend/src/AppRoutes/pageComponents.ts
@@ -131,10 +131,6 @@ export const CreateAlertChannelAlerts = Loadable(
() => import(/* webpackChunkName: "Create Channels" */ 'pages/Settings'),
);
-export const EditAlertChannelsAlerts = Loadable(
- () => import(/* webpackChunkName: "Edit Channels" */ 'pages/Settings'),
-);
-
export const AllAlertChannels = Loadable(
() => import(/* webpackChunkName: "All Channels" */ 'pages/Settings'),
);
diff --git a/frontend/src/AppRoutes/routes.ts b/frontend/src/AppRoutes/routes.ts
index a126816443..d403a3b19d 100644
--- a/frontend/src/AppRoutes/routes.ts
+++ b/frontend/src/AppRoutes/routes.ts
@@ -12,7 +12,6 @@ import {
CreateNewAlerts,
DashboardPage,
DashboardWidget,
- EditAlertChannelsAlerts,
EditRulesPage,
ErrorDetails,
Home,
@@ -253,13 +252,6 @@ const routes: AppRoutes[] = [
isPrivate: true,
key: 'CHANNELS_NEW',
},
- {
- path: ROUTES.CHANNELS_EDIT,
- exact: true,
- component: EditAlertChannelsAlerts,
- isPrivate: true,
- key: 'CHANNELS_EDIT',
- },
{
path: ROUTES.ALL_CHANNELS,
exact: true,
diff --git a/frontend/src/constants/routes.ts b/frontend/src/constants/routes.ts
index fbb53d93ea..7dc5b326fc 100644
--- a/frontend/src/constants/routes.ts
+++ b/frontend/src/constants/routes.ts
@@ -29,7 +29,7 @@ const ROUTES = {
ALERT_OVERVIEW: '/alerts/overview',
ALL_CHANNELS: '/settings/channels',
CHANNELS_NEW: '/settings/channels/new',
- CHANNELS_EDIT: '/settings/channels/edit/:id',
+ CHANNELS_EDIT: '/settings/channels/edit/:channelId',
ALL_ERROR: '/exceptions',
ERROR_DETAIL: '/error-detail',
VERSION: '/status',
diff --git a/frontend/src/container/AllAlertChannels/AlertChannels.tsx b/frontend/src/container/AllAlertChannels/AlertChannels.tsx
index cc78e0da3a..319567874e 100644
--- a/frontend/src/container/AllAlertChannels/AlertChannels.tsx
+++ b/frontend/src/container/AllAlertChannels/AlertChannels.tsx
@@ -23,7 +23,7 @@ function AlertChannels({ allChannels }: AlertChannelsProps): JSX.Element {
const onClickEditHandler = useCallback((id: string) => {
history.push(
generatePath(ROUTES.CHANNELS_EDIT, {
- id,
+ channelId: id,
}),
);
}, []);
diff --git a/frontend/src/container/FormAlertChannels/index.tsx b/frontend/src/container/FormAlertChannels/index.tsx
index 1457966897..41f44f85e1 100644
--- a/frontend/src/container/FormAlertChannels/index.tsx
+++ b/frontend/src/container/FormAlertChannels/index.tsx
@@ -149,7 +149,7 @@ function FormAlertChannels({
</Button>
<Button
onClick={(): void => {
- history.replace(ROUTES.SETTINGS);
+ history.replace(ROUTES.ALL_CHANNELS);
}}
>
{t('button_return')}
diff --git a/frontend/src/pages/AlertList/AlertList.styles.scss b/frontend/src/pages/AlertList/AlertList.styles.scss
index 57e437b435..8cacccd646 100644
--- a/frontend/src/pages/AlertList/AlertList.styles.scss
+++ b/frontend/src/pages/AlertList/AlertList.styles.scss
@@ -4,7 +4,6 @@
}
.ant-tabs-content-holder {
- padding-left: 16px;
- padding-right: 16px;
+ padding: 8px;
}
}
diff --git a/frontend/src/pages/ChannelsEdit/ChannelsEdit.styles.scss b/frontend/src/pages/ChannelsEdit/ChannelsEdit.styles.scss
index 0411842bdc..25ed5659e7 100644
--- a/frontend/src/pages/ChannelsEdit/ChannelsEdit.styles.scss
+++ b/frontend/src/pages/ChannelsEdit/ChannelsEdit.styles.scss
@@ -1,6 +1,5 @@
.edit-alert-channels-container {
- width: 90%;
- margin: 12px auto;
+ margin: 12px;
border: 1px solid var(--Slate-500, #161922);
background: var(--Ink-400, #121317);
diff --git a/frontend/src/pages/ChannelsEdit/index.tsx b/frontend/src/pages/ChannelsEdit/index.tsx
index 5b8a95c756..814792474e 100644
--- a/frontend/src/pages/ChannelsEdit/index.tsx
+++ b/frontend/src/pages/ChannelsEdit/index.tsx
@@ -15,23 +15,27 @@ import {
import EditAlertChannels from 'container/EditAlertChannels';
import { useTranslation } from 'react-i18next';
import { useQuery } from 'react-query';
-import { useParams } from 'react-router-dom';
import { SuccessResponseV2 } from 'types/api';
import { Channels } from 'types/api/channels/getAll';
import APIError from 'types/api/error';
function ChannelsEdit(): JSX.Element {
- const { id } = useParams<Params>();
const { t } = useTranslation();
+ // Extract channelId from URL pathname since useParams doesn't work in nested routing
+ const { pathname } = window.location;
+ const channelIdMatch = pathname.match(/\/settings\/channels\/edit\/([^/]+)/);
+ const channelId = channelIdMatch ? channelIdMatch[1] : undefined;
+
const { isFetching, isError, data, error } = useQuery<
SuccessResponseV2<Channels>,
APIError
- >(['getChannel', id], {
+ >(['getChannel', channelId], {
queryFn: () =>
get({
- id,
+ id: channelId || '',
}),
+ enabled: !!channelId,
});
if (isError) {
@@ -144,8 +148,5 @@ function ChannelsEdit(): JSX.Element {
</div>
);
}
-interface Params {
- id: string;
-}
export default ChannelsEdit;
diff --git a/frontend/src/pages/Settings/Settings.tsx b/frontend/src/pages/Settings/Settings.tsx
index 1f7f7c803b..4117e99554 100644
--- a/frontend/src/pages/Settings/Settings.tsx
+++ b/frontend/src/pages/Settings/Settings.tsx
@@ -217,6 +217,13 @@ function SettingsPage(): JSX.Element {
return true;
}
+ if (
+ pathname.startsWith(ROUTES.CHANNELS_EDIT) &&
+ key === ROUTES.ALL_CHANNELS
+ ) {
+ return true;
+ }
+
return pathname === key;
};