@itwin/reports-config-widget-react 0.0.6 → 0.0.8
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.
- package/.rush/temp/package-deps_rebuild.json +13 -13
- package/.rush/temp/shrinkwrap-deps.json +20 -18
- package/CHANGELOG.json +24 -0
- package/CHANGELOG.md +15 -1
- package/coverage/clover.xml +103 -102
- package/coverage/coverage-final.json +12 -12
- package/coverage/lcov-report/index.html +19 -19
- package/coverage/lcov-report/src/ReportsConfigWidget.ts.html +2 -2
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/test/index.html +1 -1
- package/coverage/lcov-report/src/test/test-utils.tsx.html +2 -2
- package/coverage/lcov-report/src/widget/ReportsConfigUiProvider.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/ActionPanel.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/AddMappingsModal.tsx.html +9 -9
- package/coverage/lcov-report/src/widget/components/DeleteModal.tsx.html +4 -4
- package/coverage/lcov-report/src/widget/components/Extraction.tsx.html +13 -13
- package/coverage/lcov-report/src/widget/components/HorizontalTile.tsx.html +2 -2
- package/coverage/lcov-report/src/widget/components/LocalizedTablePaginator.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/ReportAction.tsx.html +5 -5
- package/coverage/lcov-report/src/widget/components/ReportMappings.tsx.html +35 -26
- package/coverage/lcov-report/src/widget/components/Reports.tsx.html +34 -34
- package/coverage/lcov-report/src/widget/components/ReportsContainer.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/SearchBar.tsx.html +4 -4
- package/coverage/lcov-report/src/widget/components/SelectIModel.tsx.html +1 -1
- package/coverage/lcov-report/src/widget/components/index.html +38 -38
- package/coverage/lcov-report/src/widget/components/utils.tsx.html +30 -30
- package/coverage/lcov-report/src/widget/context/ReportsApiConfigContext.tsx.html +4 -4
- package/coverage/lcov-report/src/widget/context/index.html +1 -1
- package/coverage/lcov-report/src/widget/hooks/index.html +1 -1
- package/coverage/lcov-report/src/widget/hooks/useValidator.ts.html +1 -1
- package/coverage/lcov-report/src/widget/index.html +1 -1
- package/coverage/lcov.info +238 -317
- package/lib/cjs/test/ReportMappings.test.js +42 -31
- package/lib/cjs/test/ReportMappings.test.js.map +1 -1
- package/lib/cjs/test/Reports.test.js +12 -7
- package/lib/cjs/test/Reports.test.js.map +1 -1
- package/lib/cjs/test/test-utils.js.map +1 -1
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/widget/components/AddMappingsModal.js +5 -6
- package/lib/cjs/widget/components/AddMappingsModal.js.map +1 -1
- package/lib/cjs/widget/components/Extraction.js +9 -11
- package/lib/cjs/widget/components/Extraction.js.map +1 -1
- package/lib/cjs/widget/components/ReportAction.js +3 -3
- package/lib/cjs/widget/components/ReportAction.js.map +1 -1
- package/lib/cjs/widget/components/ReportMappings.d.ts.map +1 -1
- package/lib/cjs/widget/components/ReportMappings.js +23 -27
- package/lib/cjs/widget/components/ReportMappings.js.map +1 -1
- package/lib/cjs/widget/components/Reports.js +6 -6
- package/lib/cjs/widget/components/Reports.js.map +1 -1
- package/lib/cjs/widget/components/ReportsContainer.scss +3 -0
- package/lib/esm/test/ReportMappings.test.js +42 -31
- package/lib/esm/test/ReportMappings.test.js.map +1 -1
- package/lib/esm/test/Reports.test.js +12 -7
- package/lib/esm/test/Reports.test.js.map +1 -1
- package/lib/esm/test/test-utils.js.map +1 -1
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/widget/components/AddMappingsModal.js +6 -7
- package/lib/esm/widget/components/AddMappingsModal.js.map +1 -1
- package/lib/esm/widget/components/Extraction.js +10 -12
- package/lib/esm/widget/components/Extraction.js.map +1 -1
- package/lib/esm/widget/components/ReportAction.js +4 -4
- package/lib/esm/widget/components/ReportAction.js.map +1 -1
- package/lib/esm/widget/components/ReportMappings.d.ts.map +1 -1
- package/lib/esm/widget/components/ReportMappings.js +24 -28
- package/lib/esm/widget/components/ReportMappings.js.map +1 -1
- package/lib/esm/widget/components/Reports.js +7 -7
- package/lib/esm/widget/components/Reports.js.map +1 -1
- package/lib/esm/widget/components/ReportsContainer.scss +3 -0
- package/package.json +2 -2
- package/reports-config-widget-react.build.error.log +4 -4
- package/reports-config-widget-react.build.log +12 -12
- package/src/test/ReportMappings.test.tsx +44 -24
- package/src/test/Reports.test.tsx +18 -13
- package/src/test/test-utils.tsx +1 -1
- package/src/widget/components/AddMappingsModal.tsx +6 -6
- package/src/widget/components/Extraction.tsx +10 -10
- package/src/widget/components/ReportAction.tsx +4 -4
- package/src/widget/components/ReportMappings.tsx +21 -18
- package/src/widget/components/Reports.tsx +6 -6
- package/src/widget/components/ReportsContainer.scss +3 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Reports.js","sourceRoot":"","sources":["../../../../src/widget/components/Reports.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,OAAO,GACR,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,MAAM,EACN,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,OAAO,GACR,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,EACL,YAAY,EACZ,WAAW,EACX,WAAW,EACX,cAAc,EACd,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,gBAAgB,CAAC;AACxB,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EA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BAAmB,CAAC,YAAY,CAAC,kBAAkB,CAClD,4BAA4B,CAC7B,CACQ;oCACX,oBAAC,QAAQ,IACP,GAAG,EAAE,CAAC,EACN,OAAO,EAAE,GAAG,EAAE;4CACZ,iBAAiB,CAAC,MAAM,CAAC,CAAC;4CAC1B,kBAAkB,CAAC,IAAI,CAAC,CAAC;4CACzB,KAAK,EAAE,CAAC;wCACV,CAAC,EACD,IAAI,EAAE,oBAAC,SAAS,OAAG,IAElB,mBAAmB,CAAC,YAAY,CAAC,kBAAkB,CAClD,4BAA4B,CAC7B,CACQ;iCACZ;gCAED,oBAAC,UAAU,IAAC,SAAS,EAAC,YAAY;oCAChC,oBAAC,OAAO,IACN,KAAK,EAAE;4CACL,KAAK,EAAE,MAAM;4CACb,MAAM,EAAE,MAAM;yCACf,GACD,CACS,CACA,GAEjB,CACH,CAAA;qBAAA,CAAC,CACE,CACP,CACO;gBACV,oBAAC,WAAW,IACV,UAAU,EAAE,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,WAAW,mCAAI,EAAE,EAC7C,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,KAAK,IAAI,EAAE;;wBACnB,MAAM,kBAAkB,GAAG,IAAI,eAAe,CAC5C,WAAW,CAAC,mBAAmB,EAAE,SAAS,CAAC,OAAO,CAAC,CACpD,CAAC;wBACF,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,cAAc,EAAE,CAAC;wBACrD,MAAM,kBAAkB,CAAC,YAAY,CACnC,WAAW,EACX,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,EAAE,mCAAI,EAAE,CACzB,CAAC;oBACJ,CAAC,EACD,OAAO,EAAE,OAAO,GAChB,CACD,CACJ,CAAC;KACL;AACH,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\n SvgAdd,\n SvgDelete,\n SvgEdit,\n SvgMore,\n} from \"@itwin/itwinui-icons-react\";\nimport {\n Button,\n DropdownMenu,\n IconButton,\n MenuItem,\n Surface,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { CreateTypeFromInterface } from \"./utils\";\nimport {\n EmptyMessage,\n generateUrl,\n handleError,\n LoadingOverlay,\n WidgetHeader,\n} from \"./utils\";\nimport \"./Reports.scss\";\nimport DeleteModal from \"./DeleteModal\";\nimport type { Report } from \"@itwin/insights-client\";\nimport { REPORTING_BASE_PATH, ReportingClient } from \"@itwin/insights-client\";\nimport ReportAction from \"./ReportAction\";\nimport { ReportMappings } from \"./ReportMappings\";\nimport { HorizontalTile } from \"./HorizontalTile\";\nimport { SearchBar } from \"./SearchBar\";\nimport type { ReportsApiConfig } from \"../context/ReportsApiConfigContext\";\nimport { useReportsApiConfig } from \"../context/ReportsApiConfigContext\";\nimport { ReportsConfigWidget } from \"../../ReportsConfigWidget\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\n\nexport type ReportType = CreateTypeFromInterface<Report>;\n\nenum ReportsView {\n REPORTS = \"reports\",\n REPORTSMAPPING = \"reportsmapping\",\n ADDING = \"adding\",\n MODIFYING = \"modifying\",\n}\n\nconst fetchReports = async (\n setReports: React.Dispatch<React.SetStateAction<Report[]>>,\n iTwinId: string | undefined,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n apiContext: ReportsApiConfig\n) => {\n try {\n if (!iTwinId) return;\n setIsLoading(true);\n const reportingClientApi = new ReportingClient(\n generateUrl(REPORTING_BASE_PATH, apiContext.baseUrl)\n );\n const accessToken = await apiContext.getAccessToken();\n const reports = await reportingClientApi.getReports(accessToken, iTwinId);\n setReports(reports ?? []);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n};\n\nexport const Reports = () => {\n const iTwinId = useActiveIModelConnection()?.iTwinId ?? \"\";\n const apiConfig = useReportsApiConfig();\n const [showDeleteModal, setShowDeleteModal] = useState<boolean>(false);\n const [reportsView, setReportsView] = useState<ReportsView>(\n ReportsView.REPORTS\n );\n const [selectedReport, setSelectedReport] = useState<Report | undefined>(\n undefined\n );\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [searchValue, setSearchValue] = useState<string>(\"\");\n const [reports, setReports] = useState<Report[]>([]);\n\n useEffect(() => {\n void fetchReports(setReports, iTwinId, setIsLoading, apiConfig);\n }, [apiConfig, iTwinId, setIsLoading]);\n\n const refresh = useCallback(async () => {\n setReportsView(ReportsView.REPORTS);\n setSelectedReport(undefined);\n await fetchReports(setReports, iTwinId, setIsLoading, apiConfig);\n }, [apiConfig, iTwinId, setReports]);\n\n const addReport = () => {\n setReportsView(ReportsView.ADDING);\n };\n\n const filteredReports = useMemo(\n () =>\n reports.filter((x) =>\n [x.displayName, x.description]\n .join(\" \")\n .toLowerCase()\n .includes(searchValue.toLowerCase())\n ),\n [reports, searchValue]\n );\n\n switch (reportsView) {\n case ReportsView.ADDING:\n return iTwinId ? (\n <ReportAction iTwinId={iTwinId ?? \"\"} returnFn={refresh} />\n ) : null;\n case ReportsView.MODIFYING:\n return iTwinId ? (\n <ReportAction\n iTwinId={iTwinId}\n report={selectedReport}\n returnFn={refresh}\n />\n ) : null;\n case ReportsView.REPORTSMAPPING:\n return selectedReport ? (\n <ReportMappings report={selectedReport} goBack={refresh} />\n ) : null;\n default:\n return (\n <>\n <WidgetHeader\n title={ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ITwinReports\"\n )}\n />\n <Surface className=\"reports-list-container\">\n <div className=\"toolbar\">\n <Button\n startIcon={<SvgAdd />}\n onClick={() => addReport()}\n styleType=\"high-visibility\"\n >\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:New\"\n )}\n </Button>\n <div className=\"search-bar-container\" data-testid=\"search-bar\">\n <SearchBar\n searchValue={searchValue}\n setSearchValue={setSearchValue}\n disabled={isLoading}\n />\n </div>\n </div>\n {isLoading ? (\n <LoadingOverlay />\n ) : reports.length === 0 ? (\n <EmptyMessage>\n <>\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:NoReports\"\n )}\n <div>\n <Button onClick={() => addReport()} styleType=\"cta\">\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:CreateOneReportCTA\"\n )}\n </Button>\n </div>\n </>\n </EmptyMessage>\n ) : (\n <div className=\"reports-list\">\n {filteredReports.map((report) => (\n <HorizontalTile\n key={report.id}\n title={report.displayName ?? \"\"}\n subText={report.description ?? \"\"}\n subtextToolTip={report.description ?? \"\"}\n titleTooltip={report.displayName}\n onClickTitle={() => {\n setSelectedReport(report);\n setReportsView(ReportsView.REPORTSMAPPING);\n }}\n button={\n <DropdownMenu\n menuItems={(close: () => void) => [\n <MenuItem\n key={0}\n onClick={() => {\n setSelectedReport(report);\n setReportsView(ReportsView.MODIFYING);\n }}\n icon={<SvgEdit />}\n >\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:Modify\"\n )}\n </MenuItem>,\n <MenuItem\n key={1}\n onClick={() => {\n setSelectedReport(report);\n setShowDeleteModal(true);\n close();\n }}\n icon={<SvgDelete />}\n >\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:Remove\"\n )}\n </MenuItem>,\n ]}\n >\n <IconButton styleType=\"borderless\">\n <SvgMore\n style={{\n width: \"16px\",\n height: \"16px\",\n }}\n />\n </IconButton>\n </DropdownMenu>\n }\n />\n ))}\n </div>\n )}\n </Surface>\n <DeleteModal\n entityName={selectedReport?.displayName ?? \"\"}\n show={showDeleteModal}\n setShow={setShowDeleteModal}\n onDelete={async () => {\n const reportingClientApi = new ReportingClient(\n generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl)\n );\n const accessToken = await apiConfig.getAccessToken();\n await reportingClientApi.deleteReport(\n accessToken,\n selectedReport?.id ?? \"\"\n );\n }}\n refresh={refresh}\n />\n </>\n );\n }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"Reports.js","sourceRoot":"","sources":["../../../../src/widget/components/Reports.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,OAAO,GACR,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,MAAM,EACN,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,OAAO,GACR,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEzE,OAAO,EACL,YAAY,EACZ,WAAW,EACX,WAAW,EACX,cAAc,EACd,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,gBAAgB,CAAC;AACxB,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAI/D,IAAK,WAKJ;AALD,WAAK,WAAW;IACd,kCAAmB,CAAA;IACnB,gDAAiC,CAAA;IACjC,gCAAiB,CAAA;IACjB,sCAAuB,CAAA;AACzB,CAAC,EALI,WAAW,KAAX,WAAW,QAKf;AAED,MAAM,YAAY,GAAG,KAAK,EACxB,UAA0D,EAC1D,OAA2B,EAC3B,YAA2D,EA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K,EAAE;4CACL,KAAK,EAAE,MAAM;4CACb,MAAM,EAAE,MAAM;yCACf,GACD,CACS,CACA,GAEjB,CACH,CAAA;qBAAA,CAAC,CACE,CACP,CACO;gBACV,oBAAC,WAAW,IACV,UAAU,EAAE,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,WAAW,mCAAI,EAAE,EAC7C,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,KAAK,IAAI,EAAE;;wBACnB,MAAM,gBAAgB,GAAG,IAAI,aAAa,CACxC,WAAW,CAAC,mBAAmB,EAAE,SAAS,CAAC,OAAO,CAAC,CACpD,CAAC;wBACF,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,cAAc,EAAE,CAAC;wBACrD,MAAM,gBAAgB,CAAC,YAAY,CACjC,WAAW,EACX,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,EAAE,mCAAI,EAAE,CACzB,CAAC;oBACJ,CAAC,EACD,OAAO,EAAE,OAAO,GAChB,CACD,CACJ,CAAC;KACL;AACH,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport {\n SvgAdd,\n SvgDelete,\n SvgEdit,\n SvgMore,\n} from \"@itwin/itwinui-icons-react\";\nimport {\n Button,\n DropdownMenu,\n IconButton,\n MenuItem,\n Surface,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport type { CreateTypeFromInterface } from \"./utils\";\nimport {\n EmptyMessage,\n generateUrl,\n handleError,\n LoadingOverlay,\n WidgetHeader,\n} from \"./utils\";\nimport \"./Reports.scss\";\nimport DeleteModal from \"./DeleteModal\";\nimport type { Report } from \"@itwin/insights-client\";\nimport { REPORTING_BASE_PATH, ReportsClient } from \"@itwin/insights-client\";\nimport ReportAction from \"./ReportAction\";\nimport { ReportMappings } from \"./ReportMappings\";\nimport { HorizontalTile } from \"./HorizontalTile\";\nimport { SearchBar } from \"./SearchBar\";\nimport type { ReportsApiConfig } from \"../context/ReportsApiConfigContext\";\nimport { useReportsApiConfig } from \"../context/ReportsApiConfigContext\";\nimport { ReportsConfigWidget } from \"../../ReportsConfigWidget\";\nimport { useActiveIModelConnection } from \"@itwin/appui-react\";\n\nexport type ReportType = CreateTypeFromInterface<Report>;\n\nenum ReportsView {\n REPORTS = \"reports\",\n REPORTSMAPPING = \"reportsmapping\",\n ADDING = \"adding\",\n MODIFYING = \"modifying\",\n}\n\nconst fetchReports = async (\n setReports: React.Dispatch<React.SetStateAction<Report[]>>,\n iTwinId: string | undefined,\n setIsLoading: React.Dispatch<React.SetStateAction<boolean>>,\n apiContext: ReportsApiConfig\n) => {\n try {\n if (!iTwinId) return;\n setIsLoading(true);\n const reportsClientApi = new ReportsClient(\n generateUrl(REPORTING_BASE_PATH, apiContext.baseUrl)\n );\n const accessToken = await apiContext.getAccessToken();\n const reports = await reportsClientApi.getReports(accessToken, iTwinId);\n setReports(reports ?? []);\n } catch (error: any) {\n handleError(error.status);\n } finally {\n setIsLoading(false);\n }\n};\n\nexport const Reports = () => {\n const iTwinId = useActiveIModelConnection()?.iTwinId ?? \"\";\n const apiConfig = useReportsApiConfig();\n const [showDeleteModal, setShowDeleteModal] = useState<boolean>(false);\n const [reportsView, setReportsView] = useState<ReportsView>(\n ReportsView.REPORTS\n );\n const [selectedReport, setSelectedReport] = useState<Report | undefined>(\n undefined\n );\n const [isLoading, setIsLoading] = useState<boolean>(true);\n const [searchValue, setSearchValue] = useState<string>(\"\");\n const [reports, setReports] = useState<Report[]>([]);\n\n useEffect(() => {\n void fetchReports(setReports, iTwinId, setIsLoading, apiConfig);\n }, [apiConfig, iTwinId, setIsLoading]);\n\n const refresh = useCallback(async () => {\n setReportsView(ReportsView.REPORTS);\n setSelectedReport(undefined);\n await fetchReports(setReports, iTwinId, setIsLoading, apiConfig);\n }, [apiConfig, iTwinId, setReports]);\n\n const addReport = () => {\n setReportsView(ReportsView.ADDING);\n };\n\n const filteredReports = useMemo(\n () =>\n reports.filter((x) =>\n [x.displayName, x.description]\n .join(\" \")\n .toLowerCase()\n .includes(searchValue.toLowerCase())\n ),\n [reports, searchValue]\n );\n\n switch (reportsView) {\n case ReportsView.ADDING:\n return iTwinId ? (\n <ReportAction iTwinId={iTwinId ?? \"\"} returnFn={refresh} />\n ) : null;\n case ReportsView.MODIFYING:\n return iTwinId ? (\n <ReportAction\n iTwinId={iTwinId}\n report={selectedReport}\n returnFn={refresh}\n />\n ) : null;\n case ReportsView.REPORTSMAPPING:\n return selectedReport ? (\n <ReportMappings report={selectedReport} goBack={refresh} />\n ) : null;\n default:\n return (\n <>\n <WidgetHeader\n title={ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:ITwinReports\"\n )}\n />\n <Surface className=\"reports-list-container\">\n <div className=\"toolbar\">\n <Button\n startIcon={<SvgAdd />}\n onClick={() => addReport()}\n styleType=\"high-visibility\"\n >\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:New\"\n )}\n </Button>\n <div className=\"search-bar-container\" data-testid=\"search-bar\">\n <SearchBar\n searchValue={searchValue}\n setSearchValue={setSearchValue}\n disabled={isLoading}\n />\n </div>\n </div>\n {isLoading ? (\n <LoadingOverlay />\n ) : reports.length === 0 ? (\n <EmptyMessage>\n <>\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:NoReports\"\n )}\n <div>\n <Button onClick={() => addReport()} styleType=\"cta\">\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:CreateOneReportCTA\"\n )}\n </Button>\n </div>\n </>\n </EmptyMessage>\n ) : (\n <div className=\"reports-list\">\n {filteredReports.map((report) => (\n <HorizontalTile\n key={report.id}\n title={report.displayName}\n subText={report.description ?? \"\"}\n subtextToolTip={report.description ?? \"\"}\n titleTooltip={report.displayName}\n onClickTitle={() => {\n setSelectedReport(report);\n setReportsView(ReportsView.REPORTSMAPPING);\n }}\n button={\n <DropdownMenu\n menuItems={(close: () => void) => [\n <MenuItem\n key={0}\n onClick={() => {\n setSelectedReport(report);\n setReportsView(ReportsView.MODIFYING);\n }}\n icon={<SvgEdit />}\n >\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:Modify\"\n )}\n </MenuItem>,\n <MenuItem\n key={1}\n onClick={() => {\n setSelectedReport(report);\n setShowDeleteModal(true);\n close();\n }}\n icon={<SvgDelete />}\n >\n {ReportsConfigWidget.localization.getLocalizedString(\n \"ReportsConfigWidget:Remove\"\n )}\n </MenuItem>,\n ]}\n >\n <IconButton styleType=\"borderless\">\n <SvgMore\n style={{\n width: \"16px\",\n height: \"16px\",\n }}\n />\n </IconButton>\n </DropdownMenu>\n }\n />\n ))}\n </div>\n )}\n </Surface>\n <DeleteModal\n entityName={selectedReport?.displayName ?? \"\"}\n show={showDeleteModal}\n setShow={setShowDeleteModal}\n onDelete={async () => {\n const reportsClientApi = new ReportsClient(\n generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl)\n );\n const accessToken = await apiConfig.getAccessToken();\n await reportsClientApi.deleteReport(\n accessToken,\n selectedReport?.id ?? \"\"\n );\n }}\n refresh={refresh}\n />\n </>\n );\n }\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/reports-config-widget-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "An iTwin.js 3D Viewer Widget that interfaces with the iTwin Reporting Platform.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Bentley",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@itwin/imodels-access-frontend": "^1.0.1",
|
|
38
38
|
"@itwin/imodels-client-management": "^1.0.1",
|
|
39
|
-
"@itwin/insights-client": "^0.
|
|
39
|
+
"@itwin/insights-client": "^0.3.0",
|
|
40
40
|
"@itwin/itwinui-icons-color-react": "^1.0.1",
|
|
41
41
|
"@itwin/itwinui-icons-react": "^1.7.0",
|
|
42
42
|
"@itwin/itwinui-react": "~1.42.0",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
PASS src/test/ReportMappings.test.tsx (
|
|
2
|
-
PASS src/test/Reports.test.tsx (
|
|
3
|
-
PASS src/test/ReportAction.test.tsx
|
|
1
|
+
PASS src/test/ReportMappings.test.tsx (41.279 s)
|
|
2
|
+
PASS src/test/Reports.test.tsx (9.785 s)
|
|
3
|
+
PASS src/test/ReportAction.test.tsx (6.544 s)
|
|
4
4
|
PASS src/test/WidgetHeader.test.tsx
|
|
5
5
|
|
|
6
6
|
Test Suites: 4 passed, 4 total
|
|
7
7
|
Tests: 22 passed, 22 total
|
|
8
8
|
Snapshots: 0 total
|
|
9
|
-
Time:
|
|
9
|
+
Time: 62.23 s
|
|
10
10
|
Ran all test suites.
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
Invoking: npm test -- --coverage
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
> @itwin/reports-config-widget-react@0.0.
|
|
4
|
+
> @itwin/reports-config-widget-react@0.0.7 test /home/vsts/work/1/s/packages/itwin/reports-config-widget
|
|
5
5
|
> jest "--coverage"
|
|
6
6
|
|
|
7
|
-
PASS src/test/ReportMappings.test.tsx (
|
|
8
|
-
PASS src/test/Reports.test.tsx (
|
|
9
|
-
PASS src/test/ReportAction.test.tsx
|
|
7
|
+
PASS src/test/ReportMappings.test.tsx (41.279 s)
|
|
8
|
+
PASS src/test/Reports.test.tsx (9.785 s)
|
|
9
|
+
PASS src/test/ReportAction.test.tsx (6.544 s)
|
|
10
10
|
PASS src/test/WidgetHeader.test.tsx
|
|
11
11
|
------------------------------|---------|----------|---------|---------|-------------------------------
|
|
12
12
|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
|
13
13
|
------------------------------|---------|----------|---------|---------|-------------------------------
|
|
14
|
-
All files |
|
|
14
|
+
All files | 88.02 | 69.53 | 85.71 | 88.12 |
|
|
15
15
|
src | 100 | 75 | 100 | 100 |
|
|
16
16
|
ReportsConfigWidget.ts | 100 | 75 | 100 | 100 | 21
|
|
17
17
|
src/test | 100 | 66.66 | 100 | 100 |
|
|
18
18
|
test-utils.tsx | 100 | 66.66 | 100 | 100 | 56
|
|
19
19
|
src/widget | 40 | 0 | 0 | 40 |
|
|
20
20
|
ReportsConfigUiProvider.tsx | 40 | 0 | 0 | 40 | 23-65
|
|
21
|
-
src/widget/components |
|
|
21
|
+
src/widget/components | 88.46 | 71.07 | 86.86 | 88.67 |
|
|
22
22
|
ActionPanel.tsx | 100 | 77.77 | 100 | 100 | 25-26
|
|
23
|
-
AddMappingsModal.tsx | 91.66 |
|
|
23
|
+
AddMappingsModal.tsx | 91.66 | 83.33 | 88.88 | 93.47 | 40,120,134
|
|
24
24
|
DeleteModal.tsx | 85 | 100 | 50 | 84.21 | 42,56-87
|
|
25
|
-
Extraction.tsx | 85.41 |
|
|
25
|
+
Extraction.tsx | 85.41 | 79.48 | 85.71 | 85.71 | 51-53,138,200-203,226-229,295
|
|
26
26
|
HorizontalTile.tsx | 100 | 100 | 100 | 100 |
|
|
27
27
|
LocalizedTablePaginator.tsx | 100 | 50 | 100 | 100 | 25
|
|
28
28
|
ReportAction.tsx | 94.28 | 81.48 | 100 | 94.28 | 59-60
|
|
29
|
-
ReportMappings.tsx | 96.
|
|
30
|
-
Reports.tsx |
|
|
29
|
+
ReportMappings.tsx | 96.34 | 73.68 | 94.44 | 96.29 | 100,122,271
|
|
30
|
+
Reports.tsx | 98.57 | 78.94 | 100 | 100 | 56-72,112-124,177-178,240
|
|
31
31
|
ReportsContainer.tsx | 57.14 | 0 | 0 | 61.53 | 19,25-37
|
|
32
32
|
SearchBar.tsx | 70.58 | 71.42 | 60 | 68.75 | 31-45
|
|
33
33
|
SelectIModel.tsx | 97.05 | 81.81 | 85.71 | 96.87 | 92
|
|
34
|
-
utils.tsx |
|
|
34
|
+
utils.tsx | 64.7 | 30.76 | 100 | 58.13 | 51-94
|
|
35
35
|
src/widget/context | 80 | 0 | 50 | 77.77 |
|
|
36
36
|
ReportsApiConfigContext.tsx | 80 | 0 | 50 | 77.77 | 15,22
|
|
37
37
|
src/widget/hooks | 100 | 100 | 100 | 100 |
|
|
@@ -41,5 +41,5 @@ All files | 87.12 | 69.64 | 84.87 | 87.17 |
|
|
|
41
41
|
Test Suites: 4 passed, 4 total
|
|
42
42
|
Tests: 22 passed, 22 total
|
|
43
43
|
Snapshots: 0 total
|
|
44
|
-
Time:
|
|
44
|
+
Time: 62.23 s
|
|
45
45
|
Ran all test suites.
|
|
@@ -25,13 +25,16 @@ import * as moq from "typemoq";
|
|
|
25
25
|
import type { RequestHandler } from "msw";
|
|
26
26
|
import { rest } from "msw";
|
|
27
27
|
import type {
|
|
28
|
-
|
|
28
|
+
ExtractionStatusSingle,
|
|
29
29
|
Mapping,
|
|
30
30
|
MappingCollection,
|
|
31
31
|
MappingSingle,
|
|
32
32
|
Report,
|
|
33
33
|
ReportMappingCollection,
|
|
34
34
|
} from "@itwin/insights-client";
|
|
35
|
+
import {
|
|
36
|
+
ExtractorState,
|
|
37
|
+
} from "@itwin/insights-client";
|
|
35
38
|
import { ReportMappings } from "../widget/components/ReportMappings";
|
|
36
39
|
import { Constants, IModelState } from "@itwin/imodels-client-management";
|
|
37
40
|
import { REPORTS_CONFIG_BASE_URL } from "../widget/ReportsConfigUiProvider";
|
|
@@ -179,7 +182,7 @@ const mockReportMappingsFactory = (): ReportMappingCollection => {
|
|
|
179
182
|
const mockMappingsFactory = (
|
|
180
183
|
mockReportMappings: ReportMappingCollection
|
|
181
184
|
): [MappingSingle[], RequestHandler[]] => {
|
|
182
|
-
const mockMappings: MappingSingle[] = mockReportMappings.mappings
|
|
185
|
+
const mockMappings: MappingSingle[] = mockReportMappings.mappings.map(
|
|
183
186
|
(mapping, index) => ({
|
|
184
187
|
mapping: {
|
|
185
188
|
id: mapping.mappingId,
|
|
@@ -202,8 +205,8 @@ const mockMappingsFactory = (
|
|
|
202
205
|
|
|
203
206
|
const iModelHandlers: RequestHandler[] = mockMappings.map((mapping) =>
|
|
204
207
|
rest.get(
|
|
205
|
-
`${REPORTS_CONFIG_BASE_URL}/insights/reporting/datasources/imodels/${mapping.mapping
|
|
206
|
-
}/mappings/${mapping.mapping
|
|
208
|
+
`${REPORTS_CONFIG_BASE_URL}/insights/reporting/datasources/imodels/${mapping.mapping._links.imodel.href
|
|
209
|
+
}/mappings/${mapping.mapping.id}`,
|
|
207
210
|
async (_req, res, ctx) => {
|
|
208
211
|
return res(ctx.delay(), ctx.status(200), ctx.json(mapping));
|
|
209
212
|
}
|
|
@@ -317,16 +320,16 @@ describe("Report Mappings View", () => {
|
|
|
317
320
|
const reportMappingTile = within(horizontalTile);
|
|
318
321
|
const mockiModel = mockIModelsResponse.find(
|
|
319
322
|
(iModel) =>
|
|
320
|
-
iModel.iModel.id === mockMappings[index].mapping
|
|
323
|
+
iModel.iModel.id === mockMappings[index].mapping._links.imodel.href
|
|
321
324
|
);
|
|
322
325
|
expect(
|
|
323
326
|
reportMappingTile.getByText(
|
|
324
|
-
mockMappings[index].mapping
|
|
327
|
+
mockMappings[index].mapping.mappingName
|
|
325
328
|
)
|
|
326
329
|
).toBeInTheDocument();
|
|
327
330
|
expect(
|
|
328
331
|
reportMappingTile.getByTitle(
|
|
329
|
-
mockMappings[index].mapping
|
|
332
|
+
mockMappings[index].mapping.description ?? ""
|
|
330
333
|
)
|
|
331
334
|
).toBeInTheDocument();
|
|
332
335
|
expect(
|
|
@@ -389,24 +392,24 @@ describe("Report Mappings View", () => {
|
|
|
389
392
|
});
|
|
390
393
|
|
|
391
394
|
// Be an exact match on display name.
|
|
392
|
-
await user.type(searchInput, mockMappings[0].mapping
|
|
395
|
+
await user.type(searchInput, mockMappings[0].mapping.mappingName);
|
|
393
396
|
expect(screen.getAllByTestId("horizontal-tile")).toHaveLength(1);
|
|
394
397
|
expect(
|
|
395
|
-
screen.getByText(mockMappings[0].mapping
|
|
398
|
+
screen.getByText(mockMappings[0].mapping.mappingName)
|
|
396
399
|
).toBeInTheDocument();
|
|
397
400
|
|
|
398
401
|
// Be an exact match on description.
|
|
399
402
|
await user.clear(searchInput);
|
|
400
|
-
await user.type(searchInput, mockMappings[0].mapping
|
|
403
|
+
await user.type(searchInput, mockMappings[0].mapping.description ?? "");
|
|
401
404
|
expect(screen.getAllByTestId("horizontal-tile")).toHaveLength(1);
|
|
402
405
|
expect(
|
|
403
|
-
screen.getByTitle(mockMappings[0].mapping
|
|
406
|
+
screen.getByTitle(mockMappings[0].mapping.description ?? "")
|
|
404
407
|
).toBeInTheDocument();
|
|
405
408
|
|
|
406
409
|
// Be an exact match on iModel Name.
|
|
407
410
|
const iModel = mockIModelsResponse.find(
|
|
408
411
|
(mockIModel) =>
|
|
409
|
-
mockIModel.iModel.id === mockMappings[0].mapping
|
|
412
|
+
mockIModel.iModel.id === mockMappings[0].mapping._links.imodel.href
|
|
410
413
|
);
|
|
411
414
|
await user.clear(searchInput);
|
|
412
415
|
await user.type(searchInput, iModel?.iModel.displayName ?? "");
|
|
@@ -420,7 +423,7 @@ describe("Report Mappings View", () => {
|
|
|
420
423
|
const mockReportMappings = mockReportMappingsFactory();
|
|
421
424
|
const [_, iModelHandlers] = mockMappingsFactory(mockReportMappings);
|
|
422
425
|
|
|
423
|
-
const mockReportMappingsOriginalSize = mockReportMappings.mappings
|
|
426
|
+
const mockReportMappingsOriginalSize = mockReportMappings.mappings.length;
|
|
424
427
|
|
|
425
428
|
server.use(
|
|
426
429
|
rest.get(
|
|
@@ -455,13 +458,12 @@ describe("Report Mappings View", () => {
|
|
|
455
458
|
),
|
|
456
459
|
...iModelHandlers,
|
|
457
460
|
rest.delete(
|
|
458
|
-
`${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings/${mockReportMappings.mappings
|
|
461
|
+
`${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockReportId}/datasources/imodelMappings/${mockReportMappings.mappings[0].mappingId
|
|
459
462
|
}`,
|
|
460
463
|
async (_req, res, ctx) => {
|
|
461
|
-
mockReportMappings.mappings = mockReportMappings.mappings
|
|
464
|
+
mockReportMappings.mappings = mockReportMappings.mappings.filter(
|
|
462
465
|
(mapping) =>
|
|
463
|
-
mapping.mappingId !== mockReportMappings.mappings
|
|
464
|
-
""
|
|
466
|
+
mapping.mappingId !== mockReportMappings.mappings[0].mappingId
|
|
465
467
|
);
|
|
466
468
|
return res(ctx.delay(100), ctx.status(204));
|
|
467
469
|
}
|
|
@@ -630,7 +632,7 @@ describe("Report Mappings View", () => {
|
|
|
630
632
|
for (let i = 0; i < mockMappings.length - 1; i++) {
|
|
631
633
|
const row = screen.getByRole("row", {
|
|
632
634
|
name: new RegExp(
|
|
633
|
-
`${mockMappings[i].mapping
|
|
635
|
+
`${mockMappings[i].mapping.mappingName} ${mockMappings[i].mapping.description}`,
|
|
634
636
|
"i"
|
|
635
637
|
),
|
|
636
638
|
});
|
|
@@ -642,8 +644,8 @@ describe("Report Mappings View", () => {
|
|
|
642
644
|
// Click on checkbox on new mapping
|
|
643
645
|
const unmappedRow = screen.getByRole("row", {
|
|
644
646
|
name: new RegExp(
|
|
645
|
-
`${mockMappings[mockMappings.length - 1].mapping
|
|
646
|
-
} ${mockMappings[mockMappings.length - 1].mapping
|
|
647
|
+
`${mockMappings[mockMappings.length - 1].mapping.mappingName
|
|
648
|
+
} ${mockMappings[mockMappings.length - 1].mapping.description}`,
|
|
647
649
|
"i"
|
|
648
650
|
),
|
|
649
651
|
});
|
|
@@ -750,10 +752,16 @@ describe("Report Mappings View", () => {
|
|
|
750
752
|
},
|
|
751
753
|
};
|
|
752
754
|
|
|
753
|
-
let mockStatusResponse:
|
|
755
|
+
let mockStatusResponse: ExtractionStatusSingle = {
|
|
754
756
|
status: {
|
|
755
|
-
state:
|
|
757
|
+
state: ExtractorState.Queued,
|
|
756
758
|
reason: "",
|
|
759
|
+
containsIssues: false,
|
|
760
|
+
_links: {
|
|
761
|
+
logs: {
|
|
762
|
+
href: "",
|
|
763
|
+
},
|
|
764
|
+
},
|
|
757
765
|
},
|
|
758
766
|
};
|
|
759
767
|
|
|
@@ -852,8 +860,14 @@ describe("Report Mappings View", () => {
|
|
|
852
860
|
|
|
853
861
|
mockStatusResponse = {
|
|
854
862
|
status: {
|
|
855
|
-
state:
|
|
863
|
+
state: ExtractorState.Running,
|
|
856
864
|
reason: "",
|
|
865
|
+
containsIssues: false,
|
|
866
|
+
_links: {
|
|
867
|
+
logs: {
|
|
868
|
+
href: "",
|
|
869
|
+
},
|
|
870
|
+
},
|
|
857
871
|
},
|
|
858
872
|
};
|
|
859
873
|
|
|
@@ -864,8 +878,14 @@ describe("Report Mappings View", () => {
|
|
|
864
878
|
|
|
865
879
|
mockStatusResponse = {
|
|
866
880
|
status: {
|
|
867
|
-
state:
|
|
881
|
+
state: ExtractorState.Succeeded,
|
|
868
882
|
reason: "",
|
|
883
|
+
containsIssues: false,
|
|
884
|
+
_links: {
|
|
885
|
+
logs: {
|
|
886
|
+
href: "",
|
|
887
|
+
},
|
|
888
|
+
},
|
|
869
889
|
},
|
|
870
890
|
};
|
|
871
891
|
|
|
@@ -46,6 +46,12 @@ const reportsFactory = (): ReportCollection => ({
|
|
|
46
46
|
id: `${faker.datatype.uuid()}`,
|
|
47
47
|
displayName: `mOcKRePoRT${index}`,
|
|
48
48
|
description: `mOcKRePoRTDeScRiPtIoN${index}`,
|
|
49
|
+
deleted: false,
|
|
50
|
+
_links: {
|
|
51
|
+
project: {
|
|
52
|
+
href: "",
|
|
53
|
+
},
|
|
54
|
+
},
|
|
49
55
|
})
|
|
50
56
|
),
|
|
51
57
|
_links: {
|
|
@@ -176,18 +182,18 @@ describe("Reports View", () => {
|
|
|
176
182
|
await waitForElementToBeRemoved(() => screen.getByText(/loading/i));
|
|
177
183
|
const horizontalTiles = screen.getAllByTestId("horizontal-tile");
|
|
178
184
|
// TODO check for all descriptions and names and imodels
|
|
179
|
-
expect(horizontalTiles).toHaveLength(mockedReports?.reports
|
|
185
|
+
expect(horizontalTiles).toHaveLength(mockedReports?.reports.length);
|
|
180
186
|
|
|
181
187
|
for (const [index, horizontalTile] of horizontalTiles.entries()) {
|
|
182
188
|
const reportMappingTile = within(horizontalTile);
|
|
183
189
|
expect(
|
|
184
190
|
reportMappingTile.getByText(
|
|
185
|
-
mockedReports?.reports
|
|
191
|
+
mockedReports?.reports[index].displayName ?? ""
|
|
186
192
|
)
|
|
187
193
|
).toBeInTheDocument();
|
|
188
194
|
expect(
|
|
189
195
|
reportMappingTile.getByTitle(
|
|
190
|
-
mockedReports?.reports
|
|
196
|
+
mockedReports?.reports[index].description ?? ""
|
|
191
197
|
)
|
|
192
198
|
).toBeInTheDocument();
|
|
193
199
|
}
|
|
@@ -220,7 +226,7 @@ describe("Reports View", () => {
|
|
|
220
226
|
|
|
221
227
|
it("remove a report", async () => {
|
|
222
228
|
const mockedReports: ReportCollection = reportsFactory();
|
|
223
|
-
const mockedReportsOriginalLength = mockedReports.reports
|
|
229
|
+
const mockedReportsOriginalLength = mockedReports.reports.length;
|
|
224
230
|
server.use(
|
|
225
231
|
rest.get(
|
|
226
232
|
`${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports`,
|
|
@@ -229,12 +235,11 @@ describe("Reports View", () => {
|
|
|
229
235
|
}
|
|
230
236
|
),
|
|
231
237
|
rest.delete(
|
|
232
|
-
`${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${
|
|
233
|
-
mockedReports.reports![0].id
|
|
238
|
+
`${REPORTS_CONFIG_BASE_URL}/insights/reporting/reports/${mockedReports.reports[0].id
|
|
234
239
|
}`,
|
|
235
240
|
async (_req, res, ctx) => {
|
|
236
|
-
mockedReports.reports = mockedReports.reports
|
|
237
|
-
(report) => report.id !== mockedReports.reports
|
|
241
|
+
mockedReports.reports = mockedReports.reports.filter(
|
|
242
|
+
(report) => report.id !== mockedReports.reports[0].id
|
|
238
243
|
);
|
|
239
244
|
return res(ctx.delay(100), ctx.status(204));
|
|
240
245
|
}
|
|
@@ -297,22 +302,22 @@ describe("Reports View", () => {
|
|
|
297
302
|
// Be an exact match on display name.
|
|
298
303
|
await userEvent.type(
|
|
299
304
|
searchInput,
|
|
300
|
-
mockedReports.reports
|
|
305
|
+
mockedReports.reports[0].displayName
|
|
301
306
|
);
|
|
302
307
|
expect(screen.getAllByTestId("horizontal-tile")).toHaveLength(1);
|
|
303
308
|
expect(
|
|
304
|
-
screen.getByText(mockedReports.reports
|
|
309
|
+
screen.getByText(mockedReports.reports[0].displayName)
|
|
305
310
|
).toBeInTheDocument();
|
|
306
311
|
|
|
307
312
|
// Be an exact match on description.
|
|
308
313
|
await userEvent.clear(searchInput);
|
|
309
314
|
await userEvent.type(
|
|
310
315
|
searchInput,
|
|
311
|
-
mockedReports.reports
|
|
316
|
+
mockedReports.reports[0].description ?? ""
|
|
312
317
|
);
|
|
313
318
|
expect(screen.getAllByTestId("horizontal-tile")).toHaveLength(1);
|
|
314
319
|
expect(
|
|
315
|
-
screen.getByText(mockedReports.reports
|
|
320
|
+
screen.getByText(mockedReports.reports[0].displayName)
|
|
316
321
|
).toBeInTheDocument();
|
|
317
322
|
});
|
|
318
323
|
|
|
@@ -357,7 +362,7 @@ describe("Reports View", () => {
|
|
|
357
362
|
await waitForElementToBeRemoved(() => screen.getByText(/loading/i));
|
|
358
363
|
|
|
359
364
|
const reportName = screen.getByText(
|
|
360
|
-
mockedReports.reports
|
|
365
|
+
mockedReports.reports[0].displayName
|
|
361
366
|
);
|
|
362
367
|
await user.click(reportName);
|
|
363
368
|
expect(screen.getByText(/MockReportMappings/i)).toBeInTheDocument();
|
package/src/test/test-utils.tsx
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { Modal, Table, tableFilters } from "@itwin/itwinui-react";
|
|
6
6
|
import React, { useEffect, useMemo, useState } from "react";
|
|
7
7
|
import type { Mapping } from "@itwin/insights-client";
|
|
8
|
-
import { REPORTING_BASE_PATH,
|
|
8
|
+
import { MappingsClient, REPORTING_BASE_PATH, ReportsClient } from "@itwin/insights-client";
|
|
9
9
|
import ActionPanel from "./ActionPanel";
|
|
10
10
|
import "./AddMappingsModal.scss";
|
|
11
11
|
import { LocalizedTablePaginator } from "./LocalizedTablePaginator";
|
|
@@ -27,11 +27,11 @@ const fetchMappings = async (
|
|
|
27
27
|
) => {
|
|
28
28
|
try {
|
|
29
29
|
setIsLoading(true);
|
|
30
|
-
const
|
|
30
|
+
const mappingsClientApi = new MappingsClient(
|
|
31
31
|
generateUrl(REPORTING_BASE_PATH, apiContext.baseUrl)
|
|
32
32
|
);
|
|
33
33
|
const accessToken = await apiContext.getAccessToken();
|
|
34
|
-
const mappings = await
|
|
34
|
+
const mappings = await mappingsClientApi.getMappings(
|
|
35
35
|
accessToken,
|
|
36
36
|
iModelId
|
|
37
37
|
);
|
|
@@ -104,14 +104,14 @@ const AddMappingsModal = ({
|
|
|
104
104
|
try {
|
|
105
105
|
if (!selectedIModelId) return;
|
|
106
106
|
setIsLoading(true);
|
|
107
|
-
const
|
|
107
|
+
const reportsClientApi = new ReportsClient(
|
|
108
108
|
generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl)
|
|
109
109
|
);
|
|
110
110
|
const accessToken = await apiConfig.getAccessToken();
|
|
111
111
|
for (const mapping of selectedMappings) {
|
|
112
|
-
await
|
|
112
|
+
await reportsClientApi.createReportMapping(accessToken, reportId, {
|
|
113
113
|
imodelId: selectedIModelId,
|
|
114
|
-
mappingId: mapping.id
|
|
114
|
+
mappingId: mapping.id,
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "@itwin/itwinui-react";
|
|
12
12
|
import * as React from "react";
|
|
13
13
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
14
|
-
import {
|
|
14
|
+
import { ExtractionClient, REPORTING_BASE_PATH } from "@itwin/insights-client";
|
|
15
15
|
import { generateUrl, handleError, SkeletonBlock } from "./utils";
|
|
16
16
|
import "./Extraction.scss";
|
|
17
17
|
import {
|
|
@@ -185,15 +185,15 @@ export const Extraction = ({
|
|
|
185
185
|
try {
|
|
186
186
|
setExtractionState(ExtractionStates.Starting);
|
|
187
187
|
setExtractingIModelId(iModelId);
|
|
188
|
-
const
|
|
188
|
+
const extractionClientApi = new ExtractionClient(
|
|
189
189
|
generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl)
|
|
190
190
|
);
|
|
191
191
|
const accessToken = await apiConfig.getAccessToken();
|
|
192
|
-
const response = await
|
|
192
|
+
const response = await extractionClientApi.runExtraction(
|
|
193
193
|
accessToken,
|
|
194
194
|
iModelId
|
|
195
195
|
);
|
|
196
|
-
jobId.current = response.
|
|
196
|
+
jobId.current = response.id;
|
|
197
197
|
setIsRunning(true);
|
|
198
198
|
setExtractionState(ExtractionStates.FetchingUpdate);
|
|
199
199
|
} catch (error: any) {
|
|
@@ -207,23 +207,23 @@ export const Extraction = ({
|
|
|
207
207
|
useEffect(() => {
|
|
208
208
|
if (!intervalId.current && isRunning) {
|
|
209
209
|
const newIntervalId = window.setInterval(async () => {
|
|
210
|
-
const
|
|
210
|
+
const extractionClientApi = new ExtractionClient(
|
|
211
211
|
generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl)
|
|
212
212
|
);
|
|
213
213
|
const accessToken = await apiConfig.getAccessToken();
|
|
214
|
-
const response = await
|
|
214
|
+
const response = await extractionClientApi.getExtractionStatus(
|
|
215
215
|
accessToken,
|
|
216
216
|
jobId.current
|
|
217
217
|
);
|
|
218
|
-
if (response.
|
|
218
|
+
if (response.state === "Queued") {
|
|
219
219
|
setExtractionState(ExtractionStates.Queued);
|
|
220
|
-
} else if (response.
|
|
220
|
+
} else if (response.state === "Running") {
|
|
221
221
|
setExtractionState(ExtractionStates.Running);
|
|
222
|
-
} else if (response.
|
|
222
|
+
} else if (response.state === "Succeeded") {
|
|
223
223
|
setExtractionState(ExtractionStates.Succeeded);
|
|
224
224
|
setIsRunning(false);
|
|
225
225
|
setCurrentIModelId(undefined);
|
|
226
|
-
} else if (response.
|
|
226
|
+
} else if (response.state === "Failed") {
|
|
227
227
|
setExtractionState(ExtractionStates.Failed);
|
|
228
228
|
setIsRunning(false);
|
|
229
229
|
setCurrentIModelId(undefined);
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "./utils";
|
|
15
15
|
import "./ReportAction.scss";
|
|
16
16
|
import type { Report } from "@itwin/insights-client";
|
|
17
|
-
import { REPORTING_BASE_PATH,
|
|
17
|
+
import { REPORTING_BASE_PATH, ReportsClient } from "@itwin/insights-client";
|
|
18
18
|
import { useReportsApiConfig } from "../context/ReportsApiConfigContext";
|
|
19
19
|
import { ReportsConfigWidget } from "../../ReportsConfigWidget";
|
|
20
20
|
|
|
@@ -40,16 +40,16 @@ const ReportAction = ({ iTwinId, report, returnFn }: ReportActionProps) => {
|
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
setIsLoading(true);
|
|
43
|
-
const
|
|
43
|
+
const reportsClientApi = new ReportsClient(
|
|
44
44
|
generateUrl(REPORTING_BASE_PATH, apiConfig.baseUrl)
|
|
45
45
|
);
|
|
46
46
|
const accessToken = await apiConfig.getAccessToken();
|
|
47
47
|
report
|
|
48
|
-
? await
|
|
48
|
+
? await reportsClientApi.updateReport(accessToken, report.id ?? "", {
|
|
49
49
|
displayName: values.name,
|
|
50
50
|
description: values.description,
|
|
51
51
|
})
|
|
52
|
-
: await
|
|
52
|
+
: await reportsClientApi.createReport(accessToken, {
|
|
53
53
|
displayName: values.name,
|
|
54
54
|
description: values.description,
|
|
55
55
|
projectId: iTwinId,
|