lhcb-ntuple-wizard-test 1.3.3 → 2.0.1
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.
- package/README.md +1 -2
- package/dist/App.d.ts +12 -0
- package/dist/App.js +22 -0
- package/dist/components/ConfigFilesUploadingAlert.d.ts +1 -0
- package/dist/components/ConfigFilesUploadingAlert.js +5 -0
- package/dist/components/DatasetEventTypeBadge.d.ts +5 -0
- package/dist/components/DatasetEventTypeBadge.js +23 -0
- package/dist/components/DatasetInfo.d.ts +5 -0
- package/dist/components/DatasetInfo.js +21 -0
- package/dist/components/DecayLatex.d.ts +7 -0
- package/dist/components/DecayLatex.js +103 -0
- package/dist/components/DecayList.d.ts +8 -0
- package/dist/components/DecayList.js +37 -0
- package/dist/components/DecayListItem.d.ts +11 -0
- package/dist/components/DecayListItem.js +23 -0
- package/dist/components/DecayTagBadge.d.ts +5 -0
- package/dist/components/DecayTagBadge.js +21 -0
- package/dist/components/DecayTreeCard.d.ts +7 -0
- package/dist/components/DecayTreeCard.js +43 -0
- package/dist/components/DecayTreeCardHeader.d.ts +7 -0
- package/dist/components/DecayTreeCardHeader.js +5 -0
- package/dist/components/DecayTreeGraph.d.ts +9 -0
- package/dist/components/DecayTreeGraph.js +89 -0
- package/dist/components/DeleteButton.d.ts +9 -0
- package/dist/components/DeleteButton.js +16 -53
- package/dist/components/DttNameInput.d.ts +9 -0
- package/dist/components/DttNameInput.js +73 -0
- package/dist/components/LineTableRow.d.ts +9 -0
- package/dist/components/LineTableRow.js +123 -0
- package/dist/components/LoadingIndicator.d.ts +6 -0
- package/dist/components/LoadingIndicator.js +5 -0
- package/dist/components/NtupleWizard.d.ts +26 -0
- package/dist/components/NtupleWizard.js +28 -137
- package/dist/components/NumStrippingLinesBadge.d.ts +8 -0
- package/dist/components/NumStrippingLinesBadge.js +10 -0
- package/dist/components/ParticleDropdown.d.ts +8 -0
- package/dist/components/ParticleDropdown.js +33 -0
- package/dist/components/ParticleTagBadge.d.ts +9 -0
- package/dist/components/ParticleTagBadge.js +22 -0
- package/dist/components/ParticleTagFilters.d.ts +6 -0
- package/dist/components/ParticleTagFilters.js +51 -0
- package/dist/components/PolarityBadge.d.ts +5 -0
- package/dist/components/PolarityBadge.js +13 -33
- package/dist/components/StrippingLineBadge.d.ts +7 -0
- package/dist/components/StrippingLineBadge.js +29 -0
- package/dist/components/StrippingLineInfo.d.ts +8 -0
- package/dist/components/StrippingLineInfo.js +17 -0
- package/dist/components/SubmitRequestButton.d.ts +11 -0
- package/dist/components/SubmitRequestButton.js +39 -0
- package/dist/components/TagDropdown.d.ts +12 -0
- package/dist/components/TagDropdown.js +31 -0
- package/dist/components/TupleToolDocsAccordion.d.ts +5 -0
- package/dist/components/TupleToolDocsAccordion.js +14 -0
- package/dist/components/TupleToolDropdown.d.ts +21 -0
- package/dist/components/TupleToolDropdown.js +29 -0
- package/dist/components/TupleToolGroup.d.ts +6 -0
- package/dist/components/TupleToolGroup.js +22 -0
- package/dist/components/TupleToolLabel.d.ts +6 -0
- package/dist/components/TupleToolLabel.js +20 -0
- package/dist/components/TupleToolList.d.ts +7 -0
- package/dist/components/TupleToolList.js +38 -0
- package/dist/components/YearBadge.d.ts +5 -0
- package/dist/components/YearBadge.js +13 -33
- package/dist/components/modals/AddTupleToolModal.d.ts +7 -0
- package/dist/components/modals/AddTupleToolModal.js +32 -0
- package/dist/components/modals/ConfigureTupleToolModal.d.ts +8 -0
- package/dist/components/modals/ConfigureTupleToolModal.js +43 -0
- package/dist/components/modals/ReasonForRequestModal.d.ts +8 -0
- package/dist/components/modals/ReasonForRequestModal.js +49 -0
- package/dist/components/modals/UploadDttConfigModal.d.ts +7 -0
- package/dist/components/modals/UploadDttConfigModal.js +35 -0
- package/dist/components/modals/UploadProdConfigModal.d.ts +5 -0
- package/dist/components/modals/UploadProdConfigModal.js +27 -0
- package/dist/components/tupleToolParams/BoolParamInput.d.ts +16 -0
- package/dist/components/tupleToolParams/BoolParamInput.js +15 -0
- package/dist/components/tupleToolParams/DictParamInput.d.ts +14 -0
- package/dist/components/tupleToolParams/DictParamInput.js +31 -0
- package/dist/components/tupleToolParams/ListParamInput.d.ts +14 -0
- package/dist/components/tupleToolParams/ListParamInput.js +46 -0
- package/dist/components/tupleToolParams/NumParamInput.d.ts +18 -0
- package/dist/components/tupleToolParams/NumParamInput.js +25 -0
- package/dist/components/tupleToolParams/StrParamInput.d.ts +19 -0
- package/dist/components/tupleToolParams/StrParamInput.js +22 -0
- package/dist/config.d.ts +78 -0
- package/dist/config.js +72 -0
- package/dist/{style/DecaysList.css → index.d.ts} +2 -6
- package/dist/index.js +2 -11
- package/dist/models/bkPath.d.ts +11 -0
- package/dist/models/bkPath.js +40 -0
- package/dist/models/blobFile.d.ts +12 -0
- package/dist/models/blobFile.js +1 -0
- package/dist/models/decayData.d.ts +15 -0
- package/dist/models/decayData.js +1 -0
- package/dist/models/dropdownOption.d.ts +5 -0
- package/dist/models/dropdownOption.js +1 -0
- package/dist/models/dtt.d.ts +108 -0
- package/dist/models/dtt.js +149 -0
- package/dist/models/jobConfig.d.ts +7 -0
- package/dist/models/jobConfig.js +1 -0
- package/dist/models/particle.d.ts +12 -0
- package/dist/models/particle.js +1 -0
- package/dist/models/particleTag.d.ts +4 -0
- package/dist/models/particleTag.js +1 -0
- package/dist/models/rowData.d.ts +15 -0
- package/dist/models/rowData.js +1 -0
- package/dist/models/strippingLine.d.ts +5 -0
- package/dist/models/strippingLine.js +1 -0
- package/dist/models/strippingLineOption.d.ts +6 -0
- package/dist/models/strippingLineOption.js +1 -0
- package/dist/models/tupleTool.d.ts +8 -0
- package/dist/models/tupleTool.js +18 -0
- package/dist/models/tupleTreeGraphData.d.ts +20 -0
- package/dist/models/tupleTreeGraphData.js +1 -0
- package/dist/models/yamlFile.d.ts +11 -0
- package/dist/models/yamlFile.js +78 -0
- package/dist/pages/DecaySearchPage.d.ts +5 -0
- package/dist/pages/DecaySearchPage.js +197 -0
- package/dist/pages/DecayTreeConfigPage.d.ts +5 -0
- package/dist/pages/DecayTreeConfigPage.js +63 -0
- package/dist/pages/LinesTablePage.d.ts +14 -0
- package/dist/pages/LinesTablePage.js +120 -0
- package/dist/providers/DttProvider.d.ts +24 -0
- package/dist/providers/DttProvider.js +77 -0
- package/dist/providers/MetadataProvider.d.ts +87 -0
- package/dist/providers/MetadataProvider.js +50 -0
- package/dist/providers/ProductionConfigProvider.d.ts +14 -0
- package/dist/providers/ProductionConfigProvider.js +76 -0
- package/dist/providers/RequestProvider.d.ts +15 -0
- package/dist/providers/RequestProvider.js +35 -0
- package/dist/providers/RowsProvider.d.ts +14 -0
- package/dist/providers/RowsProvider.js +31 -0
- package/dist/utils/mathjaxUtils.d.ts +12 -0
- package/dist/utils/mathjaxUtils.js +24 -0
- package/dist/utils/utils.d.ts +31 -0
- package/dist/utils/utils.js +80 -0
- package/package.json +43 -21
- package/dist/components/App.js +0 -99
- package/dist/components/ConfigDict.js +0 -103
- package/dist/components/ConfigList.js +0 -94
- package/dist/components/ConfigNode.js +0 -320
- package/dist/components/ConfigValue.js +0 -86
- package/dist/components/Dataset.js +0 -67
- package/dist/components/Decay.js +0 -50
- package/dist/components/DecayItem.js +0 -101
- package/dist/components/DecayTag.js +0 -52
- package/dist/components/DecayTree.js +0 -451
- package/dist/components/DecaysList.js +0 -107
- package/dist/components/DescriptorsSearch.js +0 -352
- package/dist/components/EventTypeBadge.js +0 -45
- package/dist/components/ItemSearch.js +0 -120
- package/dist/components/LinesTable.js +0 -1105
- package/dist/components/ParticleTag.js +0 -54
- package/dist/components/SearchItem.js +0 -99
- package/dist/components/SelectParticle.js +0 -61
- package/dist/components/SelectTag.js +0 -66
- package/dist/components/SelectTool.js +0 -59
- package/dist/components/SelectVariables.js +0 -106
- package/dist/components/StrippingBadge.js +0 -64
- package/dist/components/StrippingLine.js +0 -50
- package/dist/components/TupleTool.js +0 -46
- package/dist/components/VariablesSearch.js +0 -128
- package/dist/config.json +0 -72
- package/dist/contexts/MetadataContext.js +0 -135
- package/dist/lib/BKPath.js +0 -58
- package/dist/lib/DTTConfig.js +0 -178
- package/dist/lib/mathjax.js +0 -35
- package/dist/lib/utils.js +0 -191
|
@@ -1,35 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var _reactBootstrap = require("react-bootstrap");
|
|
10
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
2
|
/*****************************************************************************\
|
|
13
|
-
* (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
|
|
14
|
-
* *
|
|
15
|
-
* This software is distributed under the terms of the GNU General Public *
|
|
16
|
-
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
|
|
17
|
-
* *
|
|
18
|
-
* In applying this licence, CERN does not waive the privileges and immunities *
|
|
19
|
-
* granted to it by virtue of its status as an Intergovernmental Organization *
|
|
20
|
-
* or submit itself to any jurisdiction. *
|
|
21
|
-
\*****************************************************************************/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Badge, {
|
|
26
|
-
pill: true,
|
|
27
|
-
bg: "danger",
|
|
28
|
-
children: this.props.polarity
|
|
29
|
-
});
|
|
30
|
-
}
|
|
3
|
+
* (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
|
|
4
|
+
* *
|
|
5
|
+
* This software is distributed under the terms of the GNU General Public *
|
|
6
|
+
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
|
|
7
|
+
* *
|
|
8
|
+
* In applying this licence, CERN does not waive the privileges and immunities *
|
|
9
|
+
* granted to it by virtue of its status as an Intergovernmental Organization *
|
|
10
|
+
* or submit itself to any jurisdiction. *
|
|
11
|
+
\*****************************************************************************/
|
|
12
|
+
import { Badge } from "react-bootstrap";
|
|
13
|
+
export function PolarityBadge({ polarity }) {
|
|
14
|
+
return (_jsx(Badge, { pill: true, bg: "danger", children: polarity }));
|
|
31
15
|
}
|
|
32
|
-
PolarityBadge.propTypes = {
|
|
33
|
-
polarity: _propTypes.default.arrayOf(_propTypes.default.string)
|
|
34
|
-
};
|
|
35
|
-
var _default = exports.default = PolarityBadge;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*****************************************************************************\
|
|
3
|
+
* (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
|
|
4
|
+
* *
|
|
5
|
+
* This software is distributed under the terms of the GNU General Public *
|
|
6
|
+
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
|
|
7
|
+
* *
|
|
8
|
+
* In applying this licence, CERN does not waive the privileges and immunities *
|
|
9
|
+
* granted to it by virtue of its status as an Intergovernmental Organization *
|
|
10
|
+
* or submit itself to any jurisdiction. *
|
|
11
|
+
\*****************************************************************************/
|
|
12
|
+
import { Badge, OverlayTrigger, Spinner, Tooltip } from "react-bootstrap";
|
|
13
|
+
import { useMetadata } from "../providers/MetadataProvider.js";
|
|
14
|
+
export function StrippingLineBadge({ version, line, stream, showLink }) {
|
|
15
|
+
const metadata = useMetadata();
|
|
16
|
+
// TODO: configurable baseURL, remove baseURL from metadata (or make it a top-level key)
|
|
17
|
+
const url = line && metadata && stream
|
|
18
|
+
? metadata.stripping[version][line].url[stream]
|
|
19
|
+
: `http://lhcbdoc.web.cern.ch/lhcbdoc/stripping/config/stripping${version}/index.html`;
|
|
20
|
+
const { description } = metadata ? metadata.strippingHints[version] : { description: _jsx(Spinner, { animation: "border" }) };
|
|
21
|
+
const badgeProps = showLink
|
|
22
|
+
? {
|
|
23
|
+
as: "a",
|
|
24
|
+
href: url,
|
|
25
|
+
target: "_blank",
|
|
26
|
+
}
|
|
27
|
+
: {};
|
|
28
|
+
return (_jsx(OverlayTrigger, { overlay: _jsx(Tooltip, { children: description }), children: _jsx(Badge, { pill: true, bg: "info", ...badgeProps, children: "S" + version }) }));
|
|
29
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { StrippingBadgeProps } from "./StrippingLineBadge";
|
|
2
|
+
interface Props extends Omit<StrippingBadgeProps, "version"> {
|
|
3
|
+
versions: string[];
|
|
4
|
+
line: string;
|
|
5
|
+
showLink?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function StrippingLineInfo({ versions, line, showLink, ...props }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*****************************************************************************\
|
|
3
|
+
* (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
|
|
4
|
+
* *
|
|
5
|
+
* This software is distributed under the terms of the GNU General Public *
|
|
6
|
+
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
|
|
7
|
+
* *
|
|
8
|
+
* In applying this licence, CERN does not waive the privileges and immunities *
|
|
9
|
+
* granted to it by virtue of its status as an Intergovernmental Organization *
|
|
10
|
+
* or submit itself to any jurisdiction. *
|
|
11
|
+
\*****************************************************************************/
|
|
12
|
+
import { Stack } from "react-bootstrap";
|
|
13
|
+
import { StrippingLineBadge } from "./StrippingLineBadge";
|
|
14
|
+
export function StrippingLineInfo({ versions, line, showLink, ...props }) {
|
|
15
|
+
const strippingInfo = versions.map((version) => (_jsx(StrippingLineBadge, { version: version, line: line, showLink: showLink, ...props }, `${line}-S${version}-badge`)));
|
|
16
|
+
return (_jsxs("span", { children: [line, _jsx("br", {}), _jsx(Stack, { direction: "horizontal", style: { flexWrap: "wrap" }, gap: 1, children: strippingInfo })] }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
allRowsHaveDtt: boolean;
|
|
3
|
+
disabled: boolean;
|
|
4
|
+
onSubmit: () => void;
|
|
5
|
+
submitLocation?: string;
|
|
6
|
+
hideDownloadButtons?: boolean;
|
|
7
|
+
requestReasonMessage?: string;
|
|
8
|
+
csrfToken?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function SubmitRequestButton({ allRowsHaveDtt, disabled, onSubmit, submitLocation, hideDownloadButtons, requestReasonMessage, csrfToken, }: Props): import("react/jsx-runtime").JSX.Element | null;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Button, OverlayTrigger, Tooltip } from "react-bootstrap";
|
|
3
|
+
import { Download, Send } from "react-bootstrap-icons";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { ReasonForRequestModal } from "./modals/ReasonForRequestModal";
|
|
6
|
+
import { downloadZip } from "../utils/utils";
|
|
7
|
+
import { useRows } from "../providers/RowsProvider";
|
|
8
|
+
import { useRequest } from "../providers/RequestProvider";
|
|
9
|
+
export function SubmitRequestButton({ allRowsHaveDtt, disabled, onSubmit, submitLocation, hideDownloadButtons, requestReasonMessage, csrfToken, }) {
|
|
10
|
+
const { generateAllFiles } = useRows();
|
|
11
|
+
const { productionName } = useRequest();
|
|
12
|
+
const [showReasonForRequestModal, setShowReasonForRequestModal] = useState(false);
|
|
13
|
+
const downloadAllFiles = () => {
|
|
14
|
+
const allFiles = generateAllFiles();
|
|
15
|
+
return downloadZip(allFiles, `${productionName}.zip`);
|
|
16
|
+
};
|
|
17
|
+
if (submitLocation) {
|
|
18
|
+
return (_jsxs(_Fragment, { children: [_jsx(OverlayTrigger, { overlay: _jsx(Tooltip, { children: allRowsHaveDtt
|
|
19
|
+
? disabled
|
|
20
|
+
? "Please make sure all fields are filled in before submitting"
|
|
21
|
+
: "Submit a request with the chosen configuration"
|
|
22
|
+
: "Please configure a DecayTreeTuple for each selected decay before submitting" }), children: _jsx("span", { children: _jsxs(Button, { className: "align-items-center d-flex gap-1", disabled: disabled, onClick: () => setShowReasonForRequestModal(true), children: [_jsx(Send, {}), " Submit"] }) }) }), showReasonForRequestModal && (_jsx(ReasonForRequestModal, { submitLocation: submitLocation, requestReasonMessage: requestReasonMessage, onClose: (submitted) => {
|
|
23
|
+
setShowReasonForRequestModal(false);
|
|
24
|
+
if (submitted) {
|
|
25
|
+
onSubmit();
|
|
26
|
+
}
|
|
27
|
+
}, csrfToken: csrfToken }))] }));
|
|
28
|
+
}
|
|
29
|
+
if (!hideDownloadButtons) {
|
|
30
|
+
return (_jsx(OverlayTrigger, { overlay: _jsx(Tooltip, { children: allRowsHaveDtt
|
|
31
|
+
? disabled
|
|
32
|
+
? "Please make sure all fields are filled in before downloading"
|
|
33
|
+
: "Download all DecayTreeTuple configurations"
|
|
34
|
+
: "Please configure a DecayTreeTuple for each selected decay before downloading" }), children: _jsx("span", { children: _jsxs(Button, { className: "align-items-center d-flex gap-1", disabled: disabled, onClick: () => {
|
|
35
|
+
downloadAllFiles().catch(console.error);
|
|
36
|
+
}, children: [_jsx(Download, {}), " Download"] }) }) }));
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TagHint } from "../providers/MetadataProvider.js";
|
|
2
|
+
import { Props as SelectProps } from "react-select";
|
|
3
|
+
import { DropdownOption } from "../models/dropdownOption.js";
|
|
4
|
+
export declare function getSelectTagOptions(tags: {
|
|
5
|
+
[key: string]: TagHint;
|
|
6
|
+
}, filter?: (tag: TagHint) => boolean): DropdownOption[];
|
|
7
|
+
interface Props extends SelectProps<DropdownOption, true> {
|
|
8
|
+
type: "decayTags" | "particleTags";
|
|
9
|
+
filter?: (tag: TagHint) => boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function TagDropdown({ type, filter, ...props }: Props): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*****************************************************************************\
|
|
3
|
+
* (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
|
|
4
|
+
* *
|
|
5
|
+
* This software is distributed under the terms of the GNU General Public *
|
|
6
|
+
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
|
|
7
|
+
* *
|
|
8
|
+
* In applying this licence, CERN does not waive the privileges and immunities *
|
|
9
|
+
* granted to it by virtue of its status as an Intergovernmental Organization *
|
|
10
|
+
* or submit itself to any jurisdiction. *
|
|
11
|
+
\*****************************************************************************/
|
|
12
|
+
import { OverlayTrigger, Tooltip } from "react-bootstrap";
|
|
13
|
+
import { useMetadata } from "../providers/MetadataProvider.js";
|
|
14
|
+
import Select from "react-select";
|
|
15
|
+
export function getSelectTagOptions(tags, filter = () => true) {
|
|
16
|
+
return Object.keys(tags)
|
|
17
|
+
.filter((key) => filter(tags[key]))
|
|
18
|
+
.map((key) => ({
|
|
19
|
+
value: key,
|
|
20
|
+
label: (_jsx(OverlayTrigger, { placement: "bottom", overlay: _jsx(Tooltip, { children: tags[key].description }), children: _jsx("span", { children: key }) })),
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
export function TagDropdown({ type, filter, ...props }) {
|
|
24
|
+
const metadata = useMetadata();
|
|
25
|
+
const options = getSelectTagOptions(metadata ? metadata.userHints[type] : {}, filter);
|
|
26
|
+
return (_jsx("div", { className: "react-select form-control p-0", children: _jsx(Select, { isMulti: true, options: options, isLoading: !metadata, ...props,
|
|
27
|
+
// Display the dropdown above text inputs and other elements
|
|
28
|
+
menuPortalTarget: document.body, menuPosition: "fixed", styles: {
|
|
29
|
+
menuPortal: (base) => ({ ...base, zIndex: 9999 }),
|
|
30
|
+
} }) }));
|
|
31
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Accordion, Spinner } from "react-bootstrap";
|
|
3
|
+
import { useMetadata } from "../providers/MetadataProvider";
|
|
4
|
+
import DOMPurify from "dompurify";
|
|
5
|
+
export function TupleToolDocsAccordion({ toolClass }) {
|
|
6
|
+
const metadata = useMetadata();
|
|
7
|
+
if (!metadata) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const documentation = metadata.tupleTools.tupleTools[toolClass].documentation;
|
|
11
|
+
return (_jsx(Accordion, { children: _jsxs(Accordion.Item, { eventKey: "0", children: [_jsxs(Accordion.Header, { children: ["Documentation for ", toolClass] }), _jsx(Accordion.Body, { children: toolClass ? (_jsx("div", { dangerouslySetInnerHTML: {
|
|
12
|
+
__html: DOMPurify.sanitize(documentation),
|
|
13
|
+
} })) : (_jsx(Spinner, { animation: "border" })) })] }) }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*****************************************************************************\
|
|
2
|
+
* (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
|
|
3
|
+
* *
|
|
4
|
+
* This software is distributed under the terms of the GNU General Public *
|
|
5
|
+
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
|
|
6
|
+
* *
|
|
7
|
+
* In applying this licence, CERN does not waive the privileges and immunities *
|
|
8
|
+
* granted to it by virtue of its status as an Intergovernmental Organization *
|
|
9
|
+
* or submit itself to any jurisdiction. *
|
|
10
|
+
\*****************************************************************************/
|
|
11
|
+
import { GroupBase, Props as SelectProps } from "react-select";
|
|
12
|
+
import { ReactNode } from "react";
|
|
13
|
+
type ToolOption = {
|
|
14
|
+
value: string;
|
|
15
|
+
label: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
interface Props extends SelectProps<ToolOption, false, GroupBase<ToolOption>> {
|
|
18
|
+
filterToolTags: string[];
|
|
19
|
+
}
|
|
20
|
+
export declare function TupleToolDropdown({ filterToolTags, ...props }: Props): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*****************************************************************************\
|
|
3
|
+
* (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
|
|
4
|
+
* *
|
|
5
|
+
* This software is distributed under the terms of the GNU General Public *
|
|
6
|
+
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
|
|
7
|
+
* *
|
|
8
|
+
* In applying this licence, CERN does not waive the privileges and immunities *
|
|
9
|
+
* granted to it by virtue of its status as an Intergovernmental Organization *
|
|
10
|
+
* or submit itself to any jurisdiction. *
|
|
11
|
+
\*****************************************************************************/
|
|
12
|
+
import Select from "react-select";
|
|
13
|
+
import { TupleToolLabel } from "./TupleToolLabel";
|
|
14
|
+
import { useMetadata } from "../providers/MetadataProvider.js";
|
|
15
|
+
import { TupleTool } from "../models/tupleTool";
|
|
16
|
+
export function TupleToolDropdown({ filterToolTags, ...props }) {
|
|
17
|
+
const metadata = useMetadata();
|
|
18
|
+
const options = metadata
|
|
19
|
+
? filterToolTags.map((allowedTag) => ({
|
|
20
|
+
label: allowedTag,
|
|
21
|
+
options: Object.keys(metadata.tupleTools.tupleTools)
|
|
22
|
+
.sort()
|
|
23
|
+
.map(TupleTool.fromString)
|
|
24
|
+
.map((tool) => ({ value: tool.toString(), label: _jsx(TupleToolLabel, { tool: tool }) }))
|
|
25
|
+
.filter((tool) => metadata.tupleTools.tupleTools[tool.value].tags.includes(allowedTag)),
|
|
26
|
+
}))
|
|
27
|
+
: [];
|
|
28
|
+
return (_jsx("div", { className: "react-select form-control p-0", children: _jsx(Select, { options: options, isLoading: !metadata, ...props }) }));
|
|
29
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Card, ListGroup, OverlayTrigger, Popover } from "react-bootstrap";
|
|
3
|
+
import { PencilSquare } from "react-bootstrap-icons";
|
|
4
|
+
import { DecayLatex } from "./DecayLatex";
|
|
5
|
+
import { useDtt } from "../providers/DttProvider";
|
|
6
|
+
export function TupleToolGroup({ branch, onGroupSelected }) {
|
|
7
|
+
const { dtt, decay } = useDtt();
|
|
8
|
+
let groups = {};
|
|
9
|
+
if (branch.length === 0) {
|
|
10
|
+
groups = dtt.config.groups;
|
|
11
|
+
}
|
|
12
|
+
else if (branch.length === 1) {
|
|
13
|
+
const filteredGroups = Object.entries(dtt.config.groups).filter(([key]) => key.includes(branch[0]));
|
|
14
|
+
groups = Object.fromEntries(filteredGroups);
|
|
15
|
+
}
|
|
16
|
+
const groupKeys = Object.keys(groups);
|
|
17
|
+
function ToolCount({ group }) {
|
|
18
|
+
const tools = dtt.listTools(group);
|
|
19
|
+
return (_jsx(OverlayTrigger, { overlay: _jsx(Popover, { children: _jsx(ListGroup, { children: tools.map((tool) => (_jsx(ListGroup.Item, { children: tool.toString() }, tool.toString()))) }) }), children: _jsxs("div", { children: [tools.length, " TupleTool", tools.length === 1 ? "" : "s"] }) }));
|
|
20
|
+
}
|
|
21
|
+
return (_jsxs(Card, { className: "mt-2", children: [_jsxs(Card.Header, { children: [groupKeys.length, " group", groupKeys.length === 1 ? "" : "s"] }), _jsx(ListGroup, { variant: "flush", children: groupKeys.map((selection) => (_jsxs(ListGroup.Item, { className: "d-flex justify-content-between align-items-start", children: [_jsx(DecayLatex, { decay: decay, selection: selection.split(",") }), _jsx(ToolCount, { group: selection.split(",") }), _jsx(Button, { variant: "outline-secondary", size: "sm", onClick: () => onGroupSelected(selection), children: _jsx(PencilSquare, {}) })] }, selection))) })] }));
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*****************************************************************************\
|
|
3
|
+
* (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
|
|
4
|
+
* *
|
|
5
|
+
* This software is distributed under the terms of the GNU General Public *
|
|
6
|
+
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
|
|
7
|
+
* *
|
|
8
|
+
* In applying this licence, CERN does not waive the privileges and immunities *
|
|
9
|
+
* granted to it by virtue of its status as an Intergovernmental Organization *
|
|
10
|
+
* or submit itself to any jurisdiction. *
|
|
11
|
+
\*****************************************************************************/
|
|
12
|
+
import { OverlayTrigger, Tooltip } from "react-bootstrap";
|
|
13
|
+
import { useMetadata } from "../providers/MetadataProvider.js";
|
|
14
|
+
export function TupleToolLabel({ tool }) {
|
|
15
|
+
const metadata = useMetadata();
|
|
16
|
+
if (!metadata) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return (_jsx(OverlayTrigger, { overlay: _jsx(Tooltip, { children: metadata.tupleTools.tupleTools[tool.class].description }), children: _jsx("span", { children: tool.toString() }) }));
|
|
20
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/*****************************************************************************\
|
|
3
|
+
* (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
|
|
4
|
+
* *
|
|
5
|
+
* This software is distributed under the terms of the GNU General Public *
|
|
6
|
+
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
|
|
7
|
+
* *
|
|
8
|
+
* In applying this licence, CERN does not waive the privileges and immunities *
|
|
9
|
+
* granted to it by virtue of its status as an Intergovernmental Organization *
|
|
10
|
+
* or submit itself to any jurisdiction. *
|
|
11
|
+
\*****************************************************************************/
|
|
12
|
+
import { TupleToolLabel } from "./TupleToolLabel";
|
|
13
|
+
import { DeleteButton } from "./DeleteButton.js";
|
|
14
|
+
import { Button, ButtonGroup, Card, ListGroup, OverlayTrigger, Tooltip } from "react-bootstrap";
|
|
15
|
+
import { PencilSquare, PlusLg } from "react-bootstrap-icons";
|
|
16
|
+
import { useMetadata } from "../providers/MetadataProvider.js";
|
|
17
|
+
import { useState } from "react";
|
|
18
|
+
import { TupleToolGroup } from "./TupleToolGroup";
|
|
19
|
+
import { AddTupleToolModal } from "./modals/AddTupleToolModal";
|
|
20
|
+
import { ConfigureTupleToolModal } from "./modals/ConfigureTupleToolModal";
|
|
21
|
+
import { useDtt } from "../providers/DttProvider";
|
|
22
|
+
export function TupleToolList({ branch, onGroupSelected, onSave }) {
|
|
23
|
+
const metadata = useMetadata();
|
|
24
|
+
const { dtt, dirty, save, revert, removeTool } = useDtt();
|
|
25
|
+
const [showAddModal, setShowAddModal] = useState(false);
|
|
26
|
+
const [showConfigModalWithTool, setShowConfigModalWithTool] = useState(null);
|
|
27
|
+
if (!metadata) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
const tools = dtt.listTools(branch);
|
|
31
|
+
const filterToolTags = branch.length === 0 ? ["IParticleTupleTool", "IEventTupleTool"] : ["IParticleTupleTool"];
|
|
32
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Card, { children: [_jsxs(Card.Header, { className: "d-flex justify-content-between align-items-start", children: [_jsxs("span", { children: [tools.length, " TupleTool", tools.length === 1 ? "" : "s"] }), _jsx(Button, { variant: "success", size: "sm", onClick: () => setShowAddModal(true), children: _jsx(PlusLg, {}) })] }), _jsx(ListGroup, { variant: "flush", children: tools.map((tool) => {
|
|
33
|
+
return (_jsxs(ListGroup.Item, { className: "d-flex justify-content-between align-items-start", variant: showConfigModalWithTool?.equals(tool) ? "secondary" : "", children: [_jsx(TupleToolLabel, { tool: tool }), _jsxs(ButtonGroup, { size: "sm", children: [_jsx(Button, { variant: "outline-secondary", onClick: () => setShowConfigModalWithTool(tool), children: _jsx(PencilSquare, {}) }), _jsx(DeleteButton, { outline: true, action: () => removeTool(branch, tool) })] })] }, tool.toString()));
|
|
34
|
+
}) })] }), showAddModal && (_jsx(AddTupleToolModal, { branch: branch, filterToolTags: filterToolTags, onClose: () => setShowAddModal(false) })), showConfigModalWithTool && (_jsx(ConfigureTupleToolModal, { branch: branch, tool: showConfigModalWithTool, onClose: () => setShowConfigModalWithTool(null) })), branch.length === 0 && Object.keys(dtt.config.groups).length > 0 && (_jsx(TupleToolGroup, { branch: branch, onGroupSelected: onGroupSelected })), _jsxs(ButtonGroup, { className: "mt-2", children: [_jsx(OverlayTrigger, { overlay: _jsx(Tooltip, { children: "Save changes to this DecayTreeTuple" }), children: _jsx(Button, { onClick: () => {
|
|
35
|
+
save();
|
|
36
|
+
onSave();
|
|
37
|
+
}, disabled: !dirty, children: "Save" }) }), _jsx(OverlayTrigger, { overlay: _jsx(Tooltip, { children: "Discard changes to this DecayTreeTuple" }), children: _jsx(Button, { variant: "outline-danger", onClick: revert, disabled: !dirty, children: "Revert" }) })] })] }));
|
|
38
|
+
}
|
|
@@ -1,35 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var _reactBootstrap = require("react-bootstrap");
|
|
10
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
2
|
/*****************************************************************************\
|
|
13
|
-
* (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
|
|
14
|
-
* *
|
|
15
|
-
* This software is distributed under the terms of the GNU General Public *
|
|
16
|
-
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
|
|
17
|
-
* *
|
|
18
|
-
* In applying this licence, CERN does not waive the privileges and immunities *
|
|
19
|
-
* granted to it by virtue of its status as an Intergovernmental Organization *
|
|
20
|
-
* or submit itself to any jurisdiction. *
|
|
21
|
-
\*****************************************************************************/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactBootstrap.Badge, {
|
|
26
|
-
pill: true,
|
|
27
|
-
bg: "success",
|
|
28
|
-
children: this.props.year
|
|
29
|
-
});
|
|
30
|
-
}
|
|
3
|
+
* (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration *
|
|
4
|
+
* *
|
|
5
|
+
* This software is distributed under the terms of the GNU General Public *
|
|
6
|
+
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
|
|
7
|
+
* *
|
|
8
|
+
* In applying this licence, CERN does not waive the privileges and immunities *
|
|
9
|
+
* granted to it by virtue of its status as an Intergovernmental Organization *
|
|
10
|
+
* or submit itself to any jurisdiction. *
|
|
11
|
+
\*****************************************************************************/
|
|
12
|
+
import { Badge } from "react-bootstrap";
|
|
13
|
+
export function YearBadge({ year }) {
|
|
14
|
+
return (_jsx(Badge, { pill: true, bg: "success", children: year }));
|
|
31
15
|
}
|
|
32
|
-
YearBadge.propTypes = {
|
|
33
|
-
year: _propTypes.default.string
|
|
34
|
-
};
|
|
35
|
-
var _default = exports.default = YearBadge;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, FormControl, InputGroup, Modal } from "react-bootstrap";
|
|
3
|
+
import { TupleToolDropdown } from "../TupleToolDropdown";
|
|
4
|
+
import { TupleToolDocsAccordion } from "../TupleToolDocsAccordion";
|
|
5
|
+
import { useDtt } from "../../providers/DttProvider";
|
|
6
|
+
import { TupleTool } from "../../models/tupleTool";
|
|
7
|
+
import { useEffect, useRef, useState } from "react";
|
|
8
|
+
export function AddTupleToolModal({ branch, filterToolTags, onClose }) {
|
|
9
|
+
const { dtt, addTool } = useDtt();
|
|
10
|
+
const nameInputRef = useRef(null);
|
|
11
|
+
const [selectedTool, setSelectedTool] = useState(null);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
nameInputRef.current?.focus();
|
|
14
|
+
}, [selectedTool]);
|
|
15
|
+
return (_jsxs(Modal, { show: true, onHide: onClose, children: [_jsx(Modal.Header, { closeButton: true, children: "Add TupleTool" }), _jsxs(Modal.Body, { className: "gap-3 d-flex flex-column", children: [_jsxs(InputGroup, { hasValidation: true, children: [_jsx(TupleToolDropdown, { filterToolTags: filterToolTags, placeholder: "TupleTool class", onChange: (option) => {
|
|
16
|
+
if (option) {
|
|
17
|
+
setSelectedTool((prev) => new TupleTool(option.value, prev?.name || ""));
|
|
18
|
+
}
|
|
19
|
+
}, value: selectedTool ? { value: selectedTool.class, label: selectedTool.class } : null }), _jsx(FormControl, { ref: nameInputRef, placeholder: "TupleTool name", onChange: (event) => {
|
|
20
|
+
// Remove all non-word characters
|
|
21
|
+
const name = event.target.value.replaceAll(/[^\w]/g, "");
|
|
22
|
+
setSelectedTool((prev) => new TupleTool(prev.class, name));
|
|
23
|
+
}, value: selectedTool?.name || "", disabled: !selectedTool, isInvalid: !!selectedTool && dtt.toolExists(selectedTool, branch), onKeyDown: (event) => {
|
|
24
|
+
if (event.key === "Enter") {
|
|
25
|
+
addTool(branch, selectedTool);
|
|
26
|
+
onClose();
|
|
27
|
+
}
|
|
28
|
+
} }), selectedTool && (_jsxs(FormControl.Feedback, { type: "invalid", children: ["A ", selectedTool.class, " with the name \"", selectedTool.name, "\" already exists"] }))] }), selectedTool && _jsx(TupleToolDocsAccordion, { toolClass: selectedTool.class }), _jsx(Button, { className: "align-self-end", variant: "success", disabled: !selectedTool || dtt.toolExists(selectedTool, branch), onClick: () => {
|
|
29
|
+
addTool(branch, selectedTool);
|
|
30
|
+
onClose();
|
|
31
|
+
}, children: "Add tool" })] })] }));
|
|
32
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TupleTool } from "../../models/tupleTool";
|
|
2
|
+
interface Props {
|
|
3
|
+
branch: string[];
|
|
4
|
+
tool: TupleTool;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function ConfigureTupleToolModal({ branch, tool, onClose }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Col, Form, Modal, OverlayTrigger, Row, Tooltip } from "react-bootstrap";
|
|
3
|
+
import { StrParamInput } from "../tupleToolParams/StrParamInput";
|
|
4
|
+
import { BoolParamInput } from "../tupleToolParams/BoolParamInput";
|
|
5
|
+
import { NumParamInput } from "../tupleToolParams/NumParamInput";
|
|
6
|
+
import { ListParamInput } from "../tupleToolParams/ListParamInput";
|
|
7
|
+
import { DictParamInput } from "../tupleToolParams/DictParamInput";
|
|
8
|
+
import { QuestionCircle } from "react-bootstrap-icons";
|
|
9
|
+
import { TupleToolDocsAccordion } from "../TupleToolDocsAccordion";
|
|
10
|
+
import { useDtt } from "../../providers/DttProvider";
|
|
11
|
+
export function ConfigureTupleToolModal({ branch, tool, onClose }) {
|
|
12
|
+
const { dtt, updateToolParam } = useDtt();
|
|
13
|
+
return (_jsxs(Modal, { show: true, size: "xl", fullscreen: "lg-down", onHide: onClose, children: [_jsxs(Modal.Header, { closeButton: true, children: ["Configure ", tool.toString()] }), _jsxs(Modal.Body, { className: "gap-3 d-flex flex-column", children: [tool ? (_jsx(Form, { children: Object.entries(dtt.getToolConfig(branch, tool)).map(([paramName, param]) => {
|
|
14
|
+
const { description, type, default: defaultValue, value } = param;
|
|
15
|
+
let inputComponent;
|
|
16
|
+
switch (type) {
|
|
17
|
+
case "str":
|
|
18
|
+
inputComponent = (_jsx(StrParamInput, { value: value, defaultValue: defaultValue, onChange: (newValue) => updateToolParam(branch, tool, paramName, newValue), param: paramName }));
|
|
19
|
+
break;
|
|
20
|
+
case "bool":
|
|
21
|
+
inputComponent = (_jsx(BoolParamInput, { value: value, onChange: (newValue) => updateToolParam(branch, tool, paramName, newValue) }));
|
|
22
|
+
break;
|
|
23
|
+
case "int":
|
|
24
|
+
case "uint":
|
|
25
|
+
case "float":
|
|
26
|
+
inputComponent = (_jsx(NumParamInput, { type: type, value: value, defaultValue: defaultValue, onChange: (newValue) => updateToolParam(branch, tool, paramName, newValue) }));
|
|
27
|
+
break;
|
|
28
|
+
case "text":
|
|
29
|
+
inputComponent = (_jsx(ListParamInput, { initialValues: value, defaultValues: defaultValue, newItemValue: "", onChange: (newValue) => updateToolParam(branch, tool, paramName, newValue), buildInnerInput: (props) => _jsx(StrParamInput, { ...props, param: paramName }) }));
|
|
30
|
+
break;
|
|
31
|
+
case "[int]":
|
|
32
|
+
case "[uint]":
|
|
33
|
+
case "[float]":
|
|
34
|
+
inputComponent = (_jsx(ListParamInput, { initialValues: value, defaultValues: defaultValue, newItemValue: 0, onChange: (newValue) => updateToolParam(branch, tool, paramName, newValue), buildInnerInput: (props) => (_jsx(NumParamInput, { type: type.slice(1, -1), ...props })) }));
|
|
35
|
+
break;
|
|
36
|
+
case "{str:str}":
|
|
37
|
+
case "{str:[str]}":
|
|
38
|
+
inputComponent = (_jsx(DictParamInput, { value: value, onChange: (newValue) => updateToolParam(branch, tool, paramName, newValue) }));
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
return (_jsxs(Form.Group, { as: Row, className: "mb-2", children: [_jsxs(Form.Label, { column: true, sm: 3, children: [_jsx(OverlayTrigger, { overlay: _jsx(Tooltip, { children: description }), children: _jsx(QuestionCircle, {}) }), _jsxs("code", { children: [" ", paramName, " "] })] }), _jsx(Form.Label, { column: true, sm: 2, children: _jsxs("code", { children: [" ", type, " "] }) }), _jsx(Col, { sm: 7, children: inputComponent })] }, paramName));
|
|
42
|
+
}) })) : ("No tool selected"), _jsx(TupleToolDocsAccordion, { toolClass: tool.class }), _jsx(Button, { className: "align-self-end", onClick: onClose, children: "Save & close" })] })] }));
|
|
43
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
submitLocation: string;
|
|
3
|
+
onClose: (submitted: boolean) => void;
|
|
4
|
+
requestReasonMessage?: string;
|
|
5
|
+
csrfToken?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function ReasonForRequestModal({ submitLocation, onClose, requestReasonMessage, csrfToken }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Alert, Button, FormControl, InputGroup, Modal, OverlayTrigger, Spinner, Tooltip } from "react-bootstrap";
|
|
3
|
+
import { useRequest } from "../../providers/RequestProvider";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { useRows } from "../../providers/RowsProvider";
|
|
6
|
+
export function ReasonForRequestModal({ submitLocation, onClose, requestReasonMessage, csrfToken }) {
|
|
7
|
+
const { generateAllFiles } = useRows();
|
|
8
|
+
const { productionName, reasonForRequest, setReasonForRequest } = useRequest();
|
|
9
|
+
const [requestLoading, setRequestLoading] = useState(false);
|
|
10
|
+
const [requestError, setRequestError] = useState(null);
|
|
11
|
+
const submitRequest = (url) => {
|
|
12
|
+
setRequestLoading(true);
|
|
13
|
+
setRequestError(null);
|
|
14
|
+
const allFiles = generateAllFiles();
|
|
15
|
+
const formData = new FormData();
|
|
16
|
+
allFiles.forEach((file) => {
|
|
17
|
+
formData.append("generatedFiles[]", new Blob([file.content], { type: "text/plain" }), file.name);
|
|
18
|
+
});
|
|
19
|
+
formData.append("email", localStorage.getItem("email") || "");
|
|
20
|
+
formData.append("name", productionName);
|
|
21
|
+
formData.append("reasonForRequest", reasonForRequest);
|
|
22
|
+
let headers = {};
|
|
23
|
+
if (csrfToken) {
|
|
24
|
+
headers = {
|
|
25
|
+
"X-Csrf-Token": csrfToken,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
fetch(url, {
|
|
29
|
+
method: "POST",
|
|
30
|
+
body: formData,
|
|
31
|
+
credentials: "include",
|
|
32
|
+
headers: headers,
|
|
33
|
+
})
|
|
34
|
+
.then((response) => {
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
37
|
+
}
|
|
38
|
+
onClose(true);
|
|
39
|
+
})
|
|
40
|
+
.catch((error) => {
|
|
41
|
+
console.error("Fetch error:", error);
|
|
42
|
+
setRequestError("Something went wrong while submitting your request. Please try again later or contact support.");
|
|
43
|
+
})
|
|
44
|
+
.finally(() => {
|
|
45
|
+
setRequestLoading(false);
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
return (_jsxs(Modal, { show: true, onHide: () => onClose(false), size: "lg", children: [_jsx(Modal.Header, { closeButton: true, children: _jsx(Modal.Title, { children: "Reason for request" }) }), _jsxs(Modal.Body, { children: [_jsx(Alert, { children: requestReasonMessage }), requestError && _jsx(Alert, { variant: "danger", children: requestError }), _jsxs(InputGroup, { hasValidation: true, children: [_jsx(OverlayTrigger, { overlay: _jsx(Tooltip, { children: "Reason for requesting the chosen ntuples" }), children: _jsx(InputGroup.Text, { children: "Reason for request" }) }), _jsx(FormControl, { as: "textarea", rows: 3, value: reasonForRequest, onChange: (event) => setReasonForRequest(event.target.value), isValid: !!reasonForRequest, placeholder: "I need these ntuples for..." })] })] }), _jsx(Modal.Footer, { children: _jsx(Button, { variant: "primary", onClick: () => submitRequest(submitLocation), children: requestLoading ? _jsx(Spinner, { animation: "border" }) : "Submit" }) })] }));
|
|
49
|
+
}
|