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
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,16 @@ export function HealthcheckPreview(props: HealthcheckPreviewProps) {
<div className={b('preview-header')}>
<div className={b('preview-title-wrapper')}>
<div className={b('preview-title')}>{i18n('title.healthcheck')}</div>
<Button size="s" onClick={onUpdate} loading={loading} view="flat-secondary">
<Button
size="s"
onClick={(event) => {
// FIXME: refactor card to remove the button from the anchor link.
event.preventDefault();
onUpdate();
}}
loading={loading}
view="flat-secondary"
>
<Icon data={updateArrow} width={20} height={20} />
</Button>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
import React from 'react';

import {TENANT_DIAGNOSTICS_TABS_IDS} from '../../../../../store/reducers/tenant/constants';
import {
getTopNodesByCpu,
selectTopNodesByCpu,
setDataWasNotLoaded,
} from '../../../../../store/reducers/tenantOverview/topNodesByCpu/topNodesByCpu';
import {topNodesApi} from '../../../../../store/reducers/tenantOverview/topNodes/topNodes';
import type {AdditionalNodesProps} from '../../../../../types/additionalProps';
import {
useAutofetcher,
useSearchQuery,
useTypedDispatch,
useTypedSelector,
} from '../../../../../utils/hooks';
import {DEFAULT_POLLING_INTERVAL} from '../../../../../utils/constants';
import {useSearchQuery, useTypedSelector} from '../../../../../utils/hooks';
import {getTopNodesByCpuColumns} from '../../../../Nodes/getNodesColumns';
import {TenantTabsGroups, getTenantPath} from '../../../TenantPages';
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout';
Expand All @@ -25,27 +15,18 @@ interface TopNodesByCpuProps {
}

export function TopNodesByCpu({path, additionalNodesProps}: TopNodesByCpuProps) {
const dispatch = useTypedDispatch();

const query = useSearchQuery();

const {wasLoaded, loading, error} = useTypedSelector((state) => state.topNodesByCpu);
const {autorefresh} = useTypedSelector((state) => state.schema);
const topNodes = useTypedSelector(selectTopNodesByCpu);
const columns = getTopNodesByCpuColumns(additionalNodesProps?.getNodeRef);

const fetchNodes = React.useCallback(
(isBackground: boolean) => {
if (!isBackground) {
dispatch(setDataWasNotLoaded());
}

dispatch(getTopNodesByCpu({tenant: path}));
},
[dispatch, path],
const {currentData, isFetching, error} = topNodesApi.useGetTopNodesQuery(
{tenant: path, sortValue: 'CPU'},
{pollingInterval: autorefresh ? DEFAULT_POLLING_INTERVAL : 0},
);

useAutofetcher(fetchNodes, [fetchNodes], autorefresh);
const loading = isFetching && currentData === undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and further: isn't it possible to use isLoading property from query?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it repeats the current behaviour. isLoading is false when the query arguments change.

const topNodes = currentData;

const title = getSectionTitle({
entity: i18n('nodes'),
Expand All @@ -62,7 +43,6 @@ export function TopNodesByCpu({path, additionalNodesProps}: TopNodesByCpuProps)
columns={columns}
title={title}
loading={loading}
wasLoaded={wasLoaded}
error={error}
emptyDataMessage={i18n('top-nodes.empty-data')}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
import React from 'react';

import {TENANT_DIAGNOSTICS_TABS_IDS} from '../../../../../store/reducers/tenant/constants';
import {
getTopNodesByLoad,
selectTopNodesByLoad,
setDataWasNotLoaded,
} from '../../../../../store/reducers/tenantOverview/topNodesByLoad/topNodesByLoad';
import {topNodesApi} from '../../../../../store/reducers/tenantOverview/topNodes/topNodes';
import type {AdditionalNodesProps} from '../../../../../types/additionalProps';
import {
useAutofetcher,
useSearchQuery,
useTypedDispatch,
useTypedSelector,
} from '../../../../../utils/hooks';
import {DEFAULT_POLLING_INTERVAL} from '../../../../../utils/constants';
import {useSearchQuery, useTypedSelector} from '../../../../../utils/hooks';
import {getTopNodesByLoadColumns} from '../../../../Nodes/getNodesColumns';
import {TenantTabsGroups, getTenantPath} from '../../../TenantPages';
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout';
Expand All @@ -25,27 +15,18 @@ interface TopNodesByLoadProps {
}

export function TopNodesByLoad({path, additionalNodesProps}: TopNodesByLoadProps) {
const dispatch = useTypedDispatch();

const query = useSearchQuery();

const {wasLoaded, loading, error} = useTypedSelector((state) => state.topNodesByLoad);
const {autorefresh} = useTypedSelector((state) => state.schema);
const topNodes = useTypedSelector(selectTopNodesByLoad);
const columns = getTopNodesByLoadColumns(additionalNodesProps?.getNodeRef);

const fetchNodes = React.useCallback(
(isBackground: boolean) => {
if (!isBackground) {
dispatch(setDataWasNotLoaded());
}

dispatch(getTopNodesByLoad({tenant: path}));
},
[dispatch, path],
const {currentData, isFetching, error} = topNodesApi.useGetTopNodesQuery(
{tenant: path, sortValue: 'LoadAverage'},
{pollingInterval: autorefresh ? DEFAULT_POLLING_INTERVAL : 0},
);

useAutofetcher(fetchNodes, [fetchNodes], autorefresh);
const loading = isFetching && currentData === undefined;
const topNodes = currentData;

const title = getSectionTitle({
entity: i18n('nodes'),
Expand All @@ -62,7 +43,6 @@ export function TopNodesByLoad({path, additionalNodesProps}: TopNodesByLoadProps
columns={columns}
title={title}
loading={loading}
wasLoaded={wasLoaded}
error={error}
emptyDataMessage={i18n('top-nodes.empty-data')}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import {
TENANT_PAGES_IDS,
TENANT_QUERY_TABS_ID,
} from '../../../../../store/reducers/tenant/constants';
import {
fetchTenantOverviewTopQueries,
setDataWasNotLoaded,
} from '../../../../../store/reducers/tenantOverview/topQueries/tenantOverviewTopQueries';
import {useAutofetcher, useTypedDispatch, useTypedSelector} from '../../../../../utils/hooks';
import {topQueriesApi} from '../../../../../store/reducers/tenantOverview/topQueries/tenantOverviewTopQueries';
import {DEFAULT_POLLING_INTERVAL} from '../../../../../utils/constants';
import {useTypedDispatch, useTypedSelector} from '../../../../../utils/hooks';
import {TenantTabsGroups, getTenantPath} from '../../../TenantPages';
import {getTenantOverviewTopQueriesColumns} from '../../TopQueries/getTopQueriesColumns';
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout';
Expand All @@ -33,27 +31,16 @@ export function TopQueries({path}: TopQueriesProps) {
const query = parseQuery(location);

const {autorefresh} = useTypedSelector((state) => state.schema);

const {
loading,
wasLoaded,
error,
data: {result: data = undefined} = {},
} = useTypedSelector((state) => state.tenantOverviewTopQueries);
const columns = getTenantOverviewTopQueriesColumns();

useAutofetcher(
(isBackground) => {
if (!isBackground) {
dispatch(setDataWasNotLoaded());
}

dispatch(fetchTenantOverviewTopQueries(path));
},
[dispatch, path],
autorefresh,
const {currentData, isFetching, error} = topQueriesApi.useGetTopQueriesQuery(
{database: path},
{pollingInterval: autorefresh ? DEFAULT_POLLING_INTERVAL : 0},
);

const loading = isFetching && currentData === undefined;
const {result: data} = currentData || {};

const handleRowClick = React.useCallback(
(row: any) => {
const {QueryText: input} = row;
Expand Down Expand Up @@ -89,7 +76,6 @@ export function TopQueries({path}: TopQueriesProps) {
onRowClick={handleRowClick}
title={title}
loading={loading}
wasLoaded={wasLoaded}
error={error}
tableClassNameModifiers={{'top-queries': true}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ import {useLocation} from 'react-router';

import {parseQuery} from '../../../../../routes';
import {TENANT_DIAGNOSTICS_TABS_IDS} from '../../../../../store/reducers/tenant/constants';
import {
sendTenantOverviewTopShardsQuery,
setDataWasNotLoaded,
} from '../../../../../store/reducers/tenantOverview/topShards/tenantOverviewTopShards';
import {useAutofetcher, useTypedDispatch, useTypedSelector} from '../../../../../utils/hooks';
import {topShardsApi} from '../../../../../store/reducers/tenantOverview/topShards/tenantOverviewTopShards';
import {DEFAULT_POLLING_INTERVAL} from '../../../../../utils/constants';
import {useTypedSelector} from '../../../../../utils/hooks';
import {TenantTabsGroups, getTenantPath} from '../../../TenantPages';
import {getTopShardsColumns} from '../../TopShards/getTopShardsColumns';
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout';
Expand All @@ -18,31 +16,20 @@ interface TopShardsProps {
}

export const TopShards = ({path}: TopShardsProps) => {
const dispatch = useTypedDispatch();
const location = useLocation();

const query = parseQuery(location);

const {autorefresh, currentSchemaPath} = useTypedSelector((state) => state.schema);

const {
loading,
data: {result: data = undefined} = {},
error,
wasLoaded,
} = useTypedSelector((state) => state.tenantOverviewTopShards);

useAutofetcher(
(isBackground) => {
if (!isBackground) {
dispatch(setDataWasNotLoaded());
}
dispatch(sendTenantOverviewTopShardsQuery(path, currentSchemaPath));
},
[dispatch, path, currentSchemaPath],
autorefresh,
const {currentData, isFetching, error} = topShardsApi.useGetTopShardsQuery(
{database: path, path: currentSchemaPath},
{pollingInterval: autorefresh ? DEFAULT_POLLING_INTERVAL : 0},
);

const loading = isFetching && currentData === undefined;
const {result: data} = currentData || {};

const columns = getTopShardsColumns(path, location);

const title = getSectionTitle({
Expand All @@ -60,7 +47,6 @@ export const TopShards = ({path}: TopShardsProps) => {
columns={columns}
title={title}
loading={loading}
wasLoaded={wasLoaded}
error={error}
tableClassNameModifiers={{'top-queries': true}}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
import React from 'react';

import {TENANT_DIAGNOSTICS_TABS_IDS} from '../../../../../store/reducers/tenant/constants';
import {
getTopNodesByMemory,
selectTopNodesByMemory,
setDataWasNotLoaded,
} from '../../../../../store/reducers/tenantOverview/topNodesByMemory/topNodesByMemory';
import {topNodesApi} from '../../../../../store/reducers/tenantOverview/topNodes/topNodes';
import type {AdditionalNodesProps} from '../../../../../types/additionalProps';
import {
useAutofetcher,
useSearchQuery,
useTypedDispatch,
useTypedSelector,
} from '../../../../../utils/hooks';
import {DEFAULT_POLLING_INTERVAL} from '../../../../../utils/constants';
import {useSearchQuery, useTypedSelector} from '../../../../../utils/hooks';
import {getTopNodesByMemoryColumns} from '../../../../Nodes/getNodesColumns';
import {TenantTabsGroups, getTenantPath} from '../../../TenantPages';
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout';
Expand All @@ -25,29 +15,20 @@ interface TopNodesByMemoryProps {
}

export function TopNodesByMemory({path, additionalNodesProps}: TopNodesByMemoryProps) {
const dispatch = useTypedDispatch();

const query = useSearchQuery();

const {wasLoaded, loading, error} = useTypedSelector((state) => state.topNodesByMemory);
const {autorefresh} = useTypedSelector((state) => state.schema);
const topNodes = useTypedSelector(selectTopNodesByMemory);
const columns = getTopNodesByMemoryColumns({
getNodeRef: additionalNodesProps?.getNodeRef,
});

const fetchNodes = React.useCallback(
(isBackground: boolean) => {
if (!isBackground) {
dispatch(setDataWasNotLoaded());
}

dispatch(getTopNodesByMemory({tenant: path}));
},
[dispatch, path],
const {currentData, isFetching, error} = topNodesApi.useGetTopNodesQuery(
{tenant: path, sortValue: 'Memory'},
{pollingInterval: autorefresh ? DEFAULT_POLLING_INTERVAL : 0},
);

useAutofetcher(fetchNodes, [fetchNodes], autorefresh);
const loading = isFetching && currentData === undefined;
const topNodes = currentData;

const title = getSectionTitle({
entity: i18n('nodes'),
Expand All @@ -64,7 +45,6 @@ export function TopNodesByMemory({path, additionalNodesProps}: TopNodesByMemoryP
columns={columns}
title={title}
loading={loading}
wasLoaded={wasLoaded}
error={error}
emptyDataMessage={i18n('top-nodes.empty-data')}
/>
Expand Down
Loading