Skip to content

Commit 9f8f7be

Browse files
new: STORIF-294 - Condition for showing Bucket Metrcis tab updated. (#13456)
* new: STORIF-294 - Condition for showing Bucket Metrcis tab updated. * Added changeset: New condition for displaying bucket metrics tab
1 parent b1c1b74 commit 9f8f7be

2 files changed

Lines changed: 29 additions & 8 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Added
3+
---
4+
5+
New condition for displaying bucket metrics tab ([#13456](https://github.com/linode/manager/pull/13456))

packages/manager/src/features/ObjectStorage/BucketDetail/index.tsx

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useRegionQuery } from '@linode/queries';
12
import { BetaChip, CircleProgress, ErrorState } from '@linode/ui';
23
import { useParams } from '@tanstack/react-router';
34
import * as React from 'react';
@@ -40,6 +41,7 @@ const BucketMetrics = React.lazy(() =>
4041

4142
const BUCKET_DETAILS_URL = '/object-storage/buckets/$clusterId/$bucketName';
4243
const ENDPOINT_TYPES_WITH_NO_METRICS_SUPPORT = ['E0', 'E1'];
44+
const OBJECT_STORAGE_METRICS_KEY = 'Object Storage';
4345

4446
export const BucketDetailLanding = React.memo(() => {
4547
const { bucketName, clusterId } = useParams({
@@ -52,17 +54,36 @@ export const BucketDetailLanding = React.memo(() => {
5254

5355
const {
5456
data: bucketsData,
55-
isLoading,
57+
isLoading: bucketsLoading,
5658
error,
5759
isPending,
5860
} = useObjectStorageBuckets();
5961

6062
const bucket = bucketsData?.buckets.find(({ label }) => label === bucketName);
6163

64+
const {
65+
data: region,
66+
isLoading: regionLoading,
67+
error: regionError,
68+
} = useRegionQuery(bucket?.region || '');
69+
6270
const { endpoint_type } = bucket ?? {};
6371

6472
const isGen2Endpoint = endpoint_type === 'E2' || endpoint_type === 'E3';
6573

74+
const regionSupportsMetrics = region?.monitors?.metrics?.includes(
75+
OBJECT_STORAGE_METRICS_KEY
76+
);
77+
78+
const isBucketMetricsTabHidden =
79+
!endpoint_type ||
80+
ENDPOINT_TYPES_WITH_NO_METRICS_SUPPORT.includes(endpoint_type) ||
81+
aclpServiceError ||
82+
!aclpServices?.objectstorage?.metrics?.enabled ||
83+
!objectStorageContextualMetrics ||
84+
!regionSupportsMetrics ||
85+
!!regionError;
86+
6687
const { handleTabChange, tabIndex, tabs, getTabIndex } = useTabs([
6788
{
6889
title: 'Objects',
@@ -80,17 +101,12 @@ export const BucketDetailLanding = React.memo(() => {
80101
{
81102
title: 'Metrics',
82103
to: `${BUCKET_DETAILS_URL}/metrics`,
83-
hide:
84-
!endpoint_type ||
85-
ENDPOINT_TYPES_WITH_NO_METRICS_SUPPORT.includes(endpoint_type) ||
86-
aclpServiceError ||
87-
!aclpServices?.objectstorage?.metrics?.enabled ||
88-
!objectStorageContextualMetrics,
104+
hide: isBucketMetricsTabHidden,
89105
chip: aclpServices?.objectstorage?.metrics?.beta ? <BetaChip /> : null,
90106
},
91107
]);
92108

93-
if (isPending || isLoading || aclServiceLoading) {
109+
if (isPending || bucketsLoading || regionLoading || aclServiceLoading) {
94110
return <CircleProgress />;
95111
}
96112

0 commit comments

Comments
 (0)