Skip to content

Commit da8afb8

Browse files
committed
fix: gaps
1 parent a945a25 commit da8afb8

File tree

7 files changed

+34
-98
lines changed

7 files changed

+34
-98
lines changed

src/components/TenantNameWrapper/TenantNameWrapper.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {DefinitionList, PopoverBehavior} from '@gravity-ui/uikit';
1+
import {DefinitionList, Flex, PopoverBehavior} from '@gravity-ui/uikit';
22

33
import {getTenantPath} from '../../containers/Tenant/TenantPages';
44
import type {PreparedTenant} from '../../store/reducers/tenants/types';
@@ -49,15 +49,17 @@ export function TenantNameWrapper({tenant, additionalTenantsProps}: TenantNameWr
4949
monitoringLink || logsLink ? (
5050
<DefinitionList responsive>
5151
<DefinitionList.Item name={i18n('field_links')}>
52-
{monitoringLink && (
53-
<LinkWithIcon
54-
title={i18n('field_monitoring-link')}
55-
url={monitoringLink}
56-
/>
57-
)}
58-
{logsLink && (
59-
<LinkWithIcon title={i18n('field_logs-link')} url={logsLink} />
60-
)}
52+
<Flex gap={2} wrap="wrap">
53+
{monitoringLink && (
54+
<LinkWithIcon
55+
title={i18n('field_monitoring-link')}
56+
url={monitoringLink}
57+
/>
58+
)}
59+
{logsLink && (
60+
<LinkWithIcon title={i18n('field_logs-link')} url={logsLink} />
61+
)}
62+
</Flex>
6163
</DefinitionList.Item>
6264
</DefinitionList>
6365
) : null

src/containers/AppWithClusters/AppWithClusters.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import React from 'react';
33
import type {Store} from '@reduxjs/toolkit';
44
import type {History} from 'history';
55

6-
import type {GetMonitoringClusterLink, GetMonitoringLink} from '../../utils/monitoring';
6+
import type {
7+
GetLogsLink,
8+
GetMonitoringClusterLink,
9+
GetMonitoringLink,
10+
} from '../../utils/monitoring';
711
import {
812
getMonitoringClusterLink as getMonitoringClusterLinkDefault,
913
getMonitoringLink as getMonitoringLinkDefault,
@@ -17,6 +21,7 @@ import {ExtendedTenant} from './ExtendedTenant/ExtendedTenant';
1721
export interface AppWithClustersProps {
1822
store: Store;
1923
history: History;
24+
getLogsLink?: GetLogsLink;
2025
getMonitoringLink?: GetMonitoringLink;
2126
getMonitoringClusterLink?: GetMonitoringClusterLink;
2227
userSettings?: YDBEmbeddedUISettings;
@@ -26,6 +31,7 @@ export interface AppWithClustersProps {
2631
export function AppWithClusters({
2732
store,
2833
history,
34+
getLogsLink,
2935
getMonitoringLink = getMonitoringLinkDefault,
3036
getMonitoringClusterLink = getMonitoringClusterLinkDefault,
3137
userSettings,
@@ -38,6 +44,7 @@ export function AppWithClusters({
3844
return (
3945
<ExtendedCluster
4046
component={component}
47+
getLogsLink={getLogsLink}
4148
getMonitoringLink={getMonitoringLink}
4249
getMonitoringClusterLink={getMonitoringClusterLink}
4350
/>
@@ -49,6 +56,7 @@ export function AppWithClusters({
4956
return (
5057
<ExtendedTenant
5158
component={component}
59+
getLogsLink={getLogsLink}
5260
getMonitoringLink={getMonitoringLink}
5361
/>
5462
);

src/containers/AppWithClusters/ExtendedCluster/ExtendedCluster.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,10 @@ const getAdditionalTenantsProps = (
106106

107107
if (monitoring && getLogsLink) {
108108
additionalTenantsProps.getLogsLink = (dbName?: string) => {
109-
if (dbName) {
109+
if (dbName && clusterName) {
110110
return getLogsLink({
111111
dbName,
112112
clusterName,
113-
monitoring,
114113
});
115114
}
116115

src/containers/AppWithClusters/ExtendedTenant/ExtendedTenant.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function ExtendedTenant({
1515
getMonitoringLink,
1616
getLogsLink,
1717
}: ExtendedTenantProps) {
18-
const {monitoring} = useClusterBaseInfo();
18+
const {monitoring, name: clusterName} = useClusterBaseInfo();
1919
const additionalNodesProps = useAdditionalNodesProps();
2020

2121
const additionalTenantProps = {
@@ -31,10 +31,10 @@ export function ExtendedTenant({
3131
return null;
3232
},
3333
getLogsLink: (dbName?: string) => {
34-
if (monitoring && dbName && getLogsLink) {
34+
if (clusterName && dbName && getLogsLink) {
3535
return getLogsLink({
3636
dbName,
37-
monitoring,
37+
clusterName,
3838
});
3939
}
4040

src/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
}
1818

1919
&__top {
20-
display: flex;
21-
align-items: center;
22-
gap: 4px;
23-
2420
margin-bottom: 10px;
2521

2622
line-height: 24px;

src/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Loader} from '@gravity-ui/uikit';
1+
import {Flex, Loader} from '@gravity-ui/uikit';
22

33
import {EntityStatus} from '../../../../components/EntityStatus/EntityStatus';
44
import {LogsButton} from '../../../../components/LogsButton/LogsButton';
@@ -157,11 +157,13 @@ export function TenantOverview({
157157
<div className={b()}>
158158
<div className={b('info')}>
159159
<div className={b('top-label')}>{tenantType}</div>
160-
<div className={b('top')}>
160+
<Flex alignItems="center" gap="1" className={b('top')}>
161161
{renderName()}
162-
{monitoringLink && <MonitoringButton href={monitoringLink} />}
163-
{logsLink && <LogsButton href={logsLink} />}
164-
</div>
162+
<Flex gap="2">
163+
{monitoringLink && <MonitoringButton href={monitoringLink} />}
164+
{logsLink && <LogsButton href={logsLink} />}
165+
</Flex>
166+
</Flex>
165167
<MetricsCards
166168
poolsCpuStats={poolsStats}
167169
memoryStats={memoryStats}

src/utils/monitoring.ts

Lines changed: 2 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -102,78 +102,7 @@ export function parseMonitoringData(monitoring: string): ParsedMonitoringData |
102102

103103
interface GetLogsLinkProps {
104104
dbName: string;
105-
clusterName?: string;
106-
monitoring: string;
107-
project?: string;
108-
service?: string;
109-
level?: string;
110-
from?: string;
111-
to?: string;
112-
columns?: string[];
113-
groupByField?: string;
114-
chartType?: string;
115-
linesMode?: string;
105+
clusterName: string;
116106
}
117107

118-
export type GetLogsLink = typeof getLogsLink;
119-
120-
export function getLogsLink({
121-
dbName,
122-
clusterName,
123-
monitoring,
124-
project = 'kikimr',
125-
service = 'ydb',
126-
level = 'ERROR',
127-
from = 'now-1h',
128-
to = 'now',
129-
columns = ['level', 'time', 'message', 'host'],
130-
groupByField = 'level',
131-
chartType = 'line',
132-
linesMode = 'single',
133-
}: GetLogsLinkProps): string {
134-
try {
135-
const data = parseMonitoringData(monitoring);
136-
137-
if (data) {
138-
const finalClusterName = data.cluster_name || clusterName || '';
139-
140-
const url = new URL(data.monitoring_url);
141-
142-
url.pathname += '/_______/';
143-
144-
const queryFilter = {
145-
project,
146-
service,
147-
cluster: finalClusterName,
148-
database: dbName,
149-
level,
150-
};
151-
152-
url.searchParams.set('from', from);
153-
url.searchParams.set('to', to);
154-
155-
const queryString = Object.entries(queryFilter)
156-
.map(([key, value]) => `${key} = "${value}"`)
157-
.join(', ');
158-
url.searchParams.set('query', `{${queryString}}`);
159-
160-
url.searchParams.set('columns', columns.join(','));
161-
162-
if (groupByField) {
163-
url.searchParams.set('groupByField', groupByField);
164-
}
165-
166-
if (chartType) {
167-
url.searchParams.set('chartType', chartType);
168-
}
169-
170-
if (linesMode) {
171-
url.searchParams.set('linesMode', linesMode);
172-
}
173-
174-
return url.toString();
175-
}
176-
} catch {}
177-
178-
return '';
179-
}
108+
export type GetLogsLink = (props: GetLogsLinkProps) => string;

0 commit comments

Comments
 (0)