@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,36 @@
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
+ .reports-list-container {
8
+ display: flex;
9
+ flex-direction: column;
10
+ flex-grow: 1;
11
+ padding: $iui-baseline $iui-m;
12
+ min-height: 0;
13
+
14
+ .toolbar {
15
+ display: flex;
16
+ justify-content: space-between;
17
+ gap: $iui-s;
18
+ border-bottom: 1px solid var(--iui-color-background-4);
19
+ padding-bottom: $iui-baseline;
20
+ flex-wrap: wrap;
21
+ }
22
+
23
+ .search-bar-container {
24
+ flex-basis: $iui-3xl;
25
+ flex-shrink: 1;
26
+ flex-grow: 1;
27
+ }
28
+
29
+ .reports-list {
30
+ display: flex;
31
+ flex-direction: column;
32
+ overflow-y: overlay;
33
+ gap: 7.5px;
34
+ margin-top: 7.5px;
35
+ }
36
+ }
@@ -0,0 +1,248 @@
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
+ SvgDelete,
8
+ SvgEdit,
9
+ SvgMore,
10
+ } from "@itwin/itwinui-icons-react";
11
+ import {
12
+ Button,
13
+ DropdownMenu,
14
+ IconButton,
15
+ MenuItem,
16
+ Surface,
17
+ } from "@itwin/itwinui-react";
18
+ import React, { useCallback, useEffect, useMemo, useState } from "react";
19
+ import type { CreateTypeFromInterface } from "./utils";
20
+ import {
21
+ EmptyMessage,
22
+ generateUrl,
23
+ handleError,
24
+ LoadingOverlay,
25
+ WidgetHeader,
26
+ } from "./utils";
27
+ import "./Reports.scss";
28
+ import DeleteModal from "./DeleteModal";
29
+ import type { Report } from "@itwin/insights-client";
30
+ import { REPORTING_BASE_PATH, ReportingClient } from "@itwin/insights-client";
31
+ import ReportAction from "./ReportAction";
32
+ import { ReportMappings } from "./ReportMappings";
33
+ import { HorizontalTile } from "./HorizontalTile";
34
+ import { SearchBar } from "./SearchBar";
35
+ import type { ReportsApiConfig } from "../context/ReportsApiConfigContext";
36
+ import { useReportsApiConfig } from "../context/ReportsApiConfigContext";
37
+ import { ReportsConfigWidget } from "../../ReportsConfigWidget";
38
+ import { useActiveIModelConnection } from "@itwin/appui-react";
39
+
40
+ export type ReportType = CreateTypeFromInterface<Report>;
41
+
42
+ enum ReportsView {
43
+ REPORTS = "reports",
44
+ REPORTSMAPPING = "reportsmapping",
45
+ ADDING = "adding",
46
+ MODIFYING = "modifying",
47
+ }
48
+
49
+ const fetchReports = async (
50
+ setReports: React.Dispatch<React.SetStateAction<Report[]>>,
51
+ iTwinId: string | undefined,
52
+ setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,
53
+ apiContext: ReportsApiConfig
54
+ ) => {
55
+ try {
56
+ if (!iTwinId) return;
57
+ setIsLoading(true);
58
+ const reportingClientApi = new ReportingClient(
59
+ generateUrl(REPORTING_BASE_PATH, apiContext.baseUrl)
60
+ );
61
+ const accessToken = await apiContext.getAccessToken();
62
+ const reports = await reportingClientApi.getReports(accessToken, iTwinId);
63
+ setReports(reports ?? []);
64
+ } catch (error: any) {
65
+ handleError(error.status);
66
+ } finally {
67
+ setIsLoading(false);
68
+ }
69
+ };
70
+
71
+ export const Reports = () => {
72
+ const iTwinId = useActiveIModelConnection()?.iTwinId ?? "";
73
+ const apiConfig = useReportsApiConfig();
74
+ const [showDeleteModal, setShowDeleteModal] = useState<boolean>(false);
75
+ const [reportsView, setReportsView] = useState<ReportsView>(
76
+ ReportsView.REPORTS
77
+ );
78
+ const [selectedReport, setSelectedReport] = useState<Report | undefined>(
79
+ undefined
80
+ );
81
+ const [isLoading, setIsLoading] = useState<boolean>(true);
82
+ const [searchValue, setSearchValue] = useState<string>("");
83
+ const [reports, setReports] = useState<Report[]>([]);
84
+
85
+ useEffect(() => {
86
+ void fetchReports(setReports, iTwinId, setIsLoading, apiConfig);
87
+ }, [apiConfig, iTwinId, setIsLoading]);
88
+
89
+ const refresh = useCallback(async () => {
90
+ setReportsView(ReportsView.REPORTS);
91
+ setSelectedReport(undefined);
92
+ await fetchReports(setReports, iTwinId, setIsLoading, apiConfig);
93
+ }, [apiConfig, iTwinId, setReports]);
94
+
95
+ const addReport = () => {
96
+ setReportsView(ReportsView.ADDING);
97
+ };
98
+
99
+ const filteredReports = useMemo(
100
+ () =>
101
+ reports.filter((x) =>
102
+ [x.displayName, x.description]
103
+ .join(" ")
104
+ .toLowerCase()
105
+ .includes(searchValue.toLowerCase())
106
+ ),
107
+ [reports, searchValue]
108
+ );
109
+
110
+ switch (reportsView) {
111
+ case ReportsView.ADDING:
112
+ return iTwinId ? (
113
+ <ReportAction iTwinId={iTwinId ?? ""} returnFn={refresh} />
114
+ ) : null;
115
+ case ReportsView.MODIFYING:
116
+ return iTwinId ? (
117
+ <ReportAction
118
+ iTwinId={iTwinId}
119
+ report={selectedReport}
120
+ returnFn={refresh}
121
+ />
122
+ ) : null;
123
+ case ReportsView.REPORTSMAPPING:
124
+ return selectedReport ? (
125
+ <ReportMappings report={selectedReport} goBack={refresh} />
126
+ ) : null;
127
+ default:
128
+ return (
129
+ <>
130
+ <WidgetHeader
131
+ title={ReportsConfigWidget.localization.getLocalizedString(
132
+ "ReportsConfigWidget:ITwinReports"
133
+ )}
134
+ />
135
+ <Surface className="reports-list-container">
136
+ <div className="toolbar">
137
+ <Button
138
+ startIcon={<SvgAdd />}
139
+ onClick={() => addReport()}
140
+ styleType="high-visibility"
141
+ >
142
+ {ReportsConfigWidget.localization.getLocalizedString(
143
+ "ReportsConfigWidget:New"
144
+ )}
145
+ </Button>
146
+ <div className="search-bar-container" data-testid="search-bar">
147
+ <SearchBar
148
+ searchValue={searchValue}
149
+ setSearchValue={setSearchValue}
150
+ disabled={isLoading}
151
+ />
152
+ </div>
153
+ </div>
154
+ {isLoading ? (
155
+ <LoadingOverlay />
156
+ ) : reports.length === 0 ? (
157
+ <EmptyMessage>
158
+ <>
159
+ {ReportsConfigWidget.localization.getLocalizedString(
160
+ "ReportsConfigWidget:NoReports"
161
+ )}
162
+ <div>
163
+ <Button onClick={() => addReport()} styleType="cta">
164
+ {ReportsConfigWidget.localization.getLocalizedString(
165
+ "ReportsConfigWidget:CreateOneReportCTA"
166
+ )}
167
+ </Button>
168
+ </div>
169
+ </>
170
+ </EmptyMessage>
171
+ ) : (
172
+ <div className="reports-list">
173
+ {filteredReports.map((report) => (
174
+ <HorizontalTile
175
+ key={report.id}
176
+ title={report.displayName ?? ""}
177
+ subText={report.description ?? ""}
178
+ subtextToolTip={report.description ?? ""}
179
+ titleTooltip={report.displayName}
180
+ onClickTitle={() => {
181
+ setSelectedReport(report);
182
+ setReportsView(ReportsView.REPORTSMAPPING);
183
+ }}
184
+ button={
185
+ <DropdownMenu
186
+ menuItems={(close: () => void) => [
187
+ <MenuItem
188
+ key={0}
189
+ onClick={() => {
190
+ setSelectedReport(report);
191
+ setReportsView(ReportsView.MODIFYING);
192
+ }}
193
+ icon={<SvgEdit />}
194
+ >
195
+ {ReportsConfigWidget.localization.getLocalizedString(
196
+ "ReportsConfigWidget:Modify"
197
+ )}
198
+ </MenuItem>,
199
+ <MenuItem
200
+ key={1}
201
+ onClick={() => {
202
+ setSelectedReport(report);
203
+ setShowDeleteModal(true);
204
+ close();
205
+ }}
206
+ icon={<SvgDelete />}
207
+ >
208
+ {ReportsConfigWidget.localization.getLocalizedString(
209
+ "ReportsConfigWidget:Remove"
210
+ )}
211
+ </MenuItem>,
212
+ ]}
213
+ >
214
+ <IconButton styleType="borderless">
215
+ <SvgMore
216
+ style={{
217
+ width: "16px",
218
+ height: "16px",
219
+ }}
220
+ />
221
+ </IconButton>
222
+ </DropdownMenu>
223
+ }
224
+ />
225
+ ))}
226
+ </div>
227
+ )}
228
+ </Surface>
229
+ <DeleteModal
230
+ entityName={selectedReport?.displayName ?? ""}
231
+ show={showDeleteModal}
232
+ setShow={setShowDeleteModal}
233
+ onDelete={async () => {
234
+ const reportingClientApi = new ReportingClient(
235
+ generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl)
236
+ );
237
+ const accessToken = await apiConfig.getAccessToken();
238
+ await reportingClientApi.deleteReport(
239
+ accessToken,
240
+ selectedReport?.id ?? ""
241
+ );
242
+ }}
243
+ refresh={refresh}
244
+ />
245
+ </>
246
+ );
247
+ }
248
+ };
@@ -0,0 +1,15 @@
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
+ .reports-container {
8
+ display: flex;
9
+ flex-direction: column;
10
+ padding: $iui-baseline $iui-m;
11
+ box-sizing: border-box;
12
+ height: 100%;
13
+ overflow: auto;
14
+ gap: $iui-baseline;
15
+ }
@@ -0,0 +1,36 @@
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 { IModelApp } from "@itwin/core-frontend";
7
+ import * as React from "react";
8
+ import { Reports } from "../components/Reports";
9
+ import { ReportsApiConfigContext } from "../context/ReportsApiConfigContext";
10
+ import "./ReportsContainer.scss";
11
+
12
+ interface ReportsContainerProps {
13
+ getAccessToken?: () => Promise<AccessToken>;
14
+ baseUrl: string;
15
+ }
16
+
17
+ const ReportsContainer = ({
18
+ getAccessToken,
19
+ baseUrl,
20
+ }: ReportsContainerProps) => (
21
+ <ReportsApiConfigContext.Provider
22
+ value={{
23
+ getAccessToken:
24
+ getAccessToken ??
25
+ (async () =>
26
+ (await IModelApp.authorizationClient?.getAccessToken()) ?? ""),
27
+ baseUrl,
28
+ }}
29
+ >
30
+ <div className="reports-container">
31
+ <Reports />
32
+ </div>
33
+ </ReportsApiConfigContext.Provider>
34
+ );
35
+
36
+ export default ReportsContainer;
@@ -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 "~@itwin/itwinui-css/scss/variables";
6
+
7
+ @keyframes rcw-expand {
8
+ 0% {
9
+ opacity: 0;
10
+ width: 20%;
11
+ }
12
+ 100% {
13
+ opacity: 1;
14
+ width: 100%;
15
+ }
16
+ }
17
+
18
+ @keyframes rcw-shrink {
19
+ 100% {
20
+ opacity: 0;
21
+ width: 20%;
22
+ }
23
+ 0% {
24
+ opacity: 1;
25
+ width: 100%;
26
+ }
27
+ }
@@ -0,0 +1,62 @@
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 { SvgCloseSmall, SvgSearch } from "@itwin/itwinui-icons-react";
6
+ import { IconButton, LabeledInput } from "@itwin/itwinui-react";
7
+ import React, { useState } from "react";
8
+ import { ReportsConfigWidget } from "../../ReportsConfigWidget";
9
+ import "./SearchBar.scss";
10
+
11
+ interface SearchBarProps {
12
+ searchValue: string;
13
+ setSearchValue: React.Dispatch<React.SetStateAction<string>>;
14
+ disabled?: boolean;
15
+ }
16
+
17
+ export const SearchBar = ({
18
+ searchValue,
19
+ setSearchValue,
20
+ disabled,
21
+ }: SearchBarProps) => {
22
+ const [searchBarOpen, setSearchBarOpened] = useState<boolean>(false);
23
+ const [searchBarClosing, setSearchBarClosing] = useState<boolean>(false);
24
+
25
+ return searchBarOpen || searchValue ? (
26
+ <div
27
+ style={{
28
+ animation: searchBarClosing ? "rcw-shrink .5s" : "rcw-expand .5s",
29
+ }}
30
+ onAnimationEnd={() => {
31
+ if (searchBarClosing) {
32
+ setSearchBarClosing(false);
33
+ setSearchBarOpened(false);
34
+ setSearchValue("");
35
+ }
36
+ }}
37
+ >
38
+ <LabeledInput
39
+ aria-label="search-textbox"
40
+ placeholder={ReportsConfigWidget.localization.getLocalizedString(
41
+ "ReportsConfigWidget:Search"
42
+ )}
43
+ svgIcon={
44
+ <IconButton
45
+ onClick={() => setSearchBarClosing(true)}
46
+ styleType="borderless"
47
+ >
48
+ <SvgCloseSmall />
49
+ </IconButton>
50
+ }
51
+ iconDisplayStyle="inline"
52
+ value={searchValue}
53
+ onChange={(e) => setSearchValue(e.target.value)}
54
+ disabled={disabled}
55
+ />{" "}
56
+ </div>
57
+ ) : (
58
+ <IconButton styleType="borderless" onClick={() => setSearchBarOpened(true)}>
59
+ <SvgSearch />
60
+ </IconButton>
61
+ );
62
+ };
@@ -0,0 +1,15 @@
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
+ .reports-select-imodel {
8
+ position: relative;
9
+ margin-bottom: $iui-baseline * 2;
10
+ .combobox {
11
+ display: flex;
12
+ gap: $iui-s;
13
+ width: 100%;
14
+ }
15
+ }
@@ -0,0 +1,102 @@
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 { useActiveIModelConnection } from "@itwin/appui-react";
6
+ import { AccessTokenAdapter } from "@itwin/imodels-access-frontend";
7
+ import type {
8
+ GetIModelListParams,
9
+ IModelsClientOptions,
10
+ MinimalIModel,
11
+ } from "@itwin/imodels-client-management";
12
+ import {
13
+ Constants,
14
+ IModelsClient,
15
+ toArray,
16
+ } from "@itwin/imodels-client-management";
17
+ import { ComboBox, Label } from "@itwin/itwinui-react";
18
+ import React, { useEffect, useMemo, useState } from "react";
19
+ import { ReportsConfigWidget } from "../../ReportsConfigWidget";
20
+ import type { ReportsApiConfig } from "../context/ReportsApiConfigContext";
21
+ import { useReportsApiConfig } from "../context/ReportsApiConfigContext";
22
+ import "./SelectIModel.scss";
23
+ import { generateUrl } from "./utils";
24
+
25
+ const fetchIModels = async (
26
+ setiModels: React.Dispatch<React.SetStateAction<MinimalIModel[]>>,
27
+ iTwinId: string,
28
+ apiContext: ReportsApiConfig
29
+ ) => {
30
+ const iModelClientOptions: IModelsClientOptions = {
31
+ api: { baseUrl: generateUrl(Constants.api.baseUrl, apiContext.baseUrl) },
32
+ };
33
+
34
+ const iModelsClient: IModelsClient = new IModelsClient(iModelClientOptions);
35
+ const accessToken = await apiContext.getAccessToken();
36
+ const authorization = AccessTokenAdapter.toAuthorizationCallback(accessToken);
37
+ const getiModelListParams: GetIModelListParams = {
38
+ urlParams: { projectId: iTwinId },
39
+ authorization,
40
+ };
41
+ const iModels = await toArray(
42
+ iModelsClient.iModels.getMinimalList(getiModelListParams)
43
+ );
44
+ setiModels(iModels);
45
+ };
46
+
47
+ interface SelectedIModelProps {
48
+ selectedIModelId: string;
49
+ setSelectedIModelId: React.Dispatch<React.SetStateAction<string>>;
50
+ }
51
+
52
+ export const SelectIModel = ({
53
+ selectedIModelId,
54
+ setSelectedIModelId,
55
+ }: SelectedIModelProps) => {
56
+ const apiConfig = useReportsApiConfig();
57
+ const iModelId = useActiveIModelConnection()?.iModelId ?? "";
58
+ const iTwinId = useActiveIModelConnection()?.iTwinId ?? "";
59
+ const [iModels, setIModels] = useState<MinimalIModel[]>([]);
60
+
61
+ useEffect(() => {
62
+ if (iModelId && iTwinId) {
63
+ void fetchIModels(setIModels, iTwinId, apiConfig);
64
+ }
65
+ }, [apiConfig, setIModels, iModelId, iTwinId]);
66
+
67
+ useEffect(() => {
68
+ if (iModelId && iModels.length > 0) {
69
+ setSelectedIModelId(iModelId);
70
+ }
71
+ }, [iModelId, iModels, setSelectedIModelId]);
72
+
73
+ const iModelOptions = useMemo(() => {
74
+ return iModels.map((iModel) => ({
75
+ label: iModel.displayName,
76
+ value: iModel.id,
77
+ }));
78
+ }, [iModels]);
79
+
80
+ return (
81
+ <div className="reports-select-imodel">
82
+ <Label htmlFor="combo-input">
83
+ {ReportsConfigWidget.localization.getLocalizedString(
84
+ "ReportsConfigWidget:SelectIModel"
85
+ )}
86
+ </Label>
87
+ <div className="combobox">
88
+ <ComboBox<string>
89
+ options={iModelOptions}
90
+ value={selectedIModelId}
91
+ onChange={(value) => {
92
+ setSelectedIModelId(value);
93
+ }}
94
+ inputProps={{
95
+ id: "combo-input",
96
+ }}
97
+ style={{ flexGrow: 1, maxWidth: "395px" }}
98
+ />
99
+ </div>
100
+ </div>
101
+ );
102
+ };
@@ -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
+ @import "~@itwin/itwinui-css/scss/icon/index";
7
+ @import "~@itwin/itwinui-css/scss/button/index";
8
+
9
+ .rcw-widget-header-container {
10
+ display: flex;
11
+ margin-bottom: $iui-baseline;
12
+ align-items: center;
13
+
14
+ .title {
15
+ overflow: hidden;
16
+ white-space: nowrap;
17
+ text-overflow: ellipsis;
18
+ margin-bottom: 3px;
19
+ }
20
+ }
21
+
22
+ .rcw-loading-spinner {
23
+ display: flex;
24
+ align-items: center;
25
+ }
26
+
27
+ .rcw-center-overlay {
28
+ display: flex;
29
+ justify-content: center;
30
+ align-items: center;
31
+ flex-direction: column;
32
+ gap: $iui-baseline;
33
+ height: 100%;
34
+ }
35
+
36
+ .rcw-skeleton-block {
37
+ height: $iui-baseline * 3;
38
+ width: 100%;
39
+ }