Skip to content

Commit

Permalink
fix: move tenant overview reducers to separate folder
Browse files Browse the repository at this point in the history
  • Loading branch information
krosy1337 committed Oct 5, 2023
1 parent 3f65477 commit ed93a31
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import DataTable from '@gravity-ui/react-data-table';

import {useAutofetcher, useTypedSelector} from '../../../../../utils/hooks';
import {DEFAULT_TABLE_SETTINGS} from '../../../../../utils/constants';
import {STORAGE_SORT_VALUES} from '../../../../../utils/storage';
import {
setDataWasNotLoaded,
getTopStorageGroups,
selectTopStorageGroups,
} from '../../../../../store/reducers/topStorageGroups/topStorageGroups';
import {EVersion} from '../../../../../types/api/storage';
} from '../../../../../store/reducers/tenantOverview/topStorageGroups/topStorageGroups';
import {ResponseError} from '../../../../../components/Errors/ResponseError';
import {TableSkeleton} from '../../../../../components/TableSkeleton/TableSkeleton';
import {getStorageTopGroupsColumns} from '../../../../Storage/StorageGroups/getStorageGroupsColumns';
Expand All @@ -39,16 +37,7 @@ export function TopGroups({tenant}: TopGroupsProps) {
dispatch(setDataWasNotLoaded());
}

dispatch(
getTopStorageGroups({
tenant,
visibleEntities: 'all',
limit: 5,
sortOrder: -1,
sortValue: STORAGE_SORT_VALUES.Usage,
version: EVersion.v2,
}),
);
dispatch(getTopStorageGroups({tenant}));
},
[dispatch, tenant],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {useAutofetcher, useTypedSelector} from '../../../../../utils/hooks';
import {
fetchTopTables,
setTopTablesState,
} from '../../../../../store/reducers/executeTopTables/executeTopTables';
} from '../../../../../store/reducers/tenantOverview/executeTopTables/executeTopTables';
import {DEFAULT_TABLE_SETTINGS} from '../../../../../utils/constants';
import type {KeyValueRow} from '../../../../../types/api/query';
import {formatBytes, getSizeWithSignificantDigits} from '../../../../../utils/bytesParsers';
Expand Down
4 changes: 2 additions & 2 deletions src/store/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import cluster from './cluster/cluster';
import clusterNodes from './clusterNodes/clusterNodes';
import tenant from './tenant/tenant';
import storage from './storage/storage';
import topStorageGroups from './topStorageGroups/topStorageGroups';
import topStorageGroups from './tenantOverview/topStorageGroups/topStorageGroups';
import node from './node/node';
import tooltip from './tooltip';
import tablets from './tablets';
Expand All @@ -27,7 +27,7 @@ import nodesList from './nodesList';
import describe from './describe';
import schemaAcl from './schemaAcl/schemaAcl';
import executeTopQueries from './executeTopQueries';
import executeTopTables from './executeTopTables/executeTopTables';
import executeTopTables from './tenantOverview/executeTopTables/executeTopTables';
import healthcheckInfo from './healthcheckInfo';
import shardsWorkload from './shardsWorkload';
import hotKeys from './hotKeys';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type {Reducer} from 'redux';

import {parseQueryAPIExecuteResponse} from '../../../utils/query';
import {createApiRequest, createRequestActionTypes} from '../../utils';
import {TENANT_OVERVIEW_TABLES_LIMIT} from '../../../../utils/constants';
import {parseQueryAPIExecuteResponse} from '../../../../utils/query';
import {createApiRequest, createRequestActionTypes} from '../../../utils';
import type {TopTablesAction, TopTablesState} from './types';

export const FETCH_TOP_TABLES = createRequestActionTypes('top-tables', 'FETCH_TOP_TABLES');
Expand All @@ -19,7 +20,7 @@ SELECT
FROM \`${path}/.sys/partition_stats\`
GROUP BY Path
ORDER BY Size DESC
LIMIT 5
LIMIT ${TENANT_OVERVIEW_TABLES_LIMIT}
`;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {IQueryResult, QueryErrorResponse} from '../../../types/store/query';
import type {ApiRequestAction} from '../../utils';
import type {IQueryResult, QueryErrorResponse} from '../../../../types/store/query';
import type {ApiRequestAction} from '../../../utils';
import {FETCH_TOP_TABLES, setTopTablesState} from './executeTopTables';

export interface TopTablesState {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type {Reducer} from 'redux';

import {EVersion} from '../../../types/api/storage';
import {createApiRequest, createRequestActionTypes} from '../../utils';
import type {StorageApiRequestParams} from '../storage/types';
import {TENANT_OVERVIEW_TABLES_LIMIT} from '../../../../utils/constants';
import {EVersion} from '../../../../types/api/storage';
import {createApiRequest, createRequestActionTypes} from '../../../utils';
import type {StorageApiRequestParams} from '../../storage/types';
import type {
TopStorageGroupsAction,
TopStorageGroupsState,
Expand All @@ -11,11 +12,11 @@ import type {
import {prepareTopStorageGroupsResponse} from './utils';

export const FETCH_TOP_STORAGE_GROUPS = createRequestActionTypes(
'storage',
'topStorageGroups',
'FETCH_TOP_STORAGE_GROUPS',
);

const SET_DATA_WAS_NOT_LOADED = 'storage/SET_TOP_STORAGE_GROUPS_DATA_WAS_NOT_LOADED';
const SET_DATA_WAS_NOT_LOADED = 'topStorageGroups/SET_DATA_WAS_NOT_LOADED';

const initialState = {
loading: true,
Expand All @@ -36,7 +37,7 @@ const topStorageGroups: Reducer<TopStorageGroupsState, TopStorageGroupsAction> =
case FETCH_TOP_STORAGE_GROUPS.SUCCESS: {
return {
...state,
groups: action.data.groups,
data: action.data.groups,
loading: false,
wasLoaded: true,
error: undefined,
Expand Down Expand Up @@ -67,14 +68,17 @@ const topStorageGroups: Reducer<TopStorageGroupsState, TopStorageGroupsAction> =

export const getTopStorageGroups = ({
tenant,
visibleEntities,
visibleEntities = 'all',
nodeId,
version = EVersion.v1,
sortOrder = -1,
sortValue = 'Usage',
limit = TENANT_OVERVIEW_TABLES_LIMIT,
version = EVersion.v2,
...params
}: StorageApiRequestParams) => {
return createApiRequest({
request: window.api.getStorageInfo(
{tenant, visibleEntities, nodeId, version, ...params},
{tenant, visibleEntities, nodeId, version, sortOrder, sortValue, limit, ...params},
{concurrentId: 'getTopStorageGroups'},
),
actions: FETCH_TOP_STORAGE_GROUPS,
Expand All @@ -83,7 +87,7 @@ export const getTopStorageGroups = ({
};

export const selectTopStorageGroups = (state: TopStorageGroupsStateSlice) =>
state.topStorageGroups.groups;
state.topStorageGroups.data;

export const setDataWasNotLoaded = () => {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type {IResponseError} from '../../../types/api/error';
import type {ApiRequestAction} from '../../utils';
import type {PreparedStorageGroup} from '../storage/types';
import type {IResponseError} from '../../../../types/api/error';
import type {ApiRequestAction} from '../../../utils';
import type {PreparedStorageGroup} from '../../storage/types';
import {FETCH_TOP_STORAGE_GROUPS, setDataWasNotLoaded} from './topStorageGroups';

export interface TopStorageGroupsState {
loading: boolean;
wasLoaded: boolean;
groups?: PreparedStorageGroup[];
data?: PreparedStorageGroup[];
error?: IResponseError;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {TStorageInfo} from '../../../types/api/storage';
import {prepareStorageGroups} from '../storage/utils';
import {TENANT_OVERVIEW_TABLES_LIMIT} from '../../../../utils/constants';
import type {TStorageInfo} from '../../../../types/api/storage';
import {prepareStorageGroups} from '../../storage/utils';
import type {PreparedTopStorageGroupsResponse} from './types';

export const prepareTopStorageGroupsResponse = (
Expand All @@ -16,6 +17,6 @@ export const prepareTopStorageGroupsResponse = (
}

return {
groups: sortedGroups.slice(0, 5),
groups: sortedGroups.slice(0, TENANT_OVERVIEW_TABLES_LIMIT),
};
};
2 changes: 2 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export const COLORS_PRIORITY = {
grey: 1,
};

export const TENANT_OVERVIEW_TABLES_LIMIT = 5;

// ==== Titles ====
export const DEVELOPER_UI_TITLE = 'Developer UI';
export const CLUSTER_DEFAULT_TITLE = 'Cluster';
Expand Down

0 comments on commit ed93a31

Please sign in to comment.