Skip to content

Commit d088df2

Browse files
committed
Hide metrics tab and url behind a flag
1 parent 026e414 commit d088df2

File tree

4 files changed

+39
-10
lines changed

4 files changed

+39
-10
lines changed

packages/manager/src/featureFlags.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ interface AclpLogsFlag extends BetaFeatureFlag {
134134
* This property indicates whether to show Custom HTTPS destination type
135135
*/
136136
customHttpsEnabled?: boolean;
137+
/**
138+
* This property indicates whether to show the "Metrics" tab on Logs Stream details page or not
139+
*/
140+
metricsEnabled?: boolean;
137141
/**
138142
* This property indicates whether the feature is new or not
139143
*/

packages/manager/src/features/Delivery/Streams/Stream/StreamLanding.tsx

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useParams } from '@tanstack/react-router';
22
import * as React from 'react';
3+
import { useMemo } from 'react';
34

45
import { DocumentTitleSegment } from 'src/components/DocumentTitle';
56
import {
@@ -11,25 +12,38 @@ import { SafeTabPanel } from 'src/components/Tabs/SafeTabPanel';
1112
import { TabPanels } from 'src/components/Tabs/TabPanels';
1213
import { Tabs } from 'src/components/Tabs/Tabs';
1314
import { TanStackTabLinkList } from 'src/components/Tabs/TanStackTabLinkList';
15+
import { useIsACLPLogsEnabled } from 'src/features/Delivery/deliveryUtils';
1416
import { StreamMetrics } from 'src/features/Delivery/Streams/Stream/StreamMetrics';
1517
import { StreamEdit } from 'src/features/Delivery/Streams/StreamForm/StreamEdit';
1618
import { useTabs } from 'src/hooks/useTabs';
1719

20+
import type { Tab } from 'src/hooks/useTabs';
21+
1822
export const StreamLanding = () => {
1923
const { streamId } = useParams({
2024
strict: false,
2125
});
26+
const { isACLPLogsMetricsEnabled } = useIsACLPLogsEnabled();
2227

23-
const { handleTabChange, tabIndex, tabs } = useTabs([
24-
{
25-
title: 'Summary',
26-
to: `/logs/delivery/streams/$streamId/summary`,
27-
},
28-
{
29-
title: 'Metrics',
30-
to: `/logs/delivery/streams/$streamId/metrics`,
31-
},
32-
]);
28+
const activeTabs = useMemo(() => {
29+
const result: Tab[] = [
30+
{
31+
title: 'Summary',
32+
to: `/logs/delivery/streams/$streamId/summary`,
33+
},
34+
];
35+
36+
if (isACLPLogsMetricsEnabled) {
37+
result.push({
38+
title: 'Metrics',
39+
to: `/logs/delivery/streams/$streamId/metrics`,
40+
});
41+
}
42+
43+
return result;
44+
}, [isACLPLogsMetricsEnabled]);
45+
46+
const { handleTabChange, tabIndex, tabs } = useTabs(activeTabs);
3347

3448
const landingHeaderProps: LandingHeaderProps = {
3549
breadcrumbProps: {

packages/manager/src/features/Delivery/deliveryUtils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const useIsACLPLogsEnabled = (): {
3939
isACLPLogsBeta: boolean;
4040
isACLPLogsCustomHttpsEnabled: boolean;
4141
isACLPLogsEnabled: boolean;
42+
isACLPLogsMetricsEnabled: boolean;
4243
isACLPLogsNew: boolean;
4344
} => {
4445
const { data: account } = useAccount();
@@ -55,6 +56,7 @@ export const useIsACLPLogsEnabled = (): {
5556
return {
5657
isACLPLogsBeta: !!flags.aclpLogs?.beta,
5758
isACLPLogsCustomHttpsEnabled: !!flags.aclpLogs?.customHttpsEnabled,
59+
isACLPLogsMetricsEnabled: !!flags.aclpLogs?.metricsEnabled,
5860
isACLPLogsNew: !!flags.aclpLogs?.new,
5961
isACLPLogsEnabled,
6062
};

packages/manager/src/routes/delivery/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ const streamSummaryRoute = createRoute({
9292
);
9393

9494
const streamMetricsRoute = createRoute({
95+
beforeLoad: ({ params, context }) => {
96+
if (!context?.flags?.aclpLogs?.metricsEnabled) {
97+
throw redirect({
98+
to: '/logs/delivery/streams/$streamId/summary',
99+
params: { streamId: params.streamId },
100+
replace: true,
101+
});
102+
}
103+
},
95104
getParentRoute: () => streamRoute,
96105
path: 'metrics',
97106
}).lazy(() =>

0 commit comments

Comments
 (0)