@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,175 @@
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 { Modal, Table, tableFilters } from "@itwin/itwinui-react";
6
+ import React, { useEffect, useMemo, useState } from "react";
7
+ import type { Mapping } from "@itwin/insights-client";
8
+ import { REPORTING_BASE_PATH, ReportingClient } from "@itwin/insights-client";
9
+ import ActionPanel from "./ActionPanel";
10
+ import "./AddMappingsModal.scss";
11
+ import { LocalizedTablePaginator } from "./LocalizedTablePaginator";
12
+ import type { ReportMappingAndMapping } from "./ReportMappings";
13
+ import type { ReportsApiConfig } from "../context/ReportsApiConfigContext";
14
+ import { useReportsApiConfig } from "../context/ReportsApiConfigContext";
15
+ import { SelectIModel } from "./SelectIModel";
16
+ import type { CreateTypeFromInterface } from "./utils";
17
+ import { generateUrl, handleError } from "./utils";
18
+ import { ReportsConfigWidget } from "../../ReportsConfigWidget";
19
+
20
+ export type MappingType = CreateTypeFromInterface<Mapping>;
21
+
22
+ const fetchMappings = async (
23
+ setMappings: React.Dispatch<React.SetStateAction<Mapping[]>>,
24
+ iModelId: string,
25
+ setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,
26
+ apiContext: ReportsApiConfig
27
+ ) => {
28
+ try {
29
+ setIsLoading(true);
30
+ const reportingClientApi = new ReportingClient(
31
+ generateUrl(REPORTING_BASE_PATH, apiContext.baseUrl)
32
+ );
33
+ const accessToken = await apiContext.getAccessToken();
34
+ const mappings = await reportingClientApi.getMappings(
35
+ accessToken,
36
+ iModelId
37
+ );
38
+ setMappings(mappings);
39
+ } catch (error: any) {
40
+ handleError(error.status);
41
+ } finally {
42
+ setIsLoading(false);
43
+ }
44
+ };
45
+
46
+ interface AddMappingsModalProps {
47
+ reportId: string;
48
+ existingMappings: ReportMappingAndMapping[];
49
+ show: boolean;
50
+ returnFn: () => Promise<void>;
51
+ }
52
+
53
+ const AddMappingsModal = ({
54
+ reportId,
55
+ existingMappings,
56
+ show,
57
+ returnFn,
58
+ }: AddMappingsModalProps) => {
59
+ const [isLoading, setIsLoading] = useState<boolean>(true);
60
+ const [selectedMappings, setSelectedMappings] = useState<Mapping[]>([]);
61
+ const [selectedIModelId, setSelectediModelId] = useState<string>("");
62
+ const [mappings, setMappings] = useState<Mapping[]>([]);
63
+ const apiConfig = useReportsApiConfig();
64
+
65
+ useEffect(() => {
66
+ if (selectedIModelId) {
67
+ void fetchMappings(
68
+ setMappings,
69
+ selectedIModelId,
70
+ setIsLoading,
71
+ apiConfig
72
+ );
73
+ }
74
+ }, [apiConfig, selectedIModelId, setIsLoading]);
75
+
76
+ const mappingsColumns = useMemo(
77
+ () => [
78
+ {
79
+ Header: "Table",
80
+ columns: [
81
+ {
82
+ id: "mappingName",
83
+ Header: ReportsConfigWidget.localization.getLocalizedString(
84
+ "ReportsConfigWidget:MappingName"
85
+ ),
86
+ accessor: "mappingName",
87
+ Filter: tableFilters.TextFilter(),
88
+ },
89
+ {
90
+ id: "description",
91
+ Header: ReportsConfigWidget.localization.getLocalizedString(
92
+ "ReportsConfigWidget:Description"
93
+ ),
94
+ accessor: "description",
95
+ Filter: tableFilters.TextFilter(),
96
+ },
97
+ ],
98
+ },
99
+ ],
100
+ []
101
+ );
102
+
103
+ const onSave = async () => {
104
+ try {
105
+ if (!selectedIModelId) return;
106
+ setIsLoading(true);
107
+ const reportingClientApi = new ReportingClient(
108
+ generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl)
109
+ );
110
+ const accessToken = await apiConfig.getAccessToken();
111
+ for (const mapping of selectedMappings) {
112
+ await reportingClientApi.createReportMapping(accessToken, reportId, {
113
+ imodelId: selectedIModelId,
114
+ mappingId: mapping.id ?? "",
115
+ });
116
+ }
117
+
118
+ await returnFn();
119
+ } catch (error: any) {
120
+ handleError(error.status);
121
+ } finally {
122
+ setIsLoading(false);
123
+ }
124
+ };
125
+
126
+ return (
127
+ <Modal
128
+ title={ReportsConfigWidget.localization.getLocalizedString(
129
+ "ReportsConfigWidget:AddMappings"
130
+ )}
131
+ isOpen={show}
132
+ isDismissible={!isLoading}
133
+ onClose={async () => {
134
+ await returnFn();
135
+ }}
136
+ style={{ display: "flex", flexDirection: "column", maxHeight: "77vh" }}
137
+ >
138
+ <div className="add-mappings-container">
139
+ <SelectIModel
140
+ selectedIModelId={selectedIModelId}
141
+ setSelectedIModelId={setSelectediModelId}
142
+ />
143
+ <Table<MappingType>
144
+ data={isLoading ? [] : mappings}
145
+ columns={mappingsColumns}
146
+ className="add-mappings-table"
147
+ emptyTableContent={ReportsConfigWidget.localization.getLocalizedString(
148
+ "ReportsConfigWidget:NoMappingsAvailable"
149
+ )}
150
+ isSortable
151
+ isSelectable
152
+ isLoading={isLoading}
153
+ isRowDisabled={(rowData) =>
154
+ existingMappings.some((v) => v.mappingId === rowData.id)
155
+ }
156
+ onSelect={(selectData: Mapping[] | undefined) => {
157
+ selectData && setSelectedMappings(selectData);
158
+ }}
159
+ paginatorRenderer={LocalizedTablePaginator}
160
+ />
161
+ </div>
162
+ <ActionPanel
163
+ actionLabel={ReportsConfigWidget.localization.getLocalizedString(
164
+ "ReportsConfigWidget:Add"
165
+ )}
166
+ onAction={onSave}
167
+ onCancel={returnFn}
168
+ isSavingDisabled={selectedMappings.length === 0}
169
+ isLoading={isLoading}
170
+ />
171
+ </Modal>
172
+ );
173
+ };
174
+
175
+ export default AddMappingsModal;
@@ -0,0 +1,18 @@
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 "~@itwin/itwinui-css/scss/variables";
6
+
7
+ .delete-modal-body-text {
8
+ display: flex;
9
+ gap: $iui-xs;
10
+ flex-wrap: wrap;
11
+ > strong {
12
+ min-width: 0px;
13
+ }
14
+ }
15
+
16
+ .rcw-loading-delete {
17
+ margin-right: $iui-s;
18
+ }
@@ -0,0 +1,100 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ import {
6
+ Button,
7
+ Leading,
8
+ MiddleTextTruncation,
9
+ Modal,
10
+ ModalButtonBar,
11
+ ModalContent,
12
+ } from "@itwin/itwinui-react";
13
+ import React, { useState } from "react";
14
+ import { ReportsConfigWidget } from "../../ReportsConfigWidget";
15
+ import "./DeleteModal.scss";
16
+ import { handleError, LoadingSpinner } from "./utils";
17
+
18
+ export interface DeleteModalProps {
19
+ entityName: string;
20
+ show: boolean;
21
+ setShow: React.Dispatch<React.SetStateAction<boolean>>;
22
+ onDelete: () => Promise<void>;
23
+ refresh: () => Promise<void>;
24
+ }
25
+
26
+ export const DeleteModal = ({
27
+ entityName,
28
+ show,
29
+ setShow,
30
+ onDelete,
31
+ refresh,
32
+ }: DeleteModalProps) => {
33
+ const [isLoading, setIsLoading] = useState<boolean>(false);
34
+
35
+ const deleteCallback = async () => {
36
+ try {
37
+ setIsLoading(true);
38
+ await onDelete();
39
+ setShow(false);
40
+ await refresh();
41
+ } catch (error: any) {
42
+ handleError(error.status);
43
+ } finally {
44
+ setIsLoading(false);
45
+ }
46
+ };
47
+
48
+ return (
49
+ <Modal
50
+ title={ReportsConfigWidget.localization.getLocalizedString(
51
+ "ReportsConfigWidget:Confirm"
52
+ )}
53
+ isOpen={show}
54
+ isDismissible={!isLoading}
55
+ onClose={() => {
56
+ setShow(false);
57
+ }}
58
+ >
59
+ <ModalContent>
60
+ <div className="delete-modal-body-text">
61
+ <Leading>
62
+ {ReportsConfigWidget.localization.getLocalizedString(
63
+ "ReportsConfigWidget:AreYouSureYouWantToDelete"
64
+ )}
65
+ </Leading>
66
+ <strong>{<MiddleTextTruncation text={`${entityName}?`} />}</strong>
67
+ </div>
68
+ </ModalContent>
69
+ <ModalButtonBar>
70
+ {isLoading && (
71
+ <div className="rcw-loading-delete" data-testid="rcw-loading-delete">
72
+ <LoadingSpinner />
73
+ </div>
74
+ )}
75
+ <Button
76
+ styleType="high-visibility"
77
+ onClick={deleteCallback}
78
+ disabled={isLoading}
79
+ >
80
+ {ReportsConfigWidget.localization.getLocalizedString(
81
+ "ReportsConfigWidget:Delete"
82
+ )}
83
+ </Button>
84
+ <Button
85
+ styleType="default"
86
+ onClick={() => {
87
+ setShow(false);
88
+ }}
89
+ disabled={isLoading}
90
+ >
91
+ {ReportsConfigWidget.localization.getLocalizedString(
92
+ "ReportsConfigWidget:Cancel"
93
+ )}
94
+ </Button>
95
+ </ModalButtonBar>
96
+ </Modal>
97
+ );
98
+ };
99
+
100
+ export default DeleteModal;
@@ -0,0 +1,39 @@
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 "~@itwin/itwinui-css/scss/variables";
6
+
7
+ .extraction-container {
8
+ display: flex;
9
+ justify-content: space-between;
10
+ align-items: center;
11
+ gap: $iui-s;
12
+ .extraction-combo-box {
13
+ display: flex;
14
+ flex-direction: column;
15
+ flex-grow: 1;
16
+ }
17
+ .extraction-status-container {
18
+ display: flex;
19
+ }
20
+ }
21
+
22
+ .extraction-status {
23
+ display: flex;
24
+ align-items: center;
25
+ margin: 0 $iui-s;
26
+ .status-icon {
27
+ width: $iui-icons-default;
28
+ height: $iui-icons-default;
29
+ }
30
+ }
31
+
32
+ @keyframes rcw-fadeOut {
33
+ 0% {
34
+ opacity: 1;
35
+ }
36
+ 100% {
37
+ opacity: 0;
38
+ }
39
+ }
@@ -0,0 +1,315 @@
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 { SelectOption } from "@itwin/itwinui-react";
6
+ import {
7
+ ComboBox,
8
+ Label,
9
+ ProgressRadial,
10
+ StatusMessage,
11
+ } from "@itwin/itwinui-react";
12
+ import * as React from "react";
13
+ import { useEffect, useMemo, useRef, useState } from "react";
14
+ import { REPORTING_BASE_PATH, ReportingClient } from "@itwin/insights-client";
15
+ import { generateUrl, handleError, SkeletonBlock } from "./utils";
16
+ import "./Extraction.scss";
17
+ import {
18
+ SvgStatusError,
19
+ SvgStatusPending,
20
+ SvgStatusPendingHollow,
21
+ SvgStatusSuccess,
22
+ } from "@itwin/itwinui-icons-color-react";
23
+ import { useReportsApiConfig } from "../context/ReportsApiConfigContext";
24
+ import { ReportsConfigWidget } from "../../ReportsConfigWidget";
25
+
26
+ export const REFRESH_DELAY = 2000;
27
+
28
+ export enum ExtractionStates {
29
+ None,
30
+ Starting,
31
+ FetchingUpdate,
32
+ Queued,
33
+ Running,
34
+ Succeeded,
35
+ Failed,
36
+ }
37
+ interface ExtractionStatusProps {
38
+ state: ExtractionStates;
39
+ setExtractionState?: React.Dispatch<React.SetStateAction<ExtractionStates>>;
40
+ children?: React.ReactNode;
41
+ }
42
+
43
+ export const ExtractionStatus = ({
44
+ state,
45
+ children,
46
+ setExtractionState,
47
+ }: ExtractionStatusProps) => {
48
+ const [fadeOut, setFadeOut] = useState<boolean>(false);
49
+
50
+ const onAnimationEnd = () => {
51
+ if (setExtractionState) {
52
+ setExtractionState(ExtractionStates.None);
53
+ setFadeOut(false);
54
+ }
55
+ };
56
+
57
+ useEffect(() => {
58
+ let timer: number;
59
+ switch (state) {
60
+ case ExtractionStates.Succeeded:
61
+ case ExtractionStates.Failed:
62
+ timer = window.setTimeout(() => setFadeOut(true), 5000);
63
+ }
64
+ return () => clearTimeout(timer);
65
+ }, [state, setExtractionState]);
66
+
67
+ switch (state) {
68
+ case ExtractionStates.Starting:
69
+ return (
70
+ <div
71
+ title={ReportsConfigWidget.localization.getLocalizedString(
72
+ "ReportsConfigWidget:Starting"
73
+ )}
74
+ className="extraction-status"
75
+ >
76
+ <div className="status-icon">
77
+ <SvgStatusPendingHollow />
78
+ </div>
79
+ </div>
80
+ );
81
+ case ExtractionStates.FetchingUpdate:
82
+ return (
83
+ <div
84
+ title={ReportsConfigWidget.localization.getLocalizedString(
85
+ "ReportsConfigWidget:Loading"
86
+ )}
87
+ className="extraction-status"
88
+ >
89
+ <ProgressRadial size="x-small" indeterminate />
90
+ </div>
91
+ );
92
+ case ExtractionStates.Queued:
93
+ return (
94
+ <div
95
+ title={ReportsConfigWidget.localization.getLocalizedString(
96
+ "ReportsConfigWidget:Queued"
97
+ )}
98
+ className="extraction-status"
99
+ >
100
+ <div className="status-icon">
101
+ <SvgStatusPending />
102
+ </div>
103
+ </div>
104
+ );
105
+ case ExtractionStates.Running:
106
+ return (
107
+ <div
108
+ title={ReportsConfigWidget.localization.getLocalizedString(
109
+ "ReportsConfigWidget:Running"
110
+ )}
111
+ className="extraction-status"
112
+ >
113
+ <ProgressRadial size="x-small" indeterminate />
114
+ </div>
115
+ );
116
+ case ExtractionStates.Succeeded:
117
+ return (
118
+ <div
119
+ title={ReportsConfigWidget.localization.getLocalizedString(
120
+ "ReportsConfigWidget:Success"
121
+ )}
122
+ className="extraction-status"
123
+ >
124
+ <div
125
+ className={`status-icon`}
126
+ style={{
127
+ animationName: fadeOut ? "rcw-fade-out" : "",
128
+ animationDelay: "5s",
129
+ animationDuration: "1s",
130
+ }}
131
+ onAnimationEnd={onAnimationEnd}
132
+ >
133
+ <SvgStatusSuccess />
134
+ </div>
135
+ </div>
136
+ );
137
+ case ExtractionStates.Failed:
138
+ return (
139
+ <div
140
+ title={ReportsConfigWidget.localization.getLocalizedString(
141
+ "ReportsConfigWidget:Failed"
142
+ )}
143
+ className="extraction-status"
144
+ >
145
+ <div
146
+ className={`status-icon`}
147
+ style={{
148
+ animationName: fadeOut ? "rcw-fade-out" : "",
149
+ animationDelay: "5s",
150
+ animationDuration: "1s",
151
+ }}
152
+ onAnimationEnd={onAnimationEnd}
153
+ >
154
+ <SvgStatusError />
155
+ </div>
156
+ </div>
157
+ );
158
+ default:
159
+ return <>{children}</>;
160
+ }
161
+ };
162
+
163
+ interface ExtractionProps {
164
+ iModels: Map<string, string>;
165
+ setExtractingIModelId: React.Dispatch<React.SetStateAction<string>>;
166
+ extractionState: ExtractionStates;
167
+ setExtractionState: React.Dispatch<React.SetStateAction<ExtractionStates>>;
168
+ isLoading: boolean;
169
+ }
170
+
171
+ export const Extraction = ({
172
+ iModels,
173
+ setExtractingIModelId,
174
+ extractionState,
175
+ setExtractionState,
176
+ isLoading,
177
+ }: ExtractionProps) => {
178
+ const jobId = useRef<string>("");
179
+ const intervalId = useRef<number>();
180
+ const [isRunning, setIsRunning] = useState<boolean>(false);
181
+ const [currentIModelId, setCurrentIModelId] = useState<string>();
182
+ const apiConfig = useReportsApiConfig();
183
+
184
+ const runExtraction = async (iModelId: string) => {
185
+ try {
186
+ setExtractionState(ExtractionStates.Starting);
187
+ setExtractingIModelId(iModelId);
188
+ const reportingClientApi = new ReportingClient(
189
+ generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl)
190
+ );
191
+ const accessToken = await apiConfig.getAccessToken();
192
+ const response = await reportingClientApi.runExtraction(
193
+ accessToken,
194
+ iModelId
195
+ );
196
+ jobId.current = response.run?.id ?? "";
197
+ setIsRunning(true);
198
+ setExtractionState(ExtractionStates.FetchingUpdate);
199
+ } catch (error: any) {
200
+ handleError(error.status);
201
+ setExtractionState(ExtractionStates.Failed);
202
+ setIsRunning(false);
203
+ setCurrentIModelId(undefined);
204
+ }
205
+ };
206
+
207
+ useEffect(() => {
208
+ if (!intervalId.current && isRunning) {
209
+ const newIntervalId = window.setInterval(async () => {
210
+ const reportingClientApi = new ReportingClient(
211
+ generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl)
212
+ );
213
+ const accessToken = await apiConfig.getAccessToken();
214
+ const response = await reportingClientApi.getExtractionStatus(
215
+ accessToken,
216
+ jobId.current
217
+ );
218
+ if (response.status?.state === "Queued") {
219
+ setExtractionState(ExtractionStates.Queued);
220
+ } else if (response.status?.state === "Running") {
221
+ setExtractionState(ExtractionStates.Running);
222
+ } else if (response.status?.state === "Succeeded") {
223
+ setExtractionState(ExtractionStates.Succeeded);
224
+ setIsRunning(false);
225
+ setCurrentIModelId(undefined);
226
+ } else if (response.status?.state === "Failed") {
227
+ setExtractionState(ExtractionStates.Failed);
228
+ setIsRunning(false);
229
+ setCurrentIModelId(undefined);
230
+ }
231
+ }, REFRESH_DELAY);
232
+ intervalId.current = newIntervalId;
233
+ } else if (intervalId && !isRunning) {
234
+ window.clearInterval(intervalId.current);
235
+ intervalId.current = undefined;
236
+ }
237
+ return () => window.clearInterval(intervalId.current);
238
+ }, [apiConfig, isRunning, jobId, setExtractionState]);
239
+
240
+ const iModelOptions = useMemo(() => {
241
+ // TODO Report ComboBox bug. Unique key error happens when the options list becomes reduced.
242
+ const newIModelOptions: SelectOption<string>[] = [];
243
+
244
+ for (const [iModelId, iModelName] of iModels.entries()) {
245
+ newIModelOptions.push({
246
+ label: iModelName,
247
+ value: iModelId,
248
+ key: iModelId,
249
+ disabled: extractionState !== ExtractionStates.None,
250
+ });
251
+ }
252
+ return newIModelOptions;
253
+ }, [iModels, extractionState]);
254
+
255
+ return (
256
+ <div className="extraction-container">
257
+ <div className="extraction-combo-box" data-testid="extraction-combo-box">
258
+ <Label htmlFor="combo-input">
259
+ {ReportsConfigWidget.localization.getLocalizedString(
260
+ "ReportsConfigWidget:UpdateDataset"
261
+ )}
262
+ </Label>
263
+ {isLoading ? (
264
+ <SkeletonBlock />
265
+ ) : (
266
+ <ComboBox
267
+ options={iModelOptions}
268
+ value={currentIModelId}
269
+ onChange={async (value) => {
270
+ setCurrentIModelId(value);
271
+ await runExtraction(value);
272
+ }}
273
+ inputProps={{
274
+ id: "combo-input",
275
+ placeholder: ReportsConfigWidget.localization.getLocalizedString(
276
+ "ReportsConfigWidget:SelectIModel"
277
+ ),
278
+ }}
279
+ message={
280
+ extractionState !== ExtractionStates.None && (
281
+ <StatusMessage>
282
+ <div className="extraction-status-container">
283
+ <ExtractionStatus
284
+ state={extractionState}
285
+ setExtractionState={setExtractionState}
286
+ />
287
+ {(() => {
288
+ switch (extractionState) {
289
+ case ExtractionStates.Succeeded: {
290
+ return ReportsConfigWidget.localization.getLocalizedString(
291
+ "ReportsConfigWidget:Success"
292
+ );
293
+ }
294
+ case ExtractionStates.Failed: {
295
+ return ReportsConfigWidget.localization.getLocalizedString(
296
+ "ReportsConfigWidget:Failed"
297
+ );
298
+ }
299
+ default: {
300
+ return ReportsConfigWidget.localization.getLocalizedString(
301
+ "ReportsConfigWidget:UpdateInProgress"
302
+ );
303
+ }
304
+ }
305
+ })()}
306
+ </div>
307
+ </StatusMessage>
308
+ )
309
+ }
310
+ />
311
+ )}
312
+ </div>
313
+ </div>
314
+ );
315
+ };
@@ -0,0 +1,32 @@
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 "~@itwin/itwinui-css/scss/variables";
6
+
7
+ .rcw-horizontal-tile-container {
8
+ display: flex;
9
+ justify-content: space-between;
10
+ border-radius: 5px;
11
+ background-color: var(--iui-color-background-2);
12
+ height: $iui-baseline * 4;
13
+ padding: 5.5px $iui-s;
14
+ .body {
15
+ display: flex;
16
+ flex-direction: column;
17
+ min-width: 0;
18
+ justify-content: center;
19
+ &-text {
20
+ overflow: hidden;
21
+ white-space: nowrap;
22
+ text-overflow: ellipsis;
23
+ }
24
+ }
25
+ .action-button {
26
+ margin-left: 0;
27
+ align-self: center;
28
+ min-width: 36px;
29
+ margin-right: $iui-xs;
30
+ flex-shrink: 0;
31
+ }
32
+ }