@itwin/grouping-mapping-widget 0.21.0 → 0.22.0
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/lib/cjs/common/hooks/useMemoizedCollectionPick.d.ts +2 -0
- package/lib/cjs/common/hooks/useMemoizedCollectionPick.js +31 -0
- package/lib/cjs/common/hooks/useMemoizedCollectionPick.js.map +1 -0
- package/lib/cjs/components/GroupingMappingContext.js +31 -13
- package/lib/cjs/components/GroupingMappingContext.js.map +1 -1
- package/lib/cjs/components/Groups/hooks/useFetchGroups.d.ts +5 -0
- package/lib/cjs/components/Groups/hooks/useFetchGroups.js +18 -0
- package/lib/cjs/components/Groups/hooks/useFetchGroups.js.map +1 -0
- package/lib/cjs/components/Mappings/Editing/MappingAction.js +21 -30
- package/lib/cjs/components/Mappings/Editing/MappingAction.js.map +1 -1
- package/lib/cjs/components/Mappings/Extraction/ExtractionMessageModal.d.ts +6 -1
- package/lib/cjs/components/Mappings/Extraction/ExtractionMessageModal.js +42 -31
- package/lib/cjs/components/Mappings/Extraction/ExtractionMessageModal.js.map +1 -1
- package/lib/cjs/components/Mappings/Extraction/ExtractionStatusIcon.d.ts +7 -1
- package/lib/cjs/components/Mappings/Extraction/ExtractionStatusIcon.js.map +1 -1
- package/lib/cjs/components/Mappings/{ConfirmMappingsImport.d.ts → Import/ConfirmMappingsImport.d.ts} +1 -1
- package/lib/cjs/components/Mappings/{ConfirmMappingsImport.js → Import/ConfirmMappingsImport.js} +27 -20
- package/lib/cjs/components/Mappings/Import/ConfirmMappingsImport.js.map +1 -0
- package/lib/cjs/components/Mappings/Import/MappingImportWizardModal.js +4 -7
- package/lib/cjs/components/Mappings/Import/MappingImportWizardModal.js.map +1 -1
- package/lib/cjs/components/Mappings/Import/SelectIModel.js +30 -49
- package/lib/cjs/components/Mappings/Import/SelectIModel.js.map +1 -1
- package/lib/cjs/components/Mappings/Import/SelectITwin.d.ts +6 -1
- package/lib/cjs/components/Mappings/Import/SelectITwin.js +39 -52
- package/lib/cjs/components/Mappings/Import/SelectITwin.js.map +1 -1
- package/lib/cjs/components/Mappings/Import/SelectMappings.js +13 -36
- package/lib/cjs/components/Mappings/Import/SelectMappings.js.map +1 -1
- package/lib/cjs/components/Mappings/Mappings.js +5 -27
- package/lib/cjs/components/Mappings/Mappings.js.map +1 -1
- package/lib/cjs/components/Mappings/MappingsView.d.ts +5 -4
- package/lib/cjs/components/Mappings/MappingsView.js +29 -7
- package/lib/cjs/components/Mappings/MappingsView.js.map +1 -1
- package/lib/cjs/components/Mappings/hooks/useFetchExtractionStatus.d.ts +13 -0
- package/lib/cjs/components/Mappings/hooks/useFetchExtractionStatus.js +50 -0
- package/lib/cjs/components/Mappings/hooks/useFetchExtractionStatus.js.map +1 -0
- package/lib/cjs/components/Mappings/hooks/useFetchMappings.d.ts +4 -0
- package/lib/cjs/components/Mappings/hooks/useFetchMappings.js +14 -0
- package/lib/cjs/components/Mappings/hooks/useFetchMappings.js.map +1 -0
- package/lib/cjs/components/Mappings/hooks/useMappingsOperations.d.ts +9 -10
- package/lib/cjs/components/Mappings/hooks/useMappingsOperations.js +35 -108
- package/lib/cjs/components/Mappings/hooks/useMappingsOperations.js.map +1 -1
- package/lib/cjs/components/Properties/PropertyTable.js +2 -1
- package/lib/cjs/components/Properties/PropertyTable.js.map +1 -1
- package/lib/cjs/components/SharedComponents/DeleteModal.d.ts +2 -2
- package/lib/cjs/components/SharedComponents/DeleteModal.js +15 -19
- package/lib/cjs/components/SharedComponents/DeleteModal.js.map +1 -1
- package/lib/cjs/formula/FormulaFunctionProvider.js +10 -1
- package/lib/cjs/formula/FormulaFunctionProvider.js.map +1 -1
- package/lib/esm/common/hooks/useMemoizedCollectionPick.d.ts +2 -0
- package/lib/esm/common/hooks/useMemoizedCollectionPick.js +27 -0
- package/lib/esm/common/hooks/useMemoizedCollectionPick.js.map +1 -0
- package/lib/esm/components/GroupingMappingContext.js +31 -13
- package/lib/esm/components/GroupingMappingContext.js.map +1 -1
- package/lib/esm/components/Groups/hooks/useFetchGroups.d.ts +5 -0
- package/lib/esm/components/Groups/hooks/useFetchGroups.js +13 -0
- package/lib/esm/components/Groups/hooks/useFetchGroups.js.map +1 -0
- package/lib/esm/components/Mappings/Editing/MappingAction.js +22 -31
- package/lib/esm/components/Mappings/Editing/MappingAction.js.map +1 -1
- package/lib/esm/components/Mappings/Extraction/ExtractionMessageModal.d.ts +6 -1
- package/lib/esm/components/Mappings/Extraction/ExtractionMessageModal.js +42 -31
- package/lib/esm/components/Mappings/Extraction/ExtractionMessageModal.js.map +1 -1
- package/lib/esm/components/Mappings/Extraction/ExtractionStatusIcon.d.ts +7 -1
- package/lib/esm/components/Mappings/Extraction/ExtractionStatusIcon.js.map +1 -1
- package/lib/esm/components/Mappings/{ConfirmMappingsImport.d.ts → Import/ConfirmMappingsImport.d.ts} +1 -1
- package/lib/esm/components/Mappings/{ConfirmMappingsImport.js → Import/ConfirmMappingsImport.js} +27 -20
- package/lib/esm/components/Mappings/Import/ConfirmMappingsImport.js.map +1 -0
- package/lib/esm/components/Mappings/Import/MappingImportWizardModal.js +4 -7
- package/lib/esm/components/Mappings/Import/MappingImportWizardModal.js.map +1 -1
- package/lib/esm/components/Mappings/Import/SelectIModel.js +31 -50
- package/lib/esm/components/Mappings/Import/SelectIModel.js.map +1 -1
- package/lib/esm/components/Mappings/Import/SelectITwin.d.ts +6 -1
- package/lib/esm/components/Mappings/Import/SelectITwin.js +39 -53
- package/lib/esm/components/Mappings/Import/SelectITwin.js.map +1 -1
- package/lib/esm/components/Mappings/Import/SelectMappings.js +14 -37
- package/lib/esm/components/Mappings/Import/SelectMappings.js.map +1 -1
- package/lib/esm/components/Mappings/Mappings.js +3 -9
- package/lib/esm/components/Mappings/Mappings.js.map +1 -1
- package/lib/esm/components/Mappings/MappingsView.d.ts +5 -4
- package/lib/esm/components/Mappings/MappingsView.js +10 -7
- package/lib/esm/components/Mappings/MappingsView.js.map +1 -1
- package/lib/esm/components/Mappings/hooks/useFetchExtractionStatus.d.ts +13 -0
- package/lib/esm/components/Mappings/hooks/useFetchExtractionStatus.js +46 -0
- package/lib/esm/components/Mappings/hooks/useFetchExtractionStatus.js.map +1 -0
- package/lib/esm/components/Mappings/hooks/useFetchMappings.d.ts +4 -0
- package/lib/esm/components/Mappings/hooks/useFetchMappings.js +10 -0
- package/lib/esm/components/Mappings/hooks/useFetchMappings.js.map +1 -0
- package/lib/esm/components/Mappings/hooks/useMappingsOperations.d.ts +9 -10
- package/lib/esm/components/Mappings/hooks/useMappingsOperations.js +36 -109
- package/lib/esm/components/Mappings/hooks/useMappingsOperations.js.map +1 -1
- package/lib/esm/components/Properties/PropertyTable.js +2 -1
- package/lib/esm/components/Properties/PropertyTable.js.map +1 -1
- package/lib/esm/components/SharedComponents/DeleteModal.d.ts +2 -2
- package/lib/esm/components/SharedComponents/DeleteModal.js +16 -20
- package/lib/esm/components/SharedComponents/DeleteModal.js.map +1 -1
- package/lib/esm/formula/FormulaFunctionProvider.js +10 -1
- package/lib/esm/formula/FormulaFunctionProvider.js.map +1 -1
- package/package.json +9 -4
- package/lib/cjs/components/Mappings/ConfirmMappingsImport.js.map +0 -1
- package/lib/cjs/components/context/ExtractionStatusDataContext.d.ts +0 -20
- package/lib/cjs/components/context/ExtractionStatusDataContext.js +0 -26
- package/lib/cjs/components/context/ExtractionStatusDataContext.js.map +0 -1
- package/lib/esm/components/Mappings/ConfirmMappingsImport.js.map +0 -1
- package/lib/esm/components/context/ExtractionStatusDataContext.d.ts +0 -20
- package/lib/esm/components/context/ExtractionStatusDataContext.js +0 -22
- package/lib/esm/components/context/ExtractionStatusDataContext.js.map +0 -1
- /package/lib/cjs/components/Mappings/{ConfirmMappingsImport.scss → Import/ConfirmMappingsImport.scss} +0 -0
- /package/lib/esm/components/Mappings/{ConfirmMappingsImport.scss → Import/ConfirmMappingsImport.scss} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfirmMappingsImport.js","sourceR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,CAC5B;gBACN,6BAAK,SAAS,EAAC,gBAAgB,GAAG,CAC9B,CACP,CAAC,CACE,CACF;QACN,6BAAK,SAAS,EAAC,yBAAyB;YACtC,oBAAC,MAAM,IAAC,OAAO,EAAE,MAAM,WAAe;YACtC,oBAAC,MAAM,IAAC,SAAS,EAAC,iBAAiB,EAAC,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,QAAQ,EAAE,aAE1D;YACT,oBAAC,MAAM,IAAC,OAAO,EAAE,QAAQ,aAAiB,CACtC,CACF,CACP,CACA,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,oBAAoB,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 Button,\n LabeledInput,\n MiddleTextTruncation,\n ProgressLinear,\n Text,\n} from \"@itwin/itwinui-react\";\nimport React, { useEffect, useState } from \"react\";\nimport type { IMappingTyped } from \"../Mappings\";\nimport \"./ConfirmMappingsImport.scss\";\nimport { SvgStatusSuccessHollow } from \"@itwin/itwinui-icons-react\";\nimport useValidator, { NAME_REQUIREMENTS } from \"../../Properties/hooks/useValidator\";\nimport { useMappingClient } from \"../../context/MappingClientContext\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { useMutation } from \"@tanstack/react-query\";\n\nconst defaultDisplayStrings = {\n mappings: \"Mappings\",\n};\n\ninterface ConfirmMappingImportProps {\n sourceiModelId: string;\n selectedMappings: IMappingTyped[];\n importing: boolean;\n setImporting: React.Dispatch<React.SetStateAction<boolean>>;\n setSelectedMappings: React.Dispatch<React.SetStateAction<IMappingTyped[]>>;\n backFn: () => void;\n onCancel: () => void;\n onFinish: () => void;\n displayStrings?: Partial<typeof defaultDisplayStrings>;\n}\n\nconst ConfirmMappingImport = ({\n sourceiModelId,\n selectedMappings,\n importing,\n setImporting,\n setSelectedMappings,\n backFn,\n onCancel,\n onFinish,\n displayStrings: userDisplayStrings,\n}: ConfirmMappingImportProps) => {\n const { getAccessToken, iModelId } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const [importCount, setImportCount] = useState<number>(0);\n const [currentlyImporting, setCurrentlyImporting] = useState<string>(\"\");\n const [validator, showValidationMessage] = useValidator();\n const [errored, setErrored] = useState<boolean>(false);\n\n const displayStrings = React.useMemo(\n () => ({ ...defaultDisplayStrings, ...userDisplayStrings }),\n [userDisplayStrings]\n );\n\n useEffect(() => {\n setSelectedMappings((selectedMappings) =>\n selectedMappings.map((mapping) => ({\n ...mapping,\n mappingName: `${mapping.mappingName}_Copy`,\n })),\n );\n }, [setSelectedMappings]);\n\n const handleChange = (\n e: React.ChangeEvent<HTMLInputElement>,\n index: number,\n ) => {\n const newState = [...selectedMappings];\n newState[index] = {\n ...newState[index],\n mappingName: e.target.value,\n };\n setSelectedMappings(newState);\n };\n\n const importMutation = useMutation({\n mutationFn: async (selectedMapping: IMappingTyped) => {\n const accessToken = await getAccessToken();\n await mappingClient.copyMapping(\n accessToken,\n sourceiModelId,\n selectedMapping.id,\n {\n targetIModelId: iModelId,\n mappingName: selectedMapping.mappingName,\n }\n );\n },\n onMutate: async (selectedMapping: IMappingTyped) => {\n setCurrentlyImporting(selectedMapping.mappingName);\n },\n onSuccess: () => {\n setImportCount((count) => count + 1);\n },\n onError: () => {\n setErrored(true);\n },\n });\n\n const onImport = async () => {\n if (!validator.allValid()) {\n showValidationMessage(true);\n return;\n }\n setImporting(true);\n setImportCount(0);\n for (const mapping of selectedMappings) {\n await importMutation.mutateAsync(mapping);\n }\n };\n\n return (\n <>\n {importing ? (\n <div className='gmw-import-progress-container'>\n <div className='gmw-import-progress-bar'>\n <div className='gmw-import-progress-bar-description'>\n {\n !errored ? importCount !== selectedMappings.length ? (\n <>\n <Text variant='title'>Importing</Text>\n <Text>{`We are currently importing the ${displayStrings.mappings.toLocaleLowerCase()}.`}</Text>\n </>\n ) : (\n <>\n <Text variant='title'>Done!</Text>\n <Text>{`Your imported ${displayStrings.mappings.toLocaleLowerCase()} are ready.`}</Text>\n </>\n ) :\n <>\n <Text variant='title'>Error!</Text>\n <Text>{`Sorry, there was an error importing some or all ${displayStrings.mappings}.`}</Text>\n </>}\n </div>\n <ProgressLinear\n value={(importCount / selectedMappings.length) * 100}\n labels={\n importCount === selectedMappings.length\n ? [\"Import done!\", <SvgStatusSuccessHollow key='0' />]\n : [\n <>\n <Text>Copying</Text>\n <MiddleTextTruncation text={currentlyImporting} />\n </>,\n `${importCount}/${selectedMappings.length}`,\n ]\n }\n status={\n !errored ?\n importCount === selectedMappings.length ? \"positive\" : undefined : \"negative\"\n }\n />\n </div>\n <div className='gmw-import-action-panel'>\n <Button\n disabled={!errored && importCount === selectedMappings.length}\n onClick={() => {\n setImporting(false);\n setImportCount(0);\n setCurrentlyImporting(\"\");\n setErrored(false);\n }}\n >\n Back\n </Button>\n <Button\n styleType='high-visibility'\n disabled={!errored && importCount !== selectedMappings.length}\n onClick={onFinish}\n >\n Close\n </Button>\n </div>\n </div>\n ) : (\n <div className='gmw-rename-confirm-container '>\n <div className='gmw-mapping-rename-container'>\n <div className='gmw-mapping-row-header-container'>\n <div className='gmw-mapping-row'>\n <Text variant='leading'>{displayStrings.mappings}</Text>\n <Text variant='leading'>Description</Text>\n </div>\n </div>\n <div className='gmw-mapping-row-body'>\n {selectedMappings.map((mapping, index) => (\n <div className='gmw-mapping-row-container' key={mapping.id}>\n <div className='gmw-mapping-row'>\n <LabeledInput\n value={mapping.mappingName}\n name={`mapping_${mapping.id}`}\n required\n onChange={(event) => {\n handleChange(event, index);\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n message={validator.message(\n `mapping_${mapping.id}`,\n mapping.mappingName,\n NAME_REQUIREMENTS,\n )}\n status={\n validator.message(\n `mapping_${mapping.id}`,\n mapping.mappingName,\n NAME_REQUIREMENTS,\n )\n ? \"negative\"\n : undefined\n }\n onBlur={() => {\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n onBlurCapture={(event) => {\n handleChange(event, index);\n validator.showMessageFor(`mapping_${mapping.id}`);\n }}\n />\n <div>{mapping.description}</div>\n </div>\n <div className='gmw-border-div' />\n </div>\n ))}\n </div>\n </div>\n <div className='gmw-import-action-panel'>\n <Button onClick={backFn}>Back</Button>\n <Button styleType='high-visibility' onClick={async () => onImport()}>\n Import\n </Button>\n <Button onClick={onCancel}>Cancel</Button>\n </div>\n </div>\n )}\n </>\n );\n};\n\nexport default ConfirmMappingImport;\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Stepper } from "@itwin/itwinui-react";
|
|
2
2
|
import { Modal } from "@itwin/itwinui-react";
|
|
3
3
|
import React, { useEffect, useRef, useState } from "react";
|
|
4
|
-
import ConfirmMappingImport from "
|
|
4
|
+
import ConfirmMappingImport from "./ConfirmMappingsImport";
|
|
5
5
|
import "./MappingImportWizardModal.scss";
|
|
6
6
|
import SelectIModel from "./SelectIModel";
|
|
7
|
-
import SelectITwin from "./SelectITwin";
|
|
7
|
+
import SelectITwin, { ITwinType } from "./SelectITwin";
|
|
8
8
|
import SelectMappings from "./SelectMappings";
|
|
9
9
|
import { useGroupingMappingApiConfig } from "../../context/GroupingApiConfigContext";
|
|
10
10
|
import { createIModelsClient, IModelsClientContext } from "../../context/IModelsClientContext";
|
|
@@ -22,7 +22,7 @@ const defaultDisplayStrings = {
|
|
|
22
22
|
export const MappingImportWizardModal = ({ show, setShow, onFinish, displayStrings: userDisplayStrings, }) => {
|
|
23
23
|
const { prefix } = useGroupingMappingApiConfig();
|
|
24
24
|
const [currentStep, setCurrentStep] = useState(0);
|
|
25
|
-
const [iTwinType, setITwinType] = useState(
|
|
25
|
+
const [iTwinType, setITwinType] = useState(ITwinType.Favorite);
|
|
26
26
|
const [selectedITwinId, setSelectedITwinId] = useState("");
|
|
27
27
|
const [selectedIModelId, setSelectedIModelId] = useState("");
|
|
28
28
|
const [selectedMappings, setSelectedMappings] = useState([]);
|
|
@@ -87,10 +87,7 @@ export const MappingImportWizardModal = ({ show, setShow, onFinish, displayStrin
|
|
|
87
87
|
setSelectedMappings(selectedMappings);
|
|
88
88
|
setCurrentStep(3);
|
|
89
89
|
}, onCancel: onClose, backFn: () => setCurrentStep(currentStep - 1), displayStrings: displayStrings })),
|
|
90
|
-
currentStep === 3 && (React.createElement(ConfirmMappingImport, { sourceiModelId: selectedIModelId, selectedMappings: selectedMappings, importing: importing, setImporting: setImporting, setSelectedMappings: setSelectedMappings, backFn: () => setCurrentStep(currentStep - 1), onCancel: onClose, onFinish:
|
|
91
|
-
await onClose();
|
|
92
|
-
setImporting(false);
|
|
93
|
-
}, displayStrings: displayStrings }))));
|
|
90
|
+
currentStep === 3 && (React.createElement(ConfirmMappingImport, { sourceiModelId: selectedIModelId, selectedMappings: selectedMappings, importing: importing, setImporting: setImporting, setSelectedMappings: setSelectedMappings, backFn: () => setCurrentStep(currentStep - 1), onCancel: onClose, onFinish: onClose, displayStrings: displayStrings }))));
|
|
94
91
|
default:
|
|
95
92
|
return null;
|
|
96
93
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MappingImportWizardModal.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/Import/MappingImportWizardModal.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,oBAAoB,MAAM,0BAA0B,CAAC;AAE5D,OAAO,iCAAiC,CAAC;AACzC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAA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,KAAK,EAAE,EAAE,OAAO,EAAE,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EACvD,SAAS,EAAC,uBAAuB;gCAEjC,oBAAC,cAAc,IACb,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,CAAC,gBAAgB,EAAE,EAAE;wCAC7B,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;wCACtC,cAAc,CAAC,CAAC,CAAC,CAAC;oCACpB,CAAC,EACD,QAAQ,EAAE,OAAO,EACjB,MAAM,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,WAAW,GAAG,CAAC,CAAC,EAC7C,cAAc,EAAE,cAAc,GAC9B,CACE;4BACL,WAAW,KAAK,CAAC,IAAI,CACpB,oBAAC,oBAAoB,IACnB,cAAc,EAAE,gBAAgB,EAChC,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,mBAAmB,EAAE,mBAAmB,EACxC,MAAM,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,WAAW,GAAG,CAAC,CAAC,EAC7C,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,KAAK,IAAI,EAAE;oCACnB,MAAM,OAAO,EAAE,CAAC;oCAChB,YAAY,CAAC,KAAK,CAAC,CAAC;gCACtB,CAAC,EACD,cAAc,EAAE,cAAc,GAC9B,CACH,CACA,CACJ,CAAC;oBACJ;wBACE,OAAO,IAAI,CAAC;iBACf;YACH,CAAC,CAAC,EAAE,CACA,CACA,CACT,CAAC;AACJ,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 type { IModelsClient } from \"@itwin/imodels-client-management\";\nimport type { ITwinsAccessClient } from \"@itwin/itwins-client\";\nimport type { StepProperties } from \"@itwin/itwinui-react\";\nimport { Stepper } from \"@itwin/itwinui-react\";\nimport { Modal } from \"@itwin/itwinui-react\";\nimport React, { useEffect, useRef, useState } from \"react\";\nimport ConfirmMappingImport from \"../ConfirmMappingsImport\";\nimport type { IMappingTyped } from \"../Mappings\";\nimport \"./MappingImportWizardModal.scss\";\nimport SelectIModel from \"./SelectIModel\";\nimport SelectITwin from \"./SelectITwin\";\nimport SelectMappings from \"./SelectMappings\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { createIModelsClient, IModelsClientContext } from \"../../context/IModelsClientContext\";\nimport { createITwinsClient, ITwinsClientContext } from \"../../context/ITwinsClientContext\";\n\nconst defaultDisplayStrings = {\n mappings: \"Mappings\",\n iTwins: \"iTwins\",\n iTwinNumber: \"Number\",\n iTwinName: \"Name\",\n iTwinStatus: \"Status\",\n iModels: \"iModels\",\n iModelName: \"Name\",\n iModelDescription: \"Description\",\n};\ninterface MappingImportWizardModalProps {\n show: boolean;\n setShow: (show: boolean) => void;\n onFinish: () => Promise<void>;\n displayStrings?: Partial<typeof defaultDisplayStrings>;\n}\n\nexport const MappingImportWizardModal = ({\n show,\n setShow,\n onFinish,\n displayStrings: userDisplayStrings,\n}: MappingImportWizardModalProps) => {\n const { prefix } = useGroupingMappingApiConfig();\n const [currentStep, setCurrentStep] = useState<number>(0);\n const [iTwinType, setITwinType] = useState<number>(0);\n const [selectedITwinId, setSelectedITwinId] = useState<string>(\"\");\n const [selectedIModelId, setSelectedIModelId] = useState<string>(\"\");\n const [selectedMappings, setSelectedMappings] = useState<IMappingTyped[]>([]);\n const [importing, setImporting] = useState<boolean>(false);\n const [iTwinsClient, setITwinsClient] = useState<ITwinsAccessClient>(createITwinsClient(prefix));\n const [iModelsClient, setIModelsClient] = useState<IModelsClient>(createIModelsClient(prefix));\n\n useEffect(() => {\n setITwinsClient(createITwinsClient(prefix));\n setIModelsClient(createIModelsClient(prefix));\n }, [prefix]);\n\n const displayStrings = React.useMemo(\n () => ({ ...defaultDisplayStrings, ...userDisplayStrings }),\n [userDisplayStrings]\n );\n\n const steps = useRef<StepProperties[]>([\n {\n name: \"Select iTwin\",\n description: `Select the source iTwin to bring your ${displayStrings.mappings} from.`,\n },\n {\n name: \"Select iModel\",\n description: \"Select an iModel within the iTwin you have selected.\",\n },\n {\n name: `Select ${displayStrings.mappings}`,\n description: `Select one or more ${displayStrings.mappings} to import.`,\n },\n {\n name: \"Rename & Confirm\",\n description:\n \"Rename and confirm your selections. Click import when finished.\",\n },\n ]);\n\n const onClose = async () => {\n setShow(false);\n setCurrentStep(0);\n await onFinish();\n };\n\n return (\n <Modal\n title={`Import ${displayStrings.mappings}`}\n modalRootId='grouping-mapping-widget'\n isOpen={show}\n closeOnEsc={false}\n closeOnExternalClick={false}\n isDismissible={!importing}\n styleType='fullPage'\n onClose={async () => {\n await onClose();\n }}\n >\n <div className='gmw-import-wizard-body-container'>\n <Stepper\n currentStep={currentStep}\n steps={steps.current}\n onStepClick={\n importing ? undefined : (index: number) => setCurrentStep(index)\n }\n />\n\n {(() => {\n switch (currentStep) {\n case 0:\n return (\n <ITwinsClientContext.Provider value={iTwinsClient}>\n <div className=\"gmw-table-container\">\n <SelectITwin\n onSelect={(iTwinId) => {\n setSelectedITwinId(iTwinId);\n setCurrentStep(1);\n }}\n onCancel={onClose}\n onChangeITwinType={setITwinType}\n displayStrings={displayStrings}\n defaultITwinType={iTwinType}\n />\n </div>\n </ITwinsClientContext.Provider>\n );\n case 1:\n return (\n <IModelsClientContext.Provider value={iModelsClient}>\n <div className=\"gmw-table-container\">\n <SelectIModel\n iTwinId={selectedITwinId}\n onSelect={(iModelId) => {\n setSelectedIModelId(iModelId);\n setCurrentStep(2);\n }}\n backFn={() => setCurrentStep(currentStep - 1)}\n onCancel={onClose}\n />\n </div>\n </IModelsClientContext.Provider>\n );\n case 2:\n case 3:\n // Preserve table state within Select Mappings\n return (\n <>\n <div\n style={{ display: currentStep === 2 ? \"flex\" : \"none\" }}\n className=\"gmw-mapping-container\"\n >\n <SelectMappings\n iModelId={selectedIModelId}\n onSelect={(selectedMappings) => {\n setSelectedMappings(selectedMappings);\n setCurrentStep(3);\n }}\n onCancel={onClose}\n backFn={() => setCurrentStep(currentStep - 1)}\n displayStrings={displayStrings}\n />\n </div>\n {currentStep === 3 && (\n <ConfirmMappingImport\n sourceiModelId={selectedIModelId}\n selectedMappings={selectedMappings}\n importing={importing}\n setImporting={setImporting}\n setSelectedMappings={setSelectedMappings}\n backFn={() => setCurrentStep(currentStep - 1)}\n onCancel={onClose}\n onFinish={async () => {\n await onClose();\n setImporting(false);\n }}\n displayStrings={displayStrings}\n />\n )}\n </>\n );\n default:\n return null;\n }\n })()}\n </div>\n </Modal>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"MappingImportWizardModal.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/Import/MappingImportWizardModal.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,iCAAiC,CAAC;AACzC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,WAAW,EAAE,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAE5F,MAAM,qBAAqB,GAAG;IAC5B,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ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gB,EAAE,EAAE;wCAC7B,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;wCACtC,cAAc,CAAC,CAAC,CAAC,CAAC;oCACpB,CAAC,EACD,QAAQ,EAAE,OAAO,EACjB,MAAM,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,WAAW,GAAG,CAAC,CAAC,EAC7C,cAAc,EAAE,cAAc,GAC9B,CACE;4BACL,WAAW,KAAK,CAAC,IAAI,CACpB,oBAAC,oBAAoB,IACnB,cAAc,EAAE,gBAAgB,EAChC,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,mBAAmB,EAAE,mBAAmB,EACxC,MAAM,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,WAAW,GAAG,CAAC,CAAC,EAC7C,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,OAAO,EACjB,cAAc,EAAE,cAAc,GAC9B,CACH,CACA,CACJ,CAAC;oBACJ;wBACE,OAAO,IAAI,CAAC;iBACf;YACH,CAAC,CAAC,EAAE,CACA,CACA,CACT,CAAC;AACJ,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 type { IModelsClient } from \"@itwin/imodels-client-management\";\nimport type { ITwinsAccessClient } from \"@itwin/itwins-client\";\nimport type { StepProperties } from \"@itwin/itwinui-react\";\nimport { Stepper } from \"@itwin/itwinui-react\";\nimport { Modal } from \"@itwin/itwinui-react\";\nimport React, { useEffect, useRef, useState } from \"react\";\nimport ConfirmMappingImport from \"./ConfirmMappingsImport\";\nimport type { IMappingTyped } from \"../Mappings\";\nimport \"./MappingImportWizardModal.scss\";\nimport SelectIModel from \"./SelectIModel\";\nimport SelectITwin, { ITwinType } from \"./SelectITwin\";\nimport SelectMappings from \"./SelectMappings\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { createIModelsClient, IModelsClientContext } from \"../../context/IModelsClientContext\";\nimport { createITwinsClient, ITwinsClientContext } from \"../../context/ITwinsClientContext\";\n\nconst defaultDisplayStrings = {\n mappings: \"Mappings\",\n iTwins: \"iTwins\",\n iTwinNumber: \"Number\",\n iTwinName: \"Name\",\n iTwinStatus: \"Status\",\n iModels: \"iModels\",\n iModelName: \"Name\",\n iModelDescription: \"Description\",\n};\ninterface MappingImportWizardModalProps {\n show: boolean;\n setShow: (show: boolean) => void;\n onFinish: () => Promise<void>;\n displayStrings?: Partial<typeof defaultDisplayStrings>;\n}\n\nexport const MappingImportWizardModal = ({\n show,\n setShow,\n onFinish,\n displayStrings: userDisplayStrings,\n}: MappingImportWizardModalProps) => {\n const { prefix } = useGroupingMappingApiConfig();\n const [currentStep, setCurrentStep] = useState<number>(0);\n const [iTwinType, setITwinType] = useState<ITwinType>(ITwinType.Favorite);\n const [selectedITwinId, setSelectedITwinId] = useState<string>(\"\");\n const [selectedIModelId, setSelectedIModelId] = useState<string>(\"\");\n const [selectedMappings, setSelectedMappings] = useState<IMappingTyped[]>([]);\n const [importing, setImporting] = useState<boolean>(false);\n const [iTwinsClient, setITwinsClient] = useState<ITwinsAccessClient>(createITwinsClient(prefix));\n const [iModelsClient, setIModelsClient] = useState<IModelsClient>(createIModelsClient(prefix));\n\n useEffect(() => {\n setITwinsClient(createITwinsClient(prefix));\n setIModelsClient(createIModelsClient(prefix));\n }, [prefix]);\n\n const displayStrings = React.useMemo(\n () => ({ ...defaultDisplayStrings, ...userDisplayStrings }),\n [userDisplayStrings]\n );\n\n const steps = useRef<StepProperties[]>([\n {\n name: \"Select iTwin\",\n description: `Select the source iTwin to bring your ${displayStrings.mappings} from.`,\n },\n {\n name: \"Select iModel\",\n description: \"Select an iModel within the iTwin you have selected.\",\n },\n {\n name: `Select ${displayStrings.mappings}`,\n description: `Select one or more ${displayStrings.mappings} to import.`,\n },\n {\n name: \"Rename & Confirm\",\n description:\n \"Rename and confirm your selections. Click import when finished.\",\n },\n ]);\n\n const onClose = async () => {\n setShow(false);\n setCurrentStep(0);\n await onFinish();\n };\n\n return (\n <Modal\n title={`Import ${displayStrings.mappings}`}\n modalRootId='grouping-mapping-widget'\n isOpen={show}\n closeOnEsc={false}\n closeOnExternalClick={false}\n isDismissible={!importing}\n styleType='fullPage'\n onClose={async () => {\n await onClose();\n }}\n >\n <div className='gmw-import-wizard-body-container'>\n <Stepper\n currentStep={currentStep}\n steps={steps.current}\n onStepClick={\n importing ? undefined : (index: number) => setCurrentStep(index)\n }\n />\n\n {(() => {\n switch (currentStep) {\n case 0:\n return (\n <ITwinsClientContext.Provider value={iTwinsClient}>\n <div className=\"gmw-table-container\">\n <SelectITwin\n onSelect={(iTwinId) => {\n setSelectedITwinId(iTwinId);\n setCurrentStep(1);\n }}\n onCancel={onClose}\n onChangeITwinType={setITwinType}\n displayStrings={displayStrings}\n defaultITwinType={iTwinType}\n />\n </div>\n </ITwinsClientContext.Provider>\n );\n case 1:\n return (\n <IModelsClientContext.Provider value={iModelsClient}>\n <div className=\"gmw-table-container\">\n <SelectIModel\n iTwinId={selectedITwinId}\n onSelect={(iModelId) => {\n setSelectedIModelId(iModelId);\n setCurrentStep(2);\n }}\n backFn={() => setCurrentStep(currentStep - 1)}\n onCancel={onClose}\n />\n </div>\n </IModelsClientContext.Provider>\n );\n case 2:\n case 3:\n // Preserve table state within Select Mappings\n return (\n <>\n <div\n style={{ display: currentStep === 2 ? \"flex\" : \"none\" }}\n className=\"gmw-mapping-container\"\n >\n <SelectMappings\n iModelId={selectedIModelId}\n onSelect={(selectedMappings) => {\n setSelectedMappings(selectedMappings);\n setCurrentStep(3);\n }}\n onCancel={onClose}\n backFn={() => setCurrentStep(currentStep - 1)}\n displayStrings={displayStrings}\n />\n </div>\n {currentStep === 3 && (\n <ConfirmMappingImport\n sourceiModelId={selectedIModelId}\n selectedMappings={selectedMappings}\n importing={importing}\n setImporting={setImporting}\n setSelectedMappings={setSelectedMappings}\n backFn={() => setCurrentStep(currentStep - 1)}\n onCancel={onClose}\n onFinish={onClose}\n displayStrings={displayStrings}\n />\n )}\n </>\n );\n default:\n return null;\n }\n })()}\n </div>\n </Modal>\n );\n};\n"]}
|
|
@@ -1,70 +1,51 @@
|
|
|
1
1
|
import { Button, Table, tableFilters, TablePaginator } from "@itwin/itwinui-react";
|
|
2
|
-
import React, { useCallback,
|
|
2
|
+
import React, { useCallback, useMemo } from "react";
|
|
3
3
|
import "./SelectIModel.scss";
|
|
4
4
|
import { useGroupingMappingApiConfig } from "../../context/GroupingApiConfigContext";
|
|
5
5
|
import { useIModelsClient } from "../../context/IModelsClientContext";
|
|
6
|
-
import {
|
|
6
|
+
import { useQuery } from "@tanstack/react-query";
|
|
7
|
+
import { AccessTokenAdapter } from "@itwin/imodels-access-frontend";
|
|
7
8
|
const defaultDisplayStrings = {
|
|
8
9
|
iModels: "iModels",
|
|
9
10
|
iModelName: "Name",
|
|
10
11
|
iModelDescription: "Description",
|
|
11
12
|
};
|
|
12
|
-
const fetchIModels = async (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
urlParams: {
|
|
26
|
-
iTwinId,
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
const iModels = [];
|
|
30
|
-
for await (const iModel of iModelIterator) {
|
|
31
|
-
iModels.push(iModel);
|
|
32
|
-
}
|
|
33
|
-
setIModels(iModels);
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
handleError(error.status);
|
|
37
|
-
}
|
|
38
|
-
finally {
|
|
39
|
-
setIsLoading(false);
|
|
13
|
+
const fetchIModels = async (getAccessToken, iTwinId, iModelsClient) => {
|
|
14
|
+
const accessToken = await getAccessToken();
|
|
15
|
+
const authorization = AccessTokenAdapter.toAuthorizationCallback(accessToken);
|
|
16
|
+
const iModelIterator = iModelsClient.iModels.getRepresentationList({
|
|
17
|
+
authorization,
|
|
18
|
+
urlParams: {
|
|
19
|
+
iTwinId,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
const iModels = [];
|
|
23
|
+
for await (const iModel of iModelIterator) {
|
|
24
|
+
iModels.push(iModel);
|
|
40
25
|
}
|
|
26
|
+
return iModels;
|
|
41
27
|
};
|
|
42
28
|
const SelectIModel = ({ iTwinId: iTwinId, onSelect, onCancel, backFn, displayStrings: userDisplayStrings, }) => {
|
|
43
29
|
const { getAccessToken } = useGroupingMappingApiConfig();
|
|
44
30
|
const iModelsClient = useIModelsClient();
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
31
|
+
const { data: iModels, isFetching: isLoading } = useQuery({
|
|
32
|
+
queryKey: ["iModels", iTwinId],
|
|
33
|
+
queryFn: async () => fetchIModels(getAccessToken, iTwinId, iModelsClient),
|
|
34
|
+
initialData: [],
|
|
35
|
+
});
|
|
50
36
|
const displayStrings = React.useMemo(() => ({ ...defaultDisplayStrings, ...userDisplayStrings }), [userDisplayStrings]);
|
|
51
37
|
const iModelsColumns = useMemo(() => [
|
|
52
38
|
{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
Header: `${displayStrings.iModelDescription}`,
|
|
64
|
-
accessor: "description",
|
|
65
|
-
Filter: tableFilters.TextFilter(),
|
|
66
|
-
},
|
|
67
|
-
],
|
|
39
|
+
id: "iModelName",
|
|
40
|
+
Header: `${displayStrings.iModelName}`,
|
|
41
|
+
accessor: "name",
|
|
42
|
+
Filter: tableFilters.TextFilter(),
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: "iModelDescription",
|
|
46
|
+
Header: `${displayStrings.iModelDescription}`,
|
|
47
|
+
accessor: "description",
|
|
48
|
+
Filter: tableFilters.TextFilter(),
|
|
68
49
|
},
|
|
69
50
|
], [displayStrings.iModelName, displayStrings.iModelDescription]);
|
|
70
51
|
const pageSizeList = useMemo(() => [10, 25, 50], []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectIModel.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/Import/SelectIModel.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"SelectIModel.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/Import/SelectIModel.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,qBAAqB,CAAC;AAE7B,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIpE,MAAM,qBAAqB,GAAG;IAC5B,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,MAAM;IAClB,iBAAiB,EAAE,aAAa;CACjC,CAAC;AAEF,MAAM,YAAY,GAAG,KAAK,EACxB,cAAgC,EAChC,OAAe,EACf,aAA4B,EAC5B,EAAE;IACF,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAC;IAC3C,MAAM,aAAa,GAAG,kBAAkB,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;I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AAG,cAAc,CAAC,iBAAiB,EAAE;YAC7C,QAAQ,EAAE,aAAa;YACvB,MAAM,EAAE,YAAY,CAAC,UAAU,EAAE;SAClC;KACF,EACD,CAAC,cAAc,CAAC,UAAU,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAC9D,CAAC;IAEF,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACrD,MAAM,SAAS,GAAG,WAAW,CAC3B,CAAC,KAAkC,EAAE,EAAE,CAAC,CACtC,oBAAC,cAAc,OAAK,KAAK,EAAE,YAAY,EAAE,YAAY,GAAI,CAC1D,EACD,CAAC,YAAY,CAAC,CACf,CAAC;IAEF,OAAO,CACL,6BAAK,SAAS,EAAC,mCAAmC;QAChD,oBAAC,KAAK,IACJ,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,cAAc,EACvB,SAAS,EAAC,yBAAyB,EACnC,iBAAiB,EAAE,MAAM,cAAc,CAAC,OAAO,aAAa,EAC5D,UAAU,QACV,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE;gBACrB,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YAC5B,CAAC,EACD,iBAAiB,EAAE,SAAS,GAC5B;QACF,6BAAK,SAAS,EAAC,yBAAyB;YACtC,oBAAC,MAAM,IAAC,OAAO,EAAE,MAAM,WAAe;YACtC,oBAAC,MAAM,IAAC,OAAO,EAAE,QAAQ,aAAiB,CACtC,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,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 type { IModel, IModelsClient } from \"@itwin/imodels-client-management\";\nimport type { TablePaginatorRendererProps } from \"@itwin/itwinui-react\";\nimport { Button, Table, tableFilters, TablePaginator } from \"@itwin/itwinui-react\";\nimport React, { useCallback, useMemo } from \"react\";\nimport type { CreateTypeFromInterface } from \"../../../common/utils\";\nimport \"./SelectIModel.scss\";\nimport type { GetAccessTokenFn } from \"../../context/GroupingApiConfigContext\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { useIModelsClient } from \"../../context/IModelsClientContext\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport type { Column } from \"react-table\";\nimport { AccessTokenAdapter } from \"@itwin/imodels-access-frontend\";\n\ntype IIModelTyped = CreateTypeFromInterface<IModel>;\n\nconst defaultDisplayStrings = {\n iModels: \"iModels\",\n iModelName: \"Name\",\n iModelDescription: \"Description\",\n};\n\nconst fetchIModels = async (\n getAccessToken: GetAccessTokenFn,\n iTwinId: string,\n iModelsClient: IModelsClient,\n) => {\n const accessToken = await getAccessToken();\n const authorization = AccessTokenAdapter.toAuthorizationCallback(accessToken);\n const iModelIterator = iModelsClient.iModels.getRepresentationList({\n authorization,\n urlParams: {\n iTwinId,\n },\n });\n\n const iModels = [];\n for await (const iModel of iModelIterator) {\n iModels.push(iModel);\n }\n return iModels;\n};\n\ninterface SelectIModelProps {\n iTwinId: string;\n onSelect: (iModelId: string) => void;\n onCancel: () => void;\n backFn: () => void;\n displayStrings?: Partial<typeof defaultDisplayStrings>;\n}\nconst SelectIModel = ({\n iTwinId: iTwinId,\n onSelect,\n onCancel,\n backFn,\n displayStrings: userDisplayStrings,\n}: SelectIModelProps) => {\n const { getAccessToken } = useGroupingMappingApiConfig();\n const iModelsClient = useIModelsClient();\n\n const { data: iModels, isFetching: isLoading } = useQuery({\n queryKey: [\"iModels\", iTwinId],\n queryFn: async () => fetchIModels(getAccessToken, iTwinId, iModelsClient),\n initialData: [],\n });\n\n const displayStrings = React.useMemo(\n () => ({ ...defaultDisplayStrings, ...userDisplayStrings }),\n [userDisplayStrings]\n );\n\n const iModelsColumns = useMemo<Column<IIModelTyped>[]>(\n () => [\n {\n id: \"iModelName\",\n Header: `${displayStrings.iModelName}`,\n accessor: \"name\",\n Filter: tableFilters.TextFilter(),\n },\n {\n id: \"iModelDescription\",\n Header: `${displayStrings.iModelDescription}`,\n accessor: \"description\",\n Filter: tableFilters.TextFilter(),\n },\n ],\n [displayStrings.iModelName, displayStrings.iModelDescription]\n );\n\n const pageSizeList = useMemo(() => [10, 25, 50], []);\n const paginator = useCallback(\n (props: TablePaginatorRendererProps) => (\n <TablePaginator {...props} pageSizeList={pageSizeList} />\n ),\n [pageSizeList]\n );\n\n return (\n <div className='gmw-select-imodel-table-container'>\n <Table<IIModelTyped>\n data={iModels}\n columns={iModelsColumns}\n className='gmw-select-imodel-table'\n emptyTableContent={`No ${displayStrings.iModels} available.`}\n isSortable\n isLoading={isLoading}\n onRowClick={(_, row) => {\n onSelect(row.original.id);\n }}\n paginatorRenderer={paginator}\n />\n <div className='gmw-import-action-panel'>\n <Button onClick={backFn}>Back</Button>\n <Button onClick={onCancel}>Cancel</Button>\n </div>\n </div>\n );\n};\n\nexport default SelectIModel;\n"]}
|
|
@@ -6,12 +6,17 @@ declare const defaultDisplayStrings: {
|
|
|
6
6
|
iTwinName: string;
|
|
7
7
|
iTwinStatus: string;
|
|
8
8
|
};
|
|
9
|
+
export declare enum ITwinType {
|
|
10
|
+
Favorite = 0,
|
|
11
|
+
Recent = 1,
|
|
12
|
+
All = 2
|
|
13
|
+
}
|
|
9
14
|
interface SelectITwinProps {
|
|
10
15
|
onSelect: (iTwinId: string) => void;
|
|
11
16
|
onCancel: () => void;
|
|
12
17
|
onChangeITwinType: (iTwinType: number) => void;
|
|
13
18
|
displayStrings?: Partial<typeof defaultDisplayStrings>;
|
|
14
|
-
defaultITwinType?:
|
|
19
|
+
defaultITwinType?: ITwinType;
|
|
15
20
|
}
|
|
16
21
|
declare const SelectITwin: ({ onSelect, onCancel, onChangeITwinType, displayStrings: userDisplayStrings, defaultITwinType, }: SelectITwinProps) => JSX.Element;
|
|
17
22
|
export default SelectITwin;
|
|
@@ -1,80 +1,66 @@
|
|
|
1
1
|
import { ITwinSubClass } from "@itwin/itwins-client";
|
|
2
2
|
import { SvgCalendar, SvgList, SvgStarHollow } from "@itwin/itwinui-icons-react";
|
|
3
3
|
import { Button, Tab, Table, tableFilters, TablePaginator, Tabs } from "@itwin/itwinui-react";
|
|
4
|
-
import React, { useCallback,
|
|
4
|
+
import React, { useCallback, useMemo, useState } from "react";
|
|
5
5
|
import "./SelectITwin.scss";
|
|
6
6
|
import { useGroupingMappingApiConfig } from "../../context/GroupingApiConfigContext";
|
|
7
7
|
import { useITwinsClient } from "../../context/ITwinsClientContext";
|
|
8
|
-
import {
|
|
8
|
+
import { useQuery } from "@tanstack/react-query";
|
|
9
9
|
const defaultDisplayStrings = {
|
|
10
10
|
iTwins: "iTwins",
|
|
11
11
|
iTwinNumber: "Number",
|
|
12
12
|
iTwinName: "Name",
|
|
13
13
|
iTwinStatus: "Status",
|
|
14
14
|
};
|
|
15
|
+
export var ITwinType;
|
|
16
|
+
(function (ITwinType) {
|
|
17
|
+
ITwinType[ITwinType["Favorite"] = 0] = "Favorite";
|
|
18
|
+
ITwinType[ITwinType["Recent"] = 1] = "Recent";
|
|
19
|
+
ITwinType[ITwinType["All"] = 2] = "All";
|
|
20
|
+
})(ITwinType || (ITwinType = {}));
|
|
15
21
|
const tabsWithIcons = [
|
|
16
22
|
React.createElement(Tab, { key: "favorite", label: "Favorite iTwins", startIcon: React.createElement(SvgStarHollow, null) }),
|
|
17
23
|
React.createElement(Tab, { key: "recents", label: "Recent iTwins", startIcon: React.createElement(SvgCalendar, null) }),
|
|
18
24
|
React.createElement(Tab, { key: "all", label: "My iTwins", startIcon: React.createElement(SvgList, null) }),
|
|
19
25
|
];
|
|
20
|
-
const fetchITwins = async (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
break;
|
|
30
|
-
case 1:
|
|
31
|
-
iTwinsResponse = await iTwinsClient.queryRecentsAsync(accessToken, ITwinSubClass.Project);
|
|
32
|
-
break;
|
|
33
|
-
default:
|
|
34
|
-
iTwinsResponse = await iTwinsClient.queryAsync(accessToken, ITwinSubClass.Project);
|
|
35
|
-
}
|
|
36
|
-
setITwins(iTwinsResponse.data);
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
handleError(error.status);
|
|
40
|
-
}
|
|
41
|
-
finally {
|
|
42
|
-
setIsLoading(false);
|
|
26
|
+
const fetchITwins = async (getAccessToken, iTwinsClient, iTwinType) => {
|
|
27
|
+
const accessToken = await getAccessToken();
|
|
28
|
+
switch (iTwinType) {
|
|
29
|
+
case ITwinType.Favorite:
|
|
30
|
+
return iTwinsClient.queryFavoritesAsync(accessToken, ITwinSubClass.Project);
|
|
31
|
+
case ITwinType.Recent:
|
|
32
|
+
return iTwinsClient.queryRecentsAsync(accessToken, ITwinSubClass.Project);
|
|
33
|
+
default:
|
|
34
|
+
return iTwinsClient.queryAsync(accessToken, ITwinSubClass.Project);
|
|
43
35
|
}
|
|
44
36
|
};
|
|
45
|
-
const SelectITwin = ({ onSelect, onCancel, onChangeITwinType, displayStrings: userDisplayStrings, defaultITwinType =
|
|
37
|
+
const SelectITwin = ({ onSelect, onCancel, onChangeITwinType, displayStrings: userDisplayStrings, defaultITwinType = ITwinType.Favorite, }) => {
|
|
46
38
|
const { getAccessToken } = useGroupingMappingApiConfig();
|
|
47
39
|
const iTwinsClient = useITwinsClient();
|
|
48
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
49
|
-
const [iTwins, setITwins] = useState([]);
|
|
50
40
|
const [iTwinType, setITwinType] = useState(defaultITwinType);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
const { data: iTwins, isFetching: isLoading } = useQuery({
|
|
42
|
+
queryKey: ["iTwinsByType", iTwinType],
|
|
43
|
+
queryFn: async () => (await fetchITwins(getAccessToken, iTwinsClient, iTwinType)).data,
|
|
44
|
+
});
|
|
54
45
|
const displayStrings = React.useMemo(() => ({ ...defaultDisplayStrings, ...userDisplayStrings }), [userDisplayStrings]);
|
|
55
46
|
const iTwinsColumns = useMemo(() => [
|
|
56
47
|
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
Header: `${displayStrings.iTwinStatus}`,
|
|
74
|
-
accessor: "status",
|
|
75
|
-
Filter: tableFilters.TextFilter(),
|
|
76
|
-
},
|
|
77
|
-
],
|
|
48
|
+
id: "iTwinNumber",
|
|
49
|
+
Header: `${displayStrings.iTwinNumber}`,
|
|
50
|
+
accessor: "number",
|
|
51
|
+
Filter: tableFilters.TextFilter(),
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "iTwinName",
|
|
55
|
+
Header: `${displayStrings.iTwinName}`,
|
|
56
|
+
accessor: "displayName",
|
|
57
|
+
Filter: tableFilters.TextFilter(),
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: "iTwinStatus",
|
|
61
|
+
Header: `${displayStrings.iTwinStatus}`,
|
|
62
|
+
accessor: "status",
|
|
63
|
+
Filter: tableFilters.TextFilter(),
|
|
78
64
|
},
|
|
79
65
|
], [displayStrings.iTwinNumber, displayStrings.iTwinName, displayStrings.iTwinStatus]);
|
|
80
66
|
const pageSizeList = useMemo(() => [10, 25, 50], []);
|
|
@@ -84,7 +70,7 @@ const SelectITwin = ({ onSelect, onCancel, onChangeITwinType, displayStrings: us
|
|
|
84
70
|
onChangeITwinType(type);
|
|
85
71
|
setITwinType(type);
|
|
86
72
|
}, activeIndex: iTwinType, type: "borderless", contentClassName: "gmw-table-holding-tab" }),
|
|
87
|
-
React.createElement(Table, { data: iTwins, columns: iTwinsColumns, className: 'gmw-select-itwin-table', emptyTableContent: `No ${displayStrings.iTwins} available.`, isSortable: true, isLoading: isLoading, onRowClick: (_, row) => {
|
|
73
|
+
React.createElement(Table, { data: iTwins ?? [], columns: iTwinsColumns, className: 'gmw-select-itwin-table', emptyTableContent: `No ${displayStrings.iTwins} available.`, isSortable: true, isLoading: isLoading, onRowClick: (_, row) => {
|
|
88
74
|
onSelect(row.original.id);
|
|
89
75
|
}, paginatorRenderer: paginator }),
|
|
90
76
|
React.createElement("div", { className: "gmw-import-action-panel" },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectITwin.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/Import/SelectITwin.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEjF,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"SelectITwin.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/Import/SelectITwin.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEjF,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE9D,OAAO,oBAAoB,CA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C,MAAM,IAAC,OAAO,EAAE,QAAQ,aAAiB,CACtC,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,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 type { ITwin, ITwinsAccessClient } from \"@itwin/itwins-client\";\nimport { ITwinSubClass } from \"@itwin/itwins-client\";\nimport { SvgCalendar, SvgList, SvgStarHollow } from \"@itwin/itwinui-icons-react\";\nimport type { TablePaginatorRendererProps } from \"@itwin/itwinui-react\";\nimport { Button, Tab, Table, tableFilters, TablePaginator, Tabs } from \"@itwin/itwinui-react\";\nimport React, { useCallback, useMemo, useState } from \"react\";\nimport type { CreateTypeFromInterface } from \"../../../common/utils\";\nimport \"./SelectITwin.scss\";\nimport type { GetAccessTokenFn } from \"../../context/GroupingApiConfigContext\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { useITwinsClient } from \"../../context/ITwinsClientContext\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport type { Column } from \"react-table\";\n\ntype IITwinTyped = CreateTypeFromInterface<ITwin>;\n\nconst defaultDisplayStrings = {\n iTwins: \"iTwins\",\n iTwinNumber: \"Number\",\n iTwinName: \"Name\",\n iTwinStatus: \"Status\",\n};\n\nexport enum ITwinType {\n Favorite = 0,\n Recent = 1,\n All = 2,\n}\n\nconst tabsWithIcons = [\n <Tab key=\"favorite\" label=\"Favorite iTwins\" startIcon={<SvgStarHollow />} />,\n <Tab key=\"recents\" label=\"Recent iTwins\" startIcon={<SvgCalendar />} />,\n <Tab key=\"all\" label=\"My iTwins\" startIcon={<SvgList />} />,\n];\n\nconst fetchITwins = async (\n getAccessToken: GetAccessTokenFn,\n iTwinsClient: ITwinsAccessClient,\n iTwinType: ITwinType,\n) => {\n const accessToken = await getAccessToken();\n switch (iTwinType) {\n case ITwinType.Favorite:\n return iTwinsClient.queryFavoritesAsync(accessToken, ITwinSubClass.Project);\n case ITwinType.Recent:\n return iTwinsClient.queryRecentsAsync(accessToken, ITwinSubClass.Project);\n default:\n return iTwinsClient.queryAsync(accessToken, ITwinSubClass.Project);\n }\n};\n\ninterface SelectITwinProps {\n onSelect: (iTwinId: string) => void;\n onCancel: () => void;\n onChangeITwinType: (iTwinType: number) => void;\n displayStrings?: Partial<typeof defaultDisplayStrings>;\n defaultITwinType?: ITwinType;\n}\n\nconst SelectITwin = ({\n onSelect,\n onCancel,\n onChangeITwinType,\n displayStrings: userDisplayStrings,\n defaultITwinType = ITwinType.Favorite,\n}: SelectITwinProps) => {\n const { getAccessToken } = useGroupingMappingApiConfig();\n const iTwinsClient = useITwinsClient();\n const [iTwinType, setITwinType] = useState<number>(defaultITwinType);\n\n const { data: iTwins, isFetching: isLoading } = useQuery({\n queryKey: [\"iTwinsByType\", iTwinType],\n queryFn: async () => (await fetchITwins(getAccessToken, iTwinsClient, iTwinType)).data!,\n });\n\n const displayStrings = React.useMemo(\n () => ({ ...defaultDisplayStrings, ...userDisplayStrings }),\n [userDisplayStrings]\n );\n\n const iTwinsColumns = useMemo<Column<IITwinTyped>[]>(\n () => [\n {\n id: \"iTwinNumber\",\n Header: `${displayStrings.iTwinNumber}`,\n accessor: \"number\",\n Filter: tableFilters.TextFilter(),\n },\n {\n id: \"iTwinName\",\n Header: `${displayStrings.iTwinName}`,\n accessor: \"displayName\",\n Filter: tableFilters.TextFilter(),\n },\n {\n id: \"iTwinStatus\",\n Header: `${displayStrings.iTwinStatus}`,\n accessor: \"status\",\n Filter: tableFilters.TextFilter(),\n },\n ],\n [displayStrings.iTwinNumber, displayStrings.iTwinName, displayStrings.iTwinStatus]\n );\n\n const pageSizeList = useMemo(() => [10, 25, 50], []);\n const paginator = useCallback(\n (props: TablePaginatorRendererProps) => (\n <TablePaginator {...props} pageSizeList={pageSizeList} />\n ),\n [pageSizeList]\n );\n\n return (\n <div className=\"gmw-select-itwin-table-container\">\n <Tabs\n orientation=\"horizontal\"\n labels={tabsWithIcons}\n onTabSelected={(type) => {\n onChangeITwinType(type);\n setITwinType(type);\n }}\n activeIndex={iTwinType}\n type={\"borderless\"}\n contentClassName=\"gmw-table-holding-tab\">\n </Tabs>\n <Table<IITwinTyped>\n data={iTwins ?? []}\n columns={iTwinsColumns}\n className='gmw-select-itwin-table'\n emptyTableContent={`No ${displayStrings.iTwins} available.`}\n isSortable\n isLoading={isLoading}\n onRowClick={(_, row) => {\n onSelect(row.original.id!);\n }}\n paginatorRenderer={paginator}\n />\n <div className=\"gmw-import-action-panel\">\n <Button onClick={onCancel}>Cancel</Button>\n </div>\n </div>\n );\n};\n\nexport default SelectITwin;\n"]}
|
|
@@ -1,59 +1,36 @@
|
|
|
1
1
|
import { Button, Table, tableFilters, TablePaginator, } from "@itwin/itwinui-react";
|
|
2
|
-
import React, { useCallback,
|
|
2
|
+
import React, { useCallback, useMemo, useState } from "react";
|
|
3
3
|
import { useMappingClient } from "../../context/MappingClientContext";
|
|
4
4
|
import "./SelectMapping.scss";
|
|
5
|
-
import { handleError } from "../../../common/utils";
|
|
6
5
|
import { useGroupingMappingApiConfig } from "../../context/GroupingApiConfigContext";
|
|
6
|
+
import { useFetchMappings } from "../hooks/useFetchMappings";
|
|
7
7
|
const defaultDisplayStrings = {
|
|
8
8
|
mappings: "Mappings",
|
|
9
9
|
};
|
|
10
|
-
const fetchMappings = async (setMappings, iModelId, setIsLoading, getAccessToken, mappingsClient) => {
|
|
11
|
-
try {
|
|
12
|
-
setIsLoading(true);
|
|
13
|
-
const accessToken = await getAccessToken();
|
|
14
|
-
const mappings = await mappingsClient.getMappings(accessToken, iModelId);
|
|
15
|
-
setMappings(mappings);
|
|
16
|
-
}
|
|
17
|
-
catch (error) {
|
|
18
|
-
handleError(error.status);
|
|
19
|
-
}
|
|
20
|
-
finally {
|
|
21
|
-
setIsLoading(false);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
10
|
const SelectMappings = ({ iModelId, onSelect, onCancel, backFn, displayStrings: userDisplayStrings, }) => {
|
|
25
11
|
const { getAccessToken } = useGroupingMappingApiConfig();
|
|
26
12
|
const mappingClient = useMappingClient();
|
|
27
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
28
13
|
const [selectedMappings, setSelectedMappings] = useState([]);
|
|
29
|
-
const
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
void fetchMappings(setMappings, iModelId, setIsLoading, getAccessToken, mappingClient);
|
|
32
|
-
}, [getAccessToken, mappingClient, iModelId, setIsLoading]);
|
|
14
|
+
const { data: mappings, isFetching: isLoading, } = useFetchMappings(iModelId, getAccessToken, mappingClient);
|
|
33
15
|
const displayStrings = React.useMemo(() => ({ ...defaultDisplayStrings, ...userDisplayStrings }), [userDisplayStrings]);
|
|
34
16
|
const mappingsColumns = useMemo(() => [
|
|
35
17
|
{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
Header: "Description",
|
|
47
|
-
accessor: "description",
|
|
48
|
-
Filter: tableFilters.TextFilter(),
|
|
49
|
-
},
|
|
50
|
-
],
|
|
18
|
+
id: "mappingName",
|
|
19
|
+
Header: `${displayStrings.mappings}`,
|
|
20
|
+
accessor: "mappingName",
|
|
21
|
+
Filter: tableFilters.TextFilter(),
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: "description",
|
|
25
|
+
Header: "Description",
|
|
26
|
+
accessor: "description",
|
|
27
|
+
Filter: tableFilters.TextFilter(),
|
|
51
28
|
},
|
|
52
29
|
], [displayStrings.mappings]);
|
|
53
30
|
const pageSizeList = useMemo(() => [10, 25, 50], []);
|
|
54
31
|
const paginator = useCallback((props) => (React.createElement(TablePaginator, { ...props, pageSizeList: pageSizeList })), [pageSizeList]);
|
|
55
32
|
return (React.createElement("div", { className: 'gmw-select-mapping-container' },
|
|
56
|
-
React.createElement(Table, { data: mappings, columns: mappingsColumns, className: 'gmw-select-mapping-table', emptyTableContent: `No ${displayStrings.mappings} available.`, isSortable: true, isSelectable: true, isLoading: isLoading, onSelect: (selectData) => {
|
|
33
|
+
React.createElement(Table, { data: mappings ?? [], columns: mappingsColumns, className: 'gmw-select-mapping-table', emptyTableContent: `No ${displayStrings.mappings} available.`, isSortable: true, isSelectable: true, isLoading: isLoading, onSelect: (selectData) => {
|
|
57
34
|
selectData && setSelectedMappings(selectData);
|
|
58
35
|
}, paginatorRenderer: paginator }),
|
|
59
36
|
React.createElement("div", { className: 'gmw-import-action-panel' },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectMappings.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/Import/SelectMappings.tsx"],"names":[],"mappings":"AAOA,OAAO,EACL,MAAM,EACN,KAAK,EACL,YAAY,EACZ,cAAc,GACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"SelectMappings.js","sourceRoot":"","sources":["../../../../../src/components/Mappings/Import/SelectMappings.tsx"],"names":[],"mappings":"AAOA,OAAO,EACL,MAAM,EACN,KAAK,EACL,YAAY,EACZ,cAAc,GACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,sBAAsB,CAAC;AAC9B,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAG7D,MAAM,qBAAqB,GAAG;IAC5B,QAAQ,EAAE,UAAU;CACrB,CAAC;AAUF,MAAM,cAAc,GAAG,CAAC,EACtB,QAAQ,EACR,QAAQ,EACR,QAA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L,6BAAK,SAAS,EAAC,8BAA8B;QAC3C,oBAAC,KAAK,IACJ,IAAI,EAAE,QAAQ,IAAI,EAAE,EACpB,OAAO,EAAE,eAAe,EACxB,SAAS,EAAC,0BAA0B,EACpC,iBAAiB,EAAE,MAAM,cAAc,CAAC,QAAQ,aAAa,EAC7D,UAAU,QACV,YAAY,QACZ,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,CAAC,UAAuC,EAAE,EAAE;gBACpD,UAAU,IAAI,mBAAmB,CAAC,UAAU,CAAC,CAAC;YAChD,CAAC,EACD,iBAAiB,EAAE,SAAS,GAC5B;QACF,6BAAK,SAAS,EAAC,yBAAyB;YACtC,oBAAC,MAAM,IAAC,OAAO,EAAE,MAAM,WAAe;YACtC,oBAAC,MAAM,IACL,SAAS,EAAC,iBAAiB,EAC3B,OAAO,EAAE,GAAG,EAAE;oBACZ,QAAQ,CAAC,gBAAgB,CAAC,CAAC;gBAC7B,CAAC,EACD,QAAQ,EAAE,SAAS,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,WAG7C;YACT,oBAAC,MAAM,IAAC,OAAO,EAAE,QAAQ,aAAiB,CACtC,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,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 type {\n TablePaginatorRendererProps,\n} from \"@itwin/itwinui-react\";\nimport {\n Button,\n Table,\n tableFilters,\n TablePaginator,\n} from \"@itwin/itwinui-react\";\nimport React, { useCallback, useMemo, useState } from \"react\";\nimport { useMappingClient } from \"../../context/MappingClientContext\";\nimport type { IMappingTyped } from \"../Mappings\";\nimport \"./SelectMapping.scss\";\nimport { useGroupingMappingApiConfig } from \"../../context/GroupingApiConfigContext\";\nimport { useFetchMappings } from \"../hooks/useFetchMappings\";\nimport type { Column } from \"react-table\";\n\nconst defaultDisplayStrings = {\n mappings: \"Mappings\",\n};\n\ninterface SelectMappingsProps {\n iModelId: string;\n onSelect: (selectedMappings: IMappingTyped[]) => void;\n onCancel: () => void;\n backFn: () => void;\n displayStrings?: Partial<typeof defaultDisplayStrings>;\n}\n\nconst SelectMappings = ({\n iModelId,\n onSelect,\n onCancel,\n backFn,\n displayStrings: userDisplayStrings,\n}: SelectMappingsProps) => {\n const { getAccessToken } = useGroupingMappingApiConfig();\n const mappingClient = useMappingClient();\n const [selectedMappings, setSelectedMappings] = useState<IMappingTyped[]>([]);\n\n const {\n data: mappings,\n isFetching: isLoading,\n } = useFetchMappings(iModelId, getAccessToken, mappingClient);\n\n const displayStrings = React.useMemo(\n () => ({ ...defaultDisplayStrings, ...userDisplayStrings }),\n [userDisplayStrings]\n );\n\n const mappingsColumns = useMemo<Column<IMappingTyped>[]>(\n () => [\n {\n id: \"mappingName\",\n Header: `${displayStrings.mappings}`,\n accessor: \"mappingName\",\n Filter: tableFilters.TextFilter(),\n },\n {\n id: \"description\",\n Header: \"Description\",\n accessor: \"description\",\n Filter: tableFilters.TextFilter(),\n },\n ],\n [displayStrings.mappings]\n );\n\n const pageSizeList = useMemo(() => [10, 25, 50], []);\n const paginator = useCallback(\n (props: TablePaginatorRendererProps) => (\n <TablePaginator {...props} pageSizeList={pageSizeList} />\n ),\n [pageSizeList]\n );\n\n return (\n <div className='gmw-select-mapping-container'>\n <Table<IMappingTyped>\n data={mappings ?? []}\n columns={mappingsColumns}\n className='gmw-select-mapping-table'\n emptyTableContent={`No ${displayStrings.mappings} available.`}\n isSortable\n isSelectable\n isLoading={isLoading}\n onSelect={(selectData: IMappingTyped[] | undefined) => {\n selectData && setSelectedMappings(selectData);\n }}\n paginatorRenderer={paginator}\n />\n <div className='gmw-import-action-panel'>\n <Button onClick={backFn}>Back</Button>\n <Button\n styleType='high-visibility'\n onClick={() => {\n onSelect(selectedMappings);\n }}\n disabled={isLoading || selectedMappings.length === 0}\n >\n Next\n </Button>\n <Button onClick={onCancel}>Cancel</Button>\n </div>\n </div>\n );\n};\n\nexport default SelectMappings;\n"]}
|