Skip to content

Commit 86ffd63

Browse files
committed
refactor
1 parent f080a07 commit 86ffd63

1 file changed

Lines changed: 13 additions & 18 deletions

File tree

lib/public/views/Runs/RunPerPeriod/RunsPerLhcPeriodOverviewPage.js

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,36 +66,28 @@ export const RunsPerLhcPeriodOverviewPage = ({ runs: { perLhcPeriodOverviewModel
6666
} = perLhcPeriodOverviewModel;
6767

6868
const activeColumns = {
69-
...runsActiveColumns,
70-
...remoteRuns.match({
71-
Success: (runs) => runs.some((run) => run.pdpBeamType === PdpBeamType.LEAD_LEAD)
72-
? inelasticInteractionRateActiveColumnsForPbPb
73-
: {},
74-
Other: () => {},
75-
}),
76-
...remoteRuns.match({
77-
Success: (runs) => runs.some((run) => run.pdpBeamType === PdpBeamType.PROTON_PROTON)
78-
? inelasticInteractionRateActiveColumnsForProtonProton
79-
: {},
80-
Other: () => {},
81-
}),
69+
8270
};
8371

8472
/**
8573
* Render runs table with given detectors' active columns configuration
8674
*
75+
* @param {Run[]} runs runs
8776
* @param {object} detectorsActiveColumns active columns
8877
* @return {Component} table with pagination
8978
*/
90-
const getTableWithGivenDetectorsColumns = (detectorsActiveColumns) =>
79+
const getTableWithGivenDetectorsColumns = (runs, detectorsActiveColumns) =>
9180
table(
9281

9382
/*
9483
* Columns depends on detectors' list, it's not useful to render the table when detectors are missing
9584
*/
9685
remoteRuns,
9786
{
98-
...activeColumns,
87+
...runsActiveColumns,
88+
...runs.some((run) => run.pdpBeamType === PdpBeamType.LEAD_LEAD) ? inelasticInteractionRateActiveColumnsForPbPb : {},
89+
...runs.some((run) => run.pdpBeamType === PdpBeamType.PROTON_PROTON)
90+
? inelasticInteractionRateActiveColumnsForProtonProton : {},
9991
...detectorsActiveColumns,
10092
},
10193
{ classes: getRowClasses },
@@ -114,7 +106,7 @@ export const RunsPerLhcPeriodOverviewPage = ({ runs: { perLhcPeriodOverviewModel
114106
NotAsked: () => null,
115107
Failure: (errors) => errorAlert(errors),
116108
Loading: () => spinner(),
117-
Success: ([lhcPeriod, _, detectors]) => [
109+
Success: ([lhcPeriod, runs, detectors]) => [
118110
h('.flex-row.justify-between.items-center.g2', [
119111
filtersPanelPopover(perLhcPeriodOverviewModel, activeColumns, { profile: 'runsPerLhcPeriod' }),
120112
h('.pl2#runOverviewFilter', runNumbersFilter(perLhcPeriodOverviewModel.filteringModel.get('runNumbers'))),
@@ -130,10 +122,13 @@ export const RunsPerLhcPeriodOverviewPage = ({ runs: { perLhcPeriodOverviewModel
130122
},
131123
{
132124
[RUNS_PER_LHC_PERIOD_PANELS_KEYS.DETECTOR_QUALITIES]:
133-
() => getTableWithGivenDetectorsColumns(runDetectorsQualitiesActiveColumns(detectors, { profiles: 'runsPerLhcPeriod' })),
125+
() => getTableWithGivenDetectorsColumns(
126+
runs,
127+
runDetectorsQualitiesActiveColumns(detectors, { profiles: 'runsPerLhcPeriod' }),
128+
),
134129

135130
[RUNS_PER_LHC_PERIOD_PANELS_KEYS.SYNCHRONOUS_FLAGS]:
136-
(remoteSynchronousQcSummary) => getTableWithGivenDetectorsColumns(runDetectorsSyncQcActiveColumns(detectors, {
131+
(remoteSynchronousQcSummary) => getTableWithGivenDetectorsColumns(runs, runDetectorsSyncQcActiveColumns(detectors, {
137132
profiles: 'runsPerLhcPeriod',
138133
qcSummary: remoteSynchronousQcSummary.match({ Success: (qcSummary) => qcSummary, Other: () => null }),
139134
})),

0 commit comments

Comments
 (0)