Skip to content

Commit eaa4918

Browse files
committed
[O2B-1532] Extract eorReasonComponent and revert formatter
Add a dedicated eorReasonComponent that renders the EOR reason VDOM.
1 parent dc99497 commit eaa4918

3 files changed

Lines changed: 42 additions & 17 deletions

File tree

lib/public/views/Runs/Details/runDetailsComponent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import { RunDefinition } from '../../../domain/enums/RunDefinition.js';
4040
import { formatFloat } from '../../../utilities/formatting/formatFloat.js';
4141
import { formatEditableNumber } from '../format/formatEditableNumber.js';
4242
import { editRunEorReasons } from '../format/editRunEorReasons.js';
43-
import { formatEorReason } from '../format/formatEorReason.mjs';
43+
import { eorReasonComponent } from '../format/eorReasonComponent.js';
4444
import { selectionDropdown } from '../../../components/common/selection/dropdown/selectionDropdown.js';
4545
import { formatRunCalibrationStatus } from '../format/formatRunCalibrationStatus.js';
4646
import { BeamModes } from '../../../domain/enums/BeamModes.js';
@@ -535,7 +535,7 @@ export const runDetailsComponent = (runDetailsModel, router) => runDetailsModel.
535535
? editRunEorReasons(runDetailsModel)
536536
: h(
537537
'.flex-column.g2.w-100',
538-
run.eorReasons.map((eorReason) => h('.eor-reason', formatEorReason(eorReason))),
538+
run.eorReasons.map((eorReason) => h('.eor-reason', eorReasonComponent(eorReason))),
539539
),
540540
]),
541541
]),
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
14+
import { h } from '/js/src/index.js';
15+
import { tooltip } from '../../../../components/common/popover/tooltip.js';
16+
import { formatEorReason } from './formatEorReason.mjs';
17+
18+
/**
19+
* Display the given EoR reason as a vdom component with lastEditedName tooltip
20+
*
21+
* @param {Partial<{
22+
* category: string,
23+
* title: string,
24+
* description: string,
25+
* lastEditedName: string,
26+
* }>} eorReason the EoR reason to display
27+
* @return {Component} the vdom component
28+
*/
29+
export const eorReasonComponent = (eorReason) => {
30+
const { lastEditedName } = eorReason;
31+
const reasonText = formatEorReason(eorReason);
32+
return h('.w-100.flex-row.justify-between', [
33+
h('', reasonText),
34+
tooltip(h('.w-wrapped', `${lastEditedName}`), 'Last edited by'),
35+
]);
36+
};

lib/public/views/Runs/format/formatEorReason.mjs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,14 @@
1111
* or submit itself to any jurisdiction.
1212
*/
1313

14-
import { h } from '/js/src/index.js';
15-
import { tooltip } from '../../../../components/common/popover/tooltip.js';
16-
1714
/**
1815
* Format the given EoR reason to string
1916
*
20-
* @param {Partial<{
21-
* category: string,
22-
* title: string,
23-
* description: string,
24-
* lastEditedName: string,
25-
* }>} eorReason the EoR reason to format
17+
* @param {Partial<{category: string, title: string, description: string}>} eorReason the EoR reason to
18+
* format
2619
* @return {string} the result
2720
*/
2821
export const formatEorReason = (eorReason) => {
29-
const { category, title, description, lastEditedName } = eorReason;
30-
const reasonText = [category, title, description].filter((item) => item).join(' - ');
31-
return h('.w-100.flex-row.justify-between', [
32-
h('', reasonText),
33-
tooltip(h('.w-wrapped', `${lastEditedName}`), 'Last edited by'),
34-
]);
22+
const { category, title, description } = eorReason;
23+
return [category, title, description].filter((item) => item).join(' - ');
3524
};

0 commit comments

Comments
 (0)