Skip to content

Commit

Permalink
Renames on FE
Browse files Browse the repository at this point in the history
  • Loading branch information
jskupsik committed Jan 4, 2025
1 parent 51bf50d commit 7b0b5a8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 29 deletions.
4 changes: 2 additions & 2 deletions admin/tabs/cluster/ClusterTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* Copyright © 2025 Extremely Heavy Industries Inc.
*/
import {distributedObjectsPanel} from '@xh/hoist/admin/tabs/cluster/distobjects/DistributedObjectsPanel';
import {clusterObjectsPanel} from '@xh/hoist/admin/tabs/cluster/objects/ClusterObjectsPanel';
import {instancesTab} from '@xh/hoist/admin/tabs/cluster/instances/InstancesTab';
import {tabContainer} from '@xh/hoist/cmp/tab';
import {hoistCmp} from '@xh/hoist/core';
Expand All @@ -17,7 +17,7 @@ export const clusterTab = hoistCmp.factory(() =>
switcher: {orientation: 'left', testId: 'cluster-tab-switcher'},
tabs: [
{id: 'instances', icon: Icon.info(), content: instancesTab},
{id: 'objects', icon: Icon.diff(), content: distributedObjectsPanel}
{id: 'objects', icon: Icon.diff(), content: clusterObjectsPanel}
]
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {bindable, makeObservable} from '@xh/hoist/mobx';
import {DAYS} from '@xh/hoist/utils/datetime';
import {isDisplayed, pluralize} from '@xh/hoist/utils/js';
import {
capitalize,
cloneDeep,
forOwn,
groupBy,
Expand All @@ -33,7 +32,7 @@ import {
import {action, computed, observable, runInAction} from 'mobx';
import {createRef} from 'react';

export class DistributedObjectsModel extends HoistModel {
export class ClusterObjectsModel extends HoistModel {
viewRef = createRef<HTMLElement>();

@observable.ref startTimestamp: Date = null;
Expand Down Expand Up @@ -80,7 +79,7 @@ export class DistributedObjectsModel extends HoistModel {
{name: 'parentName', type: 'string'},
{name: 'provider', type: 'string'},
{name: 'compareState', type: 'string'},
{name: 'comparisonFields', type: 'auto'},
{name: 'comparableAdminStats', type: 'auto'},
{name: 'adminStatsbyInstance', type: 'auto'}
],
idSpec: 'name'
Expand All @@ -107,7 +106,7 @@ export class DistributedObjectsModel extends HoistModel {
{field: 'displayName', isTreeColumn: true},
{field: 'type'},
{
field: 'comparisonFields',
field: 'comparableAdminStats',
renderer: v => (!isEmpty(v) ? tagsRenderer(v) : null),
hidden: true
},
Expand Down Expand Up @@ -252,11 +251,6 @@ export class DistributedObjectsModel extends HoistModel {
url: 'clusterObjectsAdmin/getClusterObjectsReport'
});

report.info = report.info.map(it => ({
...it,
comparableFields: it.comparableAdminStats
}));

this.gridModel.loadData(this.processReport(report));
runInAction(() => {
this.startTimestamp = report.startTimestamp
Expand Down Expand Up @@ -294,23 +288,23 @@ export class DistributedObjectsModel extends HoistModel {
return;
}

const {adminStatsbyInstance, comparisonFields} = record.data,
const {adminStatsbyInstance, comparableAdminStats} = record.data,
instanceNames = Object.keys(adminStatsbyInstance),
nonComparisonFields = without(
Object.keys(adminStatsbyInstance[instanceNames[0]] ?? {}),
...comparisonFields
...comparableAdminStats
),
{selectedId} = this.detailGridModel ?? {};

// Always re-create the grid model, as its not trivial to check if columns have changed.
// Always re-create the grid model, as it is not trivial to check if columns have changed.
XH.safeDestroy(this.detailGridModel);
const createColumnForField = fieldName => ({
field: {name: fieldName, displayName: fieldName},
renderer: v => (typeof v === 'object' ? JSON.stringify(v) : v),
autosizeMaxWidth: 200
});
this.detailGridModel = this.createDetailGridModel(
comparisonFields.map(createColumnForField),
comparableAdminStats.map(createColumnForField),
nonComparisonFields.map(createColumnForField)
);

Expand Down Expand Up @@ -339,7 +333,7 @@ export class DistributedObjectsModel extends HoistModel {
field: {name: 'instanceName', type: 'string', displayName: 'Instance'}
},
{
groupId: 'comparisonFields',
groupId: 'comparableAdminStats',
headerName: 'Compared Stats',
headerTooltip:
'Stats that are expected to be eventually consistent between all instances.',
Expand Down Expand Up @@ -409,7 +403,7 @@ export class DistributedObjectsModel extends HoistModel {
}): DistributedObjectRecord[] {
const byName = groupBy(info, 'name'),
recordsByName: Record<string, DistributedObjectRecord> = mapValues(byName, objs => {
const {name, type, comparisonFields} = objs[0],
const {name, type, comparableAdminStats} = objs[0],
adminStatsbyInstance: PlainObject = Object.fromEntries(
objs.map(obj => [obj.instanceName, obj.adminStats])
);
Expand All @@ -418,12 +412,12 @@ export class DistributedObjectsModel extends HoistModel {
displayName: this.deriveDisplayName(name, type),
type,
parentName: this.deriveParent(name, type),
compareState: (isEmpty(comparisonFields) || objs.length < 2
compareState: (isEmpty(comparableAdminStats) || objs.length < 2
? 'inactive'
: !isEmpty(breaks[name])
? 'failed'
: 'passed') as CompareState,
comparisonFields: comparisonFields ?? [],
comparableAdminStats: comparableAdminStats ?? [],
adminStatsbyInstance,
children: []
};
Expand Down Expand Up @@ -503,7 +497,7 @@ export class DistributedObjectsModel extends HoistModel {
return {
...args,
compareState: 'inactive',
comparisonFields: [],
comparableAdminStats: [],
adminStatsbyInstance: {},
children: []
};
Expand All @@ -517,7 +511,7 @@ export class DistributedObjectsModel extends HoistModel {
const last = name.substring(lastDotIdx + 1),
rest = name.substring(0, lastDotIdx);
// Identify collection caches by lowercase name after last dot.
if (last !== capitalize(last)) return rest;
if (!isEmpty(last) && last[0] !== last[0].toUpperCase()) return rest;
}
// Otherwise, group under the correct hibernate group record.
return name.startsWith('io.xh.hoist') ||
Expand Down Expand Up @@ -612,7 +606,7 @@ interface DistributedObjectRecord {
type: string;
parentName?: string;
compareState: CompareState;
comparisonFields: string[];
comparableAdminStats: string[];
adminStatsbyInstance: Record<string, PlainObject>;
children: DistributedObjectRecord[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import {toolbar, toolbarSep} from '@xh/hoist/desktop/cmp/toolbar';
import {fmtNumber} from '@xh/hoist/format';
import {Icon} from '@xh/hoist/icon';
import {pluralize} from '@xh/hoist/utils/js';
import {DistributedObjectsModel} from './DistributedObjectsModel';
import './DistributedObjects.scss';
import {ClusterObjectsModel} from './ClusterObjectsModel';
import './ClusterObjects.scss';

export const distributedObjectsPanel = hoistCmp.factory({
export const clusterObjectsPanel = hoistCmp.factory({
displayName: 'DistributedObjectsPanel',
model: creates(DistributedObjectsModel),
model: creates(ClusterObjectsModel),

render({model}) {
return panel({
Expand All @@ -41,7 +41,7 @@ export const distributedObjectsPanel = hoistCmp.factory({
}
});

const tbar = hoistCmp.factory<DistributedObjectsModel>(({model}) => {
const tbar = hoistCmp.factory<ClusterObjectsModel>(({model}) => {
const {counts, isSingleInstance} = model;
return toolbar({
items: [
Expand Down Expand Up @@ -87,7 +87,7 @@ const tbar = hoistCmp.factory<DistributedObjectsModel>(({model}) => {
});
});

const adminSpecsPanel = hoistCmp.factory<DistributedObjectsModel>(({model}) => {
const adminSpecsPanel = hoistCmp.factory<ClusterObjectsModel>(({model}) => {
const {
instanceName,
selectedAdminStats,
Expand Down Expand Up @@ -134,7 +134,7 @@ const adminSpecsPanel = hoistCmp.factory<DistributedObjectsModel>(({model}) => {
});
});

const bbar = hoistCmp.factory<DistributedObjectsModel>(({model}) => {
const bbar = hoistCmp.factory<ClusterObjectsModel>(({model}) => {
return toolbar(
recordActionBar({
selModel: model.gridModel.selModel,
Expand Down

0 comments on commit 7b0b5a8

Please sign in to comment.