Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default [
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
curly: ['error', 'all'],
'react-hooks/exhaustive-deps': 'warn',
'react-hooks/rules-of-hooks': 'error',
},
},
// TypeScript-specific rules that require type information
Expand Down
2 changes: 1 addition & 1 deletion src/components/ErrorBoundary/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function getBackendVersion() {
// node_id=. returns data about node that fullfills request
// normally this request should be fast (200-300ms with good connection)
// timeout=1000 in order not to wait too much in case everything is broken
const data = await window.api.viewer.getNodeInfo('.', {timeout: 1000});
const data = await window.api.viewer.getNodeInfo({nodeId: '.'}, {timeout: 1000});
return data?.SystemStateInfo?.[0]?.Version;
} catch (error) {
return {error: prepareErrorMessage(error)};
Expand Down
12 changes: 12 additions & 0 deletions src/components/NodeId/NodeId.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {getDefaultNodePath} from '../../containers/Node/NodePages';
import {useDatabaseFromQuery} from '../../utils/hooks/useDatabaseFromQuery';
import {InternalLink} from '../InternalLink';

interface NodeIdProps {
id: string | number;
}

export function NodeId({id}: NodeIdProps) {
const database = useDatabaseFromQuery();
return <InternalLink to={getDefaultNodePath(id, {database})}>{id}</InternalLink>;
}
4 changes: 3 additions & 1 deletion src/components/PDiskPopup/PDiskPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {EMPTY_DATA_PLACEHOLDER} from '../../utils/constants';
import {createPDiskDeveloperUILink} from '../../utils/developerUI/developerUI';
import type {PreparedPDisk} from '../../utils/disks/types';
import {useTypedSelector} from '../../utils/hooks';
import {useDatabaseFromQuery} from '../../utils/hooks/useDatabaseFromQuery';
import {useIsUserAllowedToMakeChanges} from '../../utils/hooks/useIsUserAllowedToMakeChanges';
import {bytesToGB, isNumeric} from '../../utils/utils';
import {InfoViewer} from '../InfoViewer';
Expand Down Expand Up @@ -109,8 +110,9 @@ interface PDiskPopupProps {
}

export const PDiskPopup = ({data}: PDiskPopupProps) => {
const database = useDatabaseFromQuery();
const isUserAllowedToMakeChanges = useIsUserAllowedToMakeChanges();
const nodesMap = useTypedSelector(selectNodesMap);
const nodesMap = useTypedSelector((state) => selectNodesMap(state, database));
const nodeData = valueIsDefined(data.NodeId) ? nodesMap?.get(data.NodeId) : undefined;
const info = React.useMemo(
() => preparePDiskData(data, nodeData, isUserAllowedToMakeChanges),
Expand Down
8 changes: 4 additions & 4 deletions src/components/ProgressWrapper/SingleProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ export function SingleProgress({
size = PROGRESS_SIZE,
withCapacityUsage = false,
}: ProgressWrapperSingleProps) {
if (!isValidValue(value)) {
return <div className={className}>{i18n('alert_no-data')}</div>;
}

const numericValue = safeParseNumber(value);
const numericCapacity = safeParseNumber(capacity);
const clampedFillWidth = calculateProgressWidth(numericValue, numericCapacity);
Expand All @@ -41,6 +37,10 @@ export function SingleProgress({
return formatProgressText(valueText, capacityText, numericCapacity);
}, [valueText, capacityText, numericCapacity]);

if (!isValidValue(value)) {
return <div className={className}>{i18n('alert_no-data')}</div>;
}

return (
<ProgressContainer
displayText={displayText}
Expand Down
8 changes: 4 additions & 4 deletions src/components/ProgressWrapper/StackProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ export function StackProgress({
return stack.filter((segment) => !segment.isInfo && segment.value > 0);
}, [stack]);

if (displaySegments.length === 0) {
return <div className={className}>{i18n('alert_no-data')}</div>;
}

const totalValue = React.useMemo(() => {
return displaySegments.reduce((sum, segment) => sum + segment.value, 0);
}, [displaySegments]);
Expand All @@ -59,6 +55,10 @@ export function StackProgress({
return formatProgressText(totalValueText, totalCapacityText, numericTotalCapacity || 0);
}, [totalValueText, totalCapacityText, numericTotalCapacity]);

if (displaySegments.length === 0) {
return <div className={className}>{i18n('alert_no-data')}</div>;
}

return (
<ProgressContainer
displayText={displayText}
Expand Down
12 changes: 6 additions & 6 deletions src/components/QueriesActivityBar/QueriesActivityCharts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ export function QueriesActivityCharts({
const queriesChartConfig = getChartByTarget('queries.requests');
const latenciesChartConfig = getChartByTarget('queries.latencies.p99');

// Early return if required charts are not found
if (!queriesChartConfig || !latenciesChartConfig) {
console.warn('Required chart configurations not found in defaultDashboardConfig');
return null;
}

// Refetch data only if charts have successfully loaded at least once
const shouldRefresh = hasChartsLoaded ? autoRefreshInterval : 0;

Expand All @@ -58,6 +52,12 @@ export function QueriesActivityCharts({
[onChartDataStatusChange],
);

// Early return if required charts are not found
if (!queriesChartConfig || !latenciesChartConfig) {
console.warn('Required chart configurations not found in defaultDashboardConfig');
return null;
}

// WORKAROUND: Charts are rendered outside Disclosure component due to YAGR tooltip bug
// Issue: https://github.com/gravity-ui/yagr/issues/262

Expand Down
8 changes: 4 additions & 4 deletions src/components/ShardsTable/columns.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import DataTable from '@gravity-ui/react-data-table';

import {getDefaultNodePath} from '../../containers/Node/NodePages';
import {EMPTY_DATA_PLACEHOLDER} from '../../utils/constants';
import {formatNumber, roundToPrecision} from '../../utils/dataFormatters/dataFormatters';
import {getUsageSeverity} from '../../utils/generateEvaluator';
import {InternalLink} from '../InternalLink';
import {LinkToSchemaObject} from '../LinkToSchemaObject/LinkToSchemaObject';
import {NodeId} from '../NodeId/NodeId';
import {TabletNameWrapper} from '../TabletNameWrapper/TabletNameWrapper';
import {UsageLabel} from '../UsageLabel/UsageLabel';

Expand Down Expand Up @@ -39,7 +38,7 @@ export const getDataSizeColumn: GetShardsColumn = () => {
align: DataTable.RIGHT,
};
};
export const getTabletIdColumn: GetShardsColumn = () => {
export const getTabletIdColumn: GetShardsColumn = ({database}) => {
return {
name: TOP_SHARDS_COLUMNS_IDS.TabletId,
header: TOP_SHARDS_COLUMNS_TITLES.TabletId,
Expand All @@ -51,6 +50,7 @@ export const getTabletIdColumn: GetShardsColumn = () => {
<TabletNameWrapper
tabletId={row.TabletId}
followerId={row.FollowerId || undefined}
database={database}
/>
);
},
Expand All @@ -65,7 +65,7 @@ export const getNodeIdColumn: GetShardsColumn = () => {
if (!row.NodeId) {
return EMPTY_DATA_PLACEHOLDER;
}
return <InternalLink to={getDefaultNodePath(row.NodeId)}>{row.NodeId}</InternalLink>;
return <NodeId id={row.NodeId} />;
},
align: DataTable.RIGHT,
};
Expand Down
6 changes: 5 additions & 1 deletion src/components/VDisk/VDisk.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {cn} from '../../utils/cn';
import type {PreparedVDisk} from '../../utils/disks/types';
import {useDatabaseFromQuery} from '../../utils/hooks/useDatabaseFromQuery';
import {DiskStateProgressBar} from '../DiskStateProgressBar/DiskStateProgressBar';
import {HoverPopup} from '../HoverPopup/HoverPopup';
import {InternalLink} from '../InternalLink';
Expand Down Expand Up @@ -34,7 +35,10 @@ export const VDisk = ({
delayClose,
delayOpen,
}: VDiskProps) => {
const vDiskPath = getVDiskLink(data);
const database = useDatabaseFromQuery();
const vDiskPath = getVDiskLink(data, {
database: database,
});

return (
<HoverPopup
Expand Down
31 changes: 9 additions & 22 deletions src/components/VDisk/utils.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
import {getVDiskPagePath} from '../../routes';
import {valueIsDefined} from '../../utils';
import type {PreparedVDisk} from '../../utils/disks/types';

export function getVDiskLink(data: PreparedVDisk) {
let vDiskPath: string | undefined;

if (
valueIsDefined(data.VDiskSlotId) &&
valueIsDefined(data.PDiskId) &&
valueIsDefined(data.NodeId)
) {
vDiskPath = getVDiskPagePath({
vDiskSlotId: data.VDiskSlotId,
pDiskId: data.PDiskId,
export function getVDiskLink(data: PreparedVDisk, query: {database: string | undefined}) {
if (!data.StringifiedId) {
return undefined;
}
return getVDiskPagePath(
{
nodeId: data.NodeId,
vDiskId: data.StringifiedId,
});
} else if (valueIsDefined(data.StringifiedId)) {
vDiskPath = getVDiskPagePath({
vDiskId: data.StringifiedId,
pDiskId: data.PDiskId,
nodeId: data.NodeId,
});
}

return vDiskPath;
},
query,
);
}
Loading
Loading