-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathaddLabelsToLayout.js
More file actions
30 lines (29 loc) · 1.07 KB
/
addLabelsToLayout.js
File metadata and controls
30 lines (29 loc) · 1.07 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
/**
* @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.
*/
/**
* Method to identify the unique prefix (encountering first '/') of objects and add it as a set of labels to layout
* @param {LayoutDto} layout - layout object to which labels will be added
* @returns {{LayoutDto, labels: string[]}} - layout object with added labels
*/
export const addLabelsToLayout = (layout) => {
const labelsSet = new Set();
layout.tabs?.forEach((tab) => {
tab.objects?.forEach((obj) => {
if (obj.name) {
const [prefix] = obj.name.split('/');
labelsSet.add(prefix);
}
});
});
return { ...layout, labels: Array.from(labelsSet) };
};