@itwin/reports-config-widget-react 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +45 -1
- package/CHANGELOG.md +23 -2
- package/README.md +1 -5
- package/api/reports-config-widget-react.api.md +11 -15
- package/api/reports-config-widget-react.exports.csv +1 -1
- package/api/temp/reports-config-widget-react.api.md +11 -15
- package/coverage/clover.xml +187 -190
- package/coverage/coverage-final.json +11 -11
- package/coverage/lcov-report/index.html +19 -19
- package/coverage/lcov-report/src/ReportsConfigWidget.ts.html +2 -2
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/test/index.html +1 -1
- package/coverage/lcov-report/src/test/test-utils.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/ReportsConfigUiProvider.tsx.html +11 -26
- package/coverage/lcov-report/src/widget/components/ActionPanel.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/AddMappingsModal.tsx.html +3 -3
- package/coverage/lcov-report/src/widget/components/BulkExtractor.ts.html +7 -10
- package/coverage/lcov-report/src/widget/components/Constants.ts.html +1 -1
- package/coverage/lcov-report/src/widget/components/DeleteModal.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/ExtractionStates/FailedExtractionState.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/ExtractionStates/QueuedExtractionState.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/ExtractionStates/RunningExtractionState.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/ExtractionStates/StartingExtractionState.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/ExtractionStates/SucceededExtractionState.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/ExtractionStates/index.html +1 -1
- package/coverage/lcov-report/src/widget/components/ExtractionStatus.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/ExtractionToast.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/HorizontalTile.tsx.html +3 -3
- package/coverage/lcov-report/src/widget/components/LocalizedTablePaginator.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/ReportAction.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/ReportHorizontalTile.tsx.html +15 -15
- package/coverage/lcov-report/src/widget/components/ReportMappingHorizontalTile.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/ReportMappings.tsx.html +14 -23
- package/coverage/lcov-report/src/widget/components/Reports.tsx.html +6 -6
- package/coverage/lcov-report/src/widget/components/ReportsConfigContext.tsx.html +111 -12
- package/coverage/lcov-report/src/widget/components/ReportsContainer.tsx.html +8 -17
- package/coverage/lcov-report/src/widget/components/ReportsHeader.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/ReportsRouter.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/SearchBar.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/SelectIModel.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/index.html +11 -11
- package/coverage/lcov-report/src/widget/components/utils.tsx.html +2 -2
- package/coverage/lcov-report/src/widget/context/BulkExtractorContext.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/context/ReportsConfigApiContext.tsx.html +7 -4
- package/coverage/lcov-report/src/widget/context/index.html +1 -1
- package/coverage/lcov-report/src/widget/hooks/index.html +1 -1
- package/coverage/lcov-report/src/widget/hooks/useValidator.ts.html +1 -1
- package/coverage/lcov-report/src/widget/index.html +13 -13
- package/coverage/lcov.info +336 -340
- package/lib/cjs/reports-config-widget-react.d.ts +1 -0
- package/lib/cjs/reports-config-widget-react.d.ts.map +1 -1
- package/lib/cjs/reports-config-widget-react.js +1 -0
- package/lib/cjs/reports-config-widget-react.js.map +1 -1
- package/lib/cjs/test/ReportAction.test.js +3 -0
- package/lib/cjs/test/ReportAction.test.js.map +1 -1
- package/lib/cjs/test/ReportMappings.test.js +4 -1
- package/lib/cjs/test/ReportMappings.test.js.map +1 -1
- package/lib/cjs/test/Reports.test.js +3 -0
- package/lib/cjs/test/Reports.test.js.map +1 -1
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/widget/ReportsConfigUiProvider.d.ts +3 -4
- package/lib/cjs/widget/ReportsConfigUiProvider.d.ts.map +1 -1
- package/lib/cjs/widget/ReportsConfigUiProvider.js +3 -4
- package/lib/cjs/widget/ReportsConfigUiProvider.js.map +1 -1
- package/lib/cjs/widget/components/AddMappingsModal.d.ts.map +1 -1
- package/lib/cjs/widget/components/AddMappingsModal.js.map +1 -1
- package/lib/cjs/widget/components/BulkExtractor.d.ts +2 -2
- package/lib/cjs/widget/components/BulkExtractor.d.ts.map +1 -1
- package/lib/cjs/widget/components/BulkExtractor.js.map +1 -1
- package/lib/cjs/widget/components/ReportMappings.d.ts.map +1 -1
- package/lib/cjs/widget/components/ReportMappings.js +4 -6
- package/lib/cjs/widget/components/ReportMappings.js.map +1 -1
- package/lib/cjs/widget/components/Reports.d.ts.map +1 -1
- package/lib/cjs/widget/components/Reports.js.map +1 -1
- package/lib/cjs/widget/components/ReportsConfigContext.d.ts +26 -4
- package/lib/cjs/widget/components/ReportsConfigContext.d.ts.map +1 -1
- package/lib/cjs/widget/components/ReportsConfigContext.js +14 -4
- package/lib/cjs/widget/components/ReportsConfigContext.js.map +1 -1
- package/lib/cjs/widget/components/ReportsContainer.d.ts +3 -6
- package/lib/cjs/widget/components/ReportsContainer.d.ts.map +1 -1
- package/lib/cjs/widget/components/ReportsContainer.js +6 -2
- package/lib/cjs/widget/components/ReportsContainer.js.map +1 -1
- package/lib/cjs/widget/context/ReportsConfigApiContext.d.ts +3 -3
- package/lib/cjs/widget/context/ReportsConfigApiContext.d.ts.map +1 -1
- package/lib/cjs/widget/context/ReportsConfigApiContext.js.map +1 -1
- package/lib/esm/reports-config-widget-react.d.ts +1 -0
- package/lib/esm/reports-config-widget-react.d.ts.map +1 -1
- package/lib/esm/reports-config-widget-react.js +1 -0
- package/lib/esm/reports-config-widget-react.js.map +1 -1
- package/lib/esm/test/ReportAction.test.js +3 -0
- package/lib/esm/test/ReportAction.test.js.map +1 -1
- package/lib/esm/test/ReportMappings.test.js +4 -1
- package/lib/esm/test/ReportMappings.test.js.map +1 -1
- package/lib/esm/test/Reports.test.js +3 -0
- package/lib/esm/test/Reports.test.js.map +1 -1
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/widget/ReportsConfigUiProvider.d.ts +3 -4
- package/lib/esm/widget/ReportsConfigUiProvider.d.ts.map +1 -1
- package/lib/esm/widget/ReportsConfigUiProvider.js +3 -4
- package/lib/esm/widget/ReportsConfigUiProvider.js.map +1 -1
- package/lib/esm/widget/components/AddMappingsModal.d.ts.map +1 -1
- package/lib/esm/widget/components/AddMappingsModal.js.map +1 -1
- package/lib/esm/widget/components/BulkExtractor.d.ts +2 -2
- package/lib/esm/widget/components/BulkExtractor.d.ts.map +1 -1
- package/lib/esm/widget/components/BulkExtractor.js.map +1 -1
- package/lib/esm/widget/components/ReportMappings.d.ts.map +1 -1
- package/lib/esm/widget/components/ReportMappings.js +5 -7
- package/lib/esm/widget/components/ReportMappings.js.map +1 -1
- package/lib/esm/widget/components/Reports.d.ts.map +1 -1
- package/lib/esm/widget/components/Reports.js.map +1 -1
- package/lib/esm/widget/components/ReportsConfigContext.d.ts +26 -4
- package/lib/esm/widget/components/ReportsConfigContext.d.ts.map +1 -1
- package/lib/esm/widget/components/ReportsConfigContext.js +14 -4
- package/lib/esm/widget/components/ReportsConfigContext.js.map +1 -1
- package/lib/esm/widget/components/ReportsContainer.d.ts +3 -6
- package/lib/esm/widget/components/ReportsContainer.d.ts.map +1 -1
- package/lib/esm/widget/components/ReportsContainer.js +6 -2
- package/lib/esm/widget/components/ReportsContainer.js.map +1 -1
- package/lib/esm/widget/context/ReportsConfigApiContext.d.ts +3 -3
- package/lib/esm/widget/context/ReportsConfigApiContext.d.ts.map +1 -1
- package/lib/esm/widget/context/ReportsConfigApiContext.js.map +1 -1
- package/package.json +2 -2
- package/src/reports-config-widget-react.ts +1 -0
- package/src/test/ReportAction.test.tsx +3 -0
- package/src/test/ReportMappings.test.tsx +4 -1
- package/src/test/Reports.test.tsx +3 -0
- package/src/widget/ReportsConfigUiProvider.tsx +3 -8
- package/src/widget/components/AddMappingsModal.tsx +2 -2
- package/src/widget/components/BulkExtractor.ts +5 -6
- package/src/widget/components/ReportMappings.tsx +8 -11
- package/src/widget/components/Reports.tsx +2 -2
- package/src/widget/components/ReportsConfigContext.tsx +41 -8
- package/src/widget/components/ReportsContainer.tsx +5 -8
- package/src/widget/context/ReportsConfigApiContext.tsx +3 -2
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { AccessToken } from "@itwin/core-bentley";
|
|
3
2
|
import "./ReportsContainer.scss";
|
|
4
3
|
import type { Report } from "@itwin/insights-client";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
baseUrl: string;
|
|
8
|
-
}
|
|
4
|
+
import type { ReportsConfigContextProps } from "./ReportsConfigContext";
|
|
5
|
+
export declare type ReportsContainerProps = Omit<ReportsConfigContextProps, "iTwinId" | "children">;
|
|
9
6
|
export declare enum RouteStep {
|
|
10
7
|
ReportsList = 0,
|
|
11
8
|
ReportAction = 1,
|
|
@@ -19,6 +16,6 @@ export interface Route {
|
|
|
19
16
|
title: string;
|
|
20
17
|
reportsRoutingFields: ReportsRouteFields;
|
|
21
18
|
}
|
|
22
|
-
declare const ReportsContainer: (
|
|
19
|
+
declare const ReportsContainer: (props: ReportsContainerProps) => JSX.Element;
|
|
23
20
|
export default ReportsContainer;
|
|
24
21
|
//# sourceMappingURL=ReportsContainer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReportsContainer.d.ts","sourceRoot":"","sources":["../../../../src/widget/components/ReportsContainer.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"ReportsContainer.d.ts","sourceRoot":"","sources":["../../../../src/widget/components/ReportsContainer.tsx"],"names":[],"mappings":";AAKA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAIrD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAGxE,oBAAY,qBAAqB,GAAG,IAAI,CAAC,yBAAyB,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC;AAE5F,oBAAY,SAAS;IACnB,WAAW,IAAA;IACX,YAAY,IAAA;IACZ,cAAc,IAAA;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,oBAAoB,EAAE,kBAAkB,CAAC;CAC1C;AAED,QAAA,MAAM,gBAAgB,UAAW,qBAAqB,gBAsBrD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,3 +1,7 @@
|
|
|
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
|
+
*--------------------------------------------------------------------------------------------*/
|
|
1
5
|
import React, { useCallback, useState } from "react";
|
|
2
6
|
import "./ReportsContainer.scss";
|
|
3
7
|
import { useActiveIModelConnection } from "@itwin/appui-react";
|
|
@@ -10,7 +14,7 @@ export var RouteStep;
|
|
|
10
14
|
RouteStep[RouteStep["ReportAction"] = 1] = "ReportAction";
|
|
11
15
|
RouteStep[RouteStep["ReportMappings"] = 2] = "ReportMappings";
|
|
12
16
|
})(RouteStep || (RouteStep = {}));
|
|
13
|
-
const ReportsContainer = (
|
|
17
|
+
const ReportsContainer = (props) => {
|
|
14
18
|
const [routingHistory, setRoutingHistory] = useState([{ step: RouteStep.ReportsList, title: "iTwin Reports", reportsRoutingFields: {} }]);
|
|
15
19
|
const currentRoute = routingHistory[routingHistory.length - 1];
|
|
16
20
|
const iTwinId = useActiveIModelConnection()?.iTwinId ?? "";
|
|
@@ -22,7 +26,7 @@ const ReportsContainer = ({ getAccessToken, baseUrl }) => {
|
|
|
22
26
|
updatedRouting.pop();
|
|
23
27
|
setRoutingHistory(updatedRouting);
|
|
24
28
|
}, [routingHistory]);
|
|
25
|
-
return (React.createElement(ReportsConfigContext, {
|
|
29
|
+
return (React.createElement(ReportsConfigContext, { ...props, iTwinId: iTwinId },
|
|
26
30
|
React.createElement("div", { className: "rcw-reports-container" },
|
|
27
31
|
React.createElement(ReportsHeader, { goBack: goBack, currentRoute: currentRoute }),
|
|
28
32
|
React.createElement(ReportsRouter, { currentRoute: currentRoute, navigateTo: navigateTo, goBack: goBack }))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReportsContainer.js","sourceRoot":"","sources":["../../../../src/widget/components/ReportsContainer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ReportsContainer.js","sourceRoot":"","sources":["../../../../src/widget/components/ReportsContainer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAI7D,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,uDAAW,CAAA;IACX,yDAAY,CAAA;IACZ,6DAAc,CAAA;AAChB,CAAC,EAJW,SAAS,KAAT,SAAS,QAIpB;AAYD,MAAM,gBAAgB,GAAG,CAAC,KAA4B,EAAE,EAAE;IACxD,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAU,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,WAAW,EAAE,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IACnJ,MAAM,YAAY,GAAG,cAAc,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC/D,MAAM,OAAO,GAAG,yBAAyB,EAAE,EAAE,OAAO,IAAI,EAAE,CAAC;IAC3D,MAAM,UAAU,GAAG,WAAW,CAAC,CAAC,OAA2C,EAAE,EAAE;QAC7E,iBAAiB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,MAAM,cAAc,GAAG,CAAC,GAAG,cAAc,CAAC,CAAC;QAC3C,cAAc,CAAC,GAAG,EAAE,CAAC;QACrB,iBAAiB,CAAC,cAAc,CAAC,CAAC;IACpC,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;IAErB,OAAO,CACL,oBAAC,oBAAoB,OAAK,KAAK,EAAE,OAAO,EAAE,OAAO;QAC/C,6BAAK,SAAS,EAAC,uBAAuB;YACpC,oBAAC,aAAa,IAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAI;YAC7D,oBAAC,aAAa,IAAC,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAI,CACjF,CACe,CACxB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,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, { useCallback, useState } from \"react\";\nimport \"./ReportsContainer.scss\";\nimport type { Report } from \"@itwin/insights-client\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\nimport { ReportsHeader } from \"./ReportsHeader\";\nimport { ReportsRouter } from \"./ReportsRouter\";\nimport type { ReportsConfigContextProps } from \"./ReportsConfigContext\";\nimport { ReportsConfigContext } from \"./ReportsConfigContext\"\n\nexport type ReportsContainerProps = Omit<ReportsConfigContextProps, \"iTwinId\" | \"children\">;\n\nexport enum RouteStep {\n ReportsList,\n ReportAction,\n ReportMappings,\n}\n\nexport interface ReportsRouteFields {\n report?: Report;\n}\n\nexport interface Route {\n step: RouteStep;\n title: string;\n reportsRoutingFields: ReportsRouteFields;\n}\n\nconst ReportsContainer = (props: ReportsContainerProps) => {\n const [routingHistory, setRoutingHistory] = useState<Route[]>([{ step: RouteStep.ReportsList, title: \"iTwin Reports\", reportsRoutingFields: {} }]);\n const currentRoute = routingHistory[routingHistory.length - 1];\n const iTwinId = useActiveIModelConnection()?.iTwinId ?? \"\";\n const navigateTo = useCallback((toRoute: (prev: Route | undefined) => Route) => {\n setRoutingHistory((r) => [...r, toRoute(r[r.length - 1])]);\n }, []);\n\n const goBack = useCallback(() => {\n const updatedRouting = [...routingHistory];\n updatedRouting.pop();\n setRoutingHistory(updatedRouting);\n }, [routingHistory]);\n\n return (\n <ReportsConfigContext {...props} iTwinId={iTwinId}>\n <div className=\"rcw-reports-container\">\n <ReportsHeader goBack={goBack} currentRoute={currentRoute} />\n <ReportsRouter currentRoute={currentRoute} navigateTo={navigateTo} goBack={goBack} />\n </div>\n </ReportsConfigContext>\n );\n};\n\nexport default ReportsContainer;\n"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { AccessToken } from "@itwin/core-bentley";
|
|
2
2
|
import { IModelsClient } from "@itwin/imodels-client-management";
|
|
3
|
-
import {
|
|
3
|
+
import type { IMappingsClient, IReportsClient } from "@itwin/insights-client";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
export declare type GetAccessTokenFn = () => Promise<AccessToken>;
|
|
6
6
|
export interface ReportsConfigApiProps {
|
|
7
7
|
getAccessToken: GetAccessTokenFn;
|
|
8
8
|
iTwinId: string;
|
|
9
9
|
baseUrl: string;
|
|
10
|
-
reportsClient:
|
|
11
|
-
mappingsClient:
|
|
10
|
+
reportsClient: IReportsClient;
|
|
11
|
+
mappingsClient: IMappingsClient;
|
|
12
12
|
iModelsClient: IModelsClient;
|
|
13
13
|
}
|
|
14
14
|
export declare const ReportsConfigApiContext: React.Context<ReportsConfigApiProps>;
|
|
@@ -1 +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,
|
|
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,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE9E,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,cAAc,CAAC;IAC9B,cAAc,EAAE,eAAe,CAAC;IAChC,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,eAAO,MAAM,uBAAuB,sCAOlC,CAAC;AAEH,eAAO,MAAM,mBAAmB,6BAM/B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReportsConfigApiContext.js","sourceRoot":"","sources":["../../../../src/widget/context/ReportsConfigApiContext.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"ReportsConfigApiContext.js","sourceRoot":"","sources":["../../../../src/widget/context/ReportsConfigApiContext.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAatC,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAAwB;IAC1E,cAAc,EAAE,KAAK,IAAI,EAAE,CAAC,EAAE;IAC9B,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;IACX,aAAa,EAAE,IAAI,aAAa,EAAE;IAClC,cAAc,EAAE,IAAI,cAAc,EAAE;IACpC,aAAa,EAAE,IAAI,aAAa,EAAE;CACnC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC;IAC1D,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;KACjG;IACD,OAAO,OAAO,CAAC;AACjB,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 type { AccessToken } from \"@itwin/core-bentley\";\nimport { IModelsClient } from \"@itwin/imodels-client-management\";\nimport type { IMappingsClient, IReportsClient } from \"@itwin/insights-client\";\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: IReportsClient;\n mappingsClient: IMappingsClient;\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(\"useReportsConfigApi should be used within a ReportsConfigApiContext provider\");\n }\n return context;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/reports-config-widget-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "An iTwin.js 3D Viewer Widget that interfaces with the iTwin Reporting Platform.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Bentley",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@itwin/imodels-access-common": "^4.1.4",
|
|
63
63
|
"@itwin/imodels-access-frontend": "^4.1.4",
|
|
64
64
|
"@itwin/imodels-client-management": "^4.2.3",
|
|
65
|
-
"@itwin/insights-client": "^0.
|
|
65
|
+
"@itwin/insights-client": "^0.13.0",
|
|
66
66
|
"@itwin/itwinui-icons-color-react": "^2.1.0",
|
|
67
67
|
"@itwin/itwinui-icons-react": "^2.4.0",
|
|
68
68
|
"@itwin/itwinui-react": "^2.11.0",
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
/** UI Provider for iTwin Viewer Applications */
|
|
6
6
|
export * from "./widget/ReportsConfigUiProvider";
|
|
7
7
|
export * from "./ReportsConfigWidget";
|
|
8
|
+
export * from "@itwin/insights-client";
|
|
8
9
|
|
|
9
10
|
export { Reports, ReportsProps } from "./widget/components/Reports";
|
|
10
11
|
export { ReportMappings, ReportMappingsProps } from "./widget/components/ReportMappings";
|
|
@@ -53,6 +53,9 @@ const mockReport: Report = {
|
|
|
53
53
|
project: {
|
|
54
54
|
href: "",
|
|
55
55
|
},
|
|
56
|
+
odata: {
|
|
57
|
+
href: "mock-odata-feed-url",
|
|
58
|
+
},
|
|
56
59
|
},
|
|
57
60
|
};
|
|
58
61
|
|
|
@@ -297,7 +300,7 @@ describe("Report Mappings View", () => {
|
|
|
297
300
|
name: /odatafeedurl/i,
|
|
298
301
|
});
|
|
299
302
|
expect(urlTextbox).toBeInTheDocument();
|
|
300
|
-
expect(screen.getByDisplayValue(`
|
|
303
|
+
expect(screen.getByDisplayValue(`mock-odata-feed-url`)).toBeInTheDocument();
|
|
301
304
|
|
|
302
305
|
const copyButton = screen.getByRole("button", {
|
|
303
306
|
name: /copy/i,
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import type { UiItemsProvider, Widget } from "@itwin/appui-react";
|
|
6
6
|
import { StagePanelLocation, StagePanelSection, StageUsage } from "@itwin/appui-react";
|
|
7
|
-
import type { AccessToken } from "@itwin/core-bentley";
|
|
8
7
|
|
|
9
8
|
import * as React from "react";
|
|
10
9
|
import { ReportsConfigWidget } from "../ReportsConfigWidget";
|
|
10
|
+
import type { ReportsContainerProps } from "./components/ReportsContainer";
|
|
11
11
|
import ReportsContainer from "./components/ReportsContainer";
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -21,13 +21,8 @@ export const REPORTS_CONFIG_BASE_URL = "https://api.bentley.com";
|
|
|
21
21
|
*/
|
|
22
22
|
export class ReportsConfigProvider implements UiItemsProvider {
|
|
23
23
|
public readonly id = "ReportsConfigProvider";
|
|
24
|
-
private readonly _getAccessToken?: () => Promise<AccessToken>;
|
|
25
|
-
private readonly _baseUrl: string;
|
|
26
24
|
|
|
27
|
-
constructor(
|
|
28
|
-
this._getAccessToken = getAccessToken;
|
|
29
|
-
this._baseUrl = baseUrl;
|
|
30
|
-
}
|
|
25
|
+
constructor(private _props?: ReportsContainerProps) { }
|
|
31
26
|
|
|
32
27
|
public provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section?: StagePanelSection): ReadonlyArray<Widget> {
|
|
33
28
|
const widgets: Widget[] = [];
|
|
@@ -35,7 +30,7 @@ export class ReportsConfigProvider implements UiItemsProvider {
|
|
|
35
30
|
const ReportsWidget: Widget = {
|
|
36
31
|
id: "reports-config-widget",
|
|
37
32
|
label: ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:ReportsConfig"),
|
|
38
|
-
content: <ReportsContainer
|
|
33
|
+
content: <ReportsContainer {...this._props} />,
|
|
39
34
|
};
|
|
40
35
|
|
|
41
36
|
widgets.push(ReportsWidget);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { Modal, Table, tableFilters } from "@itwin/itwinui-react";
|
|
6
6
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
7
|
-
import type {
|
|
7
|
+
import type { IMappingsClient, Mapping } from "@itwin/insights-client";
|
|
8
8
|
import ActionPanel from "./ActionPanel";
|
|
9
9
|
import "./AddMappingsModal.scss";
|
|
10
10
|
import { LocalizedTablePaginator } from "./LocalizedTablePaginator";
|
|
@@ -23,7 +23,7 @@ const fetchMappings = async (
|
|
|
23
23
|
setMappings: (mappings: Mapping[]) => void,
|
|
24
24
|
iModelId: string,
|
|
25
25
|
setIsLoading: (isLoading: boolean) => void,
|
|
26
|
-
mappingsClient:
|
|
26
|
+
mappingsClient: IMappingsClient,
|
|
27
27
|
getAccessToken: () => Promise<AccessToken>,
|
|
28
28
|
) => {
|
|
29
29
|
try {
|
|
@@ -6,7 +6,7 @@ import { ExtractionState } from "@itwin/insights-client";
|
|
|
6
6
|
import { handleError } from "./utils";
|
|
7
7
|
import { ExtractionStates } from "./ExtractionStatus";
|
|
8
8
|
import { STATUS_CHECK_INTERVAL } from "./Constants";
|
|
9
|
-
import type {
|
|
9
|
+
import type { ExtractionMapping, ExtractionRequestDetails, IExtractionClient, IReportsClient, ReportMapping } from "@itwin/insights-client";
|
|
10
10
|
import type { AccessToken } from "@itwin/core-bentley";
|
|
11
11
|
|
|
12
12
|
export type ReportMappingAndMapping = ReportMapping & {
|
|
@@ -19,10 +19,9 @@ export type ReportMappingAndMapping = ReportMapping & {
|
|
|
19
19
|
* @public
|
|
20
20
|
*/
|
|
21
21
|
export class BulkExtractor {
|
|
22
|
-
private _reportsClientApi:
|
|
23
|
-
private _extractionClientApi:
|
|
22
|
+
private _reportsClientApi: IReportsClient;
|
|
23
|
+
private _extractionClientApi: IExtractionClient;
|
|
24
24
|
private _accessToken: () => Promise<string>;
|
|
25
|
-
|
|
26
25
|
private _reportIModels = new Map<string, string[]>(); // key: reportId, value: iModels
|
|
27
26
|
private _iModelStates = new Map<string, ExtractionState>(); // key: iModelId, value: state
|
|
28
27
|
private _timeFetched = new Date();
|
|
@@ -34,8 +33,8 @@ export class BulkExtractor {
|
|
|
34
33
|
private _iModels: string[] = [];
|
|
35
34
|
|
|
36
35
|
constructor(
|
|
37
|
-
reportsClient:
|
|
38
|
-
extractionClient:
|
|
36
|
+
reportsClient: IReportsClient,
|
|
37
|
+
extractionClient: IExtractionClient,
|
|
39
38
|
getAccessToken: () => Promise<AccessToken>,
|
|
40
39
|
successfulExtractionToast: (iModelName: string, odataFeedUrl: string) => void,
|
|
41
40
|
failedExtractionToast: (iModelName: string) => void,
|
|
@@ -6,11 +6,10 @@ import { SvgAdd, SvgCopy, SvgRefresh } from "@itwin/itwinui-icons-react";
|
|
|
6
6
|
import { Button, IconButton, LabeledInput, Text, toaster } from "@itwin/itwinui-react";
|
|
7
7
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
8
8
|
import type { CreateTypeFromInterface } from "./utils";
|
|
9
|
-
import { EmptyMessage,
|
|
9
|
+
import { EmptyMessage, handleError, LoadingOverlay, LoadingSpinner } from "./utils";
|
|
10
10
|
import "./ReportMappings.scss";
|
|
11
11
|
import DeleteModal from "./DeleteModal";
|
|
12
|
-
import type { ExtractionRequestDetails,
|
|
13
|
-
import { REPORTING_BASE_PATH } from "@itwin/insights-client";
|
|
12
|
+
import type { ExtractionRequestDetails, IMappingsClient, IReportsClient, Report, ReportMapping } from "@itwin/insights-client";
|
|
14
13
|
import { AddMappingsModal } from "./AddMappingsModal";
|
|
15
14
|
import type { GetSingleIModelParams, IModelsClient } from "@itwin/imodels-client-management";
|
|
16
15
|
import { AccessTokenAdapter } from "@itwin/imodels-access-frontend";
|
|
@@ -33,8 +32,8 @@ const fetchReportMappings = async (
|
|
|
33
32
|
setReportMappings: (mappings: ReportMappingAndMapping[]) => void,
|
|
34
33
|
reportId: string,
|
|
35
34
|
setIsLoading: (isLoading: boolean) => void,
|
|
36
|
-
reportsClient:
|
|
37
|
-
mappingsClient:
|
|
35
|
+
reportsClient: IReportsClient,
|
|
36
|
+
mappingsClient: IMappingsClient,
|
|
38
37
|
iModelsClient: IModelsClient,
|
|
39
38
|
getAccessToken: () => Promise<AccessToken>,
|
|
40
39
|
) => {
|
|
@@ -93,7 +92,7 @@ export interface ReportMappingsProps {
|
|
|
93
92
|
* @public
|
|
94
93
|
*/
|
|
95
94
|
export const ReportMappings = ({ report, onClickClose, defaultIModelId }: ReportMappingsProps) => {
|
|
96
|
-
const { getAccessToken, reportsClient, iModelsClient, mappingsClient
|
|
95
|
+
const { getAccessToken, reportsClient, iModelsClient, mappingsClient } = useReportsConfigApi();
|
|
97
96
|
const [showDeleteModal, setShowDeleteModal] = useState<ReportMappingAndMapping | undefined>(undefined);
|
|
98
97
|
const [showAddMapping, setShowAddMapping] = useState<boolean>(false);
|
|
99
98
|
const { bulkExtractor } = useBulkExtractor();
|
|
@@ -119,8 +118,6 @@ export const ReportMappings = ({ report, onClickClose, defaultIModelId }: Report
|
|
|
119
118
|
await fetchReportMappings(setReportMappings, report.id, setIsLoading, reportsClient, mappingsClient, iModelsClient, getAccessToken);
|
|
120
119
|
}, [getAccessToken, iModelsClient, mappingsClient, report.id, reportsClient]);
|
|
121
120
|
|
|
122
|
-
const odataFeedUrl = `${generateUrl(REPORTING_BASE_PATH, baseUrl)}/odata/${report.id}`;
|
|
123
|
-
|
|
124
121
|
const addMapping = useCallback(() => {
|
|
125
122
|
setShowAddMapping(true);
|
|
126
123
|
}, []);
|
|
@@ -144,12 +141,12 @@ export const ReportMappings = ({ report, onClickClose, defaultIModelId }: Report
|
|
|
144
141
|
label={ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:ODataFeedURL")}
|
|
145
142
|
className="rcw-odata-url-input"
|
|
146
143
|
readOnly={true}
|
|
147
|
-
value={
|
|
144
|
+
value={report._links.odata.href}
|
|
148
145
|
svgIcon={
|
|
149
146
|
<IconButton
|
|
150
147
|
title={ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:Copy")}
|
|
151
148
|
onClick={async (_) => {
|
|
152
|
-
await navigator.clipboard.writeText(
|
|
149
|
+
await navigator.clipboard.writeText(report._links.odata.href);
|
|
153
150
|
toaster.positive(ReportsConfigWidget.localization.getLocalizedString("ReportsConfigWidget:CopiedToClipboard"));
|
|
154
151
|
}}
|
|
155
152
|
>
|
|
@@ -197,7 +194,7 @@ export const ReportMappings = ({ report, onClickClose, defaultIModelId }: Report
|
|
|
197
194
|
onClickDelete={() => {
|
|
198
195
|
setShowDeleteModal(mapping);
|
|
199
196
|
}}
|
|
200
|
-
odataFeedUrl={
|
|
197
|
+
odataFeedUrl={report._links.odata.href}
|
|
201
198
|
jobStartEvent={jobStartEvent}
|
|
202
199
|
/>
|
|
203
200
|
))}
|
|
@@ -9,7 +9,7 @@ import type { CreateTypeFromInterface } from "./utils";
|
|
|
9
9
|
import { EmptyMessage, handleError, LoadingOverlay } from "./utils";
|
|
10
10
|
import "./Reports.scss";
|
|
11
11
|
import DeleteModal from "./DeleteModal";
|
|
12
|
-
import type {
|
|
12
|
+
import type { IReportsClient, Report } from "@itwin/insights-client";
|
|
13
13
|
import { ReportHorizontalTile } from "./ReportHorizontalTile";
|
|
14
14
|
import { SearchBar } from "./SearchBar";
|
|
15
15
|
import { useReportsConfigApi } from "../context/ReportsConfigApiContext";
|
|
@@ -24,7 +24,7 @@ const fetchReports = async (
|
|
|
24
24
|
setReports: (reports: Report[]) => void,
|
|
25
25
|
iTwinId: string | undefined,
|
|
26
26
|
setIsLoading: (isLoading: boolean) => void,
|
|
27
|
-
reportsClient:
|
|
27
|
+
reportsClient: IReportsClient,
|
|
28
28
|
getAccessToken: () => Promise<AccessToken>,
|
|
29
29
|
) => {
|
|
30
30
|
try {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { IModelApp } from "@itwin/core-frontend";
|
|
6
6
|
import type { IModelsClientOptions } from "@itwin/imodels-client-management";
|
|
7
7
|
import { IModelsClient } from "@itwin/imodels-client-management";
|
|
8
|
+
import type { IExtractionClient, IMappingsClient, IReportsClient } from "@itwin/insights-client";
|
|
8
9
|
import { ExtractionClient, GROUPING_AND_MAPPING_BASE_PATH, MappingsClient, REPORTING_BASE_PATH, ReportsClient } from "@itwin/insights-client";
|
|
9
10
|
import { toaster } from "@itwin/itwinui-react";
|
|
10
11
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
@@ -22,13 +23,35 @@ import { generateUrl } from "./utils";
|
|
|
22
23
|
* @public
|
|
23
24
|
*/
|
|
24
25
|
export interface ReportsConfigContextProps {
|
|
26
|
+
/**
|
|
27
|
+
* A callback function that returns an access token for authenticating API requests.
|
|
28
|
+
* If not specified, it defaults to the authorizationClient of the IModelApp.
|
|
29
|
+
*/
|
|
25
30
|
getAccessToken?: GetAccessTokenFn;
|
|
31
|
+
/**
|
|
32
|
+
* The base URL for the API requests. Defaults to https://api.bentley.com.
|
|
33
|
+
*/
|
|
26
34
|
baseUrl?: string;
|
|
27
35
|
iTwinId: string;
|
|
36
|
+
/**
|
|
37
|
+
* The bulk extractor instance to use for extracting data. Internal use only.
|
|
38
|
+
*/
|
|
28
39
|
bulkExtractor?: BulkExtractor;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
/**
|
|
41
|
+
* A custom implementation of ReportsClient. If provided, baseUrl is ignored.
|
|
42
|
+
*/
|
|
43
|
+
reportsClient?: IReportsClient;
|
|
44
|
+
/**
|
|
45
|
+
* A custom implementation of MappingsClient. If provided, baseUrl is ignored.
|
|
46
|
+
*/
|
|
47
|
+
mappingsClient?: IMappingsClient;
|
|
48
|
+
/**
|
|
49
|
+
* A custom implementation of ExtractionClient. If provided, baseUrl is ignored.
|
|
50
|
+
*/
|
|
51
|
+
extractionClient?: IExtractionClient;
|
|
52
|
+
/**
|
|
53
|
+
* A custom implementation of IModelsClient. If provided, baseUrl is ignored.
|
|
54
|
+
*/
|
|
32
55
|
iModelsClient?: IModelsClient;
|
|
33
56
|
children?: React.ReactNode;
|
|
34
57
|
}
|
|
@@ -48,7 +71,7 @@ export const ReportsConfigContext = (props: ReportsConfigContextProps) => {
|
|
|
48
71
|
}),
|
|
49
72
|
[props.baseUrl],
|
|
50
73
|
);
|
|
51
|
-
const [extractionClient, setExtractionClient] = useState<
|
|
74
|
+
const [extractionClient, setExtractionClient] = useState<IExtractionClient>(props.extractionClient ?? new ExtractionClient(reportsBaseUrl()));
|
|
52
75
|
|
|
53
76
|
const [apiConfig, setApiConfig] = useState<ReportsConfigApiProps>({
|
|
54
77
|
getAccessToken: props.getAccessToken ?? authorizationClientGetAccessToken,
|
|
@@ -61,9 +84,9 @@ export const ReportsConfigContext = (props: ReportsConfigContextProps) => {
|
|
|
61
84
|
|
|
62
85
|
useEffect(() => {
|
|
63
86
|
if (!props.extractionClient) {
|
|
64
|
-
setExtractionClient(props.extractionClient ?? new ExtractionClient(
|
|
87
|
+
setExtractionClient(props.extractionClient ?? new ExtractionClient(groupingMappingBaseUrl()));
|
|
65
88
|
}
|
|
66
|
-
}, [props.extractionClient
|
|
89
|
+
}, [groupingMappingBaseUrl, props.extractionClient]);
|
|
67
90
|
|
|
68
91
|
const successfulExtractionToast = (iModelName: string, odataFeedUrl: string) => {
|
|
69
92
|
toaster.positive(<SuccessfulExtractionToast iModelName={iModelName} odataFeedUrl={odataFeedUrl} />);
|
|
@@ -88,10 +111,20 @@ export const ReportsConfigContext = (props: ReportsConfigContextProps) => {
|
|
|
88
111
|
baseUrl: props.baseUrl || REPORTS_CONFIG_BASE_URL,
|
|
89
112
|
iTwinId: props.iTwinId,
|
|
90
113
|
reportsClient: props.reportsClient ?? new ReportsClient(reportsBaseUrl()),
|
|
91
|
-
mappingsClient: props.mappingsClient ?? new MappingsClient(
|
|
114
|
+
mappingsClient: props.mappingsClient ?? new MappingsClient(groupingMappingBaseUrl()),
|
|
92
115
|
iModelsClient: props.iModelsClient ?? new IModelsClient(iModelClientOptions),
|
|
93
116
|
}));
|
|
94
|
-
}, [
|
|
117
|
+
}, [
|
|
118
|
+
props.getAccessToken,
|
|
119
|
+
props.baseUrl,
|
|
120
|
+
props.iTwinId,
|
|
121
|
+
props.reportsClient,
|
|
122
|
+
props.mappingsClient,
|
|
123
|
+
props.iModelsClient,
|
|
124
|
+
reportsBaseUrl,
|
|
125
|
+
iModelClientOptions,
|
|
126
|
+
groupingMappingBaseUrl,
|
|
127
|
+
]);
|
|
95
128
|
|
|
96
129
|
return (
|
|
97
130
|
<ReportsConfigApiContext.Provider value={apiConfig}>
|
|
@@ -2,19 +2,16 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import type { AccessToken } from "@itwin/core-bentley";
|
|
6
5
|
import React, { useCallback, useState } from "react";
|
|
7
6
|
import "./ReportsContainer.scss";
|
|
8
7
|
import type { Report } from "@itwin/insights-client";
|
|
9
8
|
import { useActiveIModelConnection } from "@itwin/appui-react";
|
|
10
9
|
import { ReportsHeader } from "./ReportsHeader";
|
|
11
10
|
import { ReportsRouter } from "./ReportsRouter";
|
|
12
|
-
import {
|
|
11
|
+
import type { ReportsConfigContextProps } from "./ReportsConfigContext";
|
|
12
|
+
import { ReportsConfigContext } from "./ReportsConfigContext"
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
getAccessToken?: () => Promise<AccessToken>;
|
|
16
|
-
baseUrl: string;
|
|
17
|
-
}
|
|
14
|
+
export type ReportsContainerProps = Omit<ReportsConfigContextProps, "iTwinId" | "children">;
|
|
18
15
|
|
|
19
16
|
export enum RouteStep {
|
|
20
17
|
ReportsList,
|
|
@@ -32,7 +29,7 @@ export interface Route {
|
|
|
32
29
|
reportsRoutingFields: ReportsRouteFields;
|
|
33
30
|
}
|
|
34
31
|
|
|
35
|
-
const ReportsContainer = (
|
|
32
|
+
const ReportsContainer = (props: ReportsContainerProps) => {
|
|
36
33
|
const [routingHistory, setRoutingHistory] = useState<Route[]>([{ step: RouteStep.ReportsList, title: "iTwin Reports", reportsRoutingFields: {} }]);
|
|
37
34
|
const currentRoute = routingHistory[routingHistory.length - 1];
|
|
38
35
|
const iTwinId = useActiveIModelConnection()?.iTwinId ?? "";
|
|
@@ -47,7 +44,7 @@ const ReportsContainer = ({ getAccessToken, baseUrl }: ReportsContainerProps) =>
|
|
|
47
44
|
}, [routingHistory]);
|
|
48
45
|
|
|
49
46
|
return (
|
|
50
|
-
<ReportsConfigContext
|
|
47
|
+
<ReportsConfigContext {...props} iTwinId={iTwinId}>
|
|
51
48
|
<div className="rcw-reports-container">
|
|
52
49
|
<ReportsHeader goBack={goBack} currentRoute={currentRoute} />
|
|
53
50
|
<ReportsRouter currentRoute={currentRoute} navigateTo={navigateTo} goBack={goBack} />
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import type { AccessToken } from "@itwin/core-bentley";
|
|
6
6
|
import { IModelsClient } from "@itwin/imodels-client-management";
|
|
7
|
+
import type { IMappingsClient, IReportsClient } from "@itwin/insights-client";
|
|
7
8
|
import { MappingsClient, ReportsClient } from "@itwin/insights-client";
|
|
8
9
|
import * as React from "react";
|
|
9
10
|
import { createContext } from "react";
|
|
@@ -14,8 +15,8 @@ export interface ReportsConfigApiProps {
|
|
|
14
15
|
getAccessToken: GetAccessTokenFn;
|
|
15
16
|
iTwinId: string;
|
|
16
17
|
baseUrl: string;
|
|
17
|
-
reportsClient:
|
|
18
|
-
mappingsClient:
|
|
18
|
+
reportsClient: IReportsClient;
|
|
19
|
+
mappingsClient: IMappingsClient;
|
|
19
20
|
iModelsClient: IModelsClient;
|
|
20
21
|
}
|
|
21
22
|
|