|
| 1 | +import {DisplayPulse} from '@gravity-ui/icons'; |
1 | 2 | import {Button, Flex, HelpMark, Icon, Label} from '@gravity-ui/uikit'; |
2 | 3 |
|
3 | 4 | import {EntityStatus} from '../../../../components/EntityStatus/EntityStatus'; |
4 | 5 | import {LoaderWrapper} from '../../../../components/LoaderWrapper/LoaderWrapper'; |
5 | 6 | import {QueriesActivityBar} from '../../../../components/QueriesActivityBar/QueriesActivityBar'; |
6 | 7 | import {useDatabasesAvailable} from '../../../../store/reducers/capabilities/hooks'; |
7 | 8 | import {overviewApi} from '../../../../store/reducers/overview/overview'; |
8 | | -import {TENANT_METRICS_TABS_IDS} from '../../../../store/reducers/tenant/constants'; |
9 | | -import {tenantApi} from '../../../../store/reducers/tenant/tenant'; |
| 9 | +import { |
| 10 | + TENANT_DIAGNOSTICS_TABS_IDS, |
| 11 | + TENANT_METRICS_TABS_IDS, |
| 12 | + TENANT_PAGES_IDS, |
| 13 | +} from '../../../../store/reducers/tenant/constants'; |
| 14 | +import { |
| 15 | + setDiagnosticsTab, |
| 16 | + setTenantPage, |
| 17 | + tenantApi, |
| 18 | +} from '../../../../store/reducers/tenant/tenant'; |
10 | 19 | import {calculateTenantMetrics} from '../../../../store/reducers/tenants/utils'; |
11 | 20 | import type {AdditionalTenantsProps} from '../../../../types/additionalProps'; |
12 | | -import {getDatabaseLinks} from '../../../../utils/additionalProps'; |
| 21 | +import {uiFactory} from '../../../../uiFactory/uiFactory'; |
| 22 | +import {getInfoTabLinks} from '../../../../utils/additionalProps'; |
13 | 23 | import {TENANT_DEFAULT_TITLE} from '../../../../utils/constants'; |
14 | | -import {useAutoRefreshInterval, useTypedSelector} from '../../../../utils/hooks'; |
| 24 | +import {useAutoRefreshInterval, useTypedDispatch, useTypedSelector} from '../../../../utils/hooks'; |
15 | 25 | import {useClusterNameFromQuery} from '../../../../utils/hooks/useDatabaseFromQuery'; |
16 | 26 | import {mapDatabaseTypeToDBName} from '../../utils/schema'; |
17 | 27 |
|
@@ -40,6 +50,7 @@ export function TenantOverview({ |
40 | 50 | const {metricsTab} = useTypedSelector((state) => state.tenant); |
41 | 51 | const [autoRefreshInterval] = useAutoRefreshInterval(); |
42 | 52 | const clusterName = useClusterNameFromQuery(); |
| 53 | + const dispatch = useTypedDispatch(); |
43 | 54 |
|
44 | 55 | const isMetaDatabasesAvailable = useDatabasesAvailable(); |
45 | 56 |
|
@@ -176,28 +187,44 @@ export function TenantOverview({ |
176 | 187 | } |
177 | 188 | }; |
178 | 189 |
|
179 | | - const links = getDatabaseLinks(additionalTenantProps, Name, Type); |
| 190 | + const links = getInfoTabLinks(additionalTenantProps, Name, Type); |
| 191 | + const monitoringTabAvailable = Boolean(uiFactory.renderMonitoring); |
| 192 | + |
| 193 | + const handleOpenMonitoring = () => { |
| 194 | + dispatch(setTenantPage(TENANT_PAGES_IDS.diagnostics)); |
| 195 | + dispatch(setDiagnosticsTab(TENANT_DIAGNOSTICS_TABS_IDS.monitoring)); |
| 196 | + }; |
180 | 197 |
|
181 | 198 | return ( |
182 | 199 | <LoaderWrapper loading={tenantLoading}> |
183 | 200 | <div className={b()}> |
184 | 201 | <div className={b('info')}> |
185 | | - <div className={b('top-label')}>{tenantType}</div> |
| 202 | + <Flex alignItems="center" gap="2" className={b('top-label')}> |
| 203 | + <div>{tenantType}</div> |
| 204 | + {monitoringTabAvailable && ( |
| 205 | + <Button view="normal" onClick={handleOpenMonitoring}> |
| 206 | + <Icon data={DisplayPulse} size={16} /> |
| 207 | + {i18n('action_open-monitoring')} |
| 208 | + </Button> |
| 209 | + )} |
| 210 | + </Flex> |
186 | 211 | <Flex alignItems="center" gap="1" className={b('top')}> |
187 | 212 | {renderName()} |
188 | | - <Flex gap="2"> |
189 | | - {links.map(({title, url, icon}) => ( |
190 | | - <Button |
191 | | - key={title} |
192 | | - href={url} |
193 | | - target="_blank" |
194 | | - size="xs" |
195 | | - title={title} |
196 | | - > |
197 | | - <Icon data={icon} /> |
198 | | - </Button> |
199 | | - ))} |
200 | | - </Flex> |
| 213 | + {links.length > 0 && ( |
| 214 | + <Flex gap="2"> |
| 215 | + {links.map(({title, url, icon}) => ( |
| 216 | + <Button |
| 217 | + key={title} |
| 218 | + href={url} |
| 219 | + target="_blank" |
| 220 | + size="xs" |
| 221 | + title={title} |
| 222 | + > |
| 223 | + <Icon data={icon} /> |
| 224 | + </Button> |
| 225 | + ))} |
| 226 | + </Flex> |
| 227 | + )} |
201 | 228 | </Flex> |
202 | 229 | <Flex direction="column" gap={4}> |
203 | 230 | {!isServerless && <HealthcheckPreview database={database} />} |
|
0 commit comments