lhcb-ntuple-wizard-test 1.1.14 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/components/ConfigDict.js +39 -38
  2. package/dist/components/ConfigList.js +33 -29
  3. package/dist/components/ConfigNode.js +135 -132
  4. package/dist/components/ConfigValue.js +22 -18
  5. package/dist/components/Dataset.js +7 -3
  6. package/dist/components/Decay.js +1 -2
  7. package/dist/components/DecayItem.js +49 -45
  8. package/dist/components/DecayTag.js +10 -7
  9. package/dist/components/DecayTree.js +153 -146
  10. package/dist/components/DecaysList.js +38 -35
  11. package/dist/components/DescriptorsSearch.js +192 -187
  12. package/dist/components/EventTypeBadge.js +9 -6
  13. package/dist/components/ItemSearch.js +15 -10
  14. package/dist/components/LinesTable.js +464 -462
  15. package/dist/components/NtupleWizard.js +32 -27
  16. package/dist/components/ParticleTag.js +10 -7
  17. package/dist/components/SearchItem.js +34 -31
  18. package/dist/components/SelectParticle.js +14 -10
  19. package/dist/components/SelectTag.js +10 -9
  20. package/dist/components/SelectTool.js +10 -9
  21. package/dist/components/SelectVariables.js +24 -22
  22. package/dist/components/StrippingBadge.js +10 -7
  23. package/dist/components/StrippingLine.js +8 -6
  24. package/dist/components/TupleTool.js +4 -3
  25. package/dist/components/VariablesSearch.js +15 -10
  26. package/dist/components/loki/LokiDict.js +184 -0
  27. package/dist/components/loki/LokiEditor.js +199 -0
  28. package/dist/components/loki/LokiForm.js +116 -0
  29. package/dist/components/semantic.js +97 -0
  30. package/dist/components/semform.js +184 -0
  31. package/dist/components/worker.js +196 -0
  32. package/dist/config.json +1 -1
  33. package/dist/contexts/MetadataContext.js +8 -7
  34. package/dist/lib/DTTConfig.js +8 -8
  35. package/package.json +25 -2
@@ -23,7 +23,11 @@ var _DeleteButton = _interopRequireDefault(require("./DeleteButton"));
23
23
  var _StrippingLine = _interopRequireDefault(require("./StrippingLine"));
24
24
  var _jsxRuntime = require("react/jsx-runtime");
25
25
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
26
- /*****************************************************************************\
26
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
27
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
28
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
29
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
30
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*****************************************************************************\
27
31
  * (c) Copyright 2021-2024 CERN for the benefit of the LHCb Collaboration *
28
32
  * *
29
33
  * This software is distributed under the terms of the GNU General Public *
@@ -33,7 +37,6 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
33
37
  * granted to it by virtue of its status as an Intergovernmental Organization *
34
38
  * or submit itself to any jurisdiction. *
35
39
  \*****************************************************************************/
36
-
37
40
  function streamLinesToOption(row) {
38
41
  let opts = {};
39
42
  let streamArr = [];
@@ -87,514 +90,512 @@ function pathToOption(path) {
87
90
  class LinesTable extends _react.default.Component {
88
91
  constructor(props) {
89
92
  super(props);
90
- this.propsVar = this.props;
91
- }
92
- componentDidMount() {
93
- const urlParams = new URLSearchParams(window.location.search);
94
- const isCloneParam = urlParams.get("clone");
95
- if (isCloneParam === "1") {
96
- if (!localStorage.getItem("yamlFilesToClone")) {
97
- window.history.replaceState({}, document.title, window.location.pathname);
98
- return;
99
- }
100
- this.setState({
101
- prodUploadLoading: true,
102
- rows: []
93
+ _defineProperty(this, "state", {
94
+ rows: this.props.rows.map(row => _objectSpread(_objectSpread({}, row), {}, {
95
+ dtt: row.dtt ? new _DTTConfig.default(row.dtt, []) : false
96
+ })),
97
+ showUploadModal: false,
98
+ showProdUploadModal: false,
99
+ prodUploadLoading: false,
100
+ modalID: -99,
101
+ productionName: this.props.name,
102
+ contactEmail: this.props.email,
103
+ reasonForRequest: this.props.reasonForRequest,
104
+ submitLocation: this.props.submitLocation,
105
+ hideDownloadButtons: this.props.hideDownloadButtons,
106
+ hideUploadButtons: this.props.hideUploadButtons,
107
+ requestLoading: false,
108
+ requestSubmitted: false,
109
+ emailIsKnown: this.props.emailIsKnown,
110
+ csrfToken: this.props.csrfToken,
111
+ showReasonForRequestModal: false,
112
+ requestReasonMessage: this.props.requestReasonMessage,
113
+ requestSubmittedMessage: this.props.requestSubmittedMessage
114
+ });
115
+ _defineProperty(this, "handleSubmitRows", history => {
116
+ let rows = [...this.state.rows];
117
+ rows.forEach(row => {
118
+ row.editTree = true;
103
119
  });
104
- let files = JSON.parse(localStorage.getItem("yamlFilesToClone"));
105
- for (let i = 0; i < files.length; i++) {
106
- if (files[i].defaults) {
107
- files[i].name = "info.yaml";
108
- }
109
- files[i].blob = new Blob([_jsYaml.default.dump(files[i])]);
110
- }
111
- this.uploadProductionConfig({
112
- target: {
113
- files
114
- }
115
- }, true);
116
- setTimeout(() => {
117
- this.uploadProductionConfig({
118
- target: {
119
- files
120
- }
121
- }, true);
122
- this.setState({
123
- prodUploadLoading: false
124
- });
125
- localStorage.removeItem("yamlFilesToClone");
126
- }, 5000);
127
- }
128
- }
129
- static contextType = (() => _MetadataContext.default)();
130
- state = (() => ({
131
- rows: this.props.rows.map(row => ({
132
- ...row,
133
- dtt: row.dtt ? new _DTTConfig.default(row.dtt, []) : false
134
- })),
135
- showUploadModal: false,
136
- showProdUploadModal: false,
137
- prodUploadLoading: false,
138
- modalID: -99,
139
- productionName: this.props.name,
140
- contactEmail: this.props.email,
141
- reasonForRequest: this.props.reasonForRequest,
142
- submitLocation: this.props.submitLocation,
143
- hideDownloadButtons: this.props.hideDownloadButtons,
144
- hideUploadButtons: this.props.hideUploadButtons,
145
- requestLoading: false,
146
- requestSubmitted: false,
147
- emailIsKnown: this.props.emailIsKnown,
148
- csrfToken: this.props.csrfToken,
149
- showReasonForRequestModal: false,
150
- requestReasonMessage: this.props.requestReasonMessage,
151
- requestSubmittedMessage: this.props.requestSubmittedMessage
152
- }))();
153
- handleSubmitRows = history => {
154
- let rows = [...this.state.rows];
155
- rows.forEach(row => {
156
- row.editTree = true;
120
+ this.props.parentCallbackRows(rows);
121
+ this.props.parentCallbackInfo(this.state.productionName, this.state.contactEmail, this.state.reasonForRequest);
122
+ history.push(this.propsVar.variablesPath);
157
123
  });
158
- this.props.parentCallbackRows(rows);
159
- this.props.parentCallbackInfo(this.state.productionName, this.state.contactEmail, this.state.reasonForRequest);
160
- history.push(this.propsVar.variablesPath);
161
- };
162
- handleSubmitSpecificRow = (history, idx) => {
163
- let rows = [...this.state.rows];
164
- rows.forEach(row => {
165
- row.editTree = row.id === idx;
124
+ _defineProperty(this, "handleSubmitSpecificRow", (history, idx) => {
125
+ let rows = [...this.state.rows];
126
+ rows.forEach(row => {
127
+ row.editTree = row.id === idx;
128
+ });
129
+ this.props.parentCallbackRows(rows);
130
+ this.props.parentCallbackInfo(this.state.productionName, this.state.contactEmail, this.state.reasonForRequest);
131
+ history.push(this.propsVar.variablesPath);
166
132
  });
167
- this.props.parentCallbackRows(rows);
168
- this.props.parentCallbackInfo(this.state.productionName, this.state.contactEmail, this.state.reasonForRequest);
169
- history.push(this.propsVar.variablesPath);
170
- };
171
- handleAddRow = history => {
172
- let rows = [...this.state.rows];
173
- this.props.parentCallbackRows(rows);
174
- this.props.parentCallbackInfo(this.state.productionName, this.state.contactEmail, this.state.reasonForRequest);
175
- history.push(this.propsVar.decaysPath);
176
- };
177
- handleRemoveSpecificRow = id => () => {
178
- let rows = [...this.state.rows];
179
- rows = rows.filter(row => row.id !== id);
180
- this.setState({
181
- rows
133
+ _defineProperty(this, "handleAddRow", history => {
134
+ let rows = [...this.state.rows];
135
+ this.props.parentCallbackRows(rows);
136
+ this.props.parentCallbackInfo(this.state.productionName, this.state.contactEmail, this.state.reasonForRequest);
137
+ history.push(this.propsVar.decaysPath);
182
138
  });
183
- this.props.parentCallbackRows(rows);
184
- };
185
- handleRemoveSpecificRowDTT = id => () => {
186
- let rows = [...this.state.rows];
187
- const index = this.state.rows.findIndex(item => item.id === id);
188
- rows[index].dtt = false;
189
- this.setState({
190
- rows
139
+ _defineProperty(this, "handleRemoveSpecificRow", id => () => {
140
+ let rows = [...this.state.rows];
141
+ rows = rows.filter(row => row.id !== id);
142
+ this.setState({
143
+ rows
144
+ });
145
+ this.props.parentCallbackRows(rows);
191
146
  });
192
- this.props.parentCallbackRows(rows);
193
- };
194
- handleCreateDTT = id => () => {
195
- let rows = [...this.state.rows];
196
- const index = this.state.rows.findIndex(item => item.id === id);
197
- rows[index].dtt = _DTTConfig.default.createDTT(rows[index].decay.descriptors.template, rows[index].decay.descriptors.mapped_list.flat(Infinity), [], "", this.context.metadata.tupleTools.tupleTools);
198
- this.setInputs(id, rows[index].lines);
199
- this.setState({
200
- rows
147
+ _defineProperty(this, "handleRemoveSpecificRowDTT", id => () => {
148
+ let rows = [...this.state.rows];
149
+ const index = this.state.rows.findIndex(item => item.id === id);
150
+ rows[index].dtt = false;
151
+ this.setState({
152
+ rows
153
+ });
154
+ this.props.parentCallbackRows(rows);
201
155
  });
202
- this.props.parentCallbackRows(rows);
203
- };
204
- validateDTTIsSetForAllRows = () => {
205
- return this.state.rows.every(row => row.dtt);
206
- };
207
- setInputs = (id, lines) => {
208
- let rows = [...this.state.rows];
209
- const index = this.state.rows.findIndex(item => item.id === id);
210
- const inputs = lines.map(_ref => {
211
- let {
212
- stream,
213
- line
214
- } = _ref;
215
- const lineLocation = String(line).replace("Stripping", "");
216
- return `/Event/${stream}/Phys/${lineLocation}/Particles`;
156
+ _defineProperty(this, "handleCreateDTT", id => () => {
157
+ let rows = [...this.state.rows];
158
+ const index = this.state.rows.findIndex(item => item.id === id);
159
+ rows[index].dtt = _DTTConfig.default.createDTT(rows[index].decay.descriptors.template, rows[index].decay.descriptors.mapped_list.flat(Infinity), [], "", this.context.metadata.tupleTools.tupleTools);
160
+ this.setInputs(id, rows[index].lines);
161
+ this.setState({
162
+ rows
163
+ });
164
+ this.props.parentCallbackRows(rows);
217
165
  });
218
- rows[index].dtt.setInputs(inputs);
219
- this.setState({
220
- rows
166
+ _defineProperty(this, "validateDTTIsSetForAllRows", () => {
167
+ return this.state.rows.every(row => row.dtt);
221
168
  });
222
- this.props.parentCallbackRows(rows);
223
- };
224
- changeSelStrLines = id => choices => {
225
- let rows = [...this.state.rows];
226
- const index = this.state.rows.findIndex(item => item.id === id); // All choices have the same value (row.id)
169
+ _defineProperty(this, "setInputs", (id, lines) => {
170
+ let rows = [...this.state.rows];
171
+ const index = this.state.rows.findIndex(item => item.id === id);
172
+ const inputs = lines.map(_ref => {
173
+ let {
174
+ stream,
175
+ line
176
+ } = _ref;
177
+ const lineLocation = String(line).replace("Stripping", "");
178
+ return "/Event/".concat(stream, "/Phys/").concat(lineLocation, "/Particles");
179
+ });
180
+ rows[index].dtt.setInputs(inputs);
181
+ this.setState({
182
+ rows
183
+ });
184
+ this.props.parentCallbackRows(rows);
185
+ });
186
+ _defineProperty(this, "changeSelStrLines", id => choices => {
187
+ let rows = [...this.state.rows];
188
+ const index = this.state.rows.findIndex(item => item.id === id); // All choices have the same value (row.id)
227
189
 
228
- if (choices.length > 1) {
229
- if (!confirm("Choosing multiple stripping lines... This can result in duplication of candidates within a given event! Are you sure you want to continue?")) {
230
- choices.pop();
190
+ if (choices.length > 1) {
191
+ if (!confirm("Choosing multiple stripping lines... This can result in duplication of candidates within a given event! Are you sure you want to continue?")) {
192
+ choices.pop();
193
+ }
194
+ }
195
+ rows[index].lines = choices.map(choice => Object({
196
+ stream: choice.group,
197
+ line: choice.value,
198
+ versions: this.state.rows[index].decay.lines[choice.group + "/" + choice.value]
199
+ }));
200
+ this.setState({
201
+ rows
202
+ });
203
+ this.pathChoiceHandler(id)(rows[index].paths.map(path => ({
204
+ value: path
205
+ })));
206
+ if (rows[index].dtt) {
207
+ this.setInputs(id, rows[index].lines);
231
208
  }
232
- }
233
- rows[index].lines = choices.map(choice => Object({
234
- stream: choice.group,
235
- line: choice.value,
236
- versions: this.state.rows[index].decay.lines[choice.group + "/" + choice.value]
237
- }));
238
- this.setState({
239
- rows
240
209
  });
241
- this.pathChoiceHandler(id)(rows[index].paths.map(path => ({
242
- value: path
243
- })));
244
- if (rows[index].dtt) {
245
- this.setInputs(id, rows[index].lines);
246
- }
247
- };
248
- validatePath = (choice, lines) => {
249
- const path = new _BKPath.default(choice);
250
- if (!path.isValid()) {
251
- return false;
252
- }
253
- return lines.every(line => {
254
- const streamName = line.stream.toLowerCase();
255
- const filename = path.getFilename().split(".")[0].toLowerCase();
256
- const matchingVersion = line.versions.some(version => path.getStrippingVersion() === version);
257
- return ["allstreams", streamName].includes(filename) && matchingVersion;
210
+ _defineProperty(this, "validatePath", (choice, lines) => {
211
+ const path = new _BKPath.default(choice);
212
+ if (!path.isValid()) {
213
+ return false;
214
+ }
215
+ return lines.every(line => {
216
+ const streamName = line.stream.toLowerCase();
217
+ const filename = path.getFilename().split(".")[0].toLowerCase();
218
+ const matchingVersion = line.versions.some(version => path.getStrippingVersion() === version);
219
+ return ["allstreams", streamName].includes(filename) && matchingVersion;
220
+ });
258
221
  });
259
- };
260
- pathChoiceHandler = id => choices => {
261
- let rows = [...this.state.rows];
262
- const index = this.state.rows.findIndex(item => item.id === id); // All choices have the same value (row.id)
263
- const validPaths = choices.filter(choice => this.validatePath(choice.value, this.state.rows[index].lines)).map(choice => choice.value);
264
- const validPathOptions = rows[index].pathOptions.filter(choice => this.validatePath(choice, this.state.rows[index].lines));
265
- rows[index].paths = validPaths;
266
- rows[index].pathOptions = validPathOptions;
267
- this.setState({
268
- rows
222
+ _defineProperty(this, "pathChoiceHandler", id => choices => {
223
+ let rows = [...this.state.rows];
224
+ const index = this.state.rows.findIndex(item => item.id === id); // All choices have the same value (row.id)
225
+ const validPaths = choices.filter(choice => this.validatePath(choice.value, this.state.rows[index].lines)).map(choice => choice.value);
226
+ const validPathOptions = rows[index].pathOptions.filter(choice => this.validatePath(choice, this.state.rows[index].lines));
227
+ rows[index].paths = validPaths;
228
+ rows[index].pathOptions = validPathOptions;
229
+ this.setState({
230
+ rows
231
+ });
232
+ this.props.parentCallbackRows(rows);
269
233
  });
270
- this.props.parentCallbackRows(rows);
271
- };
272
- pathCreateHandler = id => choice => {
273
- let rows = [...this.state.rows];
274
- const index = this.state.rows.findIndex(item => item.id === id); // All choices have the same value (row.id)
275
- if (this.validatePath(choice.value, this.state.rows[index].lines)) {
276
- rows[index].paths.push(choice.value);
277
- rows[index].pathOptions.push(choice.value);
278
- }
279
- this.setState({
280
- rows
234
+ _defineProperty(this, "pathCreateHandler", id => choice => {
235
+ let rows = [...this.state.rows];
236
+ const index = this.state.rows.findIndex(item => item.id === id); // All choices have the same value (row.id)
237
+ if (this.validatePath(choice.value, this.state.rows[index].lines)) {
238
+ rows[index].paths.push(choice.value);
239
+ rows[index].pathOptions.push(choice.value);
240
+ }
241
+ this.setState({
242
+ rows
243
+ });
281
244
  });
282
- };
283
- setRowName = id => _ref2 => {
284
- let {
285
- target
286
- } = _ref2;
287
- let rows = [...this.state.rows];
288
- const index = this.state.rows.findIndex(item => item.id === id);
289
- rows[index].dtt.setName(target.value);
290
- this.setState({
291
- rows
245
+ _defineProperty(this, "setRowName", id => _ref2 => {
246
+ let {
247
+ target
248
+ } = _ref2;
249
+ let rows = [...this.state.rows];
250
+ const index = this.state.rows.findIndex(item => item.id === id);
251
+ rows[index].dtt.setName(target.value);
252
+ this.setState({
253
+ rows
254
+ });
255
+ this.props.parentCallbackRows(rows);
292
256
  });
293
- this.props.parentCallbackRows(rows);
294
- };
295
- setProductionName = _ref3 => {
296
- let {
297
- target
298
- } = _ref3;
299
- const safeName = target.value.replaceAll(/[^\w]/g, "");
300
- this.setState({
301
- productionName: safeName
257
+ _defineProperty(this, "setProductionName", _ref3 => {
258
+ let {
259
+ target
260
+ } = _ref3;
261
+ const safeName = target.value.replaceAll(/[^\w]/g, "");
262
+ this.setState({
263
+ productionName: safeName
264
+ });
265
+ this.props.parentCallbackInfo(safeName, this.state.contactEmail, this.state.reasonForRequest);
302
266
  });
303
- this.props.parentCallbackInfo(safeName, this.state.contactEmail, this.state.reasonForRequest);
304
- };
305
- setContactEmail = _ref4 => {
306
- let {
307
- target
308
- } = _ref4;
309
- const emails = target.value.split(/[\s,]+/);
310
- this.setState({
311
- contactEmail: emails
267
+ _defineProperty(this, "setContactEmail", _ref4 => {
268
+ let {
269
+ target
270
+ } = _ref4;
271
+ const emails = target.value.split(/[\s,]+/);
272
+ this.setState({
273
+ contactEmail: emails
274
+ });
275
+ const validEmails = emails.filter(email => _emailValidator.default.validate(email));
276
+ this.props.parentCallbackInfo(this.state.productionName, validEmails, this.state.reasonForRequest);
312
277
  });
313
- const validEmails = emails.filter(email => _emailValidator.default.validate(email));
314
- this.props.parentCallbackInfo(this.state.productionName, validEmails, this.state.reasonForRequest);
315
- };
316
- setReasonForRequest = _ref5 => {
317
- let {
318
- target
319
- } = _ref5;
320
- const reasonForRequest = target.value;
321
- this.setState({
322
- reasonForRequest: reasonForRequest
278
+ _defineProperty(this, "setReasonForRequest", _ref5 => {
279
+ let {
280
+ target
281
+ } = _ref5;
282
+ const reasonForRequest = target.value;
283
+ this.setState({
284
+ reasonForRequest: reasonForRequest
285
+ });
286
+ this.props.parentCallbackInfo(this.state.productionName, this.state.contactEmail, reasonForRequest);
323
287
  });
324
- this.props.parentCallbackInfo(this.state.productionName, this.state.contactEmail, reasonForRequest);
325
- };
326
- clearAll = () => {
327
- this.setState({
328
- productionName: "",
329
- contactEmail: [],
330
- rows: [],
331
- reasonForRequest: ""
288
+ _defineProperty(this, "clearAll", () => {
289
+ this.setState({
290
+ productionName: "",
291
+ contactEmail: [],
292
+ rows: [],
293
+ reasonForRequest: ""
294
+ });
295
+ this.props.parentCallbackRows([]);
296
+ this.props.parentCallbackInfo("", [], "");
332
297
  });
333
- this.props.parentCallbackRows([]);
334
- this.props.parentCallbackInfo("", [], "");
335
- };
336
- getBKPaths = id => {
337
- const index = this.state.rows.findIndex(item => item.id === id);
338
- const row = this.state.rows[index];
339
- const options = row.paths.map(path => pathToOption(path));
340
- return options;
341
- };
342
- defaultBKPaths = id => {
343
- const index = this.state.rows.findIndex(item => item.id === id);
344
- const row = this.state.rows[index];
345
- const defaultOptions = this.context.loaded.dataset ? this.context.metadata.dataset.filter(path => this.validatePath(path, row.lines)).map(path => pathToOption(path)) : [];
346
- const options = row.pathOptions.map(path => pathToOption(path));
347
- return [].concat(defaultOptions, options);
348
- };
349
- createInfoYaml = () => {
350
- const rows = [...this.state.rows];
351
- const uniquePaths = new Set([].concat(...rows.map(row => row.paths)));
352
- let email = this.state.contactEmail;
353
- if (this.state.emailIsKnown) {
354
- email = [localStorage.getItem("email")] || [];
355
- }
356
- const uniquePathList = [...uniquePaths].sort();
357
- let info = {
358
- defaults: {
359
- application: "DaVinci/" + this.context.metadata.tupleTools.applicationInfo["DaVinci"],
360
- wg: "OpenData",
361
- // TODO: get input from (LHCb) user. keep "OpenData" if open data
362
- automatically_configure: true,
363
- inform: email,
364
- output: "DVNtuple.root" // Probably okay to leave this as the default
298
+ _defineProperty(this, "getBKPaths", id => {
299
+ const index = this.state.rows.findIndex(item => item.id === id);
300
+ const row = this.state.rows[index];
301
+ const options = row.paths.map(path => pathToOption(path));
302
+ return options;
303
+ });
304
+ _defineProperty(this, "defaultBKPaths", id => {
305
+ const index = this.state.rows.findIndex(item => item.id === id);
306
+ const row = this.state.rows[index];
307
+ const defaultOptions = this.context.loaded.dataset ? this.context.metadata.dataset.filter(path => this.validatePath(path, row.lines)).map(path => pathToOption(path)) : [];
308
+ const options = row.pathOptions.map(path => pathToOption(path));
309
+ return [].concat(defaultOptions, options);
310
+ });
311
+ _defineProperty(this, "createInfoYaml", () => {
312
+ const rows = [...this.state.rows];
313
+ const uniquePaths = new Set([].concat(...rows.map(row => row.paths)));
314
+ let email = this.state.contactEmail;
315
+ if (this.state.emailIsKnown) {
316
+ email = [localStorage.getItem("email")] || [];
365
317
  }
366
- };
367
- rows.forEach(row => {
368
- row.paths.forEach((path, _index) => {
369
- const jobID = uniquePathList.findIndex(otherPath => otherPath === path);
370
- const key = `job${jobID}`;
371
- const dttFile = row.dtt.getSafeName();
372
- if (key in info) {
373
- info[key].options.push(dttFile);
374
- } else {
375
- info[key] = {
376
- input: {
377
- bk_query: path
378
- },
379
- options: [dttFile] // TODO: figure out the actual syntax that AnaProd needs to indicate that this is to be parsed into a DecayTreeTuple
380
- };
381
- if (path.includes("MDST")) {
382
- const stream = row.lines[0].stream; // XXX: in the validation we enforce that each BK location be compatible with every line, so effectively forcing one stream per row
383
- info[key].root_in_tes = `/Event/${stream}`;
384
- }
318
+ const uniquePathList = [...uniquePaths].sort();
319
+ let info = {
320
+ defaults: {
321
+ application: "DaVinci/" + this.context.metadata.tupleTools.applicationInfo["DaVinci"],
322
+ wg: "OpenData",
323
+ // TODO: get input from (LHCb) user. keep "OpenData" if open data
324
+ automatically_configure: true,
325
+ inform: email,
326
+ output: "DVNtuple.root" // Probably okay to leave this as the default
385
327
  }
328
+ };
329
+ rows.forEach(row => {
330
+ row.paths.forEach((path, _index) => {
331
+ const jobID = uniquePathList.findIndex(otherPath => otherPath === path);
332
+ const key = "job".concat(jobID);
333
+ const dttFile = row.dtt.getSafeName();
334
+ if (key in info) {
335
+ info[key].options.push(dttFile);
336
+ } else {
337
+ info[key] = {
338
+ input: {
339
+ bk_query: path
340
+ },
341
+ options: [dttFile] // TODO: figure out the actual syntax that AnaProd needs to indicate that this is to be parsed into a DecayTreeTuple
342
+ };
343
+ if (path.includes("MDST")) {
344
+ const stream = row.lines[0].stream; // XXX: in the validation we enforce that each BK location be compatible with every line, so effectively forcing one stream per row
345
+ info[key].root_in_tes = "/Event/".concat(stream);
346
+ }
347
+ }
348
+ });
386
349
  });
350
+ return info;
387
351
  });
388
- return info;
389
- };
390
- uploadConfig = (e, id) => {
391
- let rows = [...this.state.rows];
392
- const index = this.state.rows.findIndex(item => item.id === id);
393
- e.preventDefault();
394
- const reader = new FileReader();
395
- reader.onload = async e => {
396
- const text = e.target.result;
397
- const config = _jsYaml.default.load(text);
398
- if (config.descriptorTemplate === rows[index].decay.descriptors.template) {
399
- rows[index].dtt = new _DTTConfig.default(config, []);
400
- this.setInputs(id, rows[index].lines);
401
- this.setState({
402
- rows,
403
- showUploadModal: false
404
- });
405
- this.props.parentCallbackRows(rows);
406
- } else {
407
- alert("Make sure to upload a previously downloaded configuration file for the same decay.");
408
- }
409
- };
410
- reader.readAsText(e.target.files[0]);
411
- };
412
- uploadProductionConfig = async (e, isClone) => {
413
- let rows = [];
414
- let decays = Object.values(this.context.metadata.decays);
415
- let email = [];
416
- //let descriptorTemplates = decays.descriptors.template
417
-
418
- let filelist = e.target.files || [];
419
- let files = [].slice.call(filelist);
420
- if (files.length) {
421
- for (let index = 0; index < files.length; index++) {
422
- if (files[index].name === "info.yaml") {
423
- files.push(files.splice(index, 1)[0]);
424
- break;
425
- }
426
- }
427
- for (let index = 0; index < files.length; index++) {
428
- let text;
429
- if (isClone) {
430
- text = await this.readFileAsync(files[index].blob);
431
- } else {
432
- text = await this.readFileAsync(files[index]);
433
- }
352
+ _defineProperty(this, "uploadConfig", (e, id) => {
353
+ let rows = [...this.state.rows];
354
+ const index = this.state.rows.findIndex(item => item.id === id);
355
+ e.preventDefault();
356
+ const reader = new FileReader();
357
+ reader.onload = async e => {
358
+ const text = e.target.result;
434
359
  const config = _jsYaml.default.load(text);
435
- if (files[index].name !== "info.yaml") {
436
- decays.forEach(decay => {
437
- if (config.descriptorTemplate === decay.descriptors.template) {
438
- let row = Object({
439
- id: index,
440
- decay: decay,
441
- lines: config.inputs.map(input => Object({
442
- stream: input.split("/")[2],
443
- line: "Stripping" + input.split("/")[4],
444
- versions: decay.lines[input.split("/")[2] + "/" + "Stripping" + input.split("/")[4]]
445
- })),
446
- paths: [],
447
- // Currently-selected paths
448
- pathOptions: [],
449
- // Keep a history of valid paths
450
- dtt: new _DTTConfig.default(config, [])
451
- });
452
- rows.push(row);
453
- }
360
+ if (config.descriptorTemplate === rows[index].decay.descriptors.template) {
361
+ rows[index].dtt = new _DTTConfig.default(config, []);
362
+ this.setInputs(id, rows[index].lines);
363
+ this.setState({
364
+ rows,
365
+ showUploadModal: false
454
366
  });
367
+ this.props.parentCallbackRows(rows);
455
368
  } else {
456
- email.push(config.defaults.inform[0]);
457
- rows.forEach(row => {
458
- Object.keys(config).forEach(job => {
459
- if (job !== "defaults" && job !== "name" && job !== "blob") {
460
- config[job].options.forEach(option => {
461
- let optionName = option.split(".")[0];
462
- let dttname = row.dtt.config.name.split("/")[1];
463
- if (optionName === dttname) {
464
- row.paths.push(config[job].input.bk_query);
465
- }
369
+ alert("Make sure to upload a previously downloaded configuration file for the same decay.");
370
+ }
371
+ };
372
+ reader.readAsText(e.target.files[0]);
373
+ });
374
+ _defineProperty(this, "uploadProductionConfig", async (e, isClone) => {
375
+ let rows = [];
376
+ let decays = Object.values(this.context.metadata.decays);
377
+ let email = [];
378
+ //let descriptorTemplates = decays.descriptors.template
379
+
380
+ let filelist = e.target.files || [];
381
+ let files = [].slice.call(filelist);
382
+ if (files.length) {
383
+ for (let index = 0; index < files.length; index++) {
384
+ if (files[index].name === "info.yaml") {
385
+ files.push(files.splice(index, 1)[0]);
386
+ break;
387
+ }
388
+ }
389
+ for (let index = 0; index < files.length; index++) {
390
+ let text;
391
+ if (isClone) {
392
+ text = await this.readFileAsync(files[index].blob);
393
+ } else {
394
+ text = await this.readFileAsync(files[index]);
395
+ }
396
+ const config = _jsYaml.default.load(text);
397
+ if (files[index].name !== "info.yaml") {
398
+ decays.forEach(decay => {
399
+ if (config.descriptorTemplate === decay.descriptors.template) {
400
+ let row = Object({
401
+ id: index,
402
+ decay: decay,
403
+ lines: config.inputs.map(input => Object({
404
+ stream: input.split("/")[2],
405
+ line: "Stripping" + input.split("/")[4],
406
+ versions: decay.lines[input.split("/")[2] + "/" + "Stripping" + input.split("/")[4]]
407
+ })),
408
+ paths: [],
409
+ // Currently-selected paths
410
+ pathOptions: [],
411
+ // Keep a history of valid paths
412
+ dtt: new _DTTConfig.default(config, [])
466
413
  });
414
+ rows.push(row);
467
415
  }
468
416
  });
469
- });
417
+ } else {
418
+ email.push(config.defaults.inform[0]);
419
+ rows.forEach(row => {
420
+ Object.keys(config).forEach(job => {
421
+ if (job !== "defaults" && job !== "name" && job !== "blob") {
422
+ config[job].options.forEach(option => {
423
+ let optionName = option.split(".")[0];
424
+ let dttname = row.dtt.config.name.split("/")[1];
425
+ if (optionName === dttname) {
426
+ row.paths.push(config[job].input.bk_query);
427
+ }
428
+ });
429
+ }
430
+ });
431
+ });
432
+ }
470
433
  }
471
434
  }
472
- }
473
- this.setState({
474
- rows: rows
475
- });
476
- if (!isClone) {
477
435
  this.setState({
478
- contactEmail: email
436
+ rows: rows
479
437
  });
480
- }
481
- this.props.parentCallbackRows(rows);
482
- this.props.parentCallbackInfo(this.state.productionName, this.state.contactEmail, this.state.reasonForRequest);
483
- // this.handleCloseProdUploadModal();
484
- };
485
- readFileAsync = file => {
486
- return new Promise((resolve, reject) => {
487
- const reader = new FileReader();
488
- reader.onload = function () {
489
- resolve(reader.result);
490
- };
491
- reader.onerror = function (error) {
492
- reject(error);
493
- };
494
- reader.readAsText(file);
495
- });
496
- };
497
- handleShowUploadModal = id => {
498
- this.setState({
499
- showUploadModal: true,
500
- modalID: id
438
+ if (!isClone) {
439
+ this.setState({
440
+ contactEmail: email
441
+ });
442
+ }
443
+ this.props.parentCallbackRows(rows);
444
+ this.props.parentCallbackInfo(this.state.productionName, this.state.contactEmail, this.state.reasonForRequest);
445
+ // this.handleCloseProdUploadModal();
501
446
  });
502
- };
503
- handleCloseUploadModal = () => {
504
- this.setState({
505
- showUploadModal: false
447
+ _defineProperty(this, "readFileAsync", file => {
448
+ return new Promise((resolve, reject) => {
449
+ const reader = new FileReader();
450
+ reader.onload = function () {
451
+ resolve(reader.result);
452
+ };
453
+ reader.onerror = function (error) {
454
+ reject(error);
455
+ };
456
+ reader.readAsText(file);
457
+ });
506
458
  });
507
- };
508
- handleShowProdUploadModal = () => {
509
- this.setState({
510
- showProdUploadModal: true
459
+ _defineProperty(this, "handleShowUploadModal", id => {
460
+ this.setState({
461
+ showUploadModal: true,
462
+ modalID: id
463
+ });
511
464
  });
512
- };
513
- handleCloseProdUploadModal = () => {
514
- this.setState({
515
- showProdUploadModal: false
465
+ _defineProperty(this, "handleCloseUploadModal", () => {
466
+ this.setState({
467
+ showUploadModal: false
468
+ });
516
469
  });
517
- };
518
- processSubmission = () => {
519
- if (this.state.submitLocation) {
470
+ _defineProperty(this, "handleShowProdUploadModal", () => {
520
471
  this.setState({
521
- showReasonForRequestModal: true
472
+ showProdUploadModal: true
522
473
  });
523
- } else {
524
- this.downloadAll();
525
- }
526
- };
527
- downloadAll = () => {
528
- const allFiles = this.generateAllFiles();
529
- return (0, _utils.downloadZip)(allFiles, `${this.state.productionName}.zip`);
530
- };
531
- generateAllFiles = () => {
532
- return [...this.state.rows.map(row => [`${row.dtt.getSafeName()}.yaml`, _jsYaml.default.dump(row.dtt.config)]), ["info.yaml", _jsYaml.default.dump(this.createInfoYaml())]];
533
- };
534
- submitRequest = url => {
535
- this.setState({
536
- requestLoading: true,
537
- showReasonForRequestModal: false,
538
- requestError: "",
539
- requestSubmitted: false
540
474
  });
541
- const allFiles = this.generateAllFiles();
542
- const formData = new FormData();
543
- allFiles.forEach(file => {
544
- formData.append("generatedFiles[]", new Blob([file[1]], {
545
- type: "text/plain"
546
- }), file[0]);
475
+ _defineProperty(this, "handleCloseProdUploadModal", () => {
476
+ this.setState({
477
+ showProdUploadModal: false
478
+ });
547
479
  });
548
- formData.append("email", localStorage.getItem("email") || "");
549
- formData.append("name", this.state.productionName);
550
- formData.append("reasonForRequest", this.state.reasonForRequest);
551
- let headers = {};
552
- if (this.state.csrfToken !== "") {
553
- headers = {
554
- "X-Csrf-Token": this.state.csrfToken
555
- };
556
- }
557
- fetch(url, {
558
- method: "POST",
559
- body: formData,
560
- credentials: "include",
561
- headers: headers
562
- }).then(response => {
563
- if (!response.ok) {
564
- throw new Error(`HTTP error! Status: ${response.status}`);
480
+ _defineProperty(this, "processSubmission", () => {
481
+ if (this.state.submitLocation) {
482
+ this.setState({
483
+ showReasonForRequestModal: true
484
+ });
485
+ } else {
486
+ this.downloadAll();
565
487
  }
488
+ });
489
+ _defineProperty(this, "downloadAll", () => {
490
+ const allFiles = this.generateAllFiles();
491
+ return (0, _utils.downloadZip)(allFiles, "".concat(this.state.productionName, ".zip"));
492
+ });
493
+ _defineProperty(this, "generateAllFiles", () => {
494
+ return [...this.state.rows.map(row => ["".concat(row.dtt.getSafeName(), ".yaml"), _jsYaml.default.dump(row.dtt.config)]), ["info.yaml", _jsYaml.default.dump(this.createInfoYaml())]];
495
+ });
496
+ _defineProperty(this, "submitRequest", url => {
566
497
  this.setState({
567
- requestLoading: false,
568
- requestSubmitted: true
498
+ requestLoading: true,
499
+ showReasonForRequestModal: false,
500
+ requestError: "",
501
+ requestSubmitted: false
569
502
  });
570
- }).catch(error => {
571
- console.error("Fetch error:", error);
572
- this.setState({
573
- requestLoading: false,
574
- requestError: "Something went wrong while submitting your request. Please try again later or contact support."
503
+ const allFiles = this.generateAllFiles();
504
+ const formData = new FormData();
505
+ allFiles.forEach(file => {
506
+ formData.append("generatedFiles[]", new Blob([file[1]], {
507
+ type: "text/plain"
508
+ }), file[0]);
509
+ });
510
+ formData.append("email", localStorage.getItem("email") || "");
511
+ formData.append("name", this.state.productionName);
512
+ formData.append("reasonForRequest", this.state.reasonForRequest);
513
+ let headers = {};
514
+ if (this.state.csrfToken !== "") {
515
+ headers = {
516
+ "X-Csrf-Token": this.state.csrfToken
517
+ };
518
+ }
519
+ fetch(url, {
520
+ method: "POST",
521
+ body: formData,
522
+ credentials: "include",
523
+ headers: headers
524
+ }).then(response => {
525
+ if (!response.ok) {
526
+ throw new Error("HTTP error! Status: ".concat(response.status));
527
+ }
528
+ this.setState({
529
+ requestLoading: false,
530
+ requestSubmitted: true
531
+ });
532
+ }).catch(error => {
533
+ console.error("Fetch error:", error);
534
+ this.setState({
535
+ requestLoading: false,
536
+ requestError: "Something went wrong while submitting your request. Please try again later or contact support."
537
+ });
575
538
  });
576
539
  });
577
- };
578
- handleShowReasonForRequestModal = () => {
579
- this.setState({
580
- showReasonForRequestModal: true
540
+ _defineProperty(this, "handleShowReasonForRequestModal", () => {
541
+ this.setState({
542
+ showReasonForRequestModal: true
543
+ });
581
544
  });
582
- };
583
- handleCloseReasonForRequestModal = () => {
584
- this.setState({
585
- showReasonForRequestModal: false
545
+ _defineProperty(this, "handleCloseReasonForRequestModal", () => {
546
+ this.setState({
547
+ showReasonForRequestModal: false
548
+ });
586
549
  });
587
- };
588
- dismissSubmitSuccess = () => {
589
- this.setState({
590
- requestSubmitted: false
550
+ _defineProperty(this, "dismissSubmitSuccess", () => {
551
+ this.setState({
552
+ requestSubmitted: false
553
+ });
591
554
  });
592
- };
593
- dismissSubmitError = () => {
594
- this.setState({
595
- requestError: ""
555
+ _defineProperty(this, "dismissSubmitError", () => {
556
+ this.setState({
557
+ requestError: ""
558
+ });
596
559
  });
597
- };
560
+ this.propsVar = this.props;
561
+ }
562
+ componentDidMount() {
563
+ const urlParams = new URLSearchParams(window.location.search);
564
+ const isCloneParam = urlParams.get("clone");
565
+ if (isCloneParam === "1") {
566
+ if (!localStorage.getItem("yamlFilesToClone")) {
567
+ window.history.replaceState({}, document.title, window.location.pathname);
568
+ return;
569
+ }
570
+ this.setState({
571
+ prodUploadLoading: true,
572
+ rows: []
573
+ });
574
+ let files = JSON.parse(localStorage.getItem("yamlFilesToClone"));
575
+ for (let i = 0; i < files.length; i++) {
576
+ if (files[i].defaults) {
577
+ files[i].name = "info.yaml";
578
+ }
579
+ files[i].blob = new Blob([_jsYaml.default.dump(files[i])]);
580
+ }
581
+ this.uploadProductionConfig({
582
+ target: {
583
+ files
584
+ }
585
+ }, true);
586
+ setTimeout(() => {
587
+ this.uploadProductionConfig({
588
+ target: {
589
+ files
590
+ }
591
+ }, true);
592
+ this.setState({
593
+ prodUploadLoading: false
594
+ });
595
+ localStorage.removeItem("yamlFilesToClone");
596
+ }, 5000);
597
+ }
598
+ }
598
599
  render() {
599
600
  const emptySession = !this.state.productionName && this.state.contactEmail.length === 0 && this.state.rows.length === 0;
600
601
  const validEmail = this.state.contactEmail.length > 0 && this.state.contactEmail.every(email => _emailValidator.default.validate(email));
@@ -617,7 +618,7 @@ class LinesTable extends _react.default.Component {
617
618
  stream: strline.stream,
618
619
  versions: strline.versions,
619
620
  showlink: true
620
- }, `${strline.line}`));
621
+ }, "".concat(strline.line)));
621
622
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactBootstrap.Row, {
622
623
  className: "align-items-center",
623
624
  style: {
@@ -670,7 +671,7 @@ class LinesTable extends _react.default.Component {
670
671
  className: "ms-auto",
671
672
  type: "button",
672
673
  onClick: () => {
673
- (0, _utils.download)(_jsYaml.default.dump(row.dtt.config), `${row.dtt.getSafeName()}.yaml`);
674
+ (0, _utils.download)(_jsYaml.default.dump(row.dtt.config), "".concat(row.dtt.getSafeName(), ".yaml"));
674
675
  },
675
676
  disabled: !hasValidName,
676
677
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrapIcons.Download, {})
@@ -1087,6 +1088,7 @@ class LinesTable extends _react.default.Component {
1087
1088
  });
1088
1089
  }
1089
1090
  }
1091
+ _defineProperty(LinesTable, "contextType", _MetadataContext.default);
1090
1092
  LinesTable.propTypes = {
1091
1093
  rows: _propTypes.default.arrayOf(_propTypes.default.object),
1092
1094
  name: _propTypes.default.string,