@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.
Files changed (294) hide show
  1. package/.rush/temp/package-deps_rebuild.json +48 -0
  2. package/.rush/temp/shrinkwrap-deps.json +868 -0
  3. package/CHANGELOG.json +17 -0
  4. package/CHANGELOG.md +11 -0
  5. package/LICENSE.md +9 -0
  6. package/README.md +38 -0
  7. package/__mocks__/fileMock.js +5 -0
  8. package/coverage/clover.xml +612 -0
  9. package/coverage/coverage-final.json +19 -0
  10. package/coverage/lcov-report/base.css +224 -0
  11. package/coverage/lcov-report/block-navigation.js +87 -0
  12. package/coverage/lcov-report/favicon.png +0 -0
  13. package/coverage/lcov-report/index.html +191 -0
  14. package/coverage/lcov-report/prettify.css +1 -0
  15. package/coverage/lcov-report/prettify.js +2 -0
  16. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  17. package/coverage/lcov-report/sorter.js +196 -0
  18. package/coverage/lcov-report/src/ReportsConfigWidget.ts.html +193 -0
  19. package/coverage/lcov-report/src/index.html +116 -0
  20. package/coverage/lcov-report/src/test/index.html +116 -0
  21. package/coverage/lcov-report/src/test/test-utils.tsx.html +316 -0
  22. package/coverage/lcov-report/src/widget/ReportsConfigUiProvider.tsx.html +286 -0
  23. package/coverage/lcov-report/src/widget/components/ActionPanel.tsx.html +253 -0
  24. package/coverage/lcov-report/src/widget/components/AddMappingsModal.tsx.html +610 -0
  25. package/coverage/lcov-report/src/widget/components/DeleteModal.tsx.html +385 -0
  26. package/coverage/lcov-report/src/widget/components/Extraction.tsx.html +1030 -0
  27. package/coverage/lcov-report/src/widget/components/HorizontalTile.tsx.html +256 -0
  28. package/coverage/lcov-report/src/widget/components/LocalizedTablePaginator.tsx.html +262 -0
  29. package/coverage/lcov-report/src/widget/components/ReportAction.tsx.html +523 -0
  30. package/coverage/lcov-report/src/widget/components/ReportMappings.tsx.html +1135 -0
  31. package/coverage/lcov-report/src/widget/components/Reports.tsx.html +829 -0
  32. package/coverage/lcov-report/src/widget/components/ReportsContainer.tsx.html +193 -0
  33. package/coverage/lcov-report/src/widget/components/SearchBar.tsx.html +271 -0
  34. package/coverage/lcov-report/src/widget/components/SelectIModel.tsx.html +391 -0
  35. package/coverage/lcov-report/src/widget/components/index.html +296 -0
  36. package/coverage/lcov-report/src/widget/components/utils.tsx.html +562 -0
  37. package/coverage/lcov-report/src/widget/context/ReportsApiConfigContext.tsx.html +166 -0
  38. package/coverage/lcov-report/src/widget/context/index.html +116 -0
  39. package/coverage/lcov-report/src/widget/hooks/index.html +116 -0
  40. package/coverage/lcov-report/src/widget/hooks/useValidator.ts.html +295 -0
  41. package/coverage/lcov-report/src/widget/index.html +116 -0
  42. package/coverage/lcov.info +1260 -0
  43. package/jest.config.js +19 -0
  44. package/lib/cjs/ReportsConfigWidget.d.ts +10 -0
  45. package/lib/cjs/ReportsConfigWidget.d.ts.map +1 -0
  46. package/lib/cjs/ReportsConfigWidget.js +24 -0
  47. package/lib/cjs/ReportsConfigWidget.js.map +1 -0
  48. package/lib/cjs/reports-config-widget-react.d.ts +4 -0
  49. package/lib/cjs/reports-config-widget-react.d.ts.map +1 -0
  50. package/lib/cjs/reports-config-widget-react.js +20 -0
  51. package/lib/cjs/reports-config-widget-react.js.map +1 -0
  52. package/lib/cjs/test/ReportAction.test.d.ts +2 -0
  53. package/lib/cjs/test/ReportAction.test.d.ts.map +1 -0
  54. package/lib/cjs/test/ReportAction.test.js +194 -0
  55. package/lib/cjs/test/ReportAction.test.js.map +1 -0
  56. package/lib/cjs/test/ReportMappings.test.d.ts +2 -0
  57. package/lib/cjs/test/ReportMappings.test.d.ts.map +1 -0
  58. package/lib/cjs/test/ReportMappings.test.js +530 -0
  59. package/lib/cjs/test/ReportMappings.test.js.map +1 -0
  60. package/lib/cjs/test/Reports.test.d.ts +2 -0
  61. package/lib/cjs/test/Reports.test.d.ts.map +1 -0
  62. package/lib/cjs/test/Reports.test.js +232 -0
  63. package/lib/cjs/test/Reports.test.js.map +1 -0
  64. package/lib/cjs/test/WidgetHeader.test.d.ts +2 -0
  65. package/lib/cjs/test/WidgetHeader.test.d.ts.map +1 -0
  66. package/lib/cjs/test/WidgetHeader.test.js +30 -0
  67. package/lib/cjs/test/WidgetHeader.test.js.map +1 -0
  68. package/lib/cjs/test/test-utils.d.ts +69 -0
  69. package/lib/cjs/test/test-utils.d.ts.map +1 -0
  70. package/lib/cjs/test/test-utils.js +77 -0
  71. package/lib/cjs/test/test-utils.js.map +1 -0
  72. package/lib/cjs/tsconfig.tsbuildinfo +1 -0
  73. package/lib/cjs/widget/ReportsConfigUiProvider.d.ts +12 -0
  74. package/lib/cjs/widget/ReportsConfigUiProvider.d.ts.map +1 -0
  75. package/lib/cjs/widget/ReportsConfigUiProvider.js +55 -0
  76. package/lib/cjs/widget/ReportsConfigUiProvider.js.map +1 -0
  77. package/lib/cjs/widget/components/ActionPanel.d.ts +13 -0
  78. package/lib/cjs/widget/components/ActionPanel.d.ts.map +1 -0
  79. package/lib/cjs/widget/components/ActionPanel.js +39 -0
  80. package/lib/cjs/widget/components/ActionPanel.js.map +1 -0
  81. package/lib/cjs/widget/components/ActionPanel.scss +12 -0
  82. package/lib/cjs/widget/components/AddMappingsModal.d.ts +15 -0
  83. package/lib/cjs/widget/components/AddMappingsModal.d.ts.map +1 -0
  84. package/lib/cjs/widget/components/AddMappingsModal.js +118 -0
  85. package/lib/cjs/widget/components/AddMappingsModal.js.map +1 -0
  86. package/lib/cjs/widget/components/AddMappingsModal.scss +18 -0
  87. package/lib/cjs/widget/components/DeleteModal.d.ts +12 -0
  88. package/lib/cjs/widget/components/DeleteModal.d.ts.map +1 -0
  89. package/lib/cjs/widget/components/DeleteModal.js +65 -0
  90. package/lib/cjs/widget/components/DeleteModal.js.map +1 -0
  91. package/lib/cjs/widget/components/DeleteModal.scss +18 -0
  92. package/lib/cjs/widget/components/Extraction.d.ts +28 -0
  93. package/lib/cjs/widget/components/Extraction.d.ts.map +1 -0
  94. package/lib/cjs/widget/components/Extraction.js +193 -0
  95. package/lib/cjs/widget/components/Extraction.js.map +1 -0
  96. package/lib/cjs/widget/components/Extraction.scss +39 -0
  97. package/lib/cjs/widget/components/HorizontalTile.d.ts +13 -0
  98. package/lib/cjs/widget/components/HorizontalTile.d.ts.map +1 -0
  99. package/lib/cjs/widget/components/HorizontalTile.js +18 -0
  100. package/lib/cjs/widget/components/HorizontalTile.js.map +1 -0
  101. package/lib/cjs/widget/components/HorizontalTile.scss +32 -0
  102. package/lib/cjs/widget/components/LocalizedTablePaginator.d.ts +4 -0
  103. package/lib/cjs/widget/components/LocalizedTablePaginator.d.ts.map +1 -0
  104. package/lib/cjs/widget/components/LocalizedTablePaginator.js +41 -0
  105. package/lib/cjs/widget/components/LocalizedTablePaginator.js.map +1 -0
  106. package/lib/cjs/widget/components/ReportAction.d.ts +11 -0
  107. package/lib/cjs/widget/components/ReportAction.d.ts.map +1 -0
  108. package/lib/cjs/widget/components/ReportAction.js +101 -0
  109. package/lib/cjs/widget/components/ReportAction.js.map +1 -0
  110. package/lib/cjs/widget/components/ReportAction.scss +16 -0
  111. package/lib/cjs/widget/components/ReportMappings.d.ts +17 -0
  112. package/lib/cjs/widget/components/ReportMappings.d.ts.map +1 -0
  113. package/lib/cjs/widget/components/ReportMappings.js +174 -0
  114. package/lib/cjs/widget/components/ReportMappings.js.map +1 -0
  115. package/lib/cjs/widget/components/ReportMappings.scss +46 -0
  116. package/lib/cjs/widget/components/Reports.d.ts +7 -0
  117. package/lib/cjs/widget/components/Reports.d.ts.map +1 -0
  118. package/lib/cjs/widget/components/Reports.js +143 -0
  119. package/lib/cjs/widget/components/Reports.js.map +1 -0
  120. package/lib/cjs/widget/components/Reports.scss +36 -0
  121. package/lib/cjs/widget/components/ReportsContainer.d.ts +10 -0
  122. package/lib/cjs/widget/components/ReportsContainer.d.ts.map +1 -0
  123. package/lib/cjs/widget/components/ReportsContainer.js +34 -0
  124. package/lib/cjs/widget/components/ReportsContainer.js.map +1 -0
  125. package/lib/cjs/widget/components/ReportsContainer.scss +15 -0
  126. package/lib/cjs/widget/components/SearchBar.d.ts +10 -0
  127. package/lib/cjs/widget/components/SearchBar.d.ts.map +1 -0
  128. package/lib/cjs/widget/components/SearchBar.js +50 -0
  129. package/lib/cjs/widget/components/SearchBar.js.map +1 -0
  130. package/lib/cjs/widget/components/SearchBar.scss +27 -0
  131. package/lib/cjs/widget/components/SelectIModel.d.ts +9 -0
  132. package/lib/cjs/widget/components/SelectIModel.d.ts.map +1 -0
  133. package/lib/cjs/widget/components/SelectIModel.js +82 -0
  134. package/lib/cjs/widget/components/SelectIModel.js.map +1 -0
  135. package/lib/cjs/widget/components/SelectIModel.scss +15 -0
  136. package/lib/cjs/widget/components/utils.d.ts +23 -0
  137. package/lib/cjs/widget/components/utils.d.ts.map +1 -0
  138. package/lib/cjs/widget/components/utils.js +87 -0
  139. package/lib/cjs/widget/components/utils.js.map +1 -0
  140. package/lib/cjs/widget/components/utils.scss +39 -0
  141. package/lib/cjs/widget/context/ReportsApiConfigContext.d.ts +9 -0
  142. package/lib/cjs/widget/context/ReportsApiConfigContext.d.ts.map +1 -0
  143. package/lib/cjs/widget/context/ReportsApiConfigContext.js +37 -0
  144. package/lib/cjs/widget/context/ReportsApiConfigContext.js.map +1 -0
  145. package/lib/cjs/widget/hooks/useValidator.d.ts +8 -0
  146. package/lib/cjs/widget/hooks/useValidator.d.ts.map +1 -0
  147. package/lib/cjs/widget/hooks/useValidator.js +56 -0
  148. package/lib/cjs/widget/hooks/useValidator.js.map +1 -0
  149. package/lib/esm/ReportsConfigWidget.d.ts +10 -0
  150. package/lib/esm/ReportsConfigWidget.d.ts.map +1 -0
  151. package/lib/esm/ReportsConfigWidget.js +20 -0
  152. package/lib/esm/ReportsConfigWidget.js.map +1 -0
  153. package/lib/esm/reports-config-widget-react.d.ts +4 -0
  154. package/lib/esm/reports-config-widget-react.d.ts.map +1 -0
  155. package/lib/esm/reports-config-widget-react.js +8 -0
  156. package/lib/esm/reports-config-widget-react.js.map +1 -0
  157. package/lib/esm/test/ReportAction.test.d.ts +2 -0
  158. package/lib/esm/test/ReportAction.test.d.ts.map +1 -0
  159. package/lib/esm/test/ReportAction.test.js +170 -0
  160. package/lib/esm/test/ReportAction.test.js.map +1 -0
  161. package/lib/esm/test/ReportMappings.test.d.ts +2 -0
  162. package/lib/esm/test/ReportMappings.test.d.ts.map +1 -0
  163. package/lib/esm/test/ReportMappings.test.js +506 -0
  164. package/lib/esm/test/ReportMappings.test.js.map +1 -0
  165. package/lib/esm/test/Reports.test.d.ts +2 -0
  166. package/lib/esm/test/Reports.test.d.ts.map +1 -0
  167. package/lib/esm/test/Reports.test.js +208 -0
  168. package/lib/esm/test/Reports.test.js.map +1 -0
  169. package/lib/esm/test/WidgetHeader.test.d.ts +2 -0
  170. package/lib/esm/test/WidgetHeader.test.d.ts.map +1 -0
  171. package/lib/esm/test/WidgetHeader.test.js +25 -0
  172. package/lib/esm/test/WidgetHeader.test.js.map +1 -0
  173. package/lib/esm/test/test-utils.d.ts +69 -0
  174. package/lib/esm/test/test-utils.d.ts.map +1 -0
  175. package/lib/esm/test/test-utils.js +48 -0
  176. package/lib/esm/test/test-utils.js.map +1 -0
  177. package/lib/esm/tsconfig.tsbuildinfo +1 -0
  178. package/lib/esm/widget/ReportsConfigUiProvider.d.ts +12 -0
  179. package/lib/esm/widget/ReportsConfigUiProvider.d.ts.map +1 -0
  180. package/lib/esm/widget/ReportsConfigUiProvider.js +29 -0
  181. package/lib/esm/widget/ReportsConfigUiProvider.js.map +1 -0
  182. package/lib/esm/widget/components/ActionPanel.d.ts +13 -0
  183. package/lib/esm/widget/components/ActionPanel.d.ts.map +1 -0
  184. package/lib/esm/widget/components/ActionPanel.js +18 -0
  185. package/lib/esm/widget/components/ActionPanel.js.map +1 -0
  186. package/lib/esm/widget/components/ActionPanel.scss +12 -0
  187. package/lib/esm/widget/components/AddMappingsModal.d.ts +15 -0
  188. package/lib/esm/widget/components/AddMappingsModal.d.ts.map +1 -0
  189. package/lib/esm/widget/components/AddMappingsModal.js +94 -0
  190. package/lib/esm/widget/components/AddMappingsModal.js.map +1 -0
  191. package/lib/esm/widget/components/AddMappingsModal.scss +18 -0
  192. package/lib/esm/widget/components/DeleteModal.d.ts +12 -0
  193. package/lib/esm/widget/components/DeleteModal.d.ts.map +1 -0
  194. package/lib/esm/widget/components/DeleteModal.js +42 -0
  195. package/lib/esm/widget/components/DeleteModal.js.map +1 -0
  196. package/lib/esm/widget/components/DeleteModal.scss +18 -0
  197. package/lib/esm/widget/components/Extraction.d.ts +28 -0
  198. package/lib/esm/widget/components/Extraction.d.ts.map +1 -0
  199. package/lib/esm/widget/components/Extraction.js +169 -0
  200. package/lib/esm/widget/components/Extraction.js.map +1 -0
  201. package/lib/esm/widget/components/Extraction.scss +39 -0
  202. package/lib/esm/widget/components/HorizontalTile.d.ts +13 -0
  203. package/lib/esm/widget/components/HorizontalTile.d.ts.map +1 -0
  204. package/lib/esm/widget/components/HorizontalTile.js +11 -0
  205. package/lib/esm/widget/components/HorizontalTile.js.map +1 -0
  206. package/lib/esm/widget/components/HorizontalTile.scss +32 -0
  207. package/lib/esm/widget/components/LocalizedTablePaginator.d.ts +4 -0
  208. package/lib/esm/widget/components/LocalizedTablePaginator.d.ts.map +1 -0
  209. package/lib/esm/widget/components/LocalizedTablePaginator.js +18 -0
  210. package/lib/esm/widget/components/LocalizedTablePaginator.js.map +1 -0
  211. package/lib/esm/widget/components/ReportAction.d.ts +11 -0
  212. package/lib/esm/widget/components/ReportAction.d.ts.map +1 -0
  213. package/lib/esm/widget/components/ReportAction.js +77 -0
  214. package/lib/esm/widget/components/ReportAction.js.map +1 -0
  215. package/lib/esm/widget/components/ReportAction.scss +16 -0
  216. package/lib/esm/widget/components/ReportMappings.d.ts +17 -0
  217. package/lib/esm/widget/components/ReportMappings.d.ts.map +1 -0
  218. package/lib/esm/widget/components/ReportMappings.js +148 -0
  219. package/lib/esm/widget/components/ReportMappings.js.map +1 -0
  220. package/lib/esm/widget/components/ReportMappings.scss +46 -0
  221. package/lib/esm/widget/components/Reports.d.ts +7 -0
  222. package/lib/esm/widget/components/Reports.d.ts.map +1 -0
  223. package/lib/esm/widget/components/Reports.js +117 -0
  224. package/lib/esm/widget/components/Reports.js.map +1 -0
  225. package/lib/esm/widget/components/Reports.scss +36 -0
  226. package/lib/esm/widget/components/ReportsContainer.d.ts +10 -0
  227. package/lib/esm/widget/components/ReportsContainer.d.ts.map +1 -0
  228. package/lib/esm/widget/components/ReportsContainer.js +13 -0
  229. package/lib/esm/widget/components/ReportsContainer.js.map +1 -0
  230. package/lib/esm/widget/components/ReportsContainer.scss +15 -0
  231. package/lib/esm/widget/components/SearchBar.d.ts +10 -0
  232. package/lib/esm/widget/components/SearchBar.d.ts.map +1 -0
  233. package/lib/esm/widget/components/SearchBar.js +27 -0
  234. package/lib/esm/widget/components/SearchBar.js.map +1 -0
  235. package/lib/esm/widget/components/SearchBar.scss +27 -0
  236. package/lib/esm/widget/components/SelectIModel.d.ts +9 -0
  237. package/lib/esm/widget/components/SelectIModel.d.ts.map +1 -0
  238. package/lib/esm/widget/components/SelectIModel.js +59 -0
  239. package/lib/esm/widget/components/SelectIModel.js.map +1 -0
  240. package/lib/esm/widget/components/SelectIModel.scss +15 -0
  241. package/lib/esm/widget/components/utils.d.ts +23 -0
  242. package/lib/esm/widget/components/utils.d.ts.map +1 -0
  243. package/lib/esm/widget/components/utils.js +73 -0
  244. package/lib/esm/widget/components/utils.js.map +1 -0
  245. package/lib/esm/widget/components/utils.scss +39 -0
  246. package/lib/esm/widget/context/ReportsApiConfigContext.d.ts +9 -0
  247. package/lib/esm/widget/context/ReportsApiConfigContext.d.ts.map +1 -0
  248. package/lib/esm/widget/context/ReportsApiConfigContext.js +14 -0
  249. package/lib/esm/widget/context/ReportsApiConfigContext.js.map +1 -0
  250. package/lib/esm/widget/hooks/useValidator.d.ts +8 -0
  251. package/lib/esm/widget/hooks/useValidator.d.ts.map +1 -0
  252. package/lib/esm/widget/hooks/useValidator.js +50 -0
  253. package/lib/esm/widget/hooks/useValidator.js.map +1 -0
  254. package/lib/public/locales/en/ReportsConfigWidget.json +76 -0
  255. package/package.json +124 -0
  256. package/public/locales/en/ReportsConfigWidget.json +76 -0
  257. package/reports-config-widget-react.build.error.log +10 -0
  258. package/reports-config-widget-react.build.log +45 -0
  259. package/src/ReportsConfigWidget.ts +36 -0
  260. package/src/reports-config-widget-react.ts +7 -0
  261. package/src/test/ReportAction.test.tsx +258 -0
  262. package/src/test/ReportMappings.test.tsx +882 -0
  263. package/src/test/Reports.test.tsx +365 -0
  264. package/src/test/WidgetHeader.test.tsx +29 -0
  265. package/src/test/test-utils.tsx +77 -0
  266. package/src/widget/ReportsConfigUiProvider.tsx +67 -0
  267. package/src/widget/components/ActionPanel.scss +12 -0
  268. package/src/widget/components/ActionPanel.tsx +56 -0
  269. package/src/widget/components/AddMappingsModal.scss +18 -0
  270. package/src/widget/components/AddMappingsModal.tsx +175 -0
  271. package/src/widget/components/DeleteModal.scss +18 -0
  272. package/src/widget/components/DeleteModal.tsx +100 -0
  273. package/src/widget/components/Extraction.scss +39 -0
  274. package/src/widget/components/Extraction.tsx +315 -0
  275. package/src/widget/components/HorizontalTile.scss +32 -0
  276. package/src/widget/components/HorizontalTile.tsx +57 -0
  277. package/src/widget/components/LocalizedTablePaginator.tsx +59 -0
  278. package/src/widget/components/ReportAction.scss +16 -0
  279. package/src/widget/components/ReportAction.tsx +146 -0
  280. package/src/widget/components/ReportMappings.scss +46 -0
  281. package/src/widget/components/ReportMappings.tsx +350 -0
  282. package/src/widget/components/Reports.scss +36 -0
  283. package/src/widget/components/Reports.tsx +248 -0
  284. package/src/widget/components/ReportsContainer.scss +15 -0
  285. package/src/widget/components/ReportsContainer.tsx +36 -0
  286. package/src/widget/components/SearchBar.scss +27 -0
  287. package/src/widget/components/SearchBar.tsx +62 -0
  288. package/src/widget/components/SelectIModel.scss +15 -0
  289. package/src/widget/components/SelectIModel.tsx +102 -0
  290. package/src/widget/components/utils.scss +39 -0
  291. package/src/widget/components/utils.tsx +159 -0
  292. package/src/widget/context/ReportsApiConfigContext.tsx +27 -0
  293. package/src/widget/hooks/useValidator.ts +70 -0
  294. 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
+ }