@itwin/reports-config-widget-react 0.2.0 → 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 +90 -36
- package/CHANGELOG.json +33 -0
- package/CHANGELOG.md +18 -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 +4 -4
- 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
|
@@ -1,65 +1,41 @@
|
|
|
1
1
|
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
SvgPlay,
|
|
8
|
-
} from "@itwin/itwinui-icons-react";
|
|
9
|
-
import {
|
|
10
|
-
Button,
|
|
11
|
-
IconButton,
|
|
12
|
-
Surface,
|
|
13
|
-
toaster,
|
|
14
|
-
} from "@itwin/itwinui-react";
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { SvgAdd, SvgPlay, SvgRefresh } from "@itwin/itwinui-icons-react";
|
|
6
|
+
import { Button, IconButton, Surface } from "@itwin/itwinui-react";
|
|
15
7
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
16
8
|
import type { CreateTypeFromInterface } from "./utils";
|
|
17
9
|
import {
|
|
18
10
|
EmptyMessage,
|
|
19
|
-
generateUrl,
|
|
20
11
|
handleError,
|
|
21
12
|
LoadingOverlay,
|
|
22
|
-
WidgetHeader,
|
|
23
13
|
} from "./utils";
|
|
24
14
|
import "./Reports.scss";
|
|
25
15
|
import DeleteModal from "./DeleteModal";
|
|
26
|
-
import type { Report } from "@itwin/insights-client";
|
|
27
|
-
import { REPORTING_BASE_PATH, ReportsClient } from "@itwin/insights-client";
|
|
28
|
-
import ReportAction from "./ReportAction";
|
|
29
|
-
import { ReportMappings } from "./ReportMappings";
|
|
16
|
+
import type { Report, ReportsClient } from "@itwin/insights-client";
|
|
30
17
|
import { ReportHorizontalTile } from "./ReportHorizontalTile";
|
|
31
18
|
import { SearchBar } from "./SearchBar";
|
|
32
|
-
import
|
|
33
|
-
import { useReportsApiConfig } from "../context/ReportsApiConfigContext";
|
|
19
|
+
import { useReportsConfigApi } from "../context/ReportsConfigApiContext";
|
|
34
20
|
import { ReportsConfigWidget } from "../../ReportsConfigWidget";
|
|
35
|
-
import {
|
|
36
|
-
import BulkExtractor from "./BulkExtractor";
|
|
21
|
+
import type { AccessToken } from "@itwin/core-bentley";
|
|
37
22
|
import { BeEvent } from "@itwin/core-bentley";
|
|
38
|
-
import {
|
|
23
|
+
import { useBulkExtractor } from "../context/BulkExtractorContext";
|
|
39
24
|
|
|
40
25
|
export type ReportType = CreateTypeFromInterface<Report>;
|
|
41
26
|
|
|
42
|
-
enum ReportsView {
|
|
43
|
-
REPORTS = "reports",
|
|
44
|
-
REPORTSMAPPING = "reportsmapping",
|
|
45
|
-
ADDING = "adding",
|
|
46
|
-
MODIFYING = "modifying",
|
|
47
|
-
}
|
|
48
|
-
|
|
49
27
|
const fetchReports = async (
|
|
50
|
-
setReports:
|
|
28
|
+
setReports: (reports: Report[]) => void,
|
|
51
29
|
iTwinId: string | undefined,
|
|
52
|
-
setIsLoading:
|
|
53
|
-
|
|
30
|
+
setIsLoading: (isLoading: boolean) => void,
|
|
31
|
+
reportsClient: ReportsClient,
|
|
32
|
+
getAccessToken: () => Promise<AccessToken>
|
|
54
33
|
) => {
|
|
55
34
|
try {
|
|
56
35
|
if (!iTwinId) return;
|
|
57
36
|
setIsLoading(true);
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
);
|
|
61
|
-
const accessToken = await apiContext.getAccessToken();
|
|
62
|
-
const reports = await reportsClientApi.getReports(accessToken, iTwinId);
|
|
37
|
+
const accessToken = await getAccessToken();
|
|
38
|
+
const reports = await reportsClient.getReports(accessToken, iTwinId);
|
|
63
39
|
setReports(reports ?? []);
|
|
64
40
|
} catch (error: any) {
|
|
65
41
|
handleError(error.status);
|
|
@@ -68,50 +44,50 @@ const fetchReports = async (
|
|
|
68
44
|
}
|
|
69
45
|
};
|
|
70
46
|
|
|
71
|
-
export
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const failedExtractionToast = (iModelName: string) => {
|
|
77
|
-
toaster.negative(<FailedExtractionToast iModelName={iModelName} />);
|
|
78
|
-
};
|
|
47
|
+
export interface ReportsProps {
|
|
48
|
+
onClickAddReport?: () => void;
|
|
49
|
+
onClickReportTitle?: (report: Report) => void;
|
|
50
|
+
onClickReportModify?: (report: Report) => void;
|
|
51
|
+
}
|
|
79
52
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
);
|
|
87
|
-
const [
|
|
53
|
+
export const Reports = ({
|
|
54
|
+
onClickAddReport,
|
|
55
|
+
onClickReportModify,
|
|
56
|
+
onClickReportTitle,
|
|
57
|
+
}: ReportsProps) => {
|
|
58
|
+
const { iTwinId, getAccessToken, reportsClient } = useReportsConfigApi();
|
|
59
|
+
const { bulkExtractor } = useBulkExtractor();
|
|
60
|
+
const [showDeleteModal, setShowDeleteModal] = useState<Report | undefined>(
|
|
88
61
|
undefined
|
|
89
62
|
);
|
|
63
|
+
const [selectedReportIds, setSelectedReportIds] = useState<string[]>([]);
|
|
90
64
|
const [isLoading, setIsLoading] = useState<boolean>(true);
|
|
91
65
|
const [searchValue, setSearchValue] = useState<string>("");
|
|
92
66
|
const [reports, setReports] = useState<Report[]>([]);
|
|
93
|
-
const bulkExtractor = useMemo(
|
|
94
|
-
() => new BulkExtractor(apiConfig, successfulExtractionToast, failedExtractionToast),
|
|
95
|
-
[apiConfig]
|
|
96
|
-
);
|
|
97
67
|
const jobStartEvent = useMemo(
|
|
98
68
|
() => new BeEvent<(reportId: string) => void>(),
|
|
99
69
|
[]
|
|
100
70
|
);
|
|
101
71
|
|
|
102
72
|
useEffect(() => {
|
|
103
|
-
void fetchReports(
|
|
104
|
-
|
|
73
|
+
void fetchReports(
|
|
74
|
+
setReports,
|
|
75
|
+
iTwinId,
|
|
76
|
+
setIsLoading,
|
|
77
|
+
reportsClient,
|
|
78
|
+
getAccessToken
|
|
79
|
+
);
|
|
80
|
+
}, [getAccessToken, iTwinId, reportsClient, setIsLoading]);
|
|
105
81
|
|
|
106
82
|
const refresh = useCallback(async () => {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
};
|
|
83
|
+
await fetchReports(
|
|
84
|
+
setReports,
|
|
85
|
+
iTwinId,
|
|
86
|
+
setIsLoading,
|
|
87
|
+
reportsClient,
|
|
88
|
+
getAccessToken
|
|
89
|
+
);
|
|
90
|
+
}, [getAccessToken, iTwinId, reportsClient]);
|
|
115
91
|
|
|
116
92
|
const filteredReports = useMemo(
|
|
117
93
|
() =>
|
|
@@ -125,140 +101,120 @@ export const Reports = () => {
|
|
|
125
101
|
);
|
|
126
102
|
|
|
127
103
|
const onSelectionChange = (reportId: string, control: boolean) => {
|
|
128
|
-
if (!control)
|
|
129
|
-
setSelectedReportIds([]);
|
|
104
|
+
if (!control) setSelectedReportIds([]);
|
|
130
105
|
|
|
131
106
|
setSelectedReportIds((sr) =>
|
|
132
107
|
sr.some((r) => reportId === r)
|
|
133
|
-
? sr.filter(
|
|
134
|
-
(r) => reportId !== r
|
|
135
|
-
)
|
|
108
|
+
? sr.filter((r) => reportId !== r)
|
|
136
109
|
: [...sr, reportId]
|
|
137
110
|
);
|
|
138
111
|
};
|
|
139
112
|
|
|
140
113
|
const updateDatasets = useCallback(async () => {
|
|
114
|
+
if (!bulkExtractor) return;
|
|
141
115
|
await bulkExtractor.runReportExtractions(selectedReportIds);
|
|
142
116
|
selectedReportIds.map((reportId) => jobStartEvent.raiseEvent(reportId));
|
|
143
117
|
setSelectedReportIds([]);
|
|
144
118
|
}, [selectedReportIds, jobStartEvent, bulkExtractor]);
|
|
145
119
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return (
|
|
165
|
-
<>
|
|
166
|
-
<WidgetHeader
|
|
120
|
+
if (!bulkExtractor) return null;
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<>
|
|
124
|
+
<Surface className="rcw-reports-list-container">
|
|
125
|
+
<div className="rcw-toolbar">
|
|
126
|
+
{onClickAddReport && (
|
|
127
|
+
<Button
|
|
128
|
+
startIcon={<SvgAdd />}
|
|
129
|
+
onClick={onClickAddReport}
|
|
130
|
+
styleType="high-visibility"
|
|
131
|
+
>
|
|
132
|
+
{ReportsConfigWidget.localization.getLocalizedString(
|
|
133
|
+
"ReportsConfigWidget:New"
|
|
134
|
+
)}
|
|
135
|
+
</Button>
|
|
136
|
+
)}
|
|
137
|
+
<IconButton
|
|
167
138
|
title={ReportsConfigWidget.localization.getLocalizedString(
|
|
168
|
-
"ReportsConfigWidget:
|
|
139
|
+
"ReportsConfigWidget:UpdateDatasets"
|
|
169
140
|
)}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
<
|
|
205
|
-
|
|
141
|
+
onClick={updateDatasets}
|
|
142
|
+
disabled={selectedReportIds.length === 0}
|
|
143
|
+
>
|
|
144
|
+
<SvgPlay />
|
|
145
|
+
</IconButton>
|
|
146
|
+
<div
|
|
147
|
+
className="rcw-search-bar-container"
|
|
148
|
+
data-testid="rcw-search-bar"
|
|
149
|
+
>
|
|
150
|
+
<IconButton
|
|
151
|
+
title={ReportsConfigWidget.localization.getLocalizedString(
|
|
152
|
+
"ReportsConfigWidget:Refresh"
|
|
153
|
+
)}
|
|
154
|
+
onClick={refresh}
|
|
155
|
+
disabled={isLoading}
|
|
156
|
+
styleType="borderless"
|
|
157
|
+
>
|
|
158
|
+
<SvgRefresh />
|
|
159
|
+
</IconButton>
|
|
160
|
+
<SearchBar
|
|
161
|
+
searchValue={searchValue}
|
|
162
|
+
setSearchValue={setSearchValue}
|
|
163
|
+
disabled={isLoading}
|
|
164
|
+
/>
|
|
165
|
+
</div>
|
|
166
|
+
</div>
|
|
167
|
+
{isLoading ? (
|
|
168
|
+
<LoadingOverlay />
|
|
169
|
+
) : reports.length === 0 && onClickAddReport ? (
|
|
170
|
+
<EmptyMessage>
|
|
171
|
+
<>
|
|
172
|
+
{ReportsConfigWidget.localization.getLocalizedString(
|
|
173
|
+
"ReportsConfigWidget:NoReports"
|
|
174
|
+
)}
|
|
175
|
+
<div>
|
|
176
|
+
<Button onClick={onClickAddReport} styleType="cta">
|
|
206
177
|
{ReportsConfigWidget.localization.getLocalizedString(
|
|
207
|
-
"ReportsConfigWidget:
|
|
178
|
+
"ReportsConfigWidget:CreateOneReportCTA"
|
|
208
179
|
)}
|
|
209
|
-
|
|
210
|
-
<Button onClick={addReport} styleType="cta">
|
|
211
|
-
{ReportsConfigWidget.localization.getLocalizedString(
|
|
212
|
-
"ReportsConfigWidget:CreateOneReportCTA"
|
|
213
|
-
)}
|
|
214
|
-
</Button>
|
|
215
|
-
</div>
|
|
216
|
-
</>
|
|
217
|
-
</EmptyMessage>
|
|
218
|
-
) : (
|
|
219
|
-
<div className="rcw-reports-list">
|
|
220
|
-
{filteredReports.map((report) => (
|
|
221
|
-
<ReportHorizontalTile
|
|
222
|
-
key={report.id}
|
|
223
|
-
report={report}
|
|
224
|
-
onClickTitle={() => {
|
|
225
|
-
setSelectedReport(report);
|
|
226
|
-
setReportsView(ReportsView.REPORTSMAPPING);
|
|
227
|
-
}}
|
|
228
|
-
jobStartEvent={jobStartEvent}
|
|
229
|
-
bulkExtractor={bulkExtractor}
|
|
230
|
-
onClickDelete={() => {
|
|
231
|
-
setSelectedReport(report);
|
|
232
|
-
setShowDeleteModal(true);
|
|
233
|
-
}}
|
|
234
|
-
onClickModify={() => {
|
|
235
|
-
setSelectedReport(report);
|
|
236
|
-
setReportsView(ReportsView.MODIFYING);
|
|
237
|
-
}}
|
|
238
|
-
onSelectionChange={onSelectionChange}
|
|
239
|
-
selected={selectedReportIds.some((reportId) => report.id === reportId)}
|
|
240
|
-
/>
|
|
241
|
-
))}
|
|
180
|
+
</Button>
|
|
242
181
|
</div>
|
|
243
|
-
|
|
244
|
-
</
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
182
|
+
</>
|
|
183
|
+
</EmptyMessage>
|
|
184
|
+
) : (
|
|
185
|
+
<div className="rcw-reports-list">
|
|
186
|
+
{filteredReports.map((report) => (
|
|
187
|
+
<ReportHorizontalTile
|
|
188
|
+
key={report.id}
|
|
189
|
+
report={report}
|
|
190
|
+
onClickTitle={onClickReportTitle}
|
|
191
|
+
jobStartEvent={jobStartEvent}
|
|
192
|
+
bulkExtractor={bulkExtractor}
|
|
193
|
+
onClickDelete={() => {
|
|
194
|
+
setShowDeleteModal(report);
|
|
195
|
+
}}
|
|
196
|
+
onClickModify={onClickReportModify}
|
|
197
|
+
onSelectionChange={onSelectionChange}
|
|
198
|
+
selected={selectedReportIds.some(
|
|
199
|
+
(reportId) => report.id === reportId
|
|
200
|
+
)}
|
|
201
|
+
/>
|
|
202
|
+
))}
|
|
203
|
+
</div>
|
|
204
|
+
)}
|
|
205
|
+
</Surface>
|
|
206
|
+
<DeleteModal
|
|
207
|
+
entityName={showDeleteModal?.displayName}
|
|
208
|
+
onClose={() => setShowDeleteModal(undefined)}
|
|
209
|
+
onDelete={async () => {
|
|
210
|
+
const accessToken = await getAccessToken();
|
|
211
|
+
await reportsClient.deleteReport(
|
|
212
|
+
accessToken,
|
|
213
|
+
showDeleteModal?.id ?? ""
|
|
214
|
+
);
|
|
215
|
+
}}
|
|
216
|
+
refresh={refresh}
|
|
217
|
+
/>
|
|
218
|
+
</>
|
|
219
|
+
);
|
|
264
220
|
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { IModelApp } from "@itwin/core-frontend";
|
|
6
|
+
import type { IModelsClientOptions } from "@itwin/imodels-client-management";
|
|
7
|
+
import { Constants, IModelsClient } from "@itwin/imodels-client-management";
|
|
8
|
+
import { ExtractionClient, MappingsClient, REPORTING_BASE_PATH, ReportsClient } from "@itwin/insights-client";
|
|
9
|
+
import { toaster } from "@itwin/itwinui-react";
|
|
10
|
+
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
11
|
+
import { BulkExtractorContext } from "../context/BulkExtractorContext";
|
|
12
|
+
import type {
|
|
13
|
+
GetAccessTokenFn,
|
|
14
|
+
ReportsConfigApiProps,
|
|
15
|
+
} from "../context/ReportsConfigApiContext";
|
|
16
|
+
import { ReportsConfigApiContext } from "../context/ReportsConfigApiContext";
|
|
17
|
+
import { REPORTS_CONFIG_BASE_URL } from "../ReportsConfigUiProvider";
|
|
18
|
+
import { BulkExtractor } from "./BulkExtractor";
|
|
19
|
+
import { FailedExtractionToast, SuccessfulExtractionToast } from "./ExtractionToast";
|
|
20
|
+
import { generateUrl } from "./utils";
|
|
21
|
+
|
|
22
|
+
export interface ReportsConfigContextProps {
|
|
23
|
+
getAccessToken?: GetAccessTokenFn;
|
|
24
|
+
baseUrl?: string;
|
|
25
|
+
iTwinId: string;
|
|
26
|
+
bulkExtractor?: BulkExtractor;
|
|
27
|
+
reportsClient?: ReportsClient;
|
|
28
|
+
mappingsClient?: MappingsClient;
|
|
29
|
+
extractionClient?: ExtractionClient;
|
|
30
|
+
iModelsClient?: IModelsClient;
|
|
31
|
+
children?: React.ReactNode;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const authorizationClientGetAccessToken = async () =>
|
|
35
|
+
(await IModelApp.authorizationClient?.getAccessToken()) ?? "";
|
|
36
|
+
|
|
37
|
+
export const ReportsConfigContext = (props: ReportsConfigContextProps) => {
|
|
38
|
+
const reportsBaseUrl = useCallback(() => generateUrl(
|
|
39
|
+
REPORTING_BASE_PATH,
|
|
40
|
+
props.baseUrl || REPORTS_CONFIG_BASE_URL
|
|
41
|
+
), [props.baseUrl]);
|
|
42
|
+
const iModelClientOptions: IModelsClientOptions = useMemo(() => ({
|
|
43
|
+
api: { baseUrl: generateUrl(Constants.api.baseUrl, props.baseUrl ?? REPORTS_CONFIG_BASE_URL) },
|
|
44
|
+
}), [props.baseUrl]);
|
|
45
|
+
const [extractionClient, setExtractionClient] = useState<ExtractionClient>(
|
|
46
|
+
props.extractionClient ?? new ExtractionClient(reportsBaseUrl())
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const [apiConfig, setApiConfig] = useState<ReportsConfigApiProps>({
|
|
50
|
+
getAccessToken: props.getAccessToken ?? authorizationClientGetAccessToken,
|
|
51
|
+
baseUrl: reportsBaseUrl(),
|
|
52
|
+
iTwinId: props.iTwinId,
|
|
53
|
+
reportsClient: props.reportsClient ?? new ReportsClient(reportsBaseUrl()),
|
|
54
|
+
mappingsClient: props.mappingsClient ?? new MappingsClient(reportsBaseUrl()),
|
|
55
|
+
iModelsClient: props.iModelsClient ?? new IModelsClient(iModelClientOptions),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (!props.extractionClient) {
|
|
60
|
+
setExtractionClient(props.extractionClient ?? new ExtractionClient(reportsBaseUrl()));
|
|
61
|
+
}
|
|
62
|
+
}, [props.extractionClient, reportsBaseUrl]);
|
|
63
|
+
|
|
64
|
+
const successfulExtractionToast = (iModelName: string, odataFeedUrl: string) => {
|
|
65
|
+
toaster.positive(<SuccessfulExtractionToast iModelName={iModelName} odataFeedUrl={odataFeedUrl} />);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const failedExtractionToast = (iModelName: string) => {
|
|
69
|
+
toaster.negative(<FailedExtractionToast iModelName={iModelName} />);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const bulkExtractor = useMemo(
|
|
73
|
+
() => ({ bulkExtractor: props.bulkExtractor ?? new BulkExtractor(apiConfig.reportsClient, extractionClient, apiConfig.getAccessToken, successfulExtractionToast, failedExtractionToast) }),
|
|
74
|
+
[apiConfig.getAccessToken, apiConfig.reportsClient, extractionClient, props.bulkExtractor]
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
setApiConfig(() => ({
|
|
79
|
+
getAccessToken: props.getAccessToken ?? authorizationClientGetAccessToken,
|
|
80
|
+
baseUrl: props.baseUrl || REPORTS_CONFIG_BASE_URL,
|
|
81
|
+
iTwinId: props.iTwinId,
|
|
82
|
+
reportsClient: props.reportsClient ?? new ReportsClient(reportsBaseUrl()),
|
|
83
|
+
mappingsClient: props.mappingsClient ?? new MappingsClient(reportsBaseUrl()),
|
|
84
|
+
iModelsClient: props.iModelsClient ?? new IModelsClient(iModelClientOptions),
|
|
85
|
+
}));
|
|
86
|
+
}, [props.getAccessToken, props.baseUrl, props.iTwinId, props.reportsClient, props.mappingsClient, props.iModelsClient, reportsBaseUrl, iModelClientOptions]);
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<ReportsConfigApiContext.Provider value={apiConfig}>
|
|
90
|
+
<BulkExtractorContext.Provider value={bulkExtractor}>
|
|
91
|
+
{props.children}
|
|
92
|
+
</BulkExtractorContext.Provider>
|
|
93
|
+
</ReportsConfigApiContext.Provider>
|
|
94
|
+
);
|
|
95
|
+
};
|
|
@@ -3,43 +3,69 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import type { AccessToken } from "@itwin/core-bentley";
|
|
6
|
-
import {
|
|
7
|
-
import React, { useEffect, useState } from "react";
|
|
8
|
-
import { Reports } from "../components/Reports";
|
|
9
|
-
import type { ReportsApiConfig } from "../context/ReportsApiConfigContext";
|
|
10
|
-
import { ReportsApiConfigContext } from "../context/ReportsApiConfigContext";
|
|
6
|
+
import React, { useCallback, useState } from "react";
|
|
11
7
|
import "./ReportsContainer.scss";
|
|
8
|
+
import type { Report } from "@itwin/insights-client";
|
|
9
|
+
import { useActiveIModelConnection } from "@itwin/appui-react";
|
|
10
|
+
import { ReportsHeader } from "./ReportsHeader";
|
|
11
|
+
import { ReportsRouter } from "./ReportsRouter";
|
|
12
|
+
import { ReportsConfigContext } from "./ReportsConfigContext";
|
|
12
13
|
|
|
13
14
|
interface ReportsContainerProps {
|
|
14
15
|
getAccessToken?: () => Promise<AccessToken>;
|
|
15
16
|
baseUrl: string;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
export enum RouteStep {
|
|
20
|
+
ReportsList,
|
|
21
|
+
ReportAction,
|
|
22
|
+
ReportMappings
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ReportsRouteFields {
|
|
26
|
+
report?: Report;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface Route {
|
|
30
|
+
step: RouteStep;
|
|
31
|
+
title: string;
|
|
32
|
+
reportsRoutingFields: ReportsRouteFields;
|
|
33
|
+
}
|
|
20
34
|
|
|
21
35
|
const ReportsContainer = ({
|
|
22
36
|
getAccessToken,
|
|
23
37
|
baseUrl,
|
|
24
38
|
}: ReportsContainerProps) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
|
|
40
|
+
const [routingHistory, setRoutingHistory] = useState<Route[]>([
|
|
41
|
+
{ step: RouteStep.ReportsList, title: "iTwin Reports", reportsRoutingFields: {} },
|
|
42
|
+
]);
|
|
43
|
+
const currentRoute = routingHistory[routingHistory.length - 1];
|
|
44
|
+
const iTwinId = useActiveIModelConnection()?.iTwinId ?? "";
|
|
45
|
+
const navigateTo = useCallback((toRoute: (prev: Route | undefined) => Route) => {
|
|
46
|
+
setRoutingHistory((r) => [...r, toRoute(r[r.length - 1])]);
|
|
47
|
+
}, []);
|
|
48
|
+
|
|
49
|
+
const goBack = useCallback(() => {
|
|
50
|
+
const updatedRouting = [...routingHistory];
|
|
51
|
+
updatedRouting.pop();
|
|
52
|
+
setRoutingHistory(updatedRouting);
|
|
53
|
+
}, [routingHistory]);
|
|
36
54
|
|
|
37
55
|
return (
|
|
38
|
-
<
|
|
56
|
+
<ReportsConfigContext getAccessToken={getAccessToken} baseUrl={baseUrl} iTwinId={iTwinId}>
|
|
39
57
|
<div className="rcw-reports-container">
|
|
40
|
-
<
|
|
58
|
+
<ReportsHeader
|
|
59
|
+
goBack={goBack}
|
|
60
|
+
currentRoute={currentRoute}
|
|
61
|
+
/>
|
|
62
|
+
<ReportsRouter
|
|
63
|
+
currentRoute={currentRoute}
|
|
64
|
+
navigateTo={navigateTo}
|
|
65
|
+
goBack={goBack}
|
|
66
|
+
/>
|
|
41
67
|
</div>
|
|
42
|
-
</
|
|
68
|
+
</ReportsConfigContext>
|
|
43
69
|
);
|
|
44
70
|
};
|
|
45
71
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import React from "react";
|
|
6
|
+
import type { Route } from "./ReportsContainer";
|
|
7
|
+
import { RouteStep } from "./ReportsContainer";
|
|
8
|
+
import { WidgetHeader } from "./utils";
|
|
9
|
+
|
|
10
|
+
export const ReportsHeader = ({
|
|
11
|
+
goBack,
|
|
12
|
+
currentRoute,
|
|
13
|
+
}: {
|
|
14
|
+
goBack: () => void;
|
|
15
|
+
currentRoute: Route;
|
|
16
|
+
}) => {
|
|
17
|
+
const shouldDisableReturnFn =
|
|
18
|
+
currentRoute.step === RouteStep.ReportsList ||
|
|
19
|
+
currentRoute.step === RouteStep.ReportAction;
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<WidgetHeader
|
|
23
|
+
returnFn={shouldDisableReturnFn ? undefined : goBack}
|
|
24
|
+
title={currentRoute.title}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
};
|