@itwin/reports-config-widget-react 0.2.1 → 0.3.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.
- package/.rush/temp/operation/rebuild/all.log +9 -0
- package/.rush/temp/operation/rebuild/state.json +3 -0
- package/.rush/temp/package-deps_rebuild.json +36 -32
- package/.rush/temp/shrinkwrap-deps.json +88 -34
- package/CHANGELOG.json +18 -0
- package/CHANGELOG.md +10 -1
- package/lib/cjs/reports-config-widget-react.d.ts +5 -0
- package/lib/cjs/reports-config-widget-react.d.ts.map +1 -1
- package/lib/cjs/reports-config-widget-react.js +11 -0
- package/lib/cjs/reports-config-widget-react.js.map +1 -1
- package/lib/cjs/test/AddMappingModal.test.js +15 -28
- package/lib/cjs/test/AddMappingModal.test.js.map +1 -1
- package/lib/cjs/test/BulkExtractor.test.js +13 -19
- package/lib/cjs/test/BulkExtractor.test.js.map +1 -1
- package/lib/cjs/test/DeleteModal.test.d.ts.map +1 -1
- package/lib/cjs/test/DeleteModal.test.js +4 -62
- package/lib/cjs/test/DeleteModal.test.js.map +1 -1
- package/lib/cjs/test/ReportAction.test.js +13 -78
- package/lib/cjs/test/ReportAction.test.js.map +1 -1
- package/lib/cjs/test/ReportMappingHorizontalTile.test.js +2 -35
- package/lib/cjs/test/ReportMappingHorizontalTile.test.js.map +1 -1
- package/lib/cjs/test/ReportMappings.test.d.ts.map +1 -1
- package/lib/cjs/test/ReportMappings.test.js +38 -91
- package/lib/cjs/test/ReportMappings.test.js.map +1 -1
- package/lib/cjs/test/Reports.test.js +19 -72
- package/lib/cjs/test/Reports.test.js.map +1 -1
- package/lib/cjs/test/test-utils.d.ts +3 -8
- package/lib/cjs/test/test-utils.d.ts.map +1 -1
- package/lib/cjs/test/test-utils.js +8 -33
- package/lib/cjs/test/test-utils.js.map +1 -1
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/widget/components/ActionPanel.d.ts +1 -1
- package/lib/cjs/widget/components/ActionPanel.d.ts.map +1 -1
- package/lib/cjs/widget/components/ActionPanel.js +4 -4
- package/lib/cjs/widget/components/ActionPanel.js.map +1 -1
- package/lib/cjs/widget/components/AddMappingsModal.d.ts +4 -4
- package/lib/cjs/widget/components/AddMappingsModal.d.ts.map +1 -1
- package/lib/cjs/widget/components/AddMappingsModal.js +23 -22
- package/lib/cjs/widget/components/AddMappingsModal.js.map +1 -1
- package/lib/cjs/widget/components/BulkExtractor.d.ts +4 -4
- package/lib/cjs/widget/components/BulkExtractor.d.ts.map +1 -1
- package/lib/cjs/widget/components/BulkExtractor.js +6 -6
- package/lib/cjs/widget/components/BulkExtractor.js.map +1 -1
- package/lib/cjs/widget/components/DeleteModal.d.ts +4 -5
- package/lib/cjs/widget/components/DeleteModal.d.ts.map +1 -1
- package/lib/cjs/widget/components/DeleteModal.js +9 -13
- package/lib/cjs/widget/components/DeleteModal.js.map +1 -1
- package/lib/cjs/widget/components/HorizontalTile.scss +6 -3
- package/lib/cjs/widget/components/ReportAction.d.ts +4 -5
- package/lib/cjs/widget/components/ReportAction.d.ts.map +1 -1
- package/lib/cjs/widget/components/ReportAction.js +15 -15
- package/lib/cjs/widget/components/ReportAction.js.map +1 -1
- package/lib/cjs/widget/components/ReportHorizontalTile.d.ts +4 -4
- package/lib/cjs/widget/components/ReportHorizontalTile.d.ts.map +1 -1
- package/lib/cjs/widget/components/ReportHorizontalTile.js +27 -12
- package/lib/cjs/widget/components/ReportHorizontalTile.js.map +1 -1
- package/lib/cjs/widget/components/ReportMappingHorizontalTile.d.ts +1 -1
- package/lib/cjs/widget/components/ReportMappingHorizontalTile.d.ts.map +1 -1
- package/lib/cjs/widget/components/ReportMappingHorizontalTile.js +24 -9
- package/lib/cjs/widget/components/ReportMappingHorizontalTile.js.map +1 -1
- package/lib/cjs/widget/components/ReportMappings.d.ts +4 -6
- package/lib/cjs/widget/components/ReportMappings.d.ts.map +1 -1
- package/lib/cjs/widget/components/ReportMappings.js +37 -47
- package/lib/cjs/widget/components/ReportMappings.js.map +1 -1
- package/lib/cjs/widget/components/ReportMappings.scss +3 -3
- package/lib/cjs/widget/components/Reports.d.ts +6 -1
- package/lib/cjs/widget/components/Reports.d.ts.map +1 -1
- package/lib/cjs/widget/components/Reports.js +42 -83
- package/lib/cjs/widget/components/Reports.js.map +1 -1
- package/lib/cjs/widget/components/ReportsConfigContext.d.ts +18 -0
- package/lib/cjs/widget/components/ReportsConfigContext.d.ts.map +1 -0
- package/lib/cjs/widget/components/ReportsConfigContext.js +87 -0
- package/lib/cjs/widget/components/ReportsConfigContext.js.map +1 -0
- package/lib/cjs/widget/components/ReportsContainer.d.ts +14 -0
- package/lib/cjs/widget/components/ReportsContainer.d.ts.map +1 -1
- package/lib/cjs/widget/components/ReportsContainer.js +28 -16
- package/lib/cjs/widget/components/ReportsContainer.js.map +1 -1
- package/lib/cjs/widget/components/ReportsHeader.d.ts +7 -0
- package/lib/cjs/widget/components/ReportsHeader.d.ts.map +1 -0
- package/lib/cjs/widget/components/ReportsHeader.js +20 -0
- package/lib/cjs/widget/components/ReportsHeader.js.map +1 -0
- package/lib/cjs/widget/components/ReportsRouter.d.ts +8 -0
- package/lib/cjs/widget/components/ReportsRouter.d.ts.map +1 -0
- package/lib/cjs/widget/components/ReportsRouter.js +52 -0
- package/lib/cjs/widget/components/ReportsRouter.js.map +1 -0
- package/lib/cjs/widget/components/SearchBar.js +1 -2
- package/lib/cjs/widget/components/SearchBar.js.map +1 -1
- package/lib/cjs/widget/components/SearchBar.scss +1 -1
- package/lib/cjs/widget/components/SelectIModel.d.ts +3 -3
- package/lib/cjs/widget/components/SelectIModel.d.ts.map +1 -1
- package/lib/cjs/widget/components/SelectIModel.js +6 -26
- package/lib/cjs/widget/components/SelectIModel.js.map +1 -1
- package/lib/cjs/widget/components/utils.d.ts +1 -1
- package/lib/cjs/widget/components/utils.d.ts.map +1 -1
- package/lib/cjs/widget/components/utils.js.map +1 -1
- package/lib/cjs/widget/context/BulkExtractorContext.d.ts +10 -0
- package/lib/cjs/widget/context/BulkExtractorContext.d.ts.map +1 -0
- package/lib/cjs/widget/context/{ReportsApiConfigContext.js → BulkExtractorContext.js} +7 -10
- package/lib/cjs/widget/context/BulkExtractorContext.js.map +1 -0
- package/lib/cjs/widget/context/ReportsConfigApiContext.d.ts +16 -0
- package/lib/cjs/widget/context/ReportsConfigApiContext.d.ts.map +1 -0
- package/lib/cjs/widget/context/ReportsConfigApiContext.js +43 -0
- package/lib/cjs/widget/context/ReportsConfigApiContext.js.map +1 -0
- package/lib/esm/reports-config-widget-react.d.ts +5 -0
- package/lib/esm/reports-config-widget-react.d.ts.map +1 -1
- package/lib/esm/reports-config-widget-react.js +5 -0
- package/lib/esm/reports-config-widget-react.js.map +1 -1
- package/lib/esm/test/AddMappingModal.test.js +16 -29
- package/lib/esm/test/AddMappingModal.test.js.map +1 -1
- package/lib/esm/test/BulkExtractor.test.js +14 -17
- package/lib/esm/test/BulkExtractor.test.js.map +1 -1
- package/lib/esm/test/DeleteModal.test.d.ts.map +1 -1
- package/lib/esm/test/DeleteModal.test.js +5 -44
- package/lib/esm/test/DeleteModal.test.js.map +1 -1
- package/lib/esm/test/ReportAction.test.js +14 -60
- package/lib/esm/test/ReportAction.test.js.map +1 -1
- package/lib/esm/test/ReportMappingHorizontalTile.test.js +3 -36
- package/lib/esm/test/ReportMappingHorizontalTile.test.js.map +1 -1
- package/lib/esm/test/ReportMappings.test.d.ts.map +1 -1
- package/lib/esm/test/ReportMappings.test.js +37 -90
- package/lib/esm/test/ReportMappings.test.js.map +1 -1
- package/lib/esm/test/Reports.test.js +20 -54
- package/lib/esm/test/Reports.test.js.map +1 -1
- package/lib/esm/test/test-utils.d.ts +3 -8
- package/lib/esm/test/test-utils.d.ts.map +1 -1
- package/lib/esm/test/test-utils.js +7 -31
- package/lib/esm/test/test-utils.js.map +1 -1
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/widget/components/ActionPanel.d.ts +1 -1
- package/lib/esm/widget/components/ActionPanel.d.ts.map +1 -1
- package/lib/esm/widget/components/ActionPanel.js +4 -4
- package/lib/esm/widget/components/ActionPanel.js.map +1 -1
- package/lib/esm/widget/components/AddMappingsModal.d.ts +4 -4
- package/lib/esm/widget/components/AddMappingsModal.d.ts.map +1 -1
- package/lib/esm/widget/components/AddMappingsModal.js +25 -24
- package/lib/esm/widget/components/AddMappingsModal.js.map +1 -1
- package/lib/esm/widget/components/BulkExtractor.d.ts +4 -4
- package/lib/esm/widget/components/BulkExtractor.d.ts.map +1 -1
- package/lib/esm/widget/components/BulkExtractor.js +7 -8
- package/lib/esm/widget/components/BulkExtractor.js.map +1 -1
- package/lib/esm/widget/components/DeleteModal.d.ts +4 -5
- package/lib/esm/widget/components/DeleteModal.d.ts.map +1 -1
- package/lib/esm/widget/components/DeleteModal.js +9 -13
- package/lib/esm/widget/components/DeleteModal.js.map +1 -1
- package/lib/esm/widget/components/HorizontalTile.scss +6 -3
- package/lib/esm/widget/components/ReportAction.d.ts +4 -5
- package/lib/esm/widget/components/ReportAction.d.ts.map +1 -1
- package/lib/esm/widget/components/ReportAction.js +14 -16
- package/lib/esm/widget/components/ReportAction.js.map +1 -1
- package/lib/esm/widget/components/ReportHorizontalTile.d.ts +4 -4
- package/lib/esm/widget/components/ReportHorizontalTile.d.ts.map +1 -1
- package/lib/esm/widget/components/ReportHorizontalTile.js +4 -5
- package/lib/esm/widget/components/ReportHorizontalTile.js.map +1 -1
- package/lib/esm/widget/components/ReportMappingHorizontalTile.d.ts +1 -1
- package/lib/esm/widget/components/ReportMappingHorizontalTile.d.ts.map +1 -1
- package/lib/esm/widget/components/ReportMappingHorizontalTile.js +1 -2
- package/lib/esm/widget/components/ReportMappingHorizontalTile.js.map +1 -1
- package/lib/esm/widget/components/ReportMappings.d.ts +4 -6
- package/lib/esm/widget/components/ReportMappings.d.ts.map +1 -1
- package/lib/esm/widget/components/ReportMappings.js +39 -49
- package/lib/esm/widget/components/ReportMappings.js.map +1 -1
- package/lib/esm/widget/components/ReportMappings.scss +3 -3
- package/lib/esm/widget/components/Reports.d.ts +6 -1
- package/lib/esm/widget/components/Reports.d.ts.map +1 -1
- package/lib/esm/widget/components/Reports.js +45 -86
- package/lib/esm/widget/components/Reports.js.map +1 -1
- package/lib/esm/widget/components/ReportsConfigContext.d.ts +18 -0
- package/lib/esm/widget/components/ReportsConfigContext.d.ts.map +1 -0
- package/lib/esm/widget/components/ReportsConfigContext.js +64 -0
- package/lib/esm/widget/components/ReportsConfigContext.js.map +1 -0
- package/lib/esm/widget/components/ReportsContainer.d.ts +14 -0
- package/lib/esm/widget/components/ReportsContainer.d.ts.map +1 -1
- package/lib/esm/widget/components/ReportsContainer.js +28 -17
- package/lib/esm/widget/components/ReportsContainer.js.map +1 -1
- package/lib/esm/widget/components/ReportsHeader.d.ts +7 -0
- package/lib/esm/widget/components/ReportsHeader.d.ts.map +1 -0
- package/lib/esm/widget/components/ReportsHeader.js +13 -0
- package/lib/esm/widget/components/ReportsHeader.js.map +1 -0
- package/lib/esm/widget/components/ReportsRouter.d.ts +8 -0
- package/lib/esm/widget/components/ReportsRouter.d.ts.map +1 -0
- package/lib/esm/widget/components/ReportsRouter.js +45 -0
- package/lib/esm/widget/components/ReportsRouter.js.map +1 -0
- package/lib/esm/widget/components/SearchBar.js +1 -2
- package/lib/esm/widget/components/SearchBar.js.map +1 -1
- package/lib/esm/widget/components/SearchBar.scss +1 -1
- package/lib/esm/widget/components/SelectIModel.d.ts +3 -3
- package/lib/esm/widget/components/SelectIModel.d.ts.map +1 -1
- package/lib/esm/widget/components/SelectIModel.js +7 -27
- package/lib/esm/widget/components/SelectIModel.js.map +1 -1
- package/lib/esm/widget/components/utils.d.ts +1 -1
- package/lib/esm/widget/components/utils.d.ts.map +1 -1
- package/lib/esm/widget/components/utils.js.map +1 -1
- package/lib/esm/widget/context/BulkExtractorContext.d.ts +10 -0
- package/lib/esm/widget/context/BulkExtractorContext.d.ts.map +1 -0
- package/lib/esm/widget/context/BulkExtractorContext.js +11 -0
- package/lib/esm/widget/context/BulkExtractorContext.js.map +1 -0
- package/lib/esm/widget/context/ReportsConfigApiContext.d.ts +16 -0
- package/lib/esm/widget/context/ReportsConfigApiContext.d.ts.map +1 -0
- package/lib/esm/widget/context/ReportsConfigApiContext.js +20 -0
- package/lib/esm/widget/context/ReportsConfigApiContext.js.map +1 -0
- package/lib/public/locales/en/ReportsConfigWidget.json +2 -1
- package/package.json +2 -2
- package/public/locales/en/ReportsConfigWidget.json +2 -1
- package/reports-config-widget-react.build.error.log +1 -14
- package/reports-config-widget-react.build.log +2 -60
- package/src/reports-config-widget-react.ts +6 -0
- package/src/test/AddMappingModal.test.tsx +20 -37
- package/src/test/BulkExtractor.test.ts +15 -17
- package/src/test/DeleteModal.test.tsx +4 -73
- package/src/test/ReportAction.test.tsx +17 -90
- package/src/test/ReportMappingHorizontalTile.test.tsx +3 -54
- package/src/test/ReportMappings.test.tsx +50 -135
- package/src/test/Reports.test.tsx +21 -80
- package/src/test/test-utils.tsx +9 -49
- package/src/widget/components/ActionPanel.tsx +16 -14
- package/src/widget/components/AddMappingsModal.tsx +39 -39
- package/src/widget/components/BulkExtractor.ts +11 -10
- package/src/widget/components/DeleteModal.tsx +14 -20
- package/src/widget/components/HorizontalTile.scss +6 -3
- package/src/widget/components/ReportAction.tsx +15 -30
- package/src/widget/components/ReportHorizontalTile.tsx +10 -11
- package/src/widget/components/ReportMappingHorizontalTile.tsx +2 -3
- package/src/widget/components/ReportMappings.scss +3 -3
- package/src/widget/components/ReportMappings.tsx +66 -69
- package/src/widget/components/Reports.tsx +143 -187
- package/src/widget/components/ReportsConfigContext.tsx +95 -0
- package/src/widget/components/ReportsContainer.tsx +47 -21
- package/src/widget/components/ReportsHeader.tsx +27 -0
- package/src/widget/components/ReportsRouter.tsx +63 -0
- package/src/widget/components/SearchBar.scss +1 -1
- package/src/widget/components/SearchBar.tsx +2 -2
- package/src/widget/components/SelectIModel.tsx +11 -29
- package/src/widget/components/utils.tsx +1 -1
- package/src/widget/context/{ReportsApiConfigContext.tsx → BulkExtractorContext.tsx} +9 -10
- package/src/widget/context/ReportsConfigApiContext.tsx +39 -0
- package/coverage/clover.xml +0 -838
- package/coverage/coverage-final.json +0 -29
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -206
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/src/ReportsConfigWidget.ts.html +0 -193
- package/coverage/lcov-report/src/index.html +0 -116
- package/coverage/lcov-report/src/test/index.html +0 -116
- package/coverage/lcov-report/src/test/test-utils.tsx.html +0 -316
- package/coverage/lcov-report/src/widget/ReportsConfigUiProvider.tsx.html +0 -286
- package/coverage/lcov-report/src/widget/components/ActionPanel.tsx.html +0 -241
- package/coverage/lcov-report/src/widget/components/AddMappingsModal.tsx.html +0 -604
- package/coverage/lcov-report/src/widget/components/BulkExtractor.ts.html +0 -661
- package/coverage/lcov-report/src/widget/components/Constants.ts.html +0 -106
- package/coverage/lcov-report/src/widget/components/DeleteModal.tsx.html +0 -385
- package/coverage/lcov-report/src/widget/components/ExtractionStates/FailedExtractionState.tsx.html +0 -187
- package/coverage/lcov-report/src/widget/components/ExtractionStates/QueuedExtractionState.tsx.html +0 -145
- package/coverage/lcov-report/src/widget/components/ExtractionStates/RunningExtractionState.tsx.html +0 -139
- package/coverage/lcov-report/src/widget/components/ExtractionStates/StartingExtractionState.tsx.html +0 -151
- package/coverage/lcov-report/src/widget/components/ExtractionStates/SucceededExtractionState.tsx.html +0 -190
- package/coverage/lcov-report/src/widget/components/ExtractionStates/index.html +0 -176
- package/coverage/lcov-report/src/widget/components/ExtractionStatus.tsx.html +0 -295
- package/coverage/lcov-report/src/widget/components/ExtractionToast.tsx.html +0 -208
- package/coverage/lcov-report/src/widget/components/HorizontalTile.tsx.html +0 -289
- package/coverage/lcov-report/src/widget/components/LocalizedTablePaginator.tsx.html +0 -262
- package/coverage/lcov-report/src/widget/components/ReportAction.tsx.html +0 -517
- package/coverage/lcov-report/src/widget/components/ReportHorizontalTile.tsx.html +0 -475
- package/coverage/lcov-report/src/widget/components/ReportMappingHorizontalTile.tsx.html +0 -469
- package/coverage/lcov-report/src/widget/components/ReportMappings.tsx.html +0 -1078
- package/coverage/lcov-report/src/widget/components/Reports.tsx.html +0 -877
- package/coverage/lcov-report/src/widget/components/ReportsContainer.tsx.html +0 -223
- package/coverage/lcov-report/src/widget/components/SearchBar.tsx.html +0 -271
- package/coverage/lcov-report/src/widget/components/SelectIModel.tsx.html +0 -391
- package/coverage/lcov-report/src/widget/components/index.html +0 -371
- package/coverage/lcov-report/src/widget/components/utils.tsx.html +0 -562
- package/coverage/lcov-report/src/widget/context/ReportsApiConfigContext.tsx.html +0 -166
- package/coverage/lcov-report/src/widget/context/index.html +0 -116
- package/coverage/lcov-report/src/widget/hooks/index.html +0 -116
- package/coverage/lcov-report/src/widget/hooks/useValidator.ts.html +0 -295
- package/coverage/lcov-report/src/widget/index.html +0 -116
- package/coverage/lcov.info +0 -1594
- package/lib/cjs/widget/context/ReportsApiConfigContext.d.ts +0 -9
- package/lib/cjs/widget/context/ReportsApiConfigContext.d.ts.map +0 -1
- package/lib/cjs/widget/context/ReportsApiConfigContext.js.map +0 -1
- package/lib/esm/widget/context/ReportsApiConfigContext.d.ts +0 -9
- package/lib/esm/widget/context/ReportsApiConfigContext.d.ts.map +0 -1
- package/lib/esm/widget/context/ReportsApiConfigContext.js +0 -14
- package/lib/esm/widget/context/ReportsApiConfigContext.js.map +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ReportsRouter = void 0;
|
|
7
|
+
/*---------------------------------------------------------------------------------------------
|
|
8
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
9
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
10
|
+
*--------------------------------------------------------------------------------------------*/
|
|
11
|
+
const appui_react_1 = require("@itwin/appui-react");
|
|
12
|
+
const react_1 = __importDefault(require("react"));
|
|
13
|
+
const ReportsConfigWidget_1 = require("../../ReportsConfigWidget");
|
|
14
|
+
const ReportAction_1 = require("./ReportAction");
|
|
15
|
+
const ReportMappings_1 = require("./ReportMappings");
|
|
16
|
+
const Reports_1 = require("./Reports");
|
|
17
|
+
const ReportsContainer_1 = require("./ReportsContainer");
|
|
18
|
+
const ReportsRouter = ({ currentRoute, navigateTo, goBack, }) => {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
const { report } = currentRoute.reportsRoutingFields;
|
|
21
|
+
const iModelId = (_b = (_a = appui_react_1.useActiveIModelConnection()) === null || _a === void 0 ? void 0 : _a.iModelId) !== null && _b !== void 0 ? _b : "";
|
|
22
|
+
switch (currentRoute.step) {
|
|
23
|
+
case ReportsContainer_1.RouteStep.ReportsList:
|
|
24
|
+
return (react_1.default.createElement(Reports_1.Reports, { onClickAddReport: () => navigateTo(() => ({
|
|
25
|
+
step: ReportsContainer_1.RouteStep.ReportAction,
|
|
26
|
+
title: ReportsConfigWidget_1.ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:ITwinReports"),
|
|
27
|
+
reportsRoutingFields: {},
|
|
28
|
+
})), onClickReportTitle: (r) => {
|
|
29
|
+
navigateTo(() => ({
|
|
30
|
+
step: ReportsContainer_1.RouteStep.ReportMappings,
|
|
31
|
+
reportsRoutingFields: { report: r },
|
|
32
|
+
title: r.displayName,
|
|
33
|
+
}));
|
|
34
|
+
}, onClickReportModify: (r) => {
|
|
35
|
+
navigateTo(() => ({
|
|
36
|
+
step: ReportsContainer_1.RouteStep.ReportAction,
|
|
37
|
+
reportsRoutingFields: { report: r },
|
|
38
|
+
title: r.displayName,
|
|
39
|
+
}));
|
|
40
|
+
} }));
|
|
41
|
+
case ReportsContainer_1.RouteStep.ReportAction:
|
|
42
|
+
return react_1.default.createElement(ReportAction_1.ReportAction, { report: report, onClickCancel: goBack, onSaveSuccess: goBack });
|
|
43
|
+
case ReportsContainer_1.RouteStep.ReportMappings:
|
|
44
|
+
if (!report)
|
|
45
|
+
return null;
|
|
46
|
+
return react_1.default.createElement(ReportMappings_1.ReportMappings, { report: report, onClickClose: goBack, defaultIModelId: iModelId });
|
|
47
|
+
default:
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
exports.ReportsRouter = ReportsRouter;
|
|
52
|
+
//# sourceMappingURL=ReportsRouter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReportsRouter.js","sourceRoot":"","sources":["../../../../src/widget/components/ReportsRouter.tsx"],"names":[],"mappings":";;;;;;AAAA;;;+FAG+F;AAC/F,oDAA+D;AAC/D,kDAA0B;AAC1B,mEAAgE;AAChE,iDAA8C;AAC9C,qDAAkD;AAClD,uCAAoC;AAEpC,yDAA+C;AAExC,MAAM,aAAa,GAAG,CAAC,EAC5B,YAAY,EACZ,UAAU,EACV,MAAM,GAKP,EAAE,EAAE;;IACH,MAAM,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC,oBAAoB,CAAC;IACrD,MAAM,QAAQ,GAAG,MAAA,MAAA,uCAAyB,EAAE,0CAAE,QAAQ,mCAAI,EAAE,CAAC;IAC7D,QAAQ,YAAY,CAAC,IAAI,EAAE;QACzB,KAAK,4BAAS,CAAC,WAAW;YACxB,OAAO,CACL,8BAAC,iBAAO,IACN,gBAAgB,EAAE,GAAG,EAAE,CACrB,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC;oBAChB,IAAI,EAAE,4BAAS,CAAC,YAAY;oBAC5B,KAAK,EAAE,yCAAmB,CAAC,YAAY,CAAC,kBAAkB,CACxD,kCAAkC,CACnC;oBACD,oBAAoB,EAAE,EAAE;iBACzB,CAAC,CAAC,EAEL,kBAAkB,EAAE,CAAC,CAAC,EAAE,EAAE;oBACxB,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC;wBAChB,IAAI,EAAE,4BAAS,CAAC,cAAc;wBAC9B,oBAAoB,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE;wBACnC,KAAK,EAAE,CAAC,CAAC,WAAW;qBACrB,CAAC,CAAC,CAAC;gBACN,CAAC,EACD,mBAAmB,EAAE,CAAC,CAAC,EAAE,EAAE;oBACzB,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC;wBAChB,IAAI,EAAE,4BAAS,CAAC,YAAY;wBAC5B,oBAAoB,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE;wBACnC,KAAK,EAAE,CAAC,CAAC,WAAW;qBACrB,CAAC,CAAC,CAAC;gBACN,CAAC,GACD,CACH,CAAC;QAEJ,KAAK,4BAAS,CAAC,YAAY;YACzB,OAAO,8BAAC,2BAAY,IAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAI,CAAC;QACxF,KAAK,4BAAS,CAAC,cAAc;YAC3B,IAAI,CAAC,MAAM;gBAAE,OAAO,IAAI,CAAC;YACzB,OAAO,8BAAC,+BAAc,IAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,QAAQ,GAAI,CAAC;QAC7F;YACE,OAAO,IAAI,CAAC;KACf;AACH,CAAC,CAAC;AAjDW,QAAA,aAAa,iBAiDxB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport React from \"react\";\nimport { ReportsConfigWidget } from \"../../ReportsConfigWidget\";\nimport { ReportAction } from \"./ReportAction\";\nimport { ReportMappings } from \"./ReportMappings\";\nimport { Reports } from \"./Reports\";\nimport type { Route } from \"./ReportsContainer\";\nimport { RouteStep } from \"./ReportsContainer\";\n\nexport const ReportsRouter = ({\n currentRoute,\n navigateTo,\n goBack,\n}: {\n currentRoute: Route;\n navigateTo: (toRoute: (prev: Route | undefined) => Route) => void;\n goBack: () => void;\n}) => {\n const { report } = currentRoute.reportsRoutingFields;\n const iModelId = useActiveIModelConnection()?.iModelId ?? \"\";\n switch (currentRoute.step) {\n case RouteStep.ReportsList:\n return (\n <Reports\n onClickAddReport={() =>\n navigateTo(() => ({\n step: RouteStep.ReportAction,\n title: ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ITwinReports\"\n ),\n reportsRoutingFields: {},\n }))\n }\n onClickReportTitle={(r) => {\n navigateTo(() => ({\n step: RouteStep.ReportMappings,\n reportsRoutingFields: { report: r },\n title: r.displayName,\n }));\n }}\n onClickReportModify={(r) => {\n navigateTo(() => ({\n step: RouteStep.ReportAction,\n reportsRoutingFields: { report: r },\n title: r.displayName,\n }));\n }}\n />\n );\n\n case RouteStep.ReportAction:\n return <ReportAction report={report} onClickCancel={goBack} onSaveSuccess={goBack} />;\n case RouteStep.ReportMappings:\n if (!report) return null;\n return <ReportMappings report={report} onClickClose={goBack} defaultIModelId={iModelId} />;\n default:\n return null;\n }\n};\n"]}
|
|
@@ -42,8 +42,7 @@ const SearchBar = ({ searchValue, setSearchValue, disabled, }) => {
|
|
|
42
42
|
}
|
|
43
43
|
} },
|
|
44
44
|
react_1.default.createElement(itwinui_react_1.LabeledInput, { "aria-label": "search-textbox", placeholder: ReportsConfigWidget_1.ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:Search"), svgIcon: react_1.default.createElement(itwinui_react_1.IconButton, { onClick: () => setSearchBarClosing(true), styleType: "borderless" },
|
|
45
|
-
react_1.default.createElement(itwinui_icons_react_1.SvgCloseSmall, null)), iconDisplayStyle: "inline", value: searchValue, onChange: (e) => setSearchValue(e.target.value), disabled: disabled }),
|
|
46
|
-
" ")) : (react_1.default.createElement(itwinui_react_1.IconButton, { styleType: "borderless", onClick: () => setSearchBarOpened(true) },
|
|
45
|
+
react_1.default.createElement(itwinui_icons_react_1.SvgCloseSmall, null)), iconDisplayStyle: "inline", value: searchValue, onChange: (e) => setSearchValue(e.target.value), disabled: disabled }))) : (react_1.default.createElement(itwinui_react_1.IconButton, { styleType: "borderless", "data-testid": "rcw-search-button", onClick: () => setSearchBarOpened(true) },
|
|
47
46
|
react_1.default.createElement(itwinui_icons_react_1.SvgSearch, null)));
|
|
48
47
|
};
|
|
49
48
|
exports.SearchBar = SearchBar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchBar.js","sourceRoot":"","sources":["../../../../src/widget/components/SearchBar.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,oEAAsE;AACtE,wDAAgE;AAChE,+CAAwC;AACxC,mEAAgE;AAChE,4BAA0B;AAQnB,MAAM,SAAS,GAAG,CAAC,EACxB,WAAW,EACX,cAAc,EACd,QAAQ,GACO,EAAE,EAAE;IACnB,MAAM,CAAC,aAAa,EAAE,kBAAkB,CAAC,GAAG,gBAAQ,CAAU,KAAK,CAAC,CAAC;IACrE,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,gBAAQ,CAAU,KAAK,CAAC,CAAC;IAEzE,OAAO,aAAa,IAAI,WAAW,CAAC,CAAC,CAAC,CACpC,uCAAK,SAAS,EAAC,mBAAmB,EAChC,KAAK,EAAE;YACL,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,gBAAgB;SAClE,EACD,cAAc,EAAE,GAAG,EAAE;YACnB,IAAI,gBAAgB,EAAE;gBACpB,mBAAmB,CAAC,KAAK,CAAC,CAAC;gBAC3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ACpB,mBAAmB,CAAC,KAAK,CAAC,CAAC;gBAC3B,kBAAkB,CAAC,KAAK,CAAC,CAAC;gBAC1B,cAAc,CAAC,EAAE,CAAC,CAAC;aACpB;QACH,CAAC;QAED,8BAAC,4BAAY,kBACA,gBAAgB,EAC3B,WAAW,EAAE,yCAAmB,CAAC,YAAY,CAAC,kBAAkB,CAC9D,4BAA4B,CAC7B,EACD,OAAO,EACL,8BAAC,0BAAU,IACT,OAAO,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,EACxC,SAAS,EAAC,YAAY;gBAEtB,8BAAC,mCAAa,OAAG,CACN,EAEf,gBAAgB,EAAC,QAAQ,EACzB,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC/C,QAAQ,EAAE,QAAQ,GAClB,CACE,CACP,CAAC,CAAC,CAAC,CACF,8BAAC,0BAAU,IAAC,SAAS,EAAC,YAAY,iBAAa,mBAAmB,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC;QACxG,8BAAC,+BAAS,OAAG,CACF,CACd,CAAC;AACJ,CAAC,CAAC;AA7CW,QAAA,SAAS,aA6CpB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { SvgCloseSmall, SvgSearch } from \"@itwin/itwinui-icons-react\";\nimport { IconButton, LabeledInput } from \"@itwin/itwinui-react\";\nimport React, { useState } from \"react\";\nimport { ReportsConfigWidget } from \"../../ReportsConfigWidget\";\nimport \"./SearchBar.scss\";\n\ninterface SearchBarProps {\n searchValue: string;\n setSearchValue: React.Dispatch<React.SetStateAction<string>>;\n disabled?: boolean;\n}\n\nexport const SearchBar = ({\n searchValue,\n setSearchValue,\n disabled,\n}: SearchBarProps) => {\n const [searchBarOpen, setSearchBarOpened] = useState<boolean>(false);\n const [searchBarClosing, setSearchBarClosing] = useState<boolean>(false);\n\n return searchBarOpen || searchValue ? (\n <div className=\"rcw-search-button\"\n style={{\n animation: searchBarClosing ? \"rcw-shrink .5s\" : \"rcw-expand .5s\",\n }}\n onAnimationEnd={() => {\n if (searchBarClosing) {\n setSearchBarClosing(false);\n setSearchBarOpened(false);\n setSearchValue(\"\");\n }\n }}\n >\n <LabeledInput\n aria-label=\"search-textbox\"\n placeholder={ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:Search\"\n )}\n svgIcon={\n <IconButton\n onClick={() => setSearchBarClosing(true)}\n styleType=\"borderless\"\n >\n <SvgCloseSmall />\n </IconButton>\n }\n iconDisplayStyle=\"inline\"\n value={searchValue}\n onChange={(e) => setSearchValue(e.target.value)}\n disabled={disabled}\n />\n </div>\n ) : (\n <IconButton styleType=\"borderless\" data-testid=\"rcw-search-button\" onClick={() => setSearchBarOpened(true)}>\n <SvgSearch />\n </IconButton>\n );\n};\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import "./SelectIModel.scss";
|
|
3
3
|
interface SelectedIModelProps {
|
|
4
|
-
selectedIModelId
|
|
5
|
-
setSelectedIModelId:
|
|
4
|
+
selectedIModelId?: string;
|
|
5
|
+
setSelectedIModelId: (iModelId: string) => void;
|
|
6
6
|
}
|
|
7
7
|
export declare const SelectIModel: ({ selectedIModelId, setSelectedIModelId, }: SelectedIModelProps) => JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectIModel.d.ts","sourceRoot":"","sources":["../../../../src/widget/components/SelectIModel.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SelectIModel.d.ts","sourceRoot":"","sources":["../../../../src/widget/components/SelectIModel.tsx"],"names":[],"mappings":";AAkBA,OAAO,qBAAqB,CAAC;AAoB7B,UAAU,mBAAmB;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACjD;AAED,eAAO,MAAM,YAAY,+CAGtB,mBAAmB,gBAqCrB,CAAC"}
|
|
@@ -20,25 +20,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.SelectIModel = void 0;
|
|
23
|
-
/*---------------------------------------------------------------------------------------------
|
|
24
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
25
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
26
|
-
*--------------------------------------------------------------------------------------------*/
|
|
27
|
-
const appui_react_1 = require("@itwin/appui-react");
|
|
28
23
|
const imodels_access_frontend_1 = require("@itwin/imodels-access-frontend");
|
|
29
24
|
const imodels_client_management_1 = require("@itwin/imodels-client-management");
|
|
30
25
|
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
31
26
|
const react_1 = __importStar(require("react"));
|
|
32
27
|
const ReportsConfigWidget_1 = require("../../ReportsConfigWidget");
|
|
33
|
-
const
|
|
28
|
+
const ReportsConfigApiContext_1 = require("../context/ReportsConfigApiContext");
|
|
34
29
|
require("./SelectIModel.scss");
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const iModelClientOptions = {
|
|
38
|
-
api: { baseUrl: utils_1.generateUrl(imodels_client_management_1.Constants.api.baseUrl, apiContext.baseUrl) },
|
|
39
|
-
};
|
|
40
|
-
const iModelsClient = new imodels_client_management_1.IModelsClient(iModelClientOptions);
|
|
41
|
-
const accessToken = await apiContext.getAccessToken();
|
|
30
|
+
const fetchIModels = async (setiModels, iTwinId, iModelsClient, getAccessToken) => {
|
|
31
|
+
const accessToken = await getAccessToken();
|
|
42
32
|
const authorization = imodels_access_frontend_1.AccessTokenAdapter.toAuthorizationCallback(accessToken);
|
|
43
33
|
const getiModelListParams = {
|
|
44
34
|
urlParams: { projectId: iTwinId },
|
|
@@ -48,21 +38,11 @@ const fetchIModels = async (setiModels, iTwinId, apiContext) => {
|
|
|
48
38
|
setiModels(iModels);
|
|
49
39
|
};
|
|
50
40
|
const SelectIModel = ({ selectedIModelId, setSelectedIModelId, }) => {
|
|
51
|
-
|
|
52
|
-
const apiConfig = ReportsApiConfigContext_1.useReportsApiConfig();
|
|
53
|
-
const iModelId = (_b = (_a = appui_react_1.useActiveIModelConnection()) === null || _a === void 0 ? void 0 : _a.iModelId) !== null && _b !== void 0 ? _b : "";
|
|
54
|
-
const iTwinId = (_d = (_c = appui_react_1.useActiveIModelConnection()) === null || _c === void 0 ? void 0 : _c.iTwinId) !== null && _d !== void 0 ? _d : "";
|
|
41
|
+
const { iTwinId, getAccessToken, iModelsClient } = ReportsConfigApiContext_1.useReportsConfigApi();
|
|
55
42
|
const [iModels, setIModels] = react_1.useState([]);
|
|
56
43
|
react_1.useEffect(() => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
}, [apiConfig, setIModels, iModelId, iTwinId]);
|
|
61
|
-
react_1.useEffect(() => {
|
|
62
|
-
if (iModelId && iModels.length > 0) {
|
|
63
|
-
setSelectedIModelId(iModelId);
|
|
64
|
-
}
|
|
65
|
-
}, [iModelId, iModels, setSelectedIModelId]);
|
|
44
|
+
void fetchIModels(setIModels, iTwinId, iModelsClient, getAccessToken);
|
|
45
|
+
}, [getAccessToken, iModelsClient, iTwinId, setIModels]);
|
|
66
46
|
const iModelOptions = react_1.useMemo(() => {
|
|
67
47
|
return iModels.map((iModel) => ({
|
|
68
48
|
label: iModel.displayName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectIModel.js","sourceRoot":"","sources":["../../../../src/widget/components/SelectIModel.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+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AC,CAAC;YAC9B,KAAK,EAAE,MAAM,CAAC,WAAW;YACzB,KAAK,EAAE,MAAM,CAAC,EAAE;SACjB,CAAC,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,CACL,uCAAK,SAAS,EAAC,mBAAmB;QAChC,8BAAC,qBAAK,IAAC,OAAO,EAAC,aAAa,IACzB,yCAAmB,CAAC,YAAY,CAAC,kBAAkB,CAClD,kCAAkC,CACnC,CACK;QACR,uCAAK,SAAS,EAAC,cAAc;YAC3B,8BAAC,wBAAQ,IACP,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;oBAClB,mBAAmB,CAAC,KAAK,CAAC,CAAC;gBAC7B,CAAC,EACD,UAAU,EAAE;oBACV,EAAE,EAAE,aAAa;iBAClB,EACD,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,GACzC,CACE,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAxCW,QAAA,YAAY,gBAwCvB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type { AccessToken } from \"@itwin/core-bentley\";\nimport { AccessTokenAdapter } from \"@itwin/imodels-access-frontend\";\nimport type {\n GetIModelListParams,\n IModelsClient,\n MinimalIModel,\n} from \"@itwin/imodels-client-management\";\nimport {\n toArray,\n} from \"@itwin/imodels-client-management\";\nimport { ComboBox, Label } from \"@itwin/itwinui-react\";\nimport React, { useEffect, useMemo, useState } from \"react\";\nimport { ReportsConfigWidget } from \"../../ReportsConfigWidget\";\nimport { useReportsConfigApi } from \"../context/ReportsConfigApiContext\";\nimport \"./SelectIModel.scss\";\n\nconst fetchIModels = async (\n setiModels: React.Dispatch<React.SetStateAction<MinimalIModel[]>>,\n iTwinId: string,\n iModelsClient: IModelsClient,\n getAccessToken: () => Promise<AccessToken>\n) => {\n const accessToken = await getAccessToken();\n const authorization = AccessTokenAdapter.toAuthorizationCallback(accessToken);\n const getiModelListParams: GetIModelListParams = {\n urlParams: { projectId: iTwinId },\n authorization,\n };\n const iModels = await toArray(\n iModelsClient.iModels.getMinimalList(getiModelListParams)\n );\n setiModels(iModels);\n};\n\ninterface SelectedIModelProps {\n selectedIModelId?: string;\n setSelectedIModelId: (iModelId: string) => void;\n}\n\nexport const SelectIModel = ({\n selectedIModelId,\n setSelectedIModelId,\n}: SelectedIModelProps) => {\n const { iTwinId, getAccessToken, iModelsClient } = useReportsConfigApi();\n const [iModels, setIModels] = useState<MinimalIModel[]>([]);\n\n useEffect(() => {\n void fetchIModels(setIModels, iTwinId, iModelsClient, getAccessToken);\n }, [getAccessToken, iModelsClient, iTwinId, setIModels]);\n\n const iModelOptions = useMemo(() => {\n return iModels.map((iModel) => ({\n label: iModel.displayName,\n value: iModel.id,\n }));\n }, [iModels]);\n\n return (\n <div className=\"rcw-select-imodel\">\n <Label htmlFor=\"combo-input\">\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:SelectIModel\"\n )}\n </Label>\n <div className=\"rcw-combobox\">\n <ComboBox<string>\n options={iModelOptions}\n value={selectedIModelId}\n onChange={(value) => {\n setSelectedIModelId(value);\n }}\n inputProps={{\n id: \"combo-input\",\n }}\n style={{ flexGrow: 1, maxWidth: \"395px\" }}\n />\n </div>\n </div>\n );\n};\n"]}
|
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
export interface WidgetHeaderProps {
|
|
4
4
|
title: string;
|
|
5
5
|
disabled?: boolean;
|
|
6
|
-
returnFn?: () =>
|
|
6
|
+
returnFn?: () => void;
|
|
7
7
|
}
|
|
8
8
|
export declare const WidgetHeader: ({ title, disabled, returnFn, }: WidgetHeaderProps) => JSX.Element;
|
|
9
9
|
export declare const handleError: (errorStatus: number) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/widget/components/utils.tsx"],"names":[],"mappings":"AAWA,OAAO,cAAc,CAAC;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/widget/components/utils.tsx"],"names":[],"mappings":"AAWA,OAAO,cAAc,CAAC;AACtB,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,eAAO,MAAM,YAAY,mCAItB,iBAAiB,gBAiBnB,CAAC;AAEF,eAAO,MAAM,WAAW,gBAAiB,MAAM,SAwD9C,CAAC;AAEF,eAAO,MAAM,cAAc,mBAc1B,CAAC;AACF,UAAU,iBAAiB;IACzB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AACD,eAAO,MAAM,YAAY,iBAAkB,iBAAiB,gBAE3D,CAAC;AAEF,eAAO,MAAM,iBAAiB,SACzB,MAAM,WAAW,CAAC,gBAAgB,CAAC,wEAUvC,CAAC;AAEF,eAAO,MAAM,cAAc,mBAS1B,CAAC;AAEF,eAAO,MAAM,aAAa,mBAEzB,CAAC;AAEF,eAAO,MAAM,WAAW,YAAa,MAAM,cAAc,MAAM,WAE9D,CAAC;AAEF,oBAAY,uBAAuB,CAAC,SAAS,IAAI;KAC9C,QAAQ,IAAI,MAAM,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC;CACnD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/widget/components/utils.tsx"],"names":[],"mappings":";;;;;;AAAA;;;+FAG+F;AAC/F,oEAA4D;AAC5D,wDAK8B;AAC9B,wBAAsB;AACtB,kDAA0B;AAC1B,mEAAgE;AAQzD,MAAM,YAAY,GAAG,CAAC,EAC3B,KAAK,EACL,QAAQ,GAAG,KAAK,EAChB,QAAQ,GACU,EAAE,EAAE;IACtB,OAAO,CACL,uCAAK,SAAS,EAAC,6BAA6B;QACzC,QAAQ,IAAI,CACX,8BAAC,0BAAU,IACT,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAC,YAAY;YAEtB,8BAAC,oCAAc,OAAG,CACP,CACd;QACD,8BAAC,oBAAI,IAAC,SAAS,EAAC,WAAW,EAAC,OAAO,EAAC,OAAO,IACxC,KAAK,CACD,CACH,CACP,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,YAAY,gBAqBvB;AAEK,MAAM,WAAW,GAAG,CAAC,WAAmB,EAAE,EAAE;IACjD,IAAI,YAAY,GAAG,GAAG,yCAAmB,CAAC,YAAY,CAAC,kBAAkB,CACvE,yCAAyC,CAC1C,GAAG,CAAC;IACL,QAAQ,WAAW,EAAE;QACnB,KAAK,GAAG;YACN,YAAY,IAAI,yCAAmB,CAAC,YAAY,CAAC,kBAAkB,CACjE,uCAAuC,CACxC,CAAC;YACF,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,yCAAmB,CAAC,YAAY,CAAC,kBAAkB,CACjE,uCAAuC,CACxC,CAAC;YACF,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,yCAAmB,CAAC,YAAY,CAAC,kBAAkB,CACjE,uCAAuC,CACxC,CAAC;YACF,MAAM;QACR,KAAK,GAAG;YACN,YAAY,IAAI,yCAAmB,CAAC,YAAY,CAAC,kBAAkB,CACjE,uCAAuC,CACxC,CAAC;YACF,MAAM;QACR,KAAK,GAAG;YACN,YA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tC,MAAS,EACT,SAAkD,EAClD,EAAE;IACF,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC;IAEjC,SAAS,CAAC;QACR,GAAG,MAAM;QACT,CAAC,IAAI,CAAC,EAAE,KAAK;KACd,CAAC,CAAC;AACL,CAAC,CAAC;AAXW,QAAA,iBAAiB,qBAW5B;AAEK,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,OAAO,CACL,uCACE,SAAS,EAAC,qBAAqB,iBACnB,4BAA4B;QAExC,8BAAC,8BAAc,IAAC,IAAI,EAAC,OAAO,EAAC,aAAa,SAAG,CACzC,CACP,CAAC;AACJ,CAAC,CAAC;AATW,QAAA,cAAc,kBASzB;AAEK,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,CACjC,uCAAK,SAAS,EAAC,iCAAiC,GAAG,CACpD,CAAC;AAFW,QAAA,aAAa,iBAExB;AAEK,MAAM,WAAW,GAAG,CAAC,OAAe,EAAE,UAAkB,EAAE,EAAE;IACjE,OAAO,OAAO,CAAC,OAAO,CAAC,yBAAyB,EAAE,UAAU,CAAC,CAAC;AAChE,CAAC,CAAC;AAFW,QAAA,WAAW,eAEtB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { SvgChevronLeft } from \"@itwin/itwinui-icons-react\";\nimport {\n IconButton,\n ProgressRadial,\n Text,\n toaster,\n} from \"@itwin/itwinui-react\";\nimport \"./utils.scss\";\nimport React from \"react\";\nimport { ReportsConfigWidget } from \"../../ReportsConfigWidget\";\n\nexport interface WidgetHeaderProps {\n title: string;\n disabled?: boolean;\n returnFn?: () =>
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/widget/components/utils.tsx"],"names":[],"mappings":";;;;;;AAAA;;;+FAG+F;AAC/F,oEAA4D;AAC5D,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CAAC;QACR,GAAG,MAAM;QACT,CAAC,IAAI,CAAC,EAAE,KAAK;KACd,CAAC,CAAC;AACL,CAAC,CAAC;AAXW,QAAA,iBAAiB,qBAW5B;AAEK,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,OAAO,CACL,uCACE,SAAS,EAAC,qBAAqB,iBACnB,4BAA4B;QAExC,8BAAC,8BAAc,IAAC,IAAI,EAAC,OAAO,EAAC,aAAa,SAAG,CACzC,CACP,CAAC;AACJ,CAAC,CAAC;AATW,QAAA,cAAc,kBASzB;AAEK,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,CACjC,uCAAK,SAAS,EAAC,iCAAiC,GAAG,CACpD,CAAC;AAFW,QAAA,aAAa,iBAExB;AAEK,MAAM,WAAW,GAAG,CAAC,OAAe,EAAE,UAAkB,EAAE,EAAE;IACjE,OAAO,OAAO,CAAC,OAAO,CAAC,yBAAyB,EAAE,UAAU,CAAC,CAAC;AAChE,CAAC,CAAC;AAFW,QAAA,WAAW,eAEtB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { SvgChevronLeft } from \"@itwin/itwinui-icons-react\";\nimport {\n IconButton,\n ProgressRadial,\n Text,\n toaster,\n} from \"@itwin/itwinui-react\";\nimport \"./utils.scss\";\nimport React from \"react\";\nimport { ReportsConfigWidget } from \"../../ReportsConfigWidget\";\n\nexport interface WidgetHeaderProps {\n title: string;\n disabled?: boolean;\n returnFn?: () => void;\n}\n\nexport const WidgetHeader = ({\n title,\n disabled = false,\n returnFn,\n}: WidgetHeaderProps) => {\n return (\n <div className=\"rcw-widget-header-container\">\n {returnFn && (\n <IconButton\n onClick={returnFn}\n disabled={disabled}\n styleType=\"borderless\"\n >\n <SvgChevronLeft />\n </IconButton>\n )}\n <Text className=\"rcw-title\" variant=\"title\">\n {title}\n </Text>\n </div>\n );\n};\n\nexport const handleError = (errorStatus: number) => {\n let errorMessage = `${ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.Error\"\n )} `;\n switch (errorStatus) {\n case 401:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.401\"\n );\n break;\n case 403:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.403\"\n );\n break;\n case 404:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.404\"\n );\n break;\n case 409:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.409\"\n );\n break;\n case 422:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.422\"\n );\n break;\n case 429:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.429\"\n );\n break;\n case 500:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.500\"\n );\n break;\n case 502:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.502\"\n );\n break;\n case 503:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.503\"\n );\n break;\n default:\n errorMessage += ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ErrorMessages.SomethingWentWrong\"\n );\n }\n toaster.negative(errorMessage);\n};\n\nexport const LoadingOverlay = () => (\n <div className=\"rcw-center-overlay\">\n <Text>\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:Loading\"\n )}\n </Text>\n <ProgressRadial indeterminate />\n <Text>\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:PleaseWait\"\n )}\n </Text>\n </div>\n);\ninterface EmptyMessageProps {\n children?: React.ReactNode;\n}\nexport const EmptyMessage = ({ children }: EmptyMessageProps) => {\n return <div className=\"rcw-center-overlay\">{children}</div>;\n};\n\nexport const handleInputChange = <T,>(\n e: React.ChangeEvent<HTMLInputElement>,\n values: T,\n setValues: React.Dispatch<React.SetStateAction<T>>\n) => {\n const { name, value } = e.target;\n\n setValues({\n ...values,\n [name]: value,\n });\n};\n\nexport const LoadingSpinner = () => {\n return (\n <div\n className=\"rcw-loading-spinner\"\n data-testid=\"rcw-action-loading-spinner\"\n >\n <ProgressRadial size=\"small\" indeterminate />\n </div>\n );\n};\n\nexport const SkeletonBlock = () => (\n <div className=\"rcw-skeleton-block iui-skeleton\" />\n);\n\nexport const generateUrl = (baseUrl: string, newBaseUrl: string) => {\n return baseUrl.replace(\"https://api.bentley.com\", newBaseUrl);\n};\n\nexport type CreateTypeFromInterface<Interface> = {\n [Property in keyof Interface]: Interface[Property];\n};\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AccessToken } from "@itwin/core-bentley";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import type { BulkExtractor } from "../components/BulkExtractor";
|
|
4
|
+
export declare type GetAccessTokenFn = () => Promise<AccessToken>;
|
|
5
|
+
export interface BulkExtractorContextProps {
|
|
6
|
+
bulkExtractor?: BulkExtractor;
|
|
7
|
+
}
|
|
8
|
+
export declare const BulkExtractorContext: React.Context<BulkExtractorContextProps>;
|
|
9
|
+
export declare const useBulkExtractor: () => BulkExtractorContextProps;
|
|
10
|
+
//# sourceMappingURL=BulkExtractorContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BulkExtractorContext.d.ts","sourceRoot":"","sources":["../../../../src/widget/context/BulkExtractorContext.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE,oBAAY,gBAAgB,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;AAE1D,MAAM,WAAW,yBAAyB;IACxC,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,eAAO,MAAM,oBAAoB,0CAA+C,CAAC;AAEjF,eAAO,MAAM,gBAAgB,iCAQ5B,CAAC"}
|
|
@@ -19,19 +19,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.
|
|
22
|
+
exports.useBulkExtractor = exports.BulkExtractorContext = void 0;
|
|
23
23
|
const React = __importStar(require("react"));
|
|
24
24
|
const react_1 = require("react");
|
|
25
|
-
exports.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
const useReportsApiConfig = () => {
|
|
30
|
-
const context = React.useContext(exports.ReportsApiConfigContext);
|
|
25
|
+
exports.BulkExtractorContext = react_1.createContext({});
|
|
26
|
+
const useBulkExtractor = () => {
|
|
27
|
+
const context = React.useContext(exports.BulkExtractorContext);
|
|
31
28
|
if (!context) {
|
|
32
|
-
throw new Error("
|
|
29
|
+
throw new Error("useBulkExtractor should be used within a BulkExtractorContext provider");
|
|
33
30
|
}
|
|
34
31
|
return context;
|
|
35
32
|
};
|
|
36
|
-
exports.
|
|
37
|
-
//# sourceMappingURL=
|
|
33
|
+
exports.useBulkExtractor = useBulkExtractor;
|
|
34
|
+
//# sourceMappingURL=BulkExtractorContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BulkExtractorContext.js","sourceRoot":"","sources":["../../../../src/widget/context/BulkExtractorContext.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAKA,6CAA+B;AAC/B,iCAAsC;AASzB,QAAA,oBAAoB,GAAG,qBAAa,CAA4B,EAAE,CAAC,CAAC;AAE1E,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,4BAAoB,CAAC,CAAC;IACvD,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CACb,wEAAwE,CACzE,CAAC;KACH;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AARW,QAAA,gBAAgB,oBAQ3B","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type { AccessToken } from \"@itwin/core-bentley\";\nimport * as React from \"react\";\nimport { createContext } from \"react\";\nimport type { BulkExtractor } from \"../components/BulkExtractor\";\n\nexport type GetAccessTokenFn = () => Promise<AccessToken>;\n\nexport interface BulkExtractorContextProps {\n bulkExtractor?: BulkExtractor;\n}\n\nexport const BulkExtractorContext = createContext<BulkExtractorContextProps>({});\n\nexport const useBulkExtractor = () => {\n const context = React.useContext(BulkExtractorContext);\n if (!context) {\n throw new Error(\n \"useBulkExtractor should be used within a BulkExtractorContext provider\"\n );\n }\n return context;\n};\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AccessToken } from "@itwin/core-bentley";
|
|
2
|
+
import { IModelsClient } from "@itwin/imodels-client-management";
|
|
3
|
+
import { MappingsClient, ReportsClient } from "@itwin/insights-client";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
export declare type GetAccessTokenFn = () => Promise<AccessToken>;
|
|
6
|
+
export interface ReportsConfigApiProps {
|
|
7
|
+
getAccessToken: GetAccessTokenFn;
|
|
8
|
+
iTwinId: string;
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
reportsClient: ReportsClient;
|
|
11
|
+
mappingsClient: MappingsClient;
|
|
12
|
+
iModelsClient: IModelsClient;
|
|
13
|
+
}
|
|
14
|
+
export declare const ReportsConfigApiContext: React.Context<ReportsConfigApiProps>;
|
|
15
|
+
export declare const useReportsConfigApi: () => ReportsConfigApiProps;
|
|
16
|
+
//# sourceMappingURL=ReportsConfigApiContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReportsConfigApiContext.d.ts","sourceRoot":"","sources":["../../../../src/widget/context/ReportsConfigApiContext.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,oBAAY,gBAAgB,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;AAE1D,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,gBAAgB,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,aAAa,CAAC;IAC7B,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,eAAO,MAAM,uBAAuB,sCAOlC,CAAC;AAEH,eAAO,MAAM,mBAAmB,6BAQ/B,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.useReportsConfigApi = exports.ReportsConfigApiContext = void 0;
|
|
23
|
+
const imodels_client_management_1 = require("@itwin/imodels-client-management");
|
|
24
|
+
const insights_client_1 = require("@itwin/insights-client");
|
|
25
|
+
const React = __importStar(require("react"));
|
|
26
|
+
const react_1 = require("react");
|
|
27
|
+
exports.ReportsConfigApiContext = react_1.createContext({
|
|
28
|
+
getAccessToken: async () => "",
|
|
29
|
+
iTwinId: "",
|
|
30
|
+
baseUrl: "",
|
|
31
|
+
reportsClient: new insights_client_1.ReportsClient(),
|
|
32
|
+
mappingsClient: new insights_client_1.MappingsClient(),
|
|
33
|
+
iModelsClient: new imodels_client_management_1.IModelsClient(),
|
|
34
|
+
});
|
|
35
|
+
const useReportsConfigApi = () => {
|
|
36
|
+
const context = React.useContext(exports.ReportsConfigApiContext);
|
|
37
|
+
if (!context) {
|
|
38
|
+
throw new Error("useReportsConfigApi should be used within a ReportsConfigApiContext provider");
|
|
39
|
+
}
|
|
40
|
+
return context;
|
|
41
|
+
};
|
|
42
|
+
exports.useReportsConfigApi = useReportsConfigApi;
|
|
43
|
+
//# sourceMappingURL=ReportsConfigApiContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReportsConfigApiContext.js","sourceRoot":"","sources":["../../../../src/widget/context/ReportsConfigApiContext.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAKA,gFAAiE;AACjE,4DAAuE;AACvE,6CAA+B;AAC/B,iCAAsC;AAazB,QAAA,uBAAuB,GAAG,qBAAa,CAAwB;IAC1E,cAAc,EAAE,KAAK,IAAI,EAAE,CAAC,EAAE;IAC9B,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;IACX,aAAa,EAAE,IAAI,+BAAa,EAAE;IAClC,cAAc,EAAE,IAAI,gCAAc,EAAE;IACpC,aAAa,EAAE,IAAI,yCAAa,EAAE;CACnC,CAAC,CAAC;AAEI,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,+BAAuB,CAAC,CAAC;IAC1D,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CACb,8EAA8E,CAC/E,CAAC;KACH;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AARW,QAAA,mBAAmB,uBAQ9B","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport type { AccessToken } from \"@itwin/core-bentley\";\nimport { IModelsClient } from \"@itwin/imodels-client-management\";\nimport { MappingsClient, ReportsClient } from \"@itwin/insights-client\";\nimport * as React from \"react\";\nimport { createContext } from \"react\";\n\nexport type GetAccessTokenFn = () => Promise<AccessToken>;\n\nexport interface ReportsConfigApiProps {\n getAccessToken: GetAccessTokenFn;\n iTwinId: string;\n baseUrl: string;\n reportsClient: ReportsClient;\n mappingsClient: MappingsClient;\n iModelsClient: IModelsClient;\n}\n\nexport const ReportsConfigApiContext = createContext<ReportsConfigApiProps>({\n getAccessToken: async () => \"\",\n iTwinId: \"\",\n baseUrl: \"\",\n reportsClient: new ReportsClient(),\n mappingsClient: new MappingsClient(),\n iModelsClient: new IModelsClient(),\n});\n\nexport const useReportsConfigApi = () => {\n const context = React.useContext(ReportsConfigApiContext);\n if (!context) {\n throw new Error(\n \"useReportsConfigApi should be used within a ReportsConfigApiContext provider\"\n );\n }\n return context;\n};\n"]}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
/** UI Provider for iTwin Viewer Applications */
|
|
2
2
|
export * from "./widget/ReportsConfigUiProvider";
|
|
3
3
|
export * from "./ReportsConfigWidget";
|
|
4
|
+
export { Reports, ReportsProps } from "./widget/components/Reports";
|
|
5
|
+
export { ReportMappings, ReportMappingsProps } from "./widget/components/ReportMappings";
|
|
6
|
+
export { ReportsConfigContext, ReportsConfigContextProps } from "./widget/components/ReportsConfigContext";
|
|
7
|
+
export { ReportAction, ReportActionProps } from "./widget/components/ReportAction";
|
|
8
|
+
export { BulkExtractor } from "./widget/components/BulkExtractor";
|
|
4
9
|
//# sourceMappingURL=reports-config-widget-react.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reports-config-widget-react.d.ts","sourceRoot":"","sources":["../../src/reports-config-widget-react.ts"],"names":[],"mappings":"AAIA,gDAAgD;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"reports-config-widget-react.d.ts","sourceRoot":"","sources":["../../src/reports-config-widget-react.ts"],"names":[],"mappings":"AAIA,gDAAgD;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AAC3G,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -5,4 +5,9 @@
|
|
|
5
5
|
/** UI Provider for iTwin Viewer Applications */
|
|
6
6
|
export * from "./widget/ReportsConfigUiProvider";
|
|
7
7
|
export * from "./ReportsConfigWidget";
|
|
8
|
+
export { Reports } from "./widget/components/Reports";
|
|
9
|
+
export { ReportMappings } from "./widget/components/ReportMappings";
|
|
10
|
+
export { ReportsConfigContext } from "./widget/components/ReportsConfigContext";
|
|
11
|
+
export { ReportAction } from "./widget/components/ReportAction";
|
|
12
|
+
export { BulkExtractor } from "./widget/components/BulkExtractor";
|
|
8
13
|
//# sourceMappingURL=reports-config-widget-react.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reports-config-widget-react.js","sourceRoot":"","sources":["../../src/reports-config-widget-react.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,gDAAgD;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** UI Provider for iTwin Viewer Applications */\nexport * from \"./widget/ReportsConfigUiProvider\";\nexport * from \"./ReportsConfigWidget\";\n"]}
|
|
1
|
+
{"version":3,"file":"reports-config-widget-react.js","sourceRoot":"","sources":["../../src/reports-config-widget-react.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,gDAAgD;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAgB,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAuB,MAAM,oCAAoC,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAA6B,MAAM,0CAA0C,CAAC;AAC3G,OAAO,EAAE,YAAY,EAAqB,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** UI Provider for iTwin Viewer Applications */\nexport * from \"./widget/ReportsConfigUiProvider\";\nexport * from \"./ReportsConfigWidget\";\n\nexport { Reports, ReportsProps } from \"./widget/components/Reports\";\nexport { ReportMappings, ReportMappingsProps } from \"./widget/components/ReportMappings\";\nexport { ReportsConfigContext, ReportsConfigContextProps } from \"./widget/components/ReportsConfigContext\";\nexport { ReportAction, ReportActionProps } from \"./widget/components/ReportAction\";\nexport { BulkExtractor } from \"./widget/components/BulkExtractor\";\n"]}
|
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
import React from "react";
|
|
6
6
|
import faker from "@faker-js/faker";
|
|
7
7
|
import "@testing-library/jest-dom";
|
|
8
|
-
import { NoRenderApp } from "@itwin/core-frontend";
|
|
9
8
|
import { ReportsConfigWidget } from "../ReportsConfigWidget";
|
|
10
|
-
import { render, screen,
|
|
9
|
+
import { render, screen, waitFor, within, } from "./test-utils";
|
|
11
10
|
import * as moq from "typemoq";
|
|
12
11
|
import { IModelState } from "@itwin/imodels-client-management";
|
|
13
12
|
import { AddMappingsModal } from "../widget/components/AddMappingsModal";
|
|
@@ -177,39 +176,29 @@ const mockReportMappingsAndMappingsFactory = (mockMappings, reportMappings) => {
|
|
|
177
176
|
});
|
|
178
177
|
return reportMappingsAndMapping;
|
|
179
178
|
};
|
|
180
|
-
const connectionMock = moq.Mock.ofType();
|
|
181
|
-
const mockIModelsClient = moq.Mock.ofType();
|
|
182
|
-
jest.mock("@itwin/appui-react", () => ({
|
|
183
|
-
...jest.requireActual("@itwin/appui-react"),
|
|
184
|
-
useActiveIModelConnection: () => connectionMock.object,
|
|
185
|
-
}));
|
|
186
179
|
jest.mock("@itwin/imodels-client-management", () => ({
|
|
187
180
|
...jest.requireActual("@itwin/imodels-client-management"),
|
|
188
|
-
IModelsClient: jest.fn().mockImplementation(() => ({
|
|
189
|
-
iModels: mockIModelsClient.object,
|
|
190
|
-
})),
|
|
191
181
|
toArray: jest.fn().mockImplementation(async () => {
|
|
192
182
|
return mockProjectIModels.iModels;
|
|
193
183
|
}),
|
|
194
184
|
}));
|
|
195
185
|
const mockGetMappings = jest.fn();
|
|
196
186
|
const mockCreateReportMapping = jest.fn();
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
})),
|
|
202
|
-
ReportsClient: jest.fn().mockImplementation(() => ({
|
|
203
|
-
createReportMapping: mockCreateReportMapping,
|
|
204
|
-
})),
|
|
205
|
-
}));
|
|
187
|
+
const mockIModelsClient = moq.Mock.ofType();
|
|
188
|
+
const mockIModelsClientOperations = moq.Mock.ofType();
|
|
189
|
+
const mockReportsClient = moq.Mock.ofType();
|
|
190
|
+
const mockMappingsClient = moq.Mock.ofType();
|
|
206
191
|
beforeAll(async () => {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
192
|
+
const localization = new EmptyLocalization();
|
|
193
|
+
await ReportsConfigWidget.initialize(localization);
|
|
194
|
+
mockIModelsClientOperations.setup(async (x) => x.getSingle(moq.It.isObjectWith({ iModelId: mockIModelId1 })))
|
|
195
|
+
.returns(async () => mockIModelsResponse[0].iModel);
|
|
196
|
+
mockIModelsClientOperations.setup(async (x) => x.getSingle(moq.It.isObjectWith({ iModelId: mockIModelId2 })))
|
|
197
|
+
.returns(async () => mockIModelsResponse[1].iModel);
|
|
198
|
+
mockIModelsClient.setup((x) => x.iModels)
|
|
199
|
+
.returns(() => mockIModelsClientOperations.object);
|
|
200
|
+
mockReportsClient.setup(async (x) => x.createReportMapping(moq.It.isAny(), moq.It.isAny(), moq.It.isAny())).returns(mockCreateReportMapping);
|
|
201
|
+
mockMappingsClient.setup(async (x) => x.getMappings(moq.It.isAny(), moq.It.isAny())).returns(mockGetMappings);
|
|
213
202
|
});
|
|
214
203
|
afterEach(() => {
|
|
215
204
|
mockGetMappings.mockReset();
|
|
@@ -221,7 +210,7 @@ describe("Add Mapping Modal", () => {
|
|
|
221
210
|
const mockMappings = mockMappingsFactory(mockReportMappings);
|
|
222
211
|
const mockReportMappingsAndMappings = mockReportMappingsAndMappingsFactory(mockMappings, mockReportMappings);
|
|
223
212
|
mockGetMappings.mockReturnValueOnce(mockMappings.map((m) => m.mapping));
|
|
224
|
-
const { user } = render(React.createElement(AddMappingsModal, { show: true, reportId: mockReportId, existingMappings: mockReportMappingsAndMappings,
|
|
213
|
+
const { user } = render(React.createElement(AddMappingsModal, { show: true, reportId: mockReportId, existingMappings: mockReportMappingsAndMappings, onClose: jest.fn(), defaultIModelId: mockIModelId1 }), { iTwinId: mockITwinId, reportsClient: mockReportsClient.object, mappingsClient: mockMappingsClient.object, iModelsClient: mockIModelsClient.object });
|
|
225
214
|
expect(screen.getByRole("dialog")).toBeInTheDocument();
|
|
226
215
|
const modal = screen.getByRole("dialog");
|
|
227
216
|
const withinModal = within(modal);
|
|
@@ -229,8 +218,6 @@ describe("Add Mapping Modal", () => {
|
|
|
229
218
|
const addButton = withinModal.getByRole("button", {
|
|
230
219
|
name: /add/i,
|
|
231
220
|
});
|
|
232
|
-
// Add button should be disabled
|
|
233
|
-
expect(addButton).toBeDisabled();
|
|
234
221
|
await waitFor(() => screen.getByRole("row"));
|
|
235
222
|
// Already mapped mappings are disabled
|
|
236
223
|
for (let i = 0; i < mockMappings.length - 1; i++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddMappingModal.test.js","sourceRoot":"","sources":["../../../src/test/AddMappingModal.test.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,2BAA2B,CAAC;AAInC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EACL,MAAM,EACN,MAAM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AG,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;YAChD,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE;gBAClC,IAAI,EAAE,IAAI,MAAM,CACd,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAC/E,GAAG,CACJ;aACF,CAAC,CAAC;YAEH,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;YACnD,MAAM,CAAC,QAAQ,CAAC,CAAC,YAAY,EAAE,CAAC;SACjC;QAED,mCAAmC;QACnC,MAAM,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE;YAC1C,IAAI,EAAE,IAAI,MAAM,CACd,GAAG,YAAY,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,WACjD,IAAI,YAAY,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAC/D,GAAG,CACJ;SACF,CAAC,CAAC;QAEH,MAAM,eAAe,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAElE,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAClC,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAE5B,MAAM,CAAC,uBAAuB,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport React from \"react\";\nimport faker from \"@faker-js/faker\";\nimport \"@testing-library/jest-dom\";\nimport type {\n IModelConnection,\n} from \"@itwin/core-frontend\";\nimport { NoRenderApp } from \"@itwin/core-frontend\";\nimport { ReportsConfigWidget } from \"../ReportsConfigWidget\";\nimport {\n render,\n screen,\n TestUtils,\n waitFor,\n within,\n} from \"./test-utils\";\nimport * as moq from \"typemoq\";\nimport type {\n MappingSingle,\n ReportMappingCollection,\n} from \"@itwin/insights-client\";\nimport type { ReportMappingAndMapping } from \"../widget/components/ReportMappings\";\nimport type { IModelOperations, OperationOptions } from \"@itwin/imodels-client-management\";\nimport { IModelState } from \"@itwin/imodels-client-management\";\nimport { AddMappingsModal } from \"../widget/components/AddMappingsModal\";\nimport { EmptyLocalization } from \"@itwin/core-common\";\n\nconst mockITwinId = faker.datatype.uuid();\nconst mockIModelId1 = faker.datatype.uuid();\nconst mockIModelId2 = faker.datatype.uuid();\n\nconst mockReportId = faker.datatype.uuid();\n\nconst mockIModelsResponse = [\n {\n iModel: {\n id: mockIModelId1,\n displayName: \"rAnDoMdIsPlAynAmE1\",\n name: \"rAnDomName1\",\n description: \"rAnDoMDeScRiPtIoN1\",\n createdDateTime: \"2021-10-04T22:13:50.397Z\",\n state: IModelState.Initialized,\n projectId: mockITwinId,\n extent: null,\n _links: {\n creator: {\n href: \"\",\n },\n namedVersions: {\n href: \"\",\n },\n changesets: {\n href: \"\",\n },\n },\n },\n },\n {\n iModel: {\n id: mockIModelId2,\n displayName: \"rAnDoMdIsPlAynAmE2\",\n name: \"rAnDomName2\",\n description: \"rAnDoMDeScRiPtIoN2\",\n createdDateTime: \"2021-10-04T22:13:50.397Z\",\n state: IModelState.Initialized,\n projectId: mockITwinId,\n extent: null,\n _links: {\n creator: {\n href: \"\",\n },\n namedVersions: {\n href: \"\",\n },\n changesets: {\n href: \"\",\n },\n },\n },\n },\n];\n\nconst mockProjectIModels = {\n iModels: mockIModelsResponse.map((iModel) => ({\n id: iModel.iModel.id,\n displayName: iModel.iModel.displayName,\n })),\n _links: {\n self: {\n href: \"\",\n },\n prev: null,\n next: null,\n },\n};\n\nconst mockReportMappingsFactory = (): ReportMappingCollection => {\n return {\n mappings: [\n {\n reportId: mockReportId,\n mappingId: faker.datatype.uuid(),\n imodelId: mockIModelId1,\n _links: {\n report: {\n href: \"\",\n },\n mapping: {\n href: \"\",\n },\n imodel: {\n href: \"\",\n },\n },\n },\n {\n reportId: mockReportId,\n mappingId: faker.datatype.uuid(),\n imodelId: mockIModelId2,\n _links: {\n report: {\n href: \"\",\n },\n mapping: {\n href: \"\",\n },\n imodel: {\n href: \"\",\n },\n },\n },\n ],\n _links: {\n next: undefined,\n self: {\n href: \"\",\n },\n },\n };\n};\n\nconst mockMappingsFactory = (\n mockReportMappings: ReportMappingCollection\n): MappingSingle[] => {\n const mockMappings: MappingSingle[] = mockReportMappings.mappings.map(\n (mapping, index) => ({\n mapping: {\n id: mapping.mappingId,\n mappingName: `mOcKMaPpIngNaMe${index}`,\n description: `mOcKmApPInGDeScRiPtIoN${index}`,\n extractionEnabled: false,\n createdOn: \"\",\n createdBy: \"\",\n modifiedOn: \"\",\n modifiedBy: \"\",\n _links: {\n imodel: {\n // Tie the mapping to to the iModel Id\n href: mapping.imodelId,\n },\n },\n },\n })\n );\n\n const extraMappingId = faker.datatype.uuid();\n const extraMappingName = \"mOcKNaMeExTrA\";\n const extraMappingDescription = \"mOcKDeScRiPtIoNeXtRa\";\n\n mockMappings.push({\n mapping: {\n id: extraMappingId,\n mappingName: extraMappingName,\n description: extraMappingDescription,\n extractionEnabled: false,\n createdOn: \"\",\n createdBy: \"\",\n modifiedOn: \"\",\n modifiedBy: \"\",\n _links: {\n imodel: {\n href: \"\",\n },\n },\n },\n });\n\n return mockMappings;\n};\n\nconst mockReportMappingsAndMappingsFactory = (mockMappings: MappingSingle[], reportMappings: ReportMappingCollection): ReportMappingAndMapping[] => {\n const reportMappingsAndMapping =\n reportMappings.mappings.map((reportMapping) => {\n const mapping = mockMappings.find((x) => x.mapping.id === reportMapping.mappingId)!.mapping;\n const iModelName = mockProjectIModels.iModels.find((x) => x.id === reportMapping.imodelId)!.displayName;\n const reportMappingAndMapping: ReportMappingAndMapping = {\n ...reportMapping,\n iModelName,\n mappingName: mapping.mappingName,\n mappingDescription: mapping.description ?? \"\",\n };\n return reportMappingAndMapping;\n });\n return reportMappingsAndMapping;\n};\n\nconst connectionMock = moq.Mock.ofType<IModelConnection>();\nconst mockIModelsClient = moq.Mock.ofType<IModelOperations<OperationOptions>>();\n\njest.mock(\"@itwin/appui-react\", () => ({\n ...jest.requireActual(\"@itwin/appui-react\"),\n useActiveIModelConnection: () => connectionMock.object,\n}));\n\njest.mock(\"@itwin/imodels-client-management\", () => ({\n ...jest.requireActual(\"@itwin/imodels-client-management\"),\n IModelsClient: jest.fn().mockImplementation(() => ({\n iModels: mockIModelsClient.object,\n })),\n toArray: jest.fn().mockImplementation(async () => {\n return mockProjectIModels.iModels;\n }),\n}));\n\nconst mockGetMappings = jest.fn();\nconst mockCreateReportMapping = jest.fn();\n\njest.mock(\"@itwin/insights-client\", () => ({\n ...jest.requireActual(\"@itwin/insights-client\"),\n MappingsClient: jest.fn().mockImplementation(() => ({\n getMappings: mockGetMappings,\n })),\n ReportsClient: jest.fn().mockImplementation(() => ({\n createReportMapping: mockCreateReportMapping,\n })),\n}));\n\nbeforeAll(async () => {\n await NoRenderApp.startup({localization: new EmptyLocalization()});\n connectionMock.setup((x) => x.iModelId).returns(() => mockIModelId1);\n await ReportsConfigWidget.initialize();\n});\n\nafterAll(() => {\n TestUtils.terminateUiFramework();\n});\n\nafterEach(() => {\n mockGetMappings.mockReset();\n mockIModelsClient.reset();\n});\n\ndescribe(\"Add Mapping Modal\", () => {\n it(\"Adding mapping sends create request\", async () => {\n const mockReportMappings = mockReportMappingsFactory();\n const mockMappings = mockMappingsFactory(mockReportMappings);\n const mockReportMappingsAndMappings = mockReportMappingsAndMappingsFactory(mockMappings, mockReportMappings);\n\n mockGetMappings.mockReturnValueOnce(mockMappings.map((m: MappingSingle) => m.mapping));\n\n const { user } = render(\n <AddMappingsModal\n show={true}\n reportId={mockReportId}\n existingMappings={mockReportMappingsAndMappings}\n returnFn={jest.fn()}\n />\n );\n\n expect(screen.getByRole(\"dialog\")).toBeInTheDocument();\n const modal = screen.getByRole(\"dialog\");\n const withinModal = within(modal);\n expect(withinModal.getByText(/addmappings/i)).toBeInTheDocument();\n\n const addButton = withinModal.getByRole(\"button\", {\n name: /add/i,\n });\n // Add button should be disabled\n expect(addButton).toBeDisabled();\n\n await waitFor(() => screen.getByRole(\"row\"));\n\n // Already mapped mappings are disabled\n for (let i = 0; i < mockMappings.length - 1; i++) {\n const row = screen.getByRole(\"row\", {\n name: new RegExp(\n `${mockMappings[i].mapping.mappingName} ${mockMappings[i].mapping.description}`,\n \"i\"\n ),\n });\n\n const checkbox = within(row).getByRole(\"checkbox\");\n expect(checkbox).toBeDisabled();\n }\n\n // Click on checkbox on new mapping\n const unmappedRow = screen.getByRole(\"row\", {\n name: new RegExp(\n `${mockMappings[mockMappings.length - 1].mapping.mappingName\n } ${mockMappings[mockMappings.length - 1].mapping.description}`,\n \"i\"\n ),\n });\n\n const enabledCheckbox = within(unmappedRow).getByRole(\"checkbox\");\n\n await user.click(enabledCheckbox);\n await user.click(addButton);\n\n expect(mockCreateReportMapping).toBeCalledTimes(1);\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"AddMappingModal.test.js","sourceRoot":"","sources":["../../../src/test/AddMappingModal.test.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EACL,MAAM,EACN,MAAM,EACN,OAAO,EACP,MAAM,GACP,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,GAAG,MAAM,SAAS,CAAC;AAS/B,OAAO,EAAE,W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CAAC,SAAS,CAAC,CAAC;QAE5B,MAAM,CAAC,uBAAuB,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport React from \"react\";\nimport faker from \"@faker-js/faker\";\nimport \"@testing-library/jest-dom\";\nimport { ReportsConfigWidget } from \"../ReportsConfigWidget\";\nimport {\n render,\n screen,\n waitFor,\n within,\n} from \"./test-utils\";\nimport * as moq from \"typemoq\";\nimport type {\n MappingsClient,\n MappingSingle,\n ReportMappingCollection,\n ReportsClient,\n} from \"@itwin/insights-client\";\nimport type { ReportMappingAndMapping } from \"../widget/components/ReportMappings\";\nimport type { GetSingleIModelParams, IModelOperations, IModelsClient, OperationOptions } from \"@itwin/imodels-client-management\";\nimport { IModelState } from \"@itwin/imodels-client-management\";\nimport { AddMappingsModal } from \"../widget/components/AddMappingsModal\";\nimport { EmptyLocalization } from \"@itwin/core-common\";\n\nconst mockITwinId = faker.datatype.uuid();\nconst mockIModelId1 = faker.datatype.uuid();\nconst mockIModelId2 = faker.datatype.uuid();\n\nconst mockReportId = faker.datatype.uuid();\n\nconst mockIModelsResponse = [\n {\n iModel: {\n id: mockIModelId1,\n displayName: \"rAnDoMdIsPlAynAmE1\",\n name: \"rAnDomName1\",\n description: \"rAnDoMDeScRiPtIoN1\",\n createdDateTime: \"2021-10-04T22:13:50.397Z\",\n state: IModelState.Initialized,\n projectId: mockITwinId,\n extent: null,\n _links: {\n creator: {\n href: \"\",\n },\n namedVersions: {\n href: \"\",\n },\n changesets: {\n href: \"\",\n },\n },\n },\n },\n {\n iModel: {\n id: mockIModelId2,\n displayName: \"rAnDoMdIsPlAynAmE2\",\n name: \"rAnDomName2\",\n description: \"rAnDoMDeScRiPtIoN2\",\n createdDateTime: \"2021-10-04T22:13:50.397Z\",\n state: IModelState.Initialized,\n projectId: mockITwinId,\n extent: null,\n _links: {\n creator: {\n href: \"\",\n },\n namedVersions: {\n href: \"\",\n },\n changesets: {\n href: \"\",\n },\n },\n },\n },\n];\n\nconst mockProjectIModels = {\n iModels: mockIModelsResponse.map((iModel) => ({\n id: iModel.iModel.id,\n displayName: iModel.iModel.displayName,\n })),\n _links: {\n self: {\n href: \"\",\n },\n prev: null,\n next: null,\n },\n};\n\nconst mockReportMappingsFactory = (): ReportMappingCollection => {\n return {\n mappings: [\n {\n reportId: mockReportId,\n mappingId: faker.datatype.uuid(),\n imodelId: mockIModelId1,\n _links: {\n report: {\n href: \"\",\n },\n mapping: {\n href: \"\",\n },\n imodel: {\n href: \"\",\n },\n },\n },\n {\n reportId: mockReportId,\n mappingId: faker.datatype.uuid(),\n imodelId: mockIModelId2,\n _links: {\n report: {\n href: \"\",\n },\n mapping: {\n href: \"\",\n },\n imodel: {\n href: \"\",\n },\n },\n },\n ],\n _links: {\n next: undefined,\n self: {\n href: \"\",\n },\n },\n };\n};\n\nconst mockMappingsFactory = (\n mockReportMappings: ReportMappingCollection\n): MappingSingle[] => {\n const mockMappings: MappingSingle[] = mockReportMappings.mappings.map(\n (mapping, index) => ({\n mapping: {\n id: mapping.mappingId,\n mappingName: `mOcKMaPpIngNaMe${index}`,\n description: `mOcKmApPInGDeScRiPtIoN${index}`,\n extractionEnabled: false,\n createdOn: \"\",\n createdBy: \"\",\n modifiedOn: \"\",\n modifiedBy: \"\",\n _links: {\n imodel: {\n // Tie the mapping to to the iModel Id\n href: mapping.imodelId,\n },\n },\n },\n })\n );\n\n const extraMappingId = faker.datatype.uuid();\n const extraMappingName = \"mOcKNaMeExTrA\";\n const extraMappingDescription = \"mOcKDeScRiPtIoNeXtRa\";\n\n mockMappings.push({\n mapping: {\n id: extraMappingId,\n mappingName: extraMappingName,\n description: extraMappingDescription,\n extractionEnabled: false,\n createdOn: \"\",\n createdBy: \"\",\n modifiedOn: \"\",\n modifiedBy: \"\",\n _links: {\n imodel: {\n href: \"\",\n },\n },\n },\n });\n\n return mockMappings;\n};\n\nconst mockReportMappingsAndMappingsFactory = (mockMappings: MappingSingle[], reportMappings: ReportMappingCollection): ReportMappingAndMapping[] => {\n const reportMappingsAndMapping =\n reportMappings.mappings.map((reportMapping) => {\n const mapping = mockMappings.find((x) => x.mapping.id === reportMapping.mappingId)!.mapping;\n const iModelName = mockProjectIModels.iModels.find((x) => x.id === reportMapping.imodelId)!.displayName;\n const reportMappingAndMapping: ReportMappingAndMapping = {\n ...reportMapping,\n iModelName,\n mappingName: mapping.mappingName,\n mappingDescription: mapping.description ?? \"\",\n };\n return reportMappingAndMapping;\n });\n return reportMappingsAndMapping;\n};\n\njest.mock(\"@itwin/imodels-client-management\", () => ({\n ...jest.requireActual(\"@itwin/imodels-client-management\"),\n toArray: jest.fn().mockImplementation(async () => {\n return mockProjectIModels.iModels;\n }),\n}));\n\nconst mockGetMappings = jest.fn();\nconst mockCreateReportMapping = jest.fn();\n\nconst mockIModelsClient = moq.Mock.ofType<IModelsClient>();\nconst mockIModelsClientOperations = moq.Mock.ofType<IModelOperations<OperationOptions>>();\nconst mockReportsClient = moq.Mock.ofType<ReportsClient>();\nconst mockMappingsClient = moq.Mock.ofType<MappingsClient>();\n\nbeforeAll(async () => {\n const localization = new EmptyLocalization();\n await ReportsConfigWidget.initialize(localization);\n mockIModelsClientOperations.setup(async (x) => x.getSingle(moq.It.isObjectWith<GetSingleIModelParams>({ iModelId: mockIModelId1 })))\n .returns(async () => mockIModelsResponse[0].iModel);\n mockIModelsClientOperations.setup(async (x) => x.getSingle(moq.It.isObjectWith<GetSingleIModelParams>({ iModelId: mockIModelId2 })))\n .returns(async () => mockIModelsResponse[1].iModel);\n mockIModelsClient.setup((x) => x.iModels)\n .returns(() => mockIModelsClientOperations.object);\n mockReportsClient.setup(async (x) => x.createReportMapping(moq.It.isAny(), moq.It.isAny(), moq.It.isAny())).returns(mockCreateReportMapping);\n mockMappingsClient.setup(async (x) => x.getMappings(moq.It.isAny(), moq.It.isAny())).returns(mockGetMappings);\n});\n\nafterEach(() => {\n mockGetMappings.mockReset();\n mockIModelsClient.reset();\n});\n\ndescribe(\"Add Mapping Modal\", () => {\n it(\"Adding mapping sends create request\", async () => {\n const mockReportMappings = mockReportMappingsFactory();\n const mockMappings = mockMappingsFactory(mockReportMappings);\n const mockReportMappingsAndMappings = mockReportMappingsAndMappingsFactory(mockMappings, mockReportMappings);\n\n mockGetMappings.mockReturnValueOnce(mockMappings.map((m: MappingSingle) => m.mapping));\n\n const { user } = render(\n <AddMappingsModal\n show={true}\n reportId={mockReportId}\n existingMappings={mockReportMappingsAndMappings}\n onClose={jest.fn()}\n defaultIModelId={mockIModelId1}\n />, { iTwinId: mockITwinId, reportsClient: mockReportsClient.object, mappingsClient: mockMappingsClient.object, iModelsClient: mockIModelsClient.object }\n );\n\n expect(screen.getByRole(\"dialog\")).toBeInTheDocument();\n const modal = screen.getByRole(\"dialog\");\n const withinModal = within(modal);\n expect(withinModal.getByText(/addmappings/i)).toBeInTheDocument();\n\n const addButton = withinModal.getByRole(\"button\", {\n name: /add/i,\n });\n\n await waitFor(() => screen.getByRole(\"row\"));\n\n // Already mapped mappings are disabled\n for (let i = 0; i < mockMappings.length - 1; i++) {\n const row = screen.getByRole(\"row\", {\n name: new RegExp(\n `${mockMappings[i].mapping.mappingName} ${mockMappings[i].mapping.description}`,\n \"i\"\n ),\n });\n\n const checkbox = within(row).getByRole(\"checkbox\");\n expect(checkbox).toBeDisabled();\n }\n\n // Click on checkbox on new mapping\n const unmappedRow = screen.getByRole(\"row\", {\n name: new RegExp(\n `${mockMappings[mockMappings.length - 1].mapping.mappingName\n } ${mockMappings[mockMappings.length - 1].mapping.description}`,\n \"i\"\n ),\n });\n\n const enabledCheckbox = within(unmappedRow).getByRole(\"checkbox\");\n\n await user.click(enabledCheckbox);\n await user.click(addButton);\n\n expect(mockCreateReportMapping).toBeCalledTimes(1);\n });\n});\n"]}
|