@itwin/reports-config-widget-react 0.0.6 → 0.0.7

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 (77) hide show
  1. package/.rush/temp/package-deps_rebuild.json +12 -12
  2. package/.rush/temp/shrinkwrap-deps.json +4 -2
  3. package/CHANGELOG.json +12 -0
  4. package/CHANGELOG.md +8 -1
  5. package/coverage/clover.xml +103 -102
  6. package/coverage/coverage-final.json +12 -12
  7. package/coverage/lcov-report/index.html +19 -19
  8. package/coverage/lcov-report/src/ReportsConfigWidget.ts.html +2 -2
  9. package/coverage/lcov-report/src/index.html +1 -1
  10. package/coverage/lcov-report/src/test/index.html +1 -1
  11. package/coverage/lcov-report/src/test/test-utils.tsx.html +2 -2
  12. package/coverage/lcov-report/src/widget/ReportsConfigUiProvider.tsx.html +1 -1
  13. package/coverage/lcov-report/src/widget/components/ActionPanel.tsx.html +1 -1
  14. package/coverage/lcov-report/src/widget/components/AddMappingsModal.tsx.html +9 -9
  15. package/coverage/lcov-report/src/widget/components/DeleteModal.tsx.html +4 -4
  16. package/coverage/lcov-report/src/widget/components/Extraction.tsx.html +13 -13
  17. package/coverage/lcov-report/src/widget/components/HorizontalTile.tsx.html +2 -2
  18. package/coverage/lcov-report/src/widget/components/LocalizedTablePaginator.tsx.html +1 -1
  19. package/coverage/lcov-report/src/widget/components/ReportAction.tsx.html +5 -5
  20. package/coverage/lcov-report/src/widget/components/ReportMappings.tsx.html +35 -26
  21. package/coverage/lcov-report/src/widget/components/Reports.tsx.html +34 -34
  22. package/coverage/lcov-report/src/widget/components/ReportsContainer.tsx.html +1 -1
  23. package/coverage/lcov-report/src/widget/components/SearchBar.tsx.html +4 -4
  24. package/coverage/lcov-report/src/widget/components/SelectIModel.tsx.html +1 -1
  25. package/coverage/lcov-report/src/widget/components/index.html +38 -38
  26. package/coverage/lcov-report/src/widget/components/utils.tsx.html +30 -30
  27. package/coverage/lcov-report/src/widget/context/ReportsApiConfigContext.tsx.html +4 -4
  28. package/coverage/lcov-report/src/widget/context/index.html +1 -1
  29. package/coverage/lcov-report/src/widget/hooks/index.html +1 -1
  30. package/coverage/lcov-report/src/widget/hooks/useValidator.ts.html +1 -1
  31. package/coverage/lcov-report/src/widget/index.html +1 -1
  32. package/coverage/lcov.info +238 -317
  33. package/lib/cjs/test/ReportMappings.test.js +42 -31
  34. package/lib/cjs/test/ReportMappings.test.js.map +1 -1
  35. package/lib/cjs/test/Reports.test.js +12 -7
  36. package/lib/cjs/test/Reports.test.js.map +1 -1
  37. package/lib/cjs/test/test-utils.js.map +1 -1
  38. package/lib/cjs/tsconfig.tsbuildinfo +1 -1
  39. package/lib/cjs/widget/components/AddMappingsModal.js +5 -6
  40. package/lib/cjs/widget/components/AddMappingsModal.js.map +1 -1
  41. package/lib/cjs/widget/components/Extraction.js +9 -11
  42. package/lib/cjs/widget/components/Extraction.js.map +1 -1
  43. package/lib/cjs/widget/components/ReportAction.js +3 -3
  44. package/lib/cjs/widget/components/ReportAction.js.map +1 -1
  45. package/lib/cjs/widget/components/ReportMappings.d.ts.map +1 -1
  46. package/lib/cjs/widget/components/ReportMappings.js +23 -27
  47. package/lib/cjs/widget/components/ReportMappings.js.map +1 -1
  48. package/lib/cjs/widget/components/Reports.js +6 -6
  49. package/lib/cjs/widget/components/Reports.js.map +1 -1
  50. package/lib/esm/test/ReportMappings.test.js +42 -31
  51. package/lib/esm/test/ReportMappings.test.js.map +1 -1
  52. package/lib/esm/test/Reports.test.js +12 -7
  53. package/lib/esm/test/Reports.test.js.map +1 -1
  54. package/lib/esm/test/test-utils.js.map +1 -1
  55. package/lib/esm/tsconfig.tsbuildinfo +1 -1
  56. package/lib/esm/widget/components/AddMappingsModal.js +6 -7
  57. package/lib/esm/widget/components/AddMappingsModal.js.map +1 -1
  58. package/lib/esm/widget/components/Extraction.js +10 -12
  59. package/lib/esm/widget/components/Extraction.js.map +1 -1
  60. package/lib/esm/widget/components/ReportAction.js +4 -4
  61. package/lib/esm/widget/components/ReportAction.js.map +1 -1
  62. package/lib/esm/widget/components/ReportMappings.d.ts.map +1 -1
  63. package/lib/esm/widget/components/ReportMappings.js +24 -28
  64. package/lib/esm/widget/components/ReportMappings.js.map +1 -1
  65. package/lib/esm/widget/components/Reports.js +7 -7
  66. package/lib/esm/widget/components/Reports.js.map +1 -1
  67. package/package.json +2 -2
  68. package/reports-config-widget-react.build.error.log +3 -3
  69. package/reports-config-widget-react.build.log +11 -11
  70. package/src/test/ReportMappings.test.tsx +44 -24
  71. package/src/test/Reports.test.tsx +18 -13
  72. package/src/test/test-utils.tsx +1 -1
  73. package/src/widget/components/AddMappingsModal.tsx +6 -6
  74. package/src/widget/components/Extraction.tsx +10 -10
  75. package/src/widget/components/ReportAction.tsx +4 -4
  76. package/src/widget/components/ReportMappings.tsx +21 -18
  77. package/src/widget/components/Reports.tsx +6 -6
@@ -30,7 +30,7 @@ import {
30
30
  import "./ReportMappings.scss";
31
31
  import DeleteModal from "./DeleteModal";
32
32
  import type { Report, ReportMapping } from "@itwin/insights-client";
33
- import { REPORTING_BASE_PATH, ReportingClient } from "@itwin/insights-client";
33
+ import { MappingsClient, REPORTING_BASE_PATH, ReportsClient } from "@itwin/insights-client";
34
34
  import AddMappingsModal from "./AddMappingsModal";
35
35
  import type {
36
36
  GetSingleIModelParams,
@@ -68,11 +68,14 @@ const fetchReportMappings = async (
68
68
  ) => {
69
69
  try {
70
70
  setIsLoading(true);
71
- const reportingClientApi = new ReportingClient(
71
+ const reportsClientApi = new ReportsClient(
72
+ generateUrl(REPORTING_BASE_PATH, apiContext.baseUrl)
73
+ );
74
+ const mappingsClientApi = new MappingsClient(
72
75
  generateUrl(REPORTING_BASE_PATH, apiContext.baseUrl)
73
76
  );
74
77
  const accessToken = await apiContext.getAccessToken();
75
- const reportMappings = await reportingClientApi.getReportMappings(
78
+ const reportMappings = await reportsClientApi.getReportMappings(
76
79
  accessToken,
77
80
  reportId
78
81
  );
@@ -85,13 +88,13 @@ const fetchReportMappings = async (
85
88
  AccessTokenAdapter.toAuthorizationCallback(accessToken);
86
89
  const iModelNames = new Map<string, string>();
87
90
  const reportMappingsAndMapping = await Promise.all(
88
- reportMappings?.map(async (reportMapping) => {
89
- const iModelId = reportMapping.imodelId ?? "";
91
+ reportMappings.map(async (reportMapping) => {
92
+ const iModelId = reportMapping.imodelId;
90
93
  let iModelName = "";
91
- const mapping = await reportingClientApi.getMapping(
94
+ const mapping = await mappingsClientApi.getMapping(
92
95
  accessToken,
93
- reportMapping.mappingId ?? "",
94
- iModelId
96
+ iModelId,
97
+ reportMapping.mappingId
95
98
  );
96
99
  if (iModelNames.has(iModelId)) {
97
100
  iModelName = iModelNames.get(iModelId) ?? "";
@@ -107,8 +110,8 @@ const fetchReportMappings = async (
107
110
  const reportMappingAndMapping: ReportMappingAndMapping = {
108
111
  ...reportMapping,
109
112
  iModelName,
110
- mappingName: mapping.mapping?.mappingName ?? "",
111
- mappingDescription: mapping.mapping?.description ?? "",
113
+ mappingName: mapping.mappingName,
114
+ mappingDescription: mapping.description ?? "",
112
115
  };
113
116
  return reportMappingAndMapping;
114
117
  }) ?? []
@@ -149,7 +152,7 @@ export const ReportMappings = ({ report, goBack }: ReportMappingsProps) => {
149
152
  useEffect(() => {
150
153
  void fetchReportMappings(
151
154
  setReportMappings,
152
- report.id ?? "",
155
+ report.id,
153
156
  setIsLoading,
154
157
  apiConfig
155
158
  );
@@ -159,7 +162,7 @@ export const ReportMappings = ({ report, goBack }: ReportMappingsProps) => {
159
162
  setReportMappingsView(ReportMappingsView.REPORTMAPPINGS);
160
163
  await fetchReportMappings(
161
164
  setReportMappings,
162
- report.id ?? "",
165
+ report.id,
163
166
  setIsLoading,
164
167
  apiConfig
165
168
  );
@@ -173,7 +176,7 @@ export const ReportMappings = ({ report, goBack }: ReportMappingsProps) => {
173
176
  () =>
174
177
  new Map(
175
178
  reportMappings.map((mapping) => [
176
- mapping.imodelId ?? "",
179
+ mapping.imodelId,
177
180
  mapping.iModelName,
178
181
  ])
179
182
  ),
@@ -198,7 +201,7 @@ export const ReportMappings = ({ report, goBack }: ReportMappingsProps) => {
198
201
 
199
202
  return (
200
203
  <>
201
- <WidgetHeader title={report.displayName ?? ""} returnFn={goBack} />
204
+ <WidgetHeader title={report.displayName} returnFn={goBack} />
202
205
  <div className="report-mapping-misc">
203
206
  <LabeledInput
204
207
  label={ReportsConfigWidget.localization.getLocalizedString(
@@ -324,7 +327,7 @@ export const ReportMappings = ({ report, goBack }: ReportMappingsProps) => {
324
327
  </Surface>
325
328
  <AddMappingsModal
326
329
  show={reportMappingsView === ReportMappingsView.ADDING}
327
- reportId={report.id ?? ""}
330
+ reportId={report.id}
328
331
  existingMappings={reportMappings}
329
332
  returnFn={refresh}
330
333
  />
@@ -333,13 +336,13 @@ export const ReportMappings = ({ report, goBack }: ReportMappingsProps) => {
333
336
  show={showDeleteModal}
334
337
  setShow={setShowDeleteModal}
335
338
  onDelete={async () => {
336
- const reportingClientApi = new ReportingClient(
339
+ const reportsClientApi = new ReportsClient(
337
340
  generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl)
338
341
  );
339
342
  const accessToken = await apiConfig.getAccessToken();
340
- await reportingClientApi.deleteReportMapping(
343
+ await reportsClientApi.deleteReportMapping(
341
344
  accessToken,
342
- report.id ?? "",
345
+ report.id,
343
346
  selectedReportMapping?.mappingId ?? ""
344
347
  );
345
348
  }}
@@ -27,7 +27,7 @@ import {
27
27
  import "./Reports.scss";
28
28
  import DeleteModal from "./DeleteModal";
29
29
  import type { Report } from "@itwin/insights-client";
30
- import { REPORTING_BASE_PATH, ReportingClient } from "@itwin/insights-client";
30
+ import { REPORTING_BASE_PATH, ReportsClient } from "@itwin/insights-client";
31
31
  import ReportAction from "./ReportAction";
32
32
  import { ReportMappings } from "./ReportMappings";
33
33
  import { HorizontalTile } from "./HorizontalTile";
@@ -55,11 +55,11 @@ const fetchReports = async (
55
55
  try {
56
56
  if (!iTwinId) return;
57
57
  setIsLoading(true);
58
- const reportingClientApi = new ReportingClient(
58
+ const reportsClientApi = new ReportsClient(
59
59
  generateUrl(REPORTING_BASE_PATH, apiContext.baseUrl)
60
60
  );
61
61
  const accessToken = await apiContext.getAccessToken();
62
- const reports = await reportingClientApi.getReports(accessToken, iTwinId);
62
+ const reports = await reportsClientApi.getReports(accessToken, iTwinId);
63
63
  setReports(reports ?? []);
64
64
  } catch (error: any) {
65
65
  handleError(error.status);
@@ -173,7 +173,7 @@ export const Reports = () => {
173
173
  {filteredReports.map((report) => (
174
174
  <HorizontalTile
175
175
  key={report.id}
176
- title={report.displayName ?? ""}
176
+ title={report.displayName}
177
177
  subText={report.description ?? ""}
178
178
  subtextToolTip={report.description ?? ""}
179
179
  titleTooltip={report.displayName}
@@ -231,11 +231,11 @@ export const Reports = () => {
231
231
  show={showDeleteModal}
232
232
  setShow={setShowDeleteModal}
233
233
  onDelete={async () => {
234
- const reportingClientApi = new ReportingClient(
234
+ const reportsClientApi = new ReportsClient(
235
235
  generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl)
236
236
  );
237
237
  const accessToken = await apiConfig.getAccessToken();
238
- await reportingClientApi.deleteReport(
238
+ await reportsClientApi.deleteReport(
239
239
  accessToken,
240
240
  selectedReport?.id ?? ""
241
241
  );