@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,57 @@
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 { ReactNode } from "react";
6
+ import React from "react";
7
+ import { Text } from "@itwin/itwinui-react";
8
+ import "./HorizontalTile.scss";
9
+
10
+ interface HorizontalTileProps {
11
+ title: string;
12
+ button: ReactNode;
13
+ subText?: string;
14
+ onClickTitle?: () => void;
15
+ titleTooltip?: string;
16
+ subtextToolTip?: string;
17
+ }
18
+
19
+ export const HorizontalTile = ({
20
+ title,
21
+ subText,
22
+ onClickTitle,
23
+ titleTooltip,
24
+ subtextToolTip,
25
+ button,
26
+ }: HorizontalTileProps) => {
27
+ return (
28
+ <div
29
+ className="rcw-horizontal-tile-container"
30
+ data-testid="horizontal-tile"
31
+ >
32
+ <div className="body">
33
+ <Text
34
+ className={`body-text ${onClickTitle ? "iui-anchor" : ""}`}
35
+ onClick={onClickTitle}
36
+ variant="body"
37
+ title={titleTooltip}
38
+ >
39
+ {title}
40
+ </Text>
41
+ {subText && (
42
+ <Text
43
+ className="body-text"
44
+ isMuted={true}
45
+ title={subtextToolTip}
46
+ variant="small"
47
+ >
48
+ {subText}
49
+ </Text>
50
+ )}
51
+ </div>
52
+ <div className="action-button" data-testid="tile-action-button">
53
+ {button}
54
+ </div>
55
+ </div>
56
+ );
57
+ };
@@ -0,0 +1,59 @@
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 { TablePaginatorRendererProps } from "@itwin/itwinui-react";
6
+ import { TablePaginator } from "@itwin/itwinui-react";
7
+ import React, { useMemo } from "react";
8
+ import { ReportsConfigWidget } from "../../ReportsConfigWidget";
9
+
10
+ export const LocalizedTablePaginator = (props: TablePaginatorRendererProps) => {
11
+ const pageSizeList = useMemo(() => [10, 25, 50], []);
12
+ const paginationLocalization = useMemo(
13
+ () => ({
14
+ pageSizeLabel: (size: number) =>
15
+ ReportsConfigWidget.localization.getLocalizedString(
16
+ "ReportsConfigWidget:Table.SizePerPage",
17
+ { size }
18
+ ),
19
+ rangeLabel: (
20
+ startIndex: number,
21
+ endIndex: number,
22
+ totalRows: number,
23
+ isLoading: boolean
24
+ ) =>
25
+ isLoading
26
+ ? ReportsConfigWidget.localization.getLocalizedString(
27
+ "ReportsConfigWidget:Table.StartIndexEndIndex",
28
+ { startIndex, endIndex }
29
+ )
30
+ : ReportsConfigWidget.localization.getLocalizedString(
31
+ "ReportsConfigWidget:Table.StartIndexEndIndexOf",
32
+ { startIndex, endIndex, totalRows }
33
+ ),
34
+ previousPage: ReportsConfigWidget.localization.getLocalizedString(
35
+ "ReportsConfigWidget:Table.PreviousPage"
36
+ ),
37
+ nextPage: ReportsConfigWidget.localization.getLocalizedString(
38
+ "ReportsConfigWidget:Table.NextPage"
39
+ ),
40
+ goToPageLabel: (page: number) =>
41
+ ReportsConfigWidget.localization.getLocalizedString(
42
+ "ReportsConfigWidget:Table.GoToPage",
43
+ { page }
44
+ ),
45
+ rowsPerPageLabel: ReportsConfigWidget.localization.getLocalizedString(
46
+ "ReportsConfigWidget:Table.RowsPerPage"
47
+ ),
48
+ }),
49
+ []
50
+ );
51
+
52
+ return (
53
+ <TablePaginator
54
+ {...props}
55
+ pageSizeList={pageSizeList}
56
+ localization={paginationLocalization}
57
+ />
58
+ );
59
+ };
@@ -0,0 +1,16 @@
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-details-form-container {
8
+ overflow-x: auto;
9
+ height: 100%;
10
+
11
+ .details-form {
12
+ display: flex;
13
+ flex-direction: column;
14
+ gap: $iui-baseline;
15
+ }
16
+ }
@@ -0,0 +1,146 @@
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 { Fieldset, LabeledInput, Small } from "@itwin/itwinui-react";
6
+ import React, { useState } from "react";
7
+ import ActionPanel from "./ActionPanel";
8
+ import useValidator, { NAME_REQUIREMENTS } from "../hooks/useValidator";
9
+ import {
10
+ generateUrl,
11
+ handleError,
12
+ handleInputChange,
13
+ WidgetHeader,
14
+ } from "./utils";
15
+ import "./ReportAction.scss";
16
+ import type { Report } from "@itwin/insights-client";
17
+ import { REPORTING_BASE_PATH, ReportingClient } from "@itwin/insights-client";
18
+ import { useReportsApiConfig } from "../context/ReportsApiConfigContext";
19
+ import { ReportsConfigWidget } from "../../ReportsConfigWidget";
20
+
21
+ interface ReportActionProps {
22
+ iTwinId: string;
23
+ report?: Report;
24
+ returnFn: () => Promise<void>;
25
+ }
26
+
27
+ const ReportAction = ({ iTwinId, report, returnFn }: ReportActionProps) => {
28
+ const apiConfig = useReportsApiConfig();
29
+ const [values, setValues] = useState({
30
+ name: report?.displayName ?? "",
31
+ description: report?.description ?? "",
32
+ });
33
+ const [validator, showValidationMessage] = useValidator();
34
+ const [isLoading, setIsLoading] = useState<boolean>(false);
35
+
36
+ const onSave = async () => {
37
+ try {
38
+ if (!validator.allValid()) {
39
+ showValidationMessage(true);
40
+ return;
41
+ }
42
+ setIsLoading(true);
43
+ const reportingClientApi = new ReportingClient(
44
+ generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl)
45
+ );
46
+ const accessToken = await apiConfig.getAccessToken();
47
+ report
48
+ ? await reportingClientApi.updateReport(accessToken, report.id ?? "", {
49
+ displayName: values.name,
50
+ description: values.description,
51
+ })
52
+ : await reportingClientApi.createReport(accessToken, {
53
+ displayName: values.name,
54
+ description: values.description,
55
+ projectId: iTwinId,
56
+ });
57
+ await returnFn();
58
+ } catch (error: any) {
59
+ handleError(error.status);
60
+ setIsLoading(false);
61
+ } finally {
62
+ setIsLoading(false);
63
+ }
64
+ };
65
+
66
+ return (
67
+ <>
68
+ <WidgetHeader
69
+ title={
70
+ report
71
+ ? ReportsConfigWidget.localization.getLocalizedString(
72
+ "ReportsConfigWidget:ModifyReport"
73
+ )
74
+ : ReportsConfigWidget.localization.getLocalizedString(
75
+ "ReportsConfigWidget:AddReport"
76
+ )
77
+ }
78
+ returnFn={returnFn}
79
+ />
80
+ <div className="rcw-details-form-container">
81
+ <Fieldset
82
+ legend={ReportsConfigWidget.localization.getLocalizedString(
83
+ "ReportsConfigWidget:ReportDetails"
84
+ )}
85
+ className="details-form"
86
+ >
87
+ <Small className="field-legend">
88
+ {ReportsConfigWidget.localization.getLocalizedString(
89
+ "ReportsConfigWidget:MandatoryFields"
90
+ )}
91
+ </Small>
92
+ <LabeledInput
93
+ id="name"
94
+ name="name"
95
+ label={ReportsConfigWidget.localization.getLocalizedString(
96
+ "ReportsConfigWidget:Name"
97
+ )}
98
+ value={values.name}
99
+ required
100
+ disabled={isLoading}
101
+ onChange={(event) => {
102
+ handleInputChange(event, values, setValues);
103
+ validator.showMessageFor("name");
104
+ }}
105
+ message={validator.message("name", values.name, NAME_REQUIREMENTS)}
106
+ status={
107
+ validator.message("name", values.name, NAME_REQUIREMENTS)
108
+ ? "negative"
109
+ : undefined
110
+ }
111
+ onBlur={() => {
112
+ validator.showMessageFor("name");
113
+ }}
114
+ onBlurCapture={(event) => {
115
+ handleInputChange(event, values, setValues);
116
+ validator.showMessageFor("name");
117
+ }}
118
+ />
119
+ <LabeledInput
120
+ id="description"
121
+ name="description"
122
+ label={ReportsConfigWidget.localization.getLocalizedString(
123
+ "ReportsConfigWidget:Description"
124
+ )}
125
+ value={values.description}
126
+ onChange={(event) => {
127
+ handleInputChange(event, values, setValues);
128
+ }}
129
+ disabled={isLoading}
130
+ />
131
+ </Fieldset>
132
+ </div>
133
+ <ActionPanel
134
+ actionLabel={ReportsConfigWidget.localization.getLocalizedString(
135
+ "ReportsConfigWidget:Add"
136
+ )}
137
+ onAction={onSave}
138
+ onCancel={returnFn}
139
+ isSavingDisabled={!values.name}
140
+ isLoading={isLoading}
141
+ />
142
+ </>
143
+ );
144
+ };
145
+
146
+ export default ReportAction;
@@ -0,0 +1,46 @@
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
+ .report-mapping-misc {
8
+ display: flex;
9
+ flex-direction: column;
10
+ gap: $iui-baseline;
11
+ }
12
+
13
+ .report-mappings-container {
14
+ display: flex;
15
+ flex-direction: column;
16
+ flex-grow: 1;
17
+ padding: $iui-baseline $iui-m;
18
+ min-height: 0;
19
+
20
+ .odata-url-input {
21
+ margin-bottom: $iui-baseline * 2;
22
+ }
23
+
24
+ .toolbar {
25
+ display: flex;
26
+ justify-content: space-between;
27
+ gap: $iui-s;
28
+ border-bottom: 1px solid var(--iui-color-background-4);
29
+ padding-bottom: $iui-baseline;
30
+ flex-wrap: wrap;
31
+ }
32
+
33
+ .mapping-list {
34
+ display: flex;
35
+ flex-direction: column;
36
+ overflow-y: overlay;
37
+ gap: 7.5px;
38
+ margin-top: 7.5px;
39
+ }
40
+
41
+ .search-bar-container {
42
+ flex-basis: $iui-3xl;
43
+ flex-shrink: 1;
44
+ flex-grow: 1;
45
+ }
46
+ }
@@ -0,0 +1,350 @@
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
+ SvgAdd,
7
+ SvgCopy,
8
+ SvgDelete,
9
+ SvgMore,
10
+ } from "@itwin/itwinui-icons-react";
11
+ import {
12
+ Button,
13
+ DropdownMenu,
14
+ IconButton,
15
+ LabeledInput,
16
+ MenuItem,
17
+ Surface,
18
+ Text,
19
+ toaster,
20
+ } from "@itwin/itwinui-react";
21
+ import React, { useCallback, useEffect, useMemo, useState } from "react";
22
+ import type { CreateTypeFromInterface } from "./utils";
23
+ import {
24
+ EmptyMessage,
25
+ generateUrl,
26
+ handleError,
27
+ LoadingOverlay,
28
+ WidgetHeader,
29
+ } from "./utils";
30
+ import "./ReportMappings.scss";
31
+ import DeleteModal from "./DeleteModal";
32
+ import type { Report, ReportMapping } from "@itwin/insights-client";
33
+ import { REPORTING_BASE_PATH, ReportingClient } from "@itwin/insights-client";
34
+ import AddMappingsModal from "./AddMappingsModal";
35
+ import type {
36
+ GetSingleIModelParams,
37
+ IModelsClientOptions,
38
+ } from "@itwin/imodels-client-management";
39
+ import { Constants, IModelsClient } from "@itwin/imodels-client-management";
40
+ import { AccessTokenAdapter } from "@itwin/imodels-access-frontend";
41
+ import { HorizontalTile } from "./HorizontalTile";
42
+ import { Extraction, ExtractionStates, ExtractionStatus } from "./Extraction";
43
+ import { SearchBar } from "./SearchBar";
44
+ import type { ReportsApiConfig } from "../context/ReportsApiConfigContext";
45
+ import { useReportsApiConfig } from "../context/ReportsApiConfigContext";
46
+ import { ReportsConfigWidget } from "../../ReportsConfigWidget";
47
+
48
+ export type ReportMappingType = CreateTypeFromInterface<ReportMapping>;
49
+
50
+ export type ReportMappingAndMapping = ReportMappingType & {
51
+ mappingName: string;
52
+ mappingDescription: string;
53
+ iModelName: string;
54
+ };
55
+
56
+ enum ReportMappingsView {
57
+ REPORTMAPPINGS = "reportmappings",
58
+ ADDING = "adding",
59
+ }
60
+
61
+ const fetchReportMappings = async (
62
+ setReportMappings: React.Dispatch<
63
+ React.SetStateAction<ReportMappingAndMapping[]>
64
+ >,
65
+ reportId: string,
66
+ setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,
67
+ apiContext: ReportsApiConfig
68
+ ) => {
69
+ try {
70
+ setIsLoading(true);
71
+ const reportingClientApi = new ReportingClient(
72
+ generateUrl(REPORTING_BASE_PATH, apiContext.baseUrl)
73
+ );
74
+ const accessToken = await apiContext.getAccessToken();
75
+ const reportMappings = await reportingClientApi.getReportMappings(
76
+ accessToken,
77
+ reportId
78
+ );
79
+ const iModelClientOptions: IModelsClientOptions = {
80
+ api: { baseUrl: generateUrl(Constants.api.baseUrl, apiContext.baseUrl) },
81
+ };
82
+
83
+ const iModelsClient: IModelsClient = new IModelsClient(iModelClientOptions);
84
+ const authorization =
85
+ AccessTokenAdapter.toAuthorizationCallback(accessToken);
86
+ const iModelNames = new Map<string, string>();
87
+ const reportMappingsAndMapping = await Promise.all(
88
+ reportMappings?.map(async (reportMapping) => {
89
+ const iModelId = reportMapping.imodelId ?? "";
90
+ let iModelName = "";
91
+ const mapping = await reportingClientApi.getMapping(
92
+ accessToken,
93
+ reportMapping.mappingId ?? "",
94
+ iModelId
95
+ );
96
+ if (iModelNames.has(iModelId)) {
97
+ iModelName = iModelNames.get(iModelId) ?? "";
98
+ } else {
99
+ const getSingleParams: GetSingleIModelParams = {
100
+ authorization,
101
+ iModelId,
102
+ };
103
+ const iModel = await iModelsClient.iModels.getSingle(getSingleParams);
104
+ iModelName = iModel.displayName;
105
+ iModelNames.set(iModelId, iModelName);
106
+ }
107
+ const reportMappingAndMapping: ReportMappingAndMapping = {
108
+ ...reportMapping,
109
+ iModelName,
110
+ mappingName: mapping.mapping?.mappingName ?? "",
111
+ mappingDescription: mapping.mapping?.description ?? "",
112
+ };
113
+ return reportMappingAndMapping;
114
+ }) ?? []
115
+ );
116
+
117
+ setReportMappings(reportMappingsAndMapping);
118
+ } catch (error: any) {
119
+ handleError(error.status);
120
+ } finally {
121
+ setIsLoading(false);
122
+ }
123
+ };
124
+
125
+ interface ReportMappingsProps {
126
+ report: Report;
127
+ goBack: () => Promise<void>;
128
+ }
129
+
130
+ export const ReportMappings = ({ report, goBack }: ReportMappingsProps) => {
131
+ const apiConfig = useReportsApiConfig();
132
+ const [reportMappingsView, setReportMappingsView] =
133
+ useState<ReportMappingsView>(ReportMappingsView.REPORTMAPPINGS);
134
+ const [selectedReportMapping, setSelectedReportMapping] = useState<
135
+ ReportMappingAndMapping | undefined
136
+ >(undefined);
137
+ const [showDeleteModal, setShowDeleteModal] = useState<boolean>(false);
138
+ const [isLoading, setIsLoading] = useState<boolean>(true);
139
+
140
+ const [extractionState, setExtractionState] = useState<ExtractionStates>(
141
+ ExtractionStates.None
142
+ );
143
+ const [runningIModelId, setRunningIModelId] = useState<string>("");
144
+ const [searchValue, setSearchValue] = useState<string>("");
145
+ const [reportMappings, setReportMappings] = useState<
146
+ ReportMappingAndMapping[]
147
+ >([]);
148
+
149
+ useEffect(() => {
150
+ void fetchReportMappings(
151
+ setReportMappings,
152
+ report.id ?? "",
153
+ setIsLoading,
154
+ apiConfig
155
+ );
156
+ }, [apiConfig, report.id, setIsLoading]);
157
+
158
+ const refresh = useCallback(async () => {
159
+ setReportMappingsView(ReportMappingsView.REPORTMAPPINGS);
160
+ await fetchReportMappings(
161
+ setReportMappings,
162
+ report.id ?? "",
163
+ setIsLoading,
164
+ apiConfig
165
+ );
166
+ }, [apiConfig, report.id, setReportMappings]);
167
+
168
+ const addMapping = () => {
169
+ setReportMappingsView(ReportMappingsView.ADDING);
170
+ };
171
+
172
+ const uniqueIModels = useMemo(
173
+ () =>
174
+ new Map(
175
+ reportMappings.map((mapping) => [
176
+ mapping.imodelId ?? "",
177
+ mapping.iModelName,
178
+ ])
179
+ ),
180
+ [reportMappings]
181
+ );
182
+
183
+ const odataFeedUrl = `${generateUrl(
184
+ REPORTING_BASE_PATH,
185
+ apiConfig.baseUrl
186
+ )}/odata/${report.id}`;
187
+
188
+ const filteredReportMappings = useMemo(
189
+ () =>
190
+ reportMappings.filter((x) =>
191
+ [x.iModelName, x.mappingName, x.mappingDescription]
192
+ .join(" ")
193
+ .toLowerCase()
194
+ .includes(searchValue.toLowerCase())
195
+ ),
196
+ [reportMappings, searchValue]
197
+ );
198
+
199
+ return (
200
+ <>
201
+ <WidgetHeader title={report.displayName ?? ""} returnFn={goBack} />
202
+ <div className="report-mapping-misc">
203
+ <LabeledInput
204
+ label={ReportsConfigWidget.localization.getLocalizedString(
205
+ "ReportsConfigWidget:ODataFeedURL"
206
+ )}
207
+ className="odata-url-input"
208
+ readOnly={true}
209
+ value={odataFeedUrl}
210
+ svgIcon={
211
+ <IconButton
212
+ title={ReportsConfigWidget.localization.getLocalizedString(
213
+ "ReportsConfigWidget:Copy"
214
+ )}
215
+ styleType="borderless"
216
+ onClick={async (_) => {
217
+ await navigator.clipboard.writeText(odataFeedUrl);
218
+ toaster.positive(
219
+ ReportsConfigWidget.localization.getLocalizedString(
220
+ "ReportsConfigWidget:CopiedToClipboard"
221
+ )
222
+ );
223
+ }}
224
+ >
225
+ <SvgCopy />
226
+ </IconButton>
227
+ }
228
+ iconDisplayStyle="inline"
229
+ />
230
+ <Extraction
231
+ iModels={uniqueIModels}
232
+ extractionState={extractionState}
233
+ setExtractionState={setExtractionState}
234
+ setExtractingIModelId={setRunningIModelId}
235
+ isLoading={isLoading}
236
+ />
237
+ </div>
238
+ <Surface className="report-mappings-container">
239
+ <div className="toolbar">
240
+ <Button
241
+ startIcon={<SvgAdd />}
242
+ onClick={() => addMapping()}
243
+ styleType="high-visibility"
244
+ >
245
+ {ReportsConfigWidget.localization.getLocalizedString(
246
+ "ReportsConfigWidget:AddMapping"
247
+ )}
248
+ </Button>
249
+ <div className="search-bar-container" data-testid="search-bar">
250
+ <SearchBar
251
+ searchValue={searchValue}
252
+ setSearchValue={setSearchValue}
253
+ disabled={isLoading}
254
+ />
255
+ </div>
256
+ </div>
257
+ {isLoading ? (
258
+ <LoadingOverlay />
259
+ ) : reportMappings.length === 0 ? (
260
+ <EmptyMessage>
261
+ <>
262
+ <Text>
263
+ {ReportsConfigWidget.localization.getLocalizedString(
264
+ "ReportsConfigWidget:NoReportMappings"
265
+ )}
266
+ </Text>
267
+ <div>
268
+ <Button onClick={() => addMapping()} styleType="cta">
269
+ {ReportsConfigWidget.localization.getLocalizedString(
270
+ "ReportsConfigWidget:LetsAddSomeMappingsCTA"
271
+ )}
272
+ </Button>
273
+ </div>
274
+ </>
275
+ </EmptyMessage>
276
+ ) : (
277
+ <div className="mapping-list">
278
+ {filteredReportMappings.map((mapping) => (
279
+ <HorizontalTile
280
+ key={mapping.mappingId}
281
+ title={mapping.mappingName}
282
+ subText={mapping.iModelName}
283
+ titleTooltip={mapping.mappingDescription}
284
+ button={
285
+ <ExtractionStatus
286
+ state={
287
+ mapping.imodelId === runningIModelId
288
+ ? extractionState
289
+ : ExtractionStates.None
290
+ }
291
+ >
292
+ <DropdownMenu
293
+ menuItems={(close: () => void) => [
294
+ <MenuItem
295
+ key={0}
296
+ onClick={() => {
297
+ setSelectedReportMapping(mapping);
298
+ setShowDeleteModal(true);
299
+ close();
300
+ }}
301
+ icon={<SvgDelete />}
302
+ >
303
+ {ReportsConfigWidget.localization.getLocalizedString(
304
+ "ReportsConfigWidget:Remove"
305
+ )}
306
+ </MenuItem>,
307
+ ]}
308
+ >
309
+ <IconButton styleType="borderless">
310
+ <SvgMore
311
+ style={{
312
+ width: "16px",
313
+ height: "16px",
314
+ }}
315
+ />
316
+ </IconButton>
317
+ </DropdownMenu>
318
+ </ExtractionStatus>
319
+ }
320
+ />
321
+ ))}
322
+ </div>
323
+ )}
324
+ </Surface>
325
+ <AddMappingsModal
326
+ show={reportMappingsView === ReportMappingsView.ADDING}
327
+ reportId={report.id ?? ""}
328
+ existingMappings={reportMappings}
329
+ returnFn={refresh}
330
+ />
331
+ <DeleteModal
332
+ entityName={selectedReportMapping?.mappingName ?? ""}
333
+ show={showDeleteModal}
334
+ setShow={setShowDeleteModal}
335
+ onDelete={async () => {
336
+ const reportingClientApi = new ReportingClient(
337
+ generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl)
338
+ );
339
+ const accessToken = await apiConfig.getAccessToken();
340
+ await reportingClientApi.deleteReportMapping(
341
+ accessToken,
342
+ report.id ?? "",
343
+ selectedReportMapping?.mappingId ?? ""
344
+ );
345
+ }}
346
+ refresh={refresh}
347
+ />
348
+ </>
349
+ );
350
+ };