Skip to content

Commit

Permalink
feat(Components/Versions): display more columns of node types [YTFRON…
Browse files Browse the repository at this point in the history
…T-4406]
  • Loading branch information
KostyaAvtushko committed Jan 29, 2025
1 parent b052987 commit 1d8d6ab
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {getCluster} from '../../../../store/selectors/global';
import {ThunkAction} from 'redux-thunk';
import {RootState} from '../../../../store/reducers';
import {
HostType,
SummaryItem,
VersionHostInfo,
VersionSummaryItem,
Expand All @@ -24,7 +23,7 @@ export interface DiscoverVersionsData {
summary: Record<'total' | 'error' | string, VersionSummary>;
}

type VersionSummary = Record<HostType, SummaryItem>;
type VersionSummary = Record<string, SummaryItem>;

type NodesThunkAction<T = void> = ThunkAction<Promise<T>, RootState, unknown, any>;

Expand Down Expand Up @@ -97,7 +96,7 @@ function prepareGroup(group: VersionSummary, version: string) {
(acc, value, type) => {
const {total, banned, offline} = value;

const k = type as HostType;
const k = type;
acc[k] = total;
acc.banned += banned;
acc.offline += offline;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,18 @@ export interface SummaryItem {

export type VersionHostState = 'online' | 'offline' | 'banned';

export type HostType =
| 'controller_agent'
| 'primary_master'
| 'secondary_master'
| 'node'
| 'cluster_node'
| 'http_proxy'
| 'rpc_proxy'
| 'scheduler'
| 'job_proxy';

export interface VersionHostInfo {
address: string;
banned: boolean;
type: HostType;
type: string;
version: string;
start_time: string;
state: string;
offline: boolean;
error: unknown;
}

export type VersionSummaryItem = Partial<Record<HostType, number>> &
export type VersionSummaryItem = Partial<Record<string, number>> &
Record<'banned' | 'online' | 'offline', number> & {version: string};

const ephemeralState: VersionsState = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {RootState} from '../../../../store/reducers';
import {FIX_MY_TYPE, SortState} from '../../../../types';
import {sortArrayBySortState} from '../../../../utils/sort-helpers';
import {VersionSummaryItem} from '../../../../store/reducers/components/versions/versions_v2';
import {isSupportedClusterNodeForVersions} from '../../../../store/selectors/thor/support';
import format from '../.../../../../../common/hammer/format';

export const getSummarySortState = (
state: RootState,
Expand Down Expand Up @@ -40,8 +40,8 @@ export const getVersionsSummaryData = createSelector(
);

export const getVersionsSummaryVisibleColumns = createSelector(
[getSummary, isSupportedClusterNodeForVersions],
(summary = [], useClusterNode) => {
[getSummary],
(summary = []) => {
const visibleTypes = new Set<string>();
const total = getTotalElementOfSummary(summary);
Object.keys(total ?? {}).forEach((k) => {
Expand All @@ -57,14 +57,11 @@ export const getVersionsSummaryVisibleColumns = createSelector(
}
}

tryToAdd('primary_master', 'Primary Masters', 'Pri Masters');
tryToAdd('secondary_master', 'Secondary masters', 'Sec Masters');
tryToAdd('scheduler', 'Schedulers');
tryToAdd('controller_agent', 'Controller Agents', 'CA');
tryToAdd(useClusterNode ? 'cluster_node' : 'node', 'Nodes');
tryToAdd('http_proxy', 'HTTP Proxies');
tryToAdd('rpc_proxy', 'RPC Proxies');
tryToAdd('job_proxy', 'Job Proxies');
for (const key in summary[summary.length - 1]) {
if (['online', 'offline', 'banned', 'total'].includes(key)) continue;
tryToAdd(key, format.Readable(key))
}

tryToAdd('online', 'Online');
tryToAdd('offline', 'Offline');
tryToAdd('banned', 'Banned');
Expand Down

0 comments on commit 1d8d6ab

Please sign in to comment.