-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathqcFlagCreationPanelLink.js
More file actions
74 lines (67 loc) · 2.76 KB
/
qcFlagCreationPanelLink.js
File metadata and controls
74 lines (67 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* @license
* Copyright CERN and copyright holders of ALICE O2. This software is
* distributed under the terms of the GNU General Public License v3 (GPL
* Version 3), copied verbatim in the file "COPYING".
*
* See http://alice-o2.web.cern.ch/license for full licensing information.
*
* In applying this license CERN does not waive the privileges and immunities
* granted to it by virtue of its status as an Intergovernmental Organization
* or submit itself to any jurisdiction.
*/
import { frontLink } from '../common/navigation/frontLink.js';
import { isRunNotSubjectToQc } from './isRunNotSubjectToQc.js';
import { h, iconPlus } from '/js/src/index.js';
import { getRunQcExclusionReason } from './getRunQcExclusionReason.js';
/**
* Render link to QC flag creation page
* @param {object} production object with dataPassId or simulationPassId
* @param {DataPass} [production.dataPass] data pass - exclusive with simulationPassId parameter
* @param {SimulationPass} [production.simulationPass] simulation pass - exclusive with dataPassId parameter
* @param {Run} run run
* @param {Detector|null} detector detector if user has access to it, null if not
* @param {object} [options] display options
* @param {Component} [options.noPermissionContent] a display in case user has no permission to manage QC flags for given detector
* @param {string[]} [options.linkClasses] css classes to apply to the link (in addition to the default ones)
* @return {Component} link
*/
export const qcFlagCreationPanelLink = (
{ dataPass, simulationPass },
run,
detector,
{ noPermissionContent = null, linkClasses = [] } = {},
) => {
const content = [h('.flex-row.items-center.g1', [h('small', iconPlus()), 'QC'])];
if (isRunNotSubjectToQc(run)) {
return h('button.btn.btn-primary', { disabled: true, title: getRunQcExclusionReason(run) }, content);
}
if (!detector) {
return noPermissionContent;
}
let options = {};
let pageName = '';
if (dataPass) {
if (dataPass.isFrozen) {
return h('button.btn.btn-primary', { disabled: true, title: 'Datapass is frozen' }, content);
}
options = { dataPassId: dataPass.id };
pageName = 'qc-flag-creation-for-data-pass';
} else if (simulationPass) {
options = { simulationPassId: simulationPass.id };
pageName = 'qc-flag-creation-for-simulation-pass';
} else {
return null;
}
return h('div.flex-row.align-center', [
frontLink(
content,
pageName,
{ runNumberDetectorsMap: `${run.runNumber}:${detector.id}`, ...options },
{
class: ['btn', 'btn-primary', ...linkClasses].join(' '),
title: 'Create a QC flag',
},
),
]);
};