lhcb-ntuple-wizard-test 1.0.6 → 1.0.8

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