@itwin/reports-config-widget-react 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rush/temp/package-deps_rebuild.json +48 -0
- package/.rush/temp/shrinkwrap-deps.json +868 -0
- package/CHANGELOG.json +17 -0
- package/CHANGELOG.md +11 -0
- package/LICENSE.md +9 -0
- package/README.md +38 -0
- package/__mocks__/fileMock.js +5 -0
- package/coverage/clover.xml +612 -0
- package/coverage/coverage-final.json +19 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +191 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/ReportsConfigWidget.ts.html +193 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/src/test/index.html +116 -0
- package/coverage/lcov-report/src/test/test-utils.tsx.html +316 -0
- package/coverage/lcov-report/src/widget/ReportsConfigUiProvider.tsx.html +286 -0
- package/coverage/lcov-report/src/widget/components/ActionPanel.tsx.html +253 -0
- package/coverage/lcov-report/src/widget/components/AddMappingsModal.tsx.html +610 -0
- package/coverage/lcov-report/src/widget/components/DeleteModal.tsx.html +385 -0
- package/coverage/lcov-report/src/widget/components/Extraction.tsx.html +1030 -0
- package/coverage/lcov-report/src/widget/components/HorizontalTile.tsx.html +256 -0
- package/coverage/lcov-report/src/widget/components/LocalizedTablePaginator.tsx.html +262 -0
- package/coverage/lcov-report/src/widget/components/ReportAction.tsx.html +523 -0
- package/coverage/lcov-report/src/widget/components/ReportMappings.tsx.html +1135 -0
- package/coverage/lcov-report/src/widget/components/Reports.tsx.html +829 -0
- package/coverage/lcov-report/src/widget/components/ReportsContainer.tsx.html +193 -0
- package/coverage/lcov-report/src/widget/components/SearchBar.tsx.html +271 -0
- package/coverage/lcov-report/src/widget/components/SelectIModel.tsx.html +391 -0
- package/coverage/lcov-report/src/widget/components/index.html +296 -0
- package/coverage/lcov-report/src/widget/components/utils.tsx.html +562 -0
- package/coverage/lcov-report/src/widget/context/ReportsApiConfigContext.tsx.html +166 -0
- package/coverage/lcov-report/src/widget/context/index.html +116 -0
- package/coverage/lcov-report/src/widget/hooks/index.html +116 -0
- package/coverage/lcov-report/src/widget/hooks/useValidator.ts.html +295 -0
- package/coverage/lcov-report/src/widget/index.html +116 -0
- package/coverage/lcov.info +1260 -0
- package/jest.config.js +19 -0
- package/lib/cjs/ReportsConfigWidget.d.ts +10 -0
- package/lib/cjs/ReportsConfigWidget.d.ts.map +1 -0
- package/lib/cjs/ReportsConfigWidget.js +24 -0
- package/lib/cjs/ReportsConfigWidget.js.map +1 -0
- package/lib/cjs/reports-config-widget-react.d.ts +4 -0
- package/lib/cjs/reports-config-widget-react.d.ts.map +1 -0
- package/lib/cjs/reports-config-widget-react.js +20 -0
- package/lib/cjs/reports-config-widget-react.js.map +1 -0
- package/lib/cjs/test/ReportAction.test.d.ts +2 -0
- package/lib/cjs/test/ReportAction.test.d.ts.map +1 -0
- package/lib/cjs/test/ReportAction.test.js +194 -0
- package/lib/cjs/test/ReportAction.test.js.map +1 -0
- package/lib/cjs/test/ReportMappings.test.d.ts +2 -0
- package/lib/cjs/test/ReportMappings.test.d.ts.map +1 -0
- package/lib/cjs/test/ReportMappings.test.js +530 -0
- package/lib/cjs/test/ReportMappings.test.js.map +1 -0
- package/lib/cjs/test/Reports.test.d.ts +2 -0
- package/lib/cjs/test/Reports.test.d.ts.map +1 -0
- package/lib/cjs/test/Reports.test.js +232 -0
- package/lib/cjs/test/Reports.test.js.map +1 -0
- package/lib/cjs/test/WidgetHeader.test.d.ts +2 -0
- package/lib/cjs/test/WidgetHeader.test.d.ts.map +1 -0
- package/lib/cjs/test/WidgetHeader.test.js +30 -0
- package/lib/cjs/test/WidgetHeader.test.js.map +1 -0
- package/lib/cjs/test/test-utils.d.ts +69 -0
- package/lib/cjs/test/test-utils.d.ts.map +1 -0
- package/lib/cjs/test/test-utils.js +77 -0
- package/lib/cjs/test/test-utils.js.map +1 -0
- package/lib/cjs/tsconfig.tsbuildinfo +1 -0
- package/lib/cjs/widget/ReportsConfigUiProvider.d.ts +12 -0
- package/lib/cjs/widget/ReportsConfigUiProvider.d.ts.map +1 -0
- package/lib/cjs/widget/ReportsConfigUiProvider.js +55 -0
- package/lib/cjs/widget/ReportsConfigUiProvider.js.map +1 -0
- package/lib/cjs/widget/components/ActionPanel.d.ts +13 -0
- package/lib/cjs/widget/components/ActionPanel.d.ts.map +1 -0
- package/lib/cjs/widget/components/ActionPanel.js +39 -0
- package/lib/cjs/widget/components/ActionPanel.js.map +1 -0
- package/lib/cjs/widget/components/ActionPanel.scss +12 -0
- package/lib/cjs/widget/components/AddMappingsModal.d.ts +15 -0
- package/lib/cjs/widget/components/AddMappingsModal.d.ts.map +1 -0
- package/lib/cjs/widget/components/AddMappingsModal.js +118 -0
- package/lib/cjs/widget/components/AddMappingsModal.js.map +1 -0
- package/lib/cjs/widget/components/AddMappingsModal.scss +18 -0
- package/lib/cjs/widget/components/DeleteModal.d.ts +12 -0
- package/lib/cjs/widget/components/DeleteModal.d.ts.map +1 -0
- package/lib/cjs/widget/components/DeleteModal.js +65 -0
- package/lib/cjs/widget/components/DeleteModal.js.map +1 -0
- package/lib/cjs/widget/components/DeleteModal.scss +18 -0
- package/lib/cjs/widget/components/Extraction.d.ts +28 -0
- package/lib/cjs/widget/components/Extraction.d.ts.map +1 -0
- package/lib/cjs/widget/components/Extraction.js +193 -0
- package/lib/cjs/widget/components/Extraction.js.map +1 -0
- package/lib/cjs/widget/components/Extraction.scss +39 -0
- package/lib/cjs/widget/components/HorizontalTile.d.ts +13 -0
- package/lib/cjs/widget/components/HorizontalTile.d.ts.map +1 -0
- package/lib/cjs/widget/components/HorizontalTile.js +18 -0
- package/lib/cjs/widget/components/HorizontalTile.js.map +1 -0
- package/lib/cjs/widget/components/HorizontalTile.scss +32 -0
- package/lib/cjs/widget/components/LocalizedTablePaginator.d.ts +4 -0
- package/lib/cjs/widget/components/LocalizedTablePaginator.d.ts.map +1 -0
- package/lib/cjs/widget/components/LocalizedTablePaginator.js +41 -0
- package/lib/cjs/widget/components/LocalizedTablePaginator.js.map +1 -0
- package/lib/cjs/widget/components/ReportAction.d.ts +11 -0
- package/lib/cjs/widget/components/ReportAction.d.ts.map +1 -0
- package/lib/cjs/widget/components/ReportAction.js +101 -0
- package/lib/cjs/widget/components/ReportAction.js.map +1 -0
- package/lib/cjs/widget/components/ReportAction.scss +16 -0
- package/lib/cjs/widget/components/ReportMappings.d.ts +17 -0
- package/lib/cjs/widget/components/ReportMappings.d.ts.map +1 -0
- package/lib/cjs/widget/components/ReportMappings.js +174 -0
- package/lib/cjs/widget/components/ReportMappings.js.map +1 -0
- package/lib/cjs/widget/components/ReportMappings.scss +46 -0
- package/lib/cjs/widget/components/Reports.d.ts +7 -0
- package/lib/cjs/widget/components/Reports.d.ts.map +1 -0
- package/lib/cjs/widget/components/Reports.js +143 -0
- package/lib/cjs/widget/components/Reports.js.map +1 -0
- package/lib/cjs/widget/components/Reports.scss +36 -0
- package/lib/cjs/widget/components/ReportsContainer.d.ts +10 -0
- package/lib/cjs/widget/components/ReportsContainer.d.ts.map +1 -0
- package/lib/cjs/widget/components/ReportsContainer.js +34 -0
- package/lib/cjs/widget/components/ReportsContainer.js.map +1 -0
- package/lib/cjs/widget/components/ReportsContainer.scss +15 -0
- package/lib/cjs/widget/components/SearchBar.d.ts +10 -0
- package/lib/cjs/widget/components/SearchBar.d.ts.map +1 -0
- package/lib/cjs/widget/components/SearchBar.js +50 -0
- package/lib/cjs/widget/components/SearchBar.js.map +1 -0
- package/lib/cjs/widget/components/SearchBar.scss +27 -0
- package/lib/cjs/widget/components/SelectIModel.d.ts +9 -0
- package/lib/cjs/widget/components/SelectIModel.d.ts.map +1 -0
- package/lib/cjs/widget/components/SelectIModel.js +82 -0
- package/lib/cjs/widget/components/SelectIModel.js.map +1 -0
- package/lib/cjs/widget/components/SelectIModel.scss +15 -0
- package/lib/cjs/widget/components/utils.d.ts +23 -0
- package/lib/cjs/widget/components/utils.d.ts.map +1 -0
- package/lib/cjs/widget/components/utils.js +87 -0
- package/lib/cjs/widget/components/utils.js.map +1 -0
- package/lib/cjs/widget/components/utils.scss +39 -0
- package/lib/cjs/widget/context/ReportsApiConfigContext.d.ts +9 -0
- package/lib/cjs/widget/context/ReportsApiConfigContext.d.ts.map +1 -0
- package/lib/cjs/widget/context/ReportsApiConfigContext.js +37 -0
- package/lib/cjs/widget/context/ReportsApiConfigContext.js.map +1 -0
- package/lib/cjs/widget/hooks/useValidator.d.ts +8 -0
- package/lib/cjs/widget/hooks/useValidator.d.ts.map +1 -0
- package/lib/cjs/widget/hooks/useValidator.js +56 -0
- package/lib/cjs/widget/hooks/useValidator.js.map +1 -0
- package/lib/esm/ReportsConfigWidget.d.ts +10 -0
- package/lib/esm/ReportsConfigWidget.d.ts.map +1 -0
- package/lib/esm/ReportsConfigWidget.js +20 -0
- package/lib/esm/ReportsConfigWidget.js.map +1 -0
- package/lib/esm/reports-config-widget-react.d.ts +4 -0
- package/lib/esm/reports-config-widget-react.d.ts.map +1 -0
- package/lib/esm/reports-config-widget-react.js +8 -0
- package/lib/esm/reports-config-widget-react.js.map +1 -0
- package/lib/esm/test/ReportAction.test.d.ts +2 -0
- package/lib/esm/test/ReportAction.test.d.ts.map +1 -0
- package/lib/esm/test/ReportAction.test.js +170 -0
- package/lib/esm/test/ReportAction.test.js.map +1 -0
- package/lib/esm/test/ReportMappings.test.d.ts +2 -0
- package/lib/esm/test/ReportMappings.test.d.ts.map +1 -0
- package/lib/esm/test/ReportMappings.test.js +506 -0
- package/lib/esm/test/ReportMappings.test.js.map +1 -0
- package/lib/esm/test/Reports.test.d.ts +2 -0
- package/lib/esm/test/Reports.test.d.ts.map +1 -0
- package/lib/esm/test/Reports.test.js +208 -0
- package/lib/esm/test/Reports.test.js.map +1 -0
- package/lib/esm/test/WidgetHeader.test.d.ts +2 -0
- package/lib/esm/test/WidgetHeader.test.d.ts.map +1 -0
- package/lib/esm/test/WidgetHeader.test.js +25 -0
- package/lib/esm/test/WidgetHeader.test.js.map +1 -0
- package/lib/esm/test/test-utils.d.ts +69 -0
- package/lib/esm/test/test-utils.d.ts.map +1 -0
- package/lib/esm/test/test-utils.js +48 -0
- package/lib/esm/test/test-utils.js.map +1 -0
- package/lib/esm/tsconfig.tsbuildinfo +1 -0
- package/lib/esm/widget/ReportsConfigUiProvider.d.ts +12 -0
- package/lib/esm/widget/ReportsConfigUiProvider.d.ts.map +1 -0
- package/lib/esm/widget/ReportsConfigUiProvider.js +29 -0
- package/lib/esm/widget/ReportsConfigUiProvider.js.map +1 -0
- package/lib/esm/widget/components/ActionPanel.d.ts +13 -0
- package/lib/esm/widget/components/ActionPanel.d.ts.map +1 -0
- package/lib/esm/widget/components/ActionPanel.js +18 -0
- package/lib/esm/widget/components/ActionPanel.js.map +1 -0
- package/lib/esm/widget/components/ActionPanel.scss +12 -0
- package/lib/esm/widget/components/AddMappingsModal.d.ts +15 -0
- package/lib/esm/widget/components/AddMappingsModal.d.ts.map +1 -0
- package/lib/esm/widget/components/AddMappingsModal.js +94 -0
- package/lib/esm/widget/components/AddMappingsModal.js.map +1 -0
- package/lib/esm/widget/components/AddMappingsModal.scss +18 -0
- package/lib/esm/widget/components/DeleteModal.d.ts +12 -0
- package/lib/esm/widget/components/DeleteModal.d.ts.map +1 -0
- package/lib/esm/widget/components/DeleteModal.js +42 -0
- package/lib/esm/widget/components/DeleteModal.js.map +1 -0
- package/lib/esm/widget/components/DeleteModal.scss +18 -0
- package/lib/esm/widget/components/Extraction.d.ts +28 -0
- package/lib/esm/widget/components/Extraction.d.ts.map +1 -0
- package/lib/esm/widget/components/Extraction.js +169 -0
- package/lib/esm/widget/components/Extraction.js.map +1 -0
- package/lib/esm/widget/components/Extraction.scss +39 -0
- package/lib/esm/widget/components/HorizontalTile.d.ts +13 -0
- package/lib/esm/widget/components/HorizontalTile.d.ts.map +1 -0
- package/lib/esm/widget/components/HorizontalTile.js +11 -0
- package/lib/esm/widget/components/HorizontalTile.js.map +1 -0
- package/lib/esm/widget/components/HorizontalTile.scss +32 -0
- package/lib/esm/widget/components/LocalizedTablePaginator.d.ts +4 -0
- package/lib/esm/widget/components/LocalizedTablePaginator.d.ts.map +1 -0
- package/lib/esm/widget/components/LocalizedTablePaginator.js +18 -0
- package/lib/esm/widget/components/LocalizedTablePaginator.js.map +1 -0
- package/lib/esm/widget/components/ReportAction.d.ts +11 -0
- package/lib/esm/widget/components/ReportAction.d.ts.map +1 -0
- package/lib/esm/widget/components/ReportAction.js +77 -0
- package/lib/esm/widget/components/ReportAction.js.map +1 -0
- package/lib/esm/widget/components/ReportAction.scss +16 -0
- package/lib/esm/widget/components/ReportMappings.d.ts +17 -0
- package/lib/esm/widget/components/ReportMappings.d.ts.map +1 -0
- package/lib/esm/widget/components/ReportMappings.js +148 -0
- package/lib/esm/widget/components/ReportMappings.js.map +1 -0
- package/lib/esm/widget/components/ReportMappings.scss +46 -0
- package/lib/esm/widget/components/Reports.d.ts +7 -0
- package/lib/esm/widget/components/Reports.d.ts.map +1 -0
- package/lib/esm/widget/components/Reports.js +117 -0
- package/lib/esm/widget/components/Reports.js.map +1 -0
- package/lib/esm/widget/components/Reports.scss +36 -0
- package/lib/esm/widget/components/ReportsContainer.d.ts +10 -0
- package/lib/esm/widget/components/ReportsContainer.d.ts.map +1 -0
- package/lib/esm/widget/components/ReportsContainer.js +13 -0
- package/lib/esm/widget/components/ReportsContainer.js.map +1 -0
- package/lib/esm/widget/components/ReportsContainer.scss +15 -0
- package/lib/esm/widget/components/SearchBar.d.ts +10 -0
- package/lib/esm/widget/components/SearchBar.d.ts.map +1 -0
- package/lib/esm/widget/components/SearchBar.js +27 -0
- package/lib/esm/widget/components/SearchBar.js.map +1 -0
- package/lib/esm/widget/components/SearchBar.scss +27 -0
- package/lib/esm/widget/components/SelectIModel.d.ts +9 -0
- package/lib/esm/widget/components/SelectIModel.d.ts.map +1 -0
- package/lib/esm/widget/components/SelectIModel.js +59 -0
- package/lib/esm/widget/components/SelectIModel.js.map +1 -0
- package/lib/esm/widget/components/SelectIModel.scss +15 -0
- package/lib/esm/widget/components/utils.d.ts +23 -0
- package/lib/esm/widget/components/utils.d.ts.map +1 -0
- package/lib/esm/widget/components/utils.js +73 -0
- package/lib/esm/widget/components/utils.js.map +1 -0
- package/lib/esm/widget/components/utils.scss +39 -0
- package/lib/esm/widget/context/ReportsApiConfigContext.d.ts +9 -0
- package/lib/esm/widget/context/ReportsApiConfigContext.d.ts.map +1 -0
- package/lib/esm/widget/context/ReportsApiConfigContext.js +14 -0
- package/lib/esm/widget/context/ReportsApiConfigContext.js.map +1 -0
- package/lib/esm/widget/hooks/useValidator.d.ts +8 -0
- package/lib/esm/widget/hooks/useValidator.d.ts.map +1 -0
- package/lib/esm/widget/hooks/useValidator.js +50 -0
- package/lib/esm/widget/hooks/useValidator.js.map +1 -0
- package/lib/public/locales/en/ReportsConfigWidget.json +76 -0
- package/package.json +124 -0
- package/public/locales/en/ReportsConfigWidget.json +76 -0
- package/reports-config-widget-react.build.error.log +10 -0
- package/reports-config-widget-react.build.log +45 -0
- package/src/ReportsConfigWidget.ts +36 -0
- package/src/reports-config-widget-react.ts +7 -0
- package/src/test/ReportAction.test.tsx +258 -0
- package/src/test/ReportMappings.test.tsx +882 -0
- package/src/test/Reports.test.tsx +365 -0
- package/src/test/WidgetHeader.test.tsx +29 -0
- package/src/test/test-utils.tsx +77 -0
- package/src/widget/ReportsConfigUiProvider.tsx +67 -0
- package/src/widget/components/ActionPanel.scss +12 -0
- package/src/widget/components/ActionPanel.tsx +56 -0
- package/src/widget/components/AddMappingsModal.scss +18 -0
- package/src/widget/components/AddMappingsModal.tsx +175 -0
- package/src/widget/components/DeleteModal.scss +18 -0
- package/src/widget/components/DeleteModal.tsx +100 -0
- package/src/widget/components/Extraction.scss +39 -0
- package/src/widget/components/Extraction.tsx +315 -0
- package/src/widget/components/HorizontalTile.scss +32 -0
- package/src/widget/components/HorizontalTile.tsx +57 -0
- package/src/widget/components/LocalizedTablePaginator.tsx +59 -0
- package/src/widget/components/ReportAction.scss +16 -0
- package/src/widget/components/ReportAction.tsx +146 -0
- package/src/widget/components/ReportMappings.scss +46 -0
- package/src/widget/components/ReportMappings.tsx +350 -0
- package/src/widget/components/Reports.scss +36 -0
- package/src/widget/components/Reports.tsx +248 -0
- package/src/widget/components/ReportsContainer.scss +15 -0
- package/src/widget/components/ReportsContainer.tsx +36 -0
- package/src/widget/components/SearchBar.scss +27 -0
- package/src/widget/components/SearchBar.tsx +62 -0
- package/src/widget/components/SelectIModel.scss +15 -0
- package/src/widget/components/SelectIModel.tsx +102 -0
- package/src/widget/components/utils.scss +39 -0
- package/src/widget/components/utils.tsx +159 -0
- package/src/widget/context/ReportsApiConfigContext.tsx +27 -0
- package/src/widget/hooks/useValidator.ts +70 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,159 @@
|
|
|
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 { SvgChevronLeft } from "@itwin/itwinui-icons-react";
|
|
6
|
+
import {
|
|
7
|
+
IconButton,
|
|
8
|
+
ProgressRadial,
|
|
9
|
+
Text,
|
|
10
|
+
toaster,
|
|
11
|
+
} from "@itwin/itwinui-react";
|
|
12
|
+
import "./utils.scss";
|
|
13
|
+
import React from "react";
|
|
14
|
+
import { ReportsConfigWidget } from "../../ReportsConfigWidget";
|
|
15
|
+
|
|
16
|
+
export interface WidgetHeaderProps {
|
|
17
|
+
title: string;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
returnFn?: () => Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const WidgetHeader = ({
|
|
23
|
+
title,
|
|
24
|
+
disabled = false,
|
|
25
|
+
returnFn,
|
|
26
|
+
}: WidgetHeaderProps) => {
|
|
27
|
+
return (
|
|
28
|
+
<div className="rcw-widget-header-container">
|
|
29
|
+
{returnFn && (
|
|
30
|
+
<IconButton
|
|
31
|
+
onClick={returnFn}
|
|
32
|
+
disabled={disabled}
|
|
33
|
+
styleType="borderless"
|
|
34
|
+
>
|
|
35
|
+
<SvgChevronLeft />
|
|
36
|
+
</IconButton>
|
|
37
|
+
)}
|
|
38
|
+
<Text className="title" variant="title">
|
|
39
|
+
{title}
|
|
40
|
+
</Text>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const handleError = (errorStatus: number) => {
|
|
46
|
+
let errorMessage = `${ReportsConfigWidget.localization.getLocalizedString(
|
|
47
|
+
"ReportsConfigWidget:ErrorMessages.Error"
|
|
48
|
+
)} `;
|
|
49
|
+
switch (errorStatus) {
|
|
50
|
+
case 401:
|
|
51
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString(
|
|
52
|
+
"ReportsConfigWidget:ErrorMessages.401"
|
|
53
|
+
);
|
|
54
|
+
break;
|
|
55
|
+
case 403:
|
|
56
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString(
|
|
57
|
+
"ReportsConfigWidget:ErrorMessages.403"
|
|
58
|
+
);
|
|
59
|
+
break;
|
|
60
|
+
case 404:
|
|
61
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString(
|
|
62
|
+
"ReportsConfigWidget:ErrorMessages.404"
|
|
63
|
+
);
|
|
64
|
+
break;
|
|
65
|
+
case 409:
|
|
66
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString(
|
|
67
|
+
"ReportsConfigWidget:ErrorMessages.409"
|
|
68
|
+
);
|
|
69
|
+
break;
|
|
70
|
+
case 422:
|
|
71
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString(
|
|
72
|
+
"ReportsConfigWidget:ErrorMessages.422"
|
|
73
|
+
);
|
|
74
|
+
break;
|
|
75
|
+
case 429:
|
|
76
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString(
|
|
77
|
+
"ReportsConfigWidget:ErrorMessages.429"
|
|
78
|
+
);
|
|
79
|
+
break;
|
|
80
|
+
case 500:
|
|
81
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString(
|
|
82
|
+
"ReportsConfigWidget:ErrorMessages.500"
|
|
83
|
+
);
|
|
84
|
+
break;
|
|
85
|
+
case 502:
|
|
86
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString(
|
|
87
|
+
"ReportsConfigWidget:ErrorMessages.502"
|
|
88
|
+
);
|
|
89
|
+
break;
|
|
90
|
+
case 503:
|
|
91
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString(
|
|
92
|
+
"ReportsConfigWidget:ErrorMessages.503"
|
|
93
|
+
);
|
|
94
|
+
break;
|
|
95
|
+
default:
|
|
96
|
+
errorMessage += ReportsConfigWidget.localization.getLocalizedString(
|
|
97
|
+
"ReportsConfigWidget:ErrorMessages.SomethingWentWrong"
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
toaster.negative(errorMessage);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const LoadingOverlay = () => (
|
|
104
|
+
<div className="rcw-center-overlay">
|
|
105
|
+
<Text>
|
|
106
|
+
{ReportsConfigWidget.localization.getLocalizedString(
|
|
107
|
+
"ReportsConfigWidget:Loading"
|
|
108
|
+
)}
|
|
109
|
+
</Text>
|
|
110
|
+
<ProgressRadial indeterminate />
|
|
111
|
+
<Text>
|
|
112
|
+
{ReportsConfigWidget.localization.getLocalizedString(
|
|
113
|
+
"ReportsConfigWidget:PleaseWait"
|
|
114
|
+
)}
|
|
115
|
+
</Text>
|
|
116
|
+
</div>
|
|
117
|
+
);
|
|
118
|
+
interface EmptyMessageProps {
|
|
119
|
+
children?: React.ReactNode;
|
|
120
|
+
}
|
|
121
|
+
export const EmptyMessage = ({ children }: EmptyMessageProps) => {
|
|
122
|
+
return <div className="rcw-center-overlay">{children}</div>;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const handleInputChange = <T,>(
|
|
126
|
+
e: React.ChangeEvent<HTMLInputElement>,
|
|
127
|
+
values: T,
|
|
128
|
+
setValues: React.Dispatch<React.SetStateAction<T>>
|
|
129
|
+
) => {
|
|
130
|
+
const { name, value } = e.target;
|
|
131
|
+
|
|
132
|
+
setValues({
|
|
133
|
+
...values,
|
|
134
|
+
[name]: value,
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const LoadingSpinner = () => {
|
|
139
|
+
return (
|
|
140
|
+
<div
|
|
141
|
+
className="rcw-loading-spinner"
|
|
142
|
+
data-testid="rcw-action-loading-spinner"
|
|
143
|
+
>
|
|
144
|
+
<ProgressRadial size="small" indeterminate />
|
|
145
|
+
</div>
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const SkeletonBlock = () => (
|
|
150
|
+
<div className="rcw-skeleton-block iui-skeleton" />
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
export const generateUrl = (baseUrl: string, newBaseUrl: string) => {
|
|
154
|
+
return baseUrl.replace("https://api.bentley.com", newBaseUrl);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export type CreateTypeFromInterface<Interface> = {
|
|
158
|
+
[Property in keyof Interface]: Interface[Property];
|
|
159
|
+
};
|
|
@@ -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 type { AccessToken } from "@itwin/core-bentley";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { createContext } from "react";
|
|
8
|
+
|
|
9
|
+
export interface ReportsApiConfig {
|
|
10
|
+
getAccessToken: () => Promise<AccessToken>;
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const ReportsApiConfigContext = createContext<ReportsApiConfig>({
|
|
15
|
+
getAccessToken: async () => "",
|
|
16
|
+
baseUrl: "",
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const useReportsApiConfig = () => {
|
|
20
|
+
const context = React.useContext(ReportsApiConfigContext);
|
|
21
|
+
if (!context) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
"useApiConfig should be used within a ReportsApiConfigContext provider"
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return context;
|
|
27
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
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 { useState } from "react";
|
|
6
|
+
import SimpleReactValidator from "simple-react-validator";
|
|
7
|
+
import { ReportsConfigWidget } from "../../ReportsConfigWidget";
|
|
8
|
+
|
|
9
|
+
export const NAME_REQUIREMENTS =
|
|
10
|
+
"required|NoDuplicateUnderscore|OnlyBeginsWithLetterOrUnderscore|FollowedByLettersUnderscoresSpacesAndDigits|CharLimit";
|
|
11
|
+
|
|
12
|
+
const useValidator = (): [
|
|
13
|
+
SimpleReactValidator,
|
|
14
|
+
React.Dispatch<React.SetStateAction<boolean>>
|
|
15
|
+
] => {
|
|
16
|
+
const [show, setShow] = useState(false);
|
|
17
|
+
const customValidator = {
|
|
18
|
+
NoDuplicateUnderscore: {
|
|
19
|
+
message: ReportsConfigWidget.localization.getLocalizedString(
|
|
20
|
+
"ReportsConfigWidget:Validators.NoDuplicateUnderscore"
|
|
21
|
+
),
|
|
22
|
+
rule: (val: string) => {
|
|
23
|
+
return !val.match(/__+/i);
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
OnlyBeginsWithLetterOrUnderscore: {
|
|
27
|
+
message: ReportsConfigWidget.localization.getLocalizedString(
|
|
28
|
+
"ReportsConfigWidget:Validators.OnlyBeginsWithLetterOrUnderscore"
|
|
29
|
+
),
|
|
30
|
+
rule: (val: string) => {
|
|
31
|
+
return !val.match(/^[\W\d]+/i);
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
FollowedByLettersUnderscoresSpacesAndDigits: {
|
|
35
|
+
message: ReportsConfigWidget.localization.getLocalizedString(
|
|
36
|
+
"ReportsConfigWidget:Validators.FollowedByLettersUnderscoresSpacesAndDigits"
|
|
37
|
+
),
|
|
38
|
+
rule: (val: string) => {
|
|
39
|
+
return !val.match(/[^a-zA-Z0-9_\s]+/i);
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
CharLimit: {
|
|
43
|
+
message: ReportsConfigWidget.localization.getLocalizedString(
|
|
44
|
+
"ReportsConfigWidget:Validators.CharLimit"
|
|
45
|
+
),
|
|
46
|
+
rule: (val: string) => {
|
|
47
|
+
return val.length <= 128;
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const customMessages = {
|
|
53
|
+
required: ReportsConfigWidget.localization.getLocalizedString(
|
|
54
|
+
"ReportsConfigWidget:Validators.ThisFieldIsRequired"
|
|
55
|
+
),
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const validator = new SimpleReactValidator({
|
|
59
|
+
messages: customMessages,
|
|
60
|
+
validators: customValidator,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
if (show) {
|
|
64
|
+
validator.showMessages();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return [validator, setShow];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default useValidator;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./node_modules/@itwin/build-tools/tsconfig-base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"skipLibCheck": true,
|
|
5
|
+
"jsx": "react",
|
|
6
|
+
"preserveSymlinks": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
},
|
|
9
|
+
"include": ["./src/**/*.ts*"],
|
|
10
|
+
"exclude": ["lib", "node_modules"]
|
|
11
|
+
}
|