@corva/ui 3.56.0-rc.0 → 3.57.0-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs-bundle/clients/api/constants.js +1 -1
- package/cjs-bundle/clients/api/rateLimiter.js +1 -1
- package/cjs-bundle/clients/index.js +1 -1
- package/cjs-bundle/clients/index.js.map +1 -1
- package/cjs-bundle/components/AddComment/Popover.js +1 -1
- package/cjs-bundle/components/AddComment/Popover.js.map +1 -1
- package/cjs-bundle/components/AddComment/components/Content.js +1 -1
- package/cjs-bundle/components/AddComment/components/Content.js.map +1 -1
- package/cjs-bundle/components/AssetEditor/effects/index.js +1 -1
- package/cjs-bundle/components/AssetEditor/effects/index.js.map +1 -1
- package/cjs-bundle/components/AssetEditorV2/effects/index.js +1 -1
- package/cjs-bundle/components/AssetEditorV2/effects/index.js.map +1 -1
- package/cjs-bundle/components/AssetEditorV2/effects/usePrimaryAssetSelectData.js +1 -1
- package/cjs-bundle/components/AssetEditorV2/effects/usePrimaryAssetSelectData.js.map +1 -1
- package/cjs-bundle/components/Attachment/index.js +1 -1
- package/cjs-bundle/components/Attachment/index.js.map +1 -1
- package/cjs-bundle/components/BICOffsetPickerDialog/index.js +1 -1
- package/cjs-bundle/components/BICOffsetPickerDialog/index.js.map +1 -1
- package/cjs-bundle/components/Casing/CasingTableV2/components/CasingJoints/Editor.js +1 -1
- package/cjs-bundle/components/Casing/CasingTableV2/components/CasingJoints/Editor.js.map +1 -1
- package/cjs-bundle/components/Casing/CasingTableV2/components/Component.js +1 -1
- package/cjs-bundle/components/Casing/CasingTableV2/components/Component.js.map +1 -1
- package/cjs-bundle/components/Casing/CasingTableV2/components/DrillPipe/Editor.js +1 -1
- package/cjs-bundle/components/Casing/CasingTableV2/components/DrillPipe/Editor.js.map +1 -1
- package/cjs-bundle/components/CollapsableSidebar.js +1 -1
- package/cjs-bundle/components/CollapsableSidebar.js.map +1 -1
- package/cjs-bundle/components/DevCenter/DevCenterAppContainer/DevCenterAppContainer.js +1 -1
- package/cjs-bundle/components/DevCenter/DevCenterAppContainer/DevCenterAppContainer.js.map +1 -1
- package/cjs-bundle/components/DevCenter/DevCenterAppContainer/components/CommentsSwitch/CommentsSwitchButton.js +1 -1
- package/cjs-bundle/components/DevCenter/DevCenterAppContainer/components/NonPriorityMenus/NonPriorityMenus.js +1 -1
- package/cjs-bundle/components/DevCenter/DevCenterAppContainer/components/PriorityMenus/PriorityMenus.js +1 -1
- package/cjs-bundle/components/DevCenter/DevCenterAppContainer/components/PriorityMenus/PriorityMenus.js.map +1 -1
- package/cjs-bundle/components/DevCenter/IsolatedDevCenterAppContainer/DevCenterIsolatedApp.js +1 -1
- package/cjs-bundle/components/DevCenter/IsolatedDevCenterAppContainer/DevCenterIsolatedApp.js.map +1 -1
- package/cjs-bundle/components/DevCenter/IsolatedDevCenterAppContainer/DevCenterIsolatedAppPage.js +1 -1
- package/cjs-bundle/components/DevCenter/IsolatedDevCenterAppContainer/DevCenterIsolatedAppPage.js.map +1 -1
- package/cjs-bundle/components/DocumentViewer/DocumentViewer.js +1 -1
- package/cjs-bundle/components/DocumentViewer/DocumentViewer.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Component.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Component.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js.map +1 -1
- package/cjs-bundle/components/FeedItem/FeedItem.js +1 -1
- package/cjs-bundle/components/FeedItem/FeedItem.js.map +1 -1
- package/cjs-bundle/components/FeedItem/components/FeedComments.js +1 -1
- package/cjs-bundle/components/FeedItem/components/FeedComments.js.map +1 -1
- package/cjs-bundle/components/ImageViewer/index.js +1 -1
- package/cjs-bundle/components/ImageViewer/index.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV2/OffsetWellPickerDialog.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV2/OffsetWellPickerDialog.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/index.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/index.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/index.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/index.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/WellHubView/index.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/WellHubView/index.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/OffsetWellPickerV5.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/AppHeader/components/HeaderActions/HeaderActions.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/AppHeader/components/LoadAllWellsToggle/LoadAllWellsToggle.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/Filter/Filter.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/Filter/components/PeriodFilterSelect/PeriodFilterSelect.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/Filter/components/SingleFilterSelect/SingleFilterSelect.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/Map/OffsetWellMap/components/ClusterTooltip/ClusterTooltip.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/Map/OffsetWellMap/components/LayerSwitcher/LayerSwitcher.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/Map/OffsetWellMap/components/MapControls/MapControls.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellPickerV5WithStore/components/CompanySafeguardWrapper/CompanySafeguardWrapper.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellsTable/AdvancedSearch/components/AssetResultSection/AssetResultSection.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellsTable/AdvancedSearch/components/AutoCompleteAssetSearch/AutoCompleteAssetSearch.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellsTable/AdvancedSearch/hooks/useAssetsData.utils.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellsTable/AdvancedSearch/hooks/useAssetsFetch.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellsTable/components/MetricsSettingMenu/MetricsSettingMenu.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellsTable/hooks/useAdvancedSearchHandler.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/PickerModalActions/PickerModalActions.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/useAdvancedWells.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/useCompanyMetricKey.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/useCompanyProvider.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/useFetchSubjectWell.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/useSearchedWells.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/useWellDataPipeline.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/hooks/useAllWells/useLoadAllWellsCallback.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/hooks/useBicWells.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/hooks/useCompanies.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/hooks/useIsAdmin.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/hooks/usePinnedWells.js +1 -1
- package/cjs-bundle/components/PadOffsetsPicker/StagesSelector.js +1 -1
- package/cjs-bundle/components/PadOffsetsPicker/StagesSelector.js.map +1 -1
- package/cjs-bundle/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js +1 -1
- package/cjs-bundle/components/Popover/Popover.js +1 -1
- package/cjs-bundle/components/Popper/Popper.js +1 -1
- package/cjs-bundle/components/RealTimeValuesSidebar/SidebarFooter.js +1 -1
- package/cjs-bundle/componentsV2/AppHeader/AppAssets/utils.js +1 -1
- package/cjs-bundle/componentsV2/AppHeader/V3/Actions/Actions.js +1 -1
- package/cjs-bundle/componentsV2/AppHeader/V3/AssetSelector/AssetSelector.js +1 -1
- package/cjs-bundle/componentsV2/AppHeader/V3/VersionSelect/VersionSelect.js +1 -1
- package/cjs-bundle/componentsV2/CompletionsOffsetWellPicker/Map/Map.js +1 -1
- package/cjs-bundle/componentsV2/PadModeSelect/PadModeSelect.js +1 -1
- package/cjs-bundle/componentsV2/TemplatesControl/PublishModal/PublishModal.js +1 -1
- package/cjs-bundle/componentsV2/TemplatesControl/ShareModal/ShareModal.js +1 -1
- package/cjs-bundle/componentsV2/TemplatesControl/Toggle/Toggle.js +1 -1
- package/cjs-bundle/componentsV2/TextInputNext/TextInputNext.js +1 -1
- package/cjs-bundle/componentsV2/WellArchivedMessage/WellArchivedMessage.js +1 -1
- package/cjs-bundle/effects/useGlobalOffsetWellsSync.js +1 -1
- package/cjs-bundle/effects/useGlobalOffsetWellsSync.js.map +1 -1
- package/cjs-bundle/testing/AppTestWrapper/AppTestWrapper.js +1 -1
- package/clients/api/constants.d.ts +11 -0
- package/clients/api/constants.d.ts.map +1 -1
- package/clients/api/constants.js +1 -1
- package/clients/api/rateLimiter.d.ts +1 -0
- package/clients/api/rateLimiter.d.ts.map +1 -1
- package/clients/api/rateLimiter.js +1 -1
- package/clients/index.d.ts +1 -0
- package/clients/index.d.ts.map +1 -1
- package/clients/index.js +1 -1
- package/clients/index.js.map +1 -1
- package/components/AddComment/Popover.js +1 -1
- package/components/AddComment/Popover.js.map +1 -1
- package/components/AddComment/components/Content.js +1 -1
- package/components/AddComment/components/Content.js.map +1 -1
- package/components/AssetEditor/effects/index.js +1 -1
- package/components/AssetEditor/effects/index.js.map +1 -1
- package/components/AssetEditorV2/effects/index.js +1 -1
- package/components/AssetEditorV2/effects/index.js.map +1 -1
- package/components/AssetEditorV2/effects/usePrimaryAssetSelectData.js +1 -1
- package/components/AssetEditorV2/effects/usePrimaryAssetSelectData.js.map +1 -1
- package/components/Attachment/index.js +1 -1
- package/components/Attachment/index.js.map +1 -1
- package/components/BICOffsetPickerDialog/index.js +1 -1
- package/components/BICOffsetPickerDialog/index.js.map +1 -1
- package/components/Casing/CasingTableV2/components/CasingJoints/Editor.js +1 -1
- package/components/Casing/CasingTableV2/components/CasingJoints/Editor.js.map +1 -1
- package/components/Casing/CasingTableV2/components/Component.js +1 -1
- package/components/Casing/CasingTableV2/components/Component.js.map +1 -1
- package/components/Casing/CasingTableV2/components/DrillPipe/Editor.js +1 -1
- package/components/Casing/CasingTableV2/components/DrillPipe/Editor.js.map +1 -1
- package/components/CollapsableSidebar.js +1 -1
- package/components/CollapsableSidebar.js.map +1 -1
- package/components/DevCenter/DevCenterAppContainer/DevCenterAppContainer.js +1 -1
- package/components/DevCenter/DevCenterAppContainer/DevCenterAppContainer.js.map +1 -1
- package/components/DevCenter/DevCenterAppContainer/components/CommentsSwitch/CommentsSwitchButton.js +1 -1
- package/components/DevCenter/DevCenterAppContainer/components/NonPriorityMenus/NonPriorityMenus.js +1 -1
- package/components/DevCenter/DevCenterAppContainer/components/PriorityMenus/PriorityMenus.js +1 -1
- package/components/DevCenter/DevCenterAppContainer/components/PriorityMenus/PriorityMenus.js.map +1 -1
- package/components/DevCenter/IsolatedDevCenterAppContainer/DevCenterIsolatedApp.d.ts.map +1 -1
- package/components/DevCenter/IsolatedDevCenterAppContainer/DevCenterIsolatedApp.js +1 -1
- package/components/DevCenter/IsolatedDevCenterAppContainer/DevCenterIsolatedApp.js.map +1 -1
- package/components/DevCenter/IsolatedDevCenterAppContainer/DevCenterIsolatedAppPage.d.ts.map +1 -1
- package/components/DevCenter/IsolatedDevCenterAppContainer/DevCenterIsolatedAppPage.js +1 -1
- package/components/DevCenter/IsolatedDevCenterAppContainer/DevCenterIsolatedAppPage.js.map +1 -1
- package/components/DocumentViewer/DocumentViewer.js +1 -1
- package/components/DocumentViewer/DocumentViewer.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Component.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Component.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js.map +1 -1
- package/components/FeedItem/FeedItem.js +1 -1
- package/components/FeedItem/FeedItem.js.map +1 -1
- package/components/FeedItem/components/FeedComments.js +1 -1
- package/components/FeedItem/components/FeedComments.js.map +1 -1
- package/components/ImageViewer/index.js +1 -1
- package/components/ImageViewer/index.js.map +1 -1
- package/components/OffsetWellPickerV2/OffsetWellPickerDialog.js +1 -1
- package/components/OffsetWellPickerV2/OffsetWellPickerDialog.js.map +1 -1
- package/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js +1 -1
- package/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js.map +1 -1
- package/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js +1 -1
- package/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js.map +1 -1
- package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js +1 -1
- package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js.map +1 -1
- package/components/OffsetWellPickerV3/components/CustomSelectionView/index.js +1 -1
- package/components/OffsetWellPickerV3/components/CustomSelectionView/index.js.map +1 -1
- package/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js +1 -1
- package/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js.map +1 -1
- package/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js +1 -1
- package/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js.map +1 -1
- package/components/OffsetWellPickerV3/components/TabSelection/index.js +1 -1
- package/components/OffsetWellPickerV3/components/TabSelection/index.js.map +1 -1
- package/components/OffsetWellPickerV3/components/WellHubView/index.js +1 -1
- package/components/OffsetWellPickerV3/components/WellHubView/index.js.map +1 -1
- package/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js +1 -1
- package/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js.map +1 -1
- package/components/OffsetWellPickerV5/OffsetWellPickerV5.js +1 -1
- package/components/OffsetWellPickerV5/components/AppHeader/components/HeaderActions/HeaderActions.js +1 -1
- package/components/OffsetWellPickerV5/components/AppHeader/components/LoadAllWellsToggle/LoadAllWellsToggle.js +1 -1
- package/components/OffsetWellPickerV5/components/Filter/Filter.js +1 -1
- package/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js +1 -1
- package/components/OffsetWellPickerV5/components/Filter/components/PeriodFilterSelect/PeriodFilterSelect.js +1 -1
- package/components/OffsetWellPickerV5/components/Filter/components/SingleFilterSelect/SingleFilterSelect.js +1 -1
- package/components/OffsetWellPickerV5/components/Map/OffsetWellMap/components/ClusterTooltip/ClusterTooltip.js +1 -1
- package/components/OffsetWellPickerV5/components/Map/OffsetWellMap/components/LayerSwitcher/LayerSwitcher.js +1 -1
- package/components/OffsetWellPickerV5/components/Map/OffsetWellMap/components/MapControls/MapControls.js +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellPickerV5WithStore/components/CompanySafeguardWrapper/CompanySafeguardWrapper.js +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/AdvancedSearch/components/AssetResultSection/AssetResultSection.js +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/AdvancedSearch/components/AutoCompleteAssetSearch/AutoCompleteAssetSearch.js +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/AdvancedSearch/hooks/useAssetsData.utils.js +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/AdvancedSearch/hooks/useAssetsFetch.js +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/components/MetricsSettingMenu/MetricsSettingMenu.js +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellsTable/hooks/useAdvancedSearchHandler.js +1 -1
- package/components/OffsetWellPickerV5/components/PickerModalActions/PickerModalActions.js +1 -1
- package/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/useAdvancedWells.js +1 -1
- package/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/useCompanyMetricKey.js +1 -1
- package/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/useCompanyProvider.js +1 -1
- package/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/useFetchSubjectWell.js +1 -1
- package/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/useSearchedWells.js +1 -1
- package/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/useWellDataPipeline.js +1 -1
- package/components/OffsetWellPickerV5/hooks/useAllWells/useLoadAllWellsCallback.js +1 -1
- package/components/OffsetWellPickerV5/hooks/useBicWells.js +1 -1
- package/components/OffsetWellPickerV5/hooks/useCompanies.js +1 -1
- package/components/OffsetWellPickerV5/hooks/useIsAdmin.js +1 -1
- package/components/OffsetWellPickerV5/hooks/usePinnedWells.js +1 -1
- package/components/PadOffsetsPicker/StagesSelector.js +1 -1
- package/components/PadOffsetsPicker/StagesSelector.js.map +1 -1
- package/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js +1 -1
- package/components/Popover/Popover.js +1 -1
- package/components/Popper/Popper.js +1 -1
- package/components/RealTimeValuesSidebar/SidebarFooter.js +1 -1
- package/componentsV2/AppHeader/AppAssets/utils.js +1 -1
- package/componentsV2/AppHeader/V3/Actions/Actions.js +1 -1
- package/componentsV2/AppHeader/V3/AssetSelector/AssetSelector.js +1 -1
- package/componentsV2/AppHeader/V3/VersionSelect/VersionSelect.js +1 -1
- package/componentsV2/CompletionsOffsetWellPicker/Map/Map.js +1 -1
- package/componentsV2/PadModeSelect/PadModeSelect.js +1 -1
- package/componentsV2/TemplatesControl/PublishModal/PublishModal.js +1 -1
- package/componentsV2/TemplatesControl/ShareModal/ShareModal.js +1 -1
- package/componentsV2/TemplatesControl/Toggle/Toggle.js +1 -1
- package/componentsV2/TextInputNext/TextInputNext.js +1 -1
- package/componentsV2/WellArchivedMessage/WellArchivedMessage.js +1 -1
- package/effects/useGlobalOffsetWellsSync.js +1 -1
- package/effects/useGlobalOffsetWellsSync.js.map +1 -1
- package/mcp-server/server.mjs +1 -1
- package/package.json +1 -1
- package/testing/AppTestWrapper/AppTestWrapper.js +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/asyncToGenerator"),t=require("@babel/runtime/helpers/slicedToArray"),r=require("@babel/runtime/helpers/defineProperty"),n=require("@babel/runtime/helpers/toConsumableArray"),s=require("@babel/runtime/regenerator"),a=require("react"),u=require("lodash"),i=require("../constants.js");require("uuid"),require("lodash/set"),require("lodash/get"),require("lodash/unset"),require("moment");var c=require("../../../clients/jsonApi/index.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("../../../clients/subscriptions/constants.js"),require("../../../clients/subscriptions.v1.js"),require("../../../clients/subscriptions/subscriptions-client.factory.js"),require("../../../clients/api/apiCore.js"),require("../../../clients/constants.js"),require("../../../clients/sso/auth0.js"),require("../../../clients/sso/oauth2.js");var p=o(e),l=o(t),f=o(r),d=o(n),y=o(s);function b(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?b(Object(r),!0).forEach((function(t){f.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var h=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{sort:"name",order:"asc",fields:["".concat(e,".name"),"".concat(e,".asset_id")].concat(d.default(t))}},v=function(e){var t,r,n;return m(m({},e.attributes),{},{id:+e.id,programId:+(null===(t=e.relationships)||void 0===t||null===(r=t.program)||void 0===r||null===(n=r.data)||void 0===n?void 0:n.id)})};exports.useAssetAutoCompleteSelectData=function(e){var t=e.appKey,r=e.assetType,n=e.companyId,s=e.currentValue,o=e.isMultiple,f=e.parentAssetId,d=e.parentAssetType,b=e.scrollPage,q=e.searchText,j=e.setCurrentOption,g=e.queryParams,O=e.assetFields,x=a.useState([]),A=l.default(x,2),P=A[0],w=A[1],k=a.useState(!1),E=l.default(k,2),S=E[0],_=E[1],T=a.useRef(),D=a.useRef();return a.useEffect((function(){function e(){return(e=p.default(y.default.mark((function e(){var t;return y.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c.mapAssetGetRequest(r)(m(m({},h(r,O)),{},{ids:o?s:[s]},g));case 2:if(t=e.sent,!u.isEmpty(t.data)){e.next=7;break}return e.next=6,c.getAssets(m(m({},h(r,O)),{},{ids:o?s:[s]},g));case 6:t=e.sent;case 7:j((function(){if(o)return t.data.map(v);var e=t.data[0];return e?v(e):null}));case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}(o?s.length:s)&&function(){e.apply(this,arguments)}()}),[]),a.useEffect((function(){function e(){return(e=p.default(y.default.mark((function e(){var s,a,u,o,p;return y.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,_(!0),s={per_page:i.PER_PAGE,page:b},d&&f&&(s[d]=f),n&&(s.company=n),q&&(s.search=q),t&&(s.app_key=t),a=c.mapAssetGetRequest(r)(m(m(m({},h(r,O)),s),g)),D.current=a,e.next=11,a;case 11:if(u=e.sent,D.current===a){e.next=14;break}return e.abrupt("return");case 14:o=u.data.map(v),p=T.current!==r||1===b,w(p?o:function(e){return e.concat(o)}),T.current=r,e.next=23;break;case 20:e.prev=20,e.t0=e.catch(0),console.error(e.t0);case 23:_(!1);case 24:case"end":return e.stop()}}),e,null,[[0,20]])})))).apply(this,arguments)}!function(){e.apply(this,arguments)}()}),[r,d,f,n,q,b,t]),{assets:P,loading:S}},exports.useAssetSelectData=function(e){var t=e.appKey,r=e.assetType,n=e.assetId,s=e.parentAssetType,u=e.parentAssetId,i=e.queryParams,o=void 0===i?null:i,d=a.useState([]),b=l.default(d,2),q=b[0],j=b[1],g=a.useState(!0),O=l.default(g,2),x=O[0],A=O[1];return a.useEffect((function(){function e(){return(e=p.default(y.default.mark((function e(){var n;return y.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c.mapAssetGetRequest(r)(m(m(m({},h(r)),{},f.default({per_page:1e4},s,u),t&&{app_key:t}),o));case 2:n=e.sent,j(n.data.map(v)),A(!1);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}A(!0),function(){e.apply(this,arguments)}()}),[r,n,s,u,t]),{assets:q,loading:x}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/asyncToGenerator"),t=require("@babel/runtime/helpers/slicedToArray"),r=require("@babel/runtime/helpers/defineProperty"),n=require("@babel/runtime/helpers/toConsumableArray"),s=require("@babel/runtime/regenerator"),a=require("react"),u=require("lodash"),i=require("../constants.js");require("uuid"),require("lodash/set"),require("lodash/get"),require("lodash/unset"),require("moment");var c=require("../../../clients/jsonApi/index.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("../../../clients/subscriptions/constants.js"),require("../../../clients/subscriptions.v1.js"),require("../../../clients/subscriptions/subscriptions-client.factory.js"),require("../../../clients/api/apiCore.js"),require("../../../clients/constants.js"),require("../../../clients/sso/auth0.js"),require("../../../clients/sso/oauth2.js"),require("../../../clients/api/rateLimiter.js");var p=o(e),l=o(t),f=o(r),d=o(n),y=o(s);function b(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?b(Object(r),!0).forEach((function(t){f.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var h=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{sort:"name",order:"asc",fields:["".concat(e,".name"),"".concat(e,".asset_id")].concat(d.default(t))}},v=function(e){var t,r,n;return m(m({},e.attributes),{},{id:+e.id,programId:+(null===(t=e.relationships)||void 0===t||null===(r=t.program)||void 0===r||null===(n=r.data)||void 0===n?void 0:n.id)})};exports.useAssetAutoCompleteSelectData=function(e){var t=e.appKey,r=e.assetType,n=e.companyId,s=e.currentValue,o=e.isMultiple,f=e.parentAssetId,d=e.parentAssetType,b=e.scrollPage,q=e.searchText,j=e.setCurrentOption,g=e.queryParams,O=e.assetFields,x=a.useState([]),A=l.default(x,2),P=A[0],w=A[1],k=a.useState(!1),E=l.default(k,2),S=E[0],_=E[1],T=a.useRef(),D=a.useRef();return a.useEffect((function(){function e(){return(e=p.default(y.default.mark((function e(){var t;return y.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c.mapAssetGetRequest(r)(m(m({},h(r,O)),{},{ids:o?s:[s]},g));case 2:if(t=e.sent,!u.isEmpty(t.data)){e.next=7;break}return e.next=6,c.getAssets(m(m({},h(r,O)),{},{ids:o?s:[s]},g));case 6:t=e.sent;case 7:j((function(){if(o)return t.data.map(v);var e=t.data[0];return e?v(e):null}));case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}(o?s.length:s)&&function(){e.apply(this,arguments)}()}),[]),a.useEffect((function(){function e(){return(e=p.default(y.default.mark((function e(){var s,a,u,o,p;return y.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,_(!0),s={per_page:i.PER_PAGE,page:b},d&&f&&(s[d]=f),n&&(s.company=n),q&&(s.search=q),t&&(s.app_key=t),a=c.mapAssetGetRequest(r)(m(m(m({},h(r,O)),s),g)),D.current=a,e.next=11,a;case 11:if(u=e.sent,D.current===a){e.next=14;break}return e.abrupt("return");case 14:o=u.data.map(v),p=T.current!==r||1===b,w(p?o:function(e){return e.concat(o)}),T.current=r,e.next=23;break;case 20:e.prev=20,e.t0=e.catch(0),console.error(e.t0);case 23:_(!1);case 24:case"end":return e.stop()}}),e,null,[[0,20]])})))).apply(this,arguments)}!function(){e.apply(this,arguments)}()}),[r,d,f,n,q,b,t]),{assets:P,loading:S}},exports.useAssetSelectData=function(e){var t=e.appKey,r=e.assetType,n=e.assetId,s=e.parentAssetType,u=e.parentAssetId,i=e.queryParams,o=void 0===i?null:i,d=a.useState([]),b=l.default(d,2),q=b[0],j=b[1],g=a.useState(!0),O=l.default(g,2),x=O[0],A=O[1];return a.useEffect((function(){function e(){return(e=p.default(y.default.mark((function e(){var n;return y.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c.mapAssetGetRequest(r)(m(m(m({},h(r)),{},f.default({per_page:1e4},s,u),t&&{app_key:t}),o));case 2:n=e.sent,j(n.data.map(v)),A(!1);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}A(!0),function(){e.apply(this,arguments)}()}),[r,n,s,u,t]),{assets:q,loading:x}};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/components/AssetEditor/effects/index.js"],"sourcesContent":["import { useEffect, useState, useRef } from 'react';\nimport { isEmpty } from 'lodash';\n\nimport { PER_PAGE } from '../constants';\n\nimport { jsonApi } from '~/clients';\n\nconst getRequestOptions = (assetType, assetFields = []) => ({\n sort: 'name',\n order: 'asc',\n fields: [`${assetType}.name`, `${assetType}.asset_id`, ...assetFields],\n});\n\nconst deserializeAsset = asset => ({\n ...asset.attributes,\n id: +asset.id,\n programId: +asset.relationships?.program?.data?.id,\n});\n\nexport function useAssetSelectData({\n appKey,\n assetType,\n assetId,\n parentAssetType,\n parentAssetId,\n queryParams = null,\n}) {\n const [assets, setAssets] = useState([]);\n const [loading, setLoading] = useState(true);\n useEffect(() => {\n setLoading(true);\n async function loadAssets() {\n const response = await jsonApi.mapAssetGetRequest(assetType)({\n ...getRequestOptions(assetType),\n per_page: 10000,\n [parentAssetType]: parentAssetId,\n ...(appKey && { app_key: appKey }),\n ...queryParams,\n });\n\n setAssets(response.data.map(deserializeAsset));\n setLoading(false);\n }\n loadAssets();\n }, [assetType, assetId, parentAssetType, parentAssetId, appKey]);\n\n return { assets, loading };\n}\n\nexport function useAssetAutoCompleteSelectData({\n appKey,\n assetType,\n companyId,\n currentValue,\n isMultiple,\n parentAssetId,\n parentAssetType,\n scrollPage,\n searchText,\n setCurrentOption,\n queryParams,\n assetFields,\n}) {\n const [assets, setAssets] = useState([]);\n const [loading, setLoading] = useState(false);\n const previousTypeRef = useRef();\n const lastLoadAssetsReqPromise = useRef();\n\n // NOTE: Fetch currently selected option\n useEffect(() => {\n async function loadCurrentOption() {\n let response = await jsonApi.mapAssetGetRequest(assetType)({\n ...getRequestOptions(assetType, assetFields),\n ids: isMultiple ? currentValue : [currentValue],\n ...queryParams,\n });\n if (isEmpty(response.data)) {\n // NOTE: Try fetch current option from v2/assets\n response = await jsonApi.getAssets({\n ...getRequestOptions(assetType, assetFields),\n ids: isMultiple ? currentValue : [currentValue],\n ...queryParams,\n });\n }\n\n setCurrentOption(() => {\n if (isMultiple) return response.data.map(deserializeAsset);\n const option = response.data[0];\n return option ? deserializeAsset(option) : null;\n });\n }\n if (isMultiple ? currentValue.length : currentValue) loadCurrentOption();\n }, []);\n\n useEffect(() => {\n async function loadAssets() {\n try {\n setLoading(true);\n const requestParams = { per_page: PER_PAGE, page: scrollPage };\n if (parentAssetType && parentAssetId) requestParams[parentAssetType] = parentAssetId;\n if (companyId) requestParams.company = companyId;\n if (searchText) requestParams.search = searchText;\n if (appKey) requestParams.app_key = appKey;\n\n const requestPromise = jsonApi.mapAssetGetRequest(assetType)({\n ...getRequestOptions(assetType, assetFields),\n ...requestParams,\n ...queryParams,\n });\n\n lastLoadAssetsReqPromise.current = requestPromise;\n const response = await requestPromise;\n\n if (lastLoadAssetsReqPromise.current !== requestPromise) {\n return;\n }\n\n const responseAssets = response.data.map(deserializeAsset);\n const isPaginationDisabled = previousTypeRef.current !== assetType || scrollPage === 1;\n\n setAssets(\n isPaginationDisabled ? responseAssets : prevState => prevState.concat(responseAssets)\n );\n\n previousTypeRef.current = assetType;\n } catch (e) {\n console.error(e);\n }\n setLoading(false);\n }\n loadAssets();\n }, [assetType, parentAssetType, parentAssetId, companyId, searchText, scrollPage, appKey]);\n\n return { assets, loading };\n}\n"],"names":["getRequestOptions","assetType","assetFields","sort","order","fields","deserializeAsset","asset","_asset$relationships","_asset$relationships$","_asset$relationships$2","attributes","id","programId","relationships","program","data","_ref2","appKey","companyId","currentValue","isMultiple","parentAssetId","parentAssetType","scrollPage","searchText","setCurrentOption","queryParams","useState","_useState6","_slicedToArray","_useState5","assets","setAssets","_useState8","_useState7","loading","setLoading","previousTypeRef","useRef","lastLoadAssetsReqPromise","useEffect","_loadCurrentOption","_asyncToGenerator","_regeneratorRuntime","mark","_callee2","response","wrap","_context2","prev","next","jsonApi","ids","sent","isEmpty","getAssets","_objectSpread","map","option","stop","apply","this","arguments","length","loadCurrentOption","_loadAssets2","_callee3","requestParams","requestPromise","responseAssets","isPaginationDisabled","_context3","per_page","PER_PAGE","page","company","search","app_key","mapAssetGetRequest","current","abrupt","prevState","concat","t0","console","error","loadAssets","_ref","assetId","_ref$queryParams","_useState2","_useState","_useState4","_useState3","_loadAssets","_callee","_context","_defineProperty"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/components/AssetEditor/effects/index.js"],"sourcesContent":["import { useEffect, useState, useRef } from 'react';\nimport { isEmpty } from 'lodash';\n\nimport { PER_PAGE } from '../constants';\n\nimport { jsonApi } from '~/clients';\n\nconst getRequestOptions = (assetType, assetFields = []) => ({\n sort: 'name',\n order: 'asc',\n fields: [`${assetType}.name`, `${assetType}.asset_id`, ...assetFields],\n});\n\nconst deserializeAsset = asset => ({\n ...asset.attributes,\n id: +asset.id,\n programId: +asset.relationships?.program?.data?.id,\n});\n\nexport function useAssetSelectData({\n appKey,\n assetType,\n assetId,\n parentAssetType,\n parentAssetId,\n queryParams = null,\n}) {\n const [assets, setAssets] = useState([]);\n const [loading, setLoading] = useState(true);\n useEffect(() => {\n setLoading(true);\n async function loadAssets() {\n const response = await jsonApi.mapAssetGetRequest(assetType)({\n ...getRequestOptions(assetType),\n per_page: 10000,\n [parentAssetType]: parentAssetId,\n ...(appKey && { app_key: appKey }),\n ...queryParams,\n });\n\n setAssets(response.data.map(deserializeAsset));\n setLoading(false);\n }\n loadAssets();\n }, [assetType, assetId, parentAssetType, parentAssetId, appKey]);\n\n return { assets, loading };\n}\n\nexport function useAssetAutoCompleteSelectData({\n appKey,\n assetType,\n companyId,\n currentValue,\n isMultiple,\n parentAssetId,\n parentAssetType,\n scrollPage,\n searchText,\n setCurrentOption,\n queryParams,\n assetFields,\n}) {\n const [assets, setAssets] = useState([]);\n const [loading, setLoading] = useState(false);\n const previousTypeRef = useRef();\n const lastLoadAssetsReqPromise = useRef();\n\n // NOTE: Fetch currently selected option\n useEffect(() => {\n async function loadCurrentOption() {\n let response = await jsonApi.mapAssetGetRequest(assetType)({\n ...getRequestOptions(assetType, assetFields),\n ids: isMultiple ? currentValue : [currentValue],\n ...queryParams,\n });\n if (isEmpty(response.data)) {\n // NOTE: Try fetch current option from v2/assets\n response = await jsonApi.getAssets({\n ...getRequestOptions(assetType, assetFields),\n ids: isMultiple ? currentValue : [currentValue],\n ...queryParams,\n });\n }\n\n setCurrentOption(() => {\n if (isMultiple) return response.data.map(deserializeAsset);\n const option = response.data[0];\n return option ? deserializeAsset(option) : null;\n });\n }\n if (isMultiple ? currentValue.length : currentValue) loadCurrentOption();\n }, []);\n\n useEffect(() => {\n async function loadAssets() {\n try {\n setLoading(true);\n const requestParams = { per_page: PER_PAGE, page: scrollPage };\n if (parentAssetType && parentAssetId) requestParams[parentAssetType] = parentAssetId;\n if (companyId) requestParams.company = companyId;\n if (searchText) requestParams.search = searchText;\n if (appKey) requestParams.app_key = appKey;\n\n const requestPromise = jsonApi.mapAssetGetRequest(assetType)({\n ...getRequestOptions(assetType, assetFields),\n ...requestParams,\n ...queryParams,\n });\n\n lastLoadAssetsReqPromise.current = requestPromise;\n const response = await requestPromise;\n\n if (lastLoadAssetsReqPromise.current !== requestPromise) {\n return;\n }\n\n const responseAssets = response.data.map(deserializeAsset);\n const isPaginationDisabled = previousTypeRef.current !== assetType || scrollPage === 1;\n\n setAssets(\n isPaginationDisabled ? responseAssets : prevState => prevState.concat(responseAssets)\n );\n\n previousTypeRef.current = assetType;\n } catch (e) {\n console.error(e);\n }\n setLoading(false);\n }\n loadAssets();\n }, [assetType, parentAssetType, parentAssetId, companyId, searchText, scrollPage, appKey]);\n\n return { assets, loading };\n}\n"],"names":["getRequestOptions","assetType","assetFields","sort","order","fields","deserializeAsset","asset","_asset$relationships","_asset$relationships$","_asset$relationships$2","attributes","id","programId","relationships","program","data","_ref2","appKey","companyId","currentValue","isMultiple","parentAssetId","parentAssetType","scrollPage","searchText","setCurrentOption","queryParams","useState","_useState6","_slicedToArray","_useState5","assets","setAssets","_useState8","_useState7","loading","setLoading","previousTypeRef","useRef","lastLoadAssetsReqPromise","useEffect","_loadCurrentOption","_asyncToGenerator","_regeneratorRuntime","mark","_callee2","response","wrap","_context2","prev","next","jsonApi","ids","sent","isEmpty","getAssets","_objectSpread","map","option","stop","apply","this","arguments","length","loadCurrentOption","_loadAssets2","_callee3","requestParams","requestPromise","responseAssets","isPaginationDisabled","_context3","per_page","PER_PAGE","page","company","search","app_key","mapAssetGetRequest","current","abrupt","prevState","concat","t0","console","error","loadAssets","_ref","assetId","_ref$queryParams","_useState2","_useState","_useState4","_useState3","_loadAssets","_callee","_context","_defineProperty"],"m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yD,EAAA,GAAExD,EAAUwD,EAAA,GAkB1B,OAjBApD,EAAAA,WAAU,WAEiB,SAAAsD,IAWxB,OAXwBA,EAAzBpD,EAAAA,QAAAC,EAAAA,QAAAC,MAAA,SAAAmD,IAAA,IAAAjD,EAAA,OAAAH,UAAAI,MAAA,SAAAiD,GAAA,OAAA,OAAAA,EAAA/C,KAAA+C,EAAA9C,MAAA,KAAA,EAAA,OAAA8C,EAAA9C,KAAA,EACyBC,qBAA2BnD,EAA3BmD,CAClBpD,EAAAA,EAAAA,EAAAA,CAAAA,EAAAA,EAAkBC,IAAU,CAAA,EAAAiG,EAAAA,QAAA,CAC/BzB,SAAU,KACTlD,EAAkBD,GACfJ,GAAU,CAAE4D,QAAS5D,IACtBS,IACH,KAAA,EANIoB,EAAQkD,EAAA3C,KAQdrB,EAAUc,EAAS/B,KAAK0C,IAAIpD,IAC5B+B,GAAW,GAAO,KAAA,EAAA,IAAA,MAAA,OAAA4D,EAAArC,OAAA,GAAAoC,EACnB,MAAAnC,MAAAC,KAAAC,UAAA,CAZD1B,GAAW,GAAM,WACQ0D,EAAAlC,MAAAC,KAAAC,UAAA,CAYzBwB,EACF,GAAG,CAACtF,EAAWwF,EAASlE,EAAiBD,EAAeJ,IAEjD,CAAEc,OAAAA,EAAQI,QAAAA,EACnB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/toConsumableArray"),t=require("@babel/runtime/helpers/defineProperty"),r=require("@babel/runtime/helpers/asyncToGenerator"),s=require("@babel/runtime/helpers/slicedToArray"),n=require("@babel/runtime/regenerator"),a=require("react"),i=require("lodash"),u=require("../utils/index.js");require("uuid"),require("lodash/set"),require("lodash/get"),require("lodash/unset"),require("moment");var o=require("../../../clients/jsonApi/index.js");require("../../../clients/subscriptions/constants.js"),require("../../../clients/subscriptions.v1.js"),require("../../../clients/subscriptions/subscriptions-client.factory.js"),require("../../../clients/api/apiCore.js"),require("../../../clients/constants.js"),require("../../../clients/sso/auth0.js"),require("../../../clients/sso/oauth2.js");var c=require("../../../utils/jsonaDataFormatter.js");require("../../../constants/goals.js"),require("../../../constants/segment.js"),require("../../../constants/alerts.js"),require("../../../constants/apps.js"),require("../../../constants/drillstring.js"),require("../../../constants/completion.js"),require("../../../constants/appPackages.js"),require("../../../constants/notifications.js"),require("../../../constants/feed.js"),require("../../../constants/bha.js");var l=require("../../../constants/assetTypes.js");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("../../../constants/corvaCompanyId.js"),require("../../GradientManager/configuration/constants.js");var f=p(e),d=p(t),y=p(r),q=p(s),v=p(n);function j(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach((function(t){d.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var b=function(e){return e===l.ASSET_TYPES.intervention_unit.type?"intervention_unit_id":e};var h=function(e,t){return e===l.ASSET_TYPES.pad.type?[].concat(f.default(t),["pad.active","pad.parent_frac_fleet_id","pad.current"]):e===l.ASSET_TYPES.intervention_unit.type?[].concat(f.default(t),["intervention_unit.active","intervention_unit.current"]):t};exports.usePrimaryAssetSelectData=function(e){var t,r=e.appKey,s=e.assetType,n=e.company,p=e.groups,d=e.isRequiredAssetId,j=e.parentAssetId,b=e.parentAssetType,g=e.searchText,A=e.assetFields,O=e.currentValue,S=e.setCurrentOption,P=e.onActiveAssetIdChange,_=a.useState([]),x=q.default(_,2),T=x[0],E=x[1],I=a.useState(!1),w=q.default(I,2),k=w[0],D=w[1],R=a.useRef(null),C=(t=y.default(v.default.mark((function e(t){var a,p,y,q,_,x,T;return v.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,a=(null==t?void 0:t.type)||s,p={per_page:1e4},b&&j&&(p[b]=j),n&&"all"!==n&&(p.company=n),g&&(p.search=g),r&&(p.app_key=r),R.current=n,y=o.mapAssetGetRequest(a)(m(m({},u.getRequestOptions(a,h(a,A))),p)),e.next=11,y;case 11:q=e.sent,_=c.jsonaDataFormatter.deserialize(q),x=_.map((function(e){return u.formatAsset({asset:e,group:null==t?void 0:t.name,isRequiredAssetId:d,isPrimaryAsset:!0})})).filter(Boolean).sort(u.sortAsset),R.current===n&&E((function(e){return[].concat(f.default(e),f.default(x))})),O&&a===s&&(T=x.find((function(e){return O===e.id||e.assetId&&O===e.assetId})),i.isEmpty(T)||S(T),a===l.ASSET_TYPES.rig.type&&P(null==T?void 0:T.activeWellId)),e.next=21;break;case 18:e.prev=18,e.t0=e.catch(0),console.error(e.t0);case 21:case"end":return e.stop()}}),e,null,[[0,18]])}))),function(e){return t.apply(this,arguments)});return a.useEffect((function(){n&&E([])}),[n]),a.useEffect((function(){var e,t=(e=y.default(v.default.mark((function e(){return v.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,D(!0),!p){e.next=7;break}return e.next=5,Promise.all(p.map((function(e){return C(e)})));case 5:e.next=9;break;case 7:return e.next=9,C();case 9:e.next=14;break;case 11:e.prev=11,e.t0=e.catch(0),console.error(e.t0);case 14:return e.prev=14,D(!1),e.finish(14);case 17:case"end":return e.stop()}}),e,null,[[0,11,14,17]])}))),function(){return e.apply(this,arguments)});t()}),[s,b,j,n,r,null==p?void 0:p.length]),{assets:k?[]:T,loading:k}},exports.useSecondaryAssetSelectData=function(e){var t=e.appKey,r=e.assetType,s=e.assetId,n=e.company,i=e.parentAssetType,l=e.parentAssetId,p=e.queryParams,f=e.assetFields,j=e.activeWellId,h=e.isRequiredAssetId,g=a.useState([]),A=q.default(g,2),O=A[0],S=A[1],P=a.useState(!0),_=q.default(P,2),x=_[0],T=_[1];return a.useEffect((function(){function e(){return(e=y.default(v.default.mark((function e(){var s,a;return v.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.mapAssetGetRequest(r)(m(m(m({},u.getRequestOptions(r,f)),{},d.default({per_page:1e4,company:"all"!==n?n:null},b(i),l),t&&{app_key:t}),p));case 2:s=e.sent,a=c.jsonaDataFormatter.deserialize(s),S(a.map((function(e){return u.formatAsset({asset:e,activeWellId:j,isRequiredAssetId:h})})).sort(u.sortAsset)),T(!1);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}T(!0),function(){e.apply(this,arguments)}()}),[r,s,i,l,t,j,n]),{assets:O,loading:x}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/toConsumableArray"),t=require("@babel/runtime/helpers/defineProperty"),r=require("@babel/runtime/helpers/asyncToGenerator"),s=require("@babel/runtime/helpers/slicedToArray"),n=require("@babel/runtime/regenerator"),a=require("react"),i=require("lodash"),u=require("../utils/index.js");require("uuid"),require("lodash/set"),require("lodash/get"),require("lodash/unset"),require("moment");var o=require("../../../clients/jsonApi/index.js");require("../../../clients/subscriptions/constants.js"),require("../../../clients/subscriptions.v1.js"),require("../../../clients/subscriptions/subscriptions-client.factory.js"),require("../../../clients/api/apiCore.js"),require("../../../clients/constants.js"),require("../../../clients/sso/auth0.js"),require("../../../clients/sso/oauth2.js"),require("../../../clients/api/rateLimiter.js");var c=require("../../../utils/jsonaDataFormatter.js");require("../../../constants/goals.js"),require("../../../constants/segment.js"),require("../../../constants/alerts.js"),require("../../../constants/apps.js"),require("../../../constants/drillstring.js"),require("../../../constants/completion.js"),require("../../../constants/appPackages.js"),require("../../../constants/notifications.js"),require("../../../constants/feed.js"),require("../../../constants/bha.js");var l=require("../../../constants/assetTypes.js");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("../../../constants/corvaCompanyId.js"),require("../../GradientManager/configuration/constants.js");var f=p(e),d=p(t),y=p(r),q=p(s),v=p(n);function j(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach((function(t){d.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var b=function(e){return e===l.ASSET_TYPES.intervention_unit.type?"intervention_unit_id":e};var h=function(e,t){return e===l.ASSET_TYPES.pad.type?[].concat(f.default(t),["pad.active","pad.parent_frac_fleet_id","pad.current"]):e===l.ASSET_TYPES.intervention_unit.type?[].concat(f.default(t),["intervention_unit.active","intervention_unit.current"]):t};exports.usePrimaryAssetSelectData=function(e){var t,r=e.appKey,s=e.assetType,n=e.company,p=e.groups,d=e.isRequiredAssetId,j=e.parentAssetId,b=e.parentAssetType,g=e.searchText,A=e.assetFields,O=e.currentValue,S=e.setCurrentOption,P=e.onActiveAssetIdChange,_=a.useState([]),x=q.default(_,2),T=x[0],E=x[1],I=a.useState(!1),w=q.default(I,2),k=w[0],D=w[1],R=a.useRef(null),C=(t=y.default(v.default.mark((function e(t){var a,p,y,q,_,x,T;return v.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,a=(null==t?void 0:t.type)||s,p={per_page:1e4},b&&j&&(p[b]=j),n&&"all"!==n&&(p.company=n),g&&(p.search=g),r&&(p.app_key=r),R.current=n,y=o.mapAssetGetRequest(a)(m(m({},u.getRequestOptions(a,h(a,A))),p)),e.next=11,y;case 11:q=e.sent,_=c.jsonaDataFormatter.deserialize(q),x=_.map((function(e){return u.formatAsset({asset:e,group:null==t?void 0:t.name,isRequiredAssetId:d,isPrimaryAsset:!0})})).filter(Boolean).sort(u.sortAsset),R.current===n&&E((function(e){return[].concat(f.default(e),f.default(x))})),O&&a===s&&(T=x.find((function(e){return O===e.id||e.assetId&&O===e.assetId})),i.isEmpty(T)||S(T),a===l.ASSET_TYPES.rig.type&&P(null==T?void 0:T.activeWellId)),e.next=21;break;case 18:e.prev=18,e.t0=e.catch(0),console.error(e.t0);case 21:case"end":return e.stop()}}),e,null,[[0,18]])}))),function(e){return t.apply(this,arguments)});return a.useEffect((function(){n&&E([])}),[n]),a.useEffect((function(){var e,t=(e=y.default(v.default.mark((function e(){return v.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,D(!0),!p){e.next=7;break}return e.next=5,Promise.all(p.map((function(e){return C(e)})));case 5:e.next=9;break;case 7:return e.next=9,C();case 9:e.next=14;break;case 11:e.prev=11,e.t0=e.catch(0),console.error(e.t0);case 14:return e.prev=14,D(!1),e.finish(14);case 17:case"end":return e.stop()}}),e,null,[[0,11,14,17]])}))),function(){return e.apply(this,arguments)});t()}),[s,b,j,n,r,null==p?void 0:p.length]),{assets:k?[]:T,loading:k}},exports.useSecondaryAssetSelectData=function(e){var t=e.appKey,r=e.assetType,s=e.assetId,n=e.company,i=e.parentAssetType,l=e.parentAssetId,p=e.queryParams,f=e.assetFields,j=e.activeWellId,h=e.isRequiredAssetId,g=a.useState([]),A=q.default(g,2),O=A[0],S=A[1],P=a.useState(!0),_=q.default(P,2),x=_[0],T=_[1];return a.useEffect((function(){function e(){return(e=y.default(v.default.mark((function e(){var s,a;return v.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.mapAssetGetRequest(r)(m(m(m({},u.getRequestOptions(r,f)),{},d.default({per_page:1e4,company:"all"!==n?n:null},b(i),l),t&&{app_key:t}),p));case 2:s=e.sent,a=c.jsonaDataFormatter.deserialize(s),S(a.map((function(e){return u.formatAsset({asset:e,activeWellId:j,isRequiredAssetId:h})})).sort(u.sortAsset)),T(!1);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}T(!0),function(){e.apply(this,arguments)}()}),[r,s,i,l,t,j,n]),{assets:O,loading:x}};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/components/AssetEditorV2/effects/index.js"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { isEmpty } from 'lodash';\n\nimport { formatAsset, getRequestOptions, sortAsset } from '../utils';\n\nimport { jsonApi } from '~/clients';\nimport { jsonaDataFormatter } from '~/utils/jsonaDataFormatter';\nimport { ASSET_TYPES } from '~/constants';\n\nconst getParentAssetKey = assetType => {\n if (assetType === ASSET_TYPES.intervention_unit.type) {\n return 'intervention_unit_id';\n }\n return assetType;\n};\n\nexport function useSecondaryAssetSelectData({\n appKey,\n assetType,\n assetId,\n company,\n parentAssetType,\n parentAssetId,\n queryParams,\n assetFields,\n activeWellId,\n isRequiredAssetId,\n}) {\n const [assets, setAssets] = useState([]);\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n setLoading(true);\n async function loadAssets() {\n const response = await jsonApi.mapAssetGetRequest(assetType)({\n ...getRequestOptions(assetType, assetFields),\n per_page: 10000,\n company: company !== 'all' ? company : null,\n [getParentAssetKey(parentAssetType)]: parentAssetId,\n ...(appKey && { app_key: appKey }),\n ...queryParams,\n });\n\n const deserializedResponse = jsonaDataFormatter.deserialize(response);\n\n setAssets(\n deserializedResponse\n .map(asset => formatAsset({ asset, activeWellId, isRequiredAssetId }))\n .sort(sortAsset)\n );\n setLoading(false);\n }\n loadAssets();\n }, [assetType, assetId, parentAssetType, parentAssetId, appKey, activeWellId, company]);\n\n return { assets, loading };\n}\n\nconst getAssetFields = (assetType, assetFields) => {\n if (assetType === ASSET_TYPES.pad.type) {\n return [...assetFields, 'pad.active', 'pad.parent_frac_fleet_id', 'pad.current'];\n } else if (assetType === ASSET_TYPES.intervention_unit.type) {\n return [...assetFields, 'intervention_unit.active', 'intervention_unit.current'];\n }\n\n return assetFields;\n};\n\nexport function usePrimaryAssetSelectData({\n appKey,\n assetType,\n company,\n groups,\n isRequiredAssetId,\n parentAssetId,\n parentAssetType,\n searchText,\n assetFields,\n currentValue,\n setCurrentOption,\n onActiveAssetIdChange,\n}) {\n const [assets, setAssets] = useState([]);\n const [loading, setLoading] = useState(false);\n const prevCompany = useRef(null);\n\n const loadAssets = async group => {\n try {\n const currentAssetType = group?.type || assetType;\n const requestParams = { per_page: 10000 };\n if (parentAssetType && parentAssetId) requestParams[parentAssetType] = parentAssetId;\n if (company && company !== 'all') requestParams.company = company;\n if (searchText) requestParams.search = searchText;\n if (appKey) requestParams.app_key = appKey;\n\n prevCompany.current = company;\n\n const requestPromise = jsonApi.mapAssetGetRequest(currentAssetType)({\n ...getRequestOptions(currentAssetType, getAssetFields(currentAssetType, assetFields)),\n ...requestParams,\n });\n\n const response = await requestPromise;\n const deserializedResponse = jsonaDataFormatter.deserialize(response);\n\n const responseAssets = deserializedResponse\n .map(asset =>\n formatAsset({ asset, group: group?.name, isRequiredAssetId, isPrimaryAsset: true })\n )\n .filter(Boolean)\n .sort(sortAsset);\n\n if (prevCompany.current === company) {\n setAssets(prevState => [...prevState, ...responseAssets]);\n }\n if (currentValue && currentAssetType === assetType) {\n const currentAsset = responseAssets.find(\n asset => currentValue === asset.id || (asset.assetId && currentValue === asset.assetId)\n );\n if (!isEmpty(currentAsset)) {\n setCurrentOption(currentAsset);\n }\n\n if (currentAssetType === ASSET_TYPES.rig.type) {\n onActiveAssetIdChange(currentAsset?.activeWellId);\n }\n }\n } catch (e) {\n console.error(e);\n }\n };\n\n useEffect(() => {\n if (company) {\n setAssets([]);\n }\n }, [company]);\n\n useEffect(() => {\n const loadEverything = async () => {\n try {\n setLoading(true);\n\n if (groups) {\n await Promise.all(groups.map(group => loadAssets(group)));\n } else {\n await loadAssets();\n }\n } catch (e) {\n console.error(e);\n } finally {\n setLoading(false);\n }\n };\n\n loadEverything();\n }, [assetType, parentAssetType, parentAssetId, company, appKey, groups?.length]);\n\n return { assets: loading ? [] : assets, loading };\n}\n"],"names":["getParentAssetKey","assetType","ASSET_TYPES","intervention_unit","type","getAssetFields","assetFields","pad","concat","_toConsumableArray","_ref2","_ref3","appKey","company","groups","isRequiredAssetId","parentAssetId","parentAssetType","searchText","currentValue","setCurrentOption","onActiveAssetIdChange","useState","_useState6","_slicedToArray","_useState5","assets","setAssets","_useState8","_useState7","loading","setLoading","prevCompany","useRef","loadAssets","_asyncToGenerator","_regeneratorRuntime","mark","group","currentAssetType","requestParams","requestPromise","response","deserializedResponse","responseAssets","currentAsset","wrap","_context2","prev","next","per_page","search","app_key","current","jsonApi","mapAssetGetRequest","getRequestOptions","sent","jsonaDataFormatter","deserialize","map","asset","formatAsset","name","isPrimaryAsset","filter","Boolean","sort","sortAsset","prevState","find","id","assetId","isEmpty","rig","activeWellId","t0","console","error","stop","_callee2","_x","apply","this","arguments","useEffect","_ref4","loadEverything","_callee3","_context3","Promise","all","finish","length","_ref","queryParams","_useState2","_useState","_useState4","_useState3","_loadAssets","_callee","_context","_defineProperty"],"mappings":"+pEASA,IAAMA,EAAoB,SAAAC,GACxB,OAAIA,IAAcC,EAAAA,YAAYC,kBAAkBC,KACvC,uBAEFH,CACT,EA4CA,IAAMI,EAAiB,SAACJ,EAAWK,GACjC,OAAIL,IAAcC,EAAAA,YAAYK,IAAIH,KAChC,GAAAI,OAAAC,EAAAA,QAAWH,GAAa,CAAA,aAAc,2BAA4B,gBACzDL,IAAcC,cAAYC,kBAAkBC,KACrD,GAAAI,OAAAC,UAAWH,GAAW,CAAE,2BAA4B,8BAG/CA,CACT,oCAEO,SAaJI,GAAA,IAKeC,EAjBhBC,IAAAA,OACAX,IAAAA,UACAY,IAAAA,QACAC,IAAAA,OACAC,IAAAA,kBACAC,IAAAA,cACAC,IAAAA,gBACAC,IAAAA,WACAZ,IAAAA,YACAa,IAAAA,aACAC,IAAAA,iBAC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,IACtBmF,IACH,KAAA,EAPIrD,EAAQ4D,EAAA7C,KASRd,EAAuBe,EAAkBA,mBAACC,YAAYjB,GAE5Df,EACEgB,EACGiB,KAAI,SAAAC,GAAK,OAAIC,cAAY,CAAED,MAAAA,EAAOc,aAAAA,EAAc5D,kBAAAA,GAAoB,IACpEoD,KAAKC,EAASA,YAEnBrC,GAAW,GAAO,KAAA,EAAA,IAAA,MAAA,OAAAuE,EAAAvB,OAAA,GAAAsB,EACnB,MAAAnB,MAAAC,KAAAC,UAAA,CAnBDrD,GAAW,GAAM,WACQqE,EAAAlB,MAAAC,KAAAC,UAAA,CAmBzBlD,EACF,GAAG,CAACjC,EAAWuE,EAASvD,EAAiBD,EAAeJ,EAAQ+D,EAAc9D,IAEvE,CAAEa,OAAAA,EAAQI,QAAAA,EACnB"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/components/AssetEditorV2/effects/index.js"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { isEmpty } from 'lodash';\n\nimport { formatAsset, getRequestOptions, sortAsset } from '../utils';\n\nimport { jsonApi } from '~/clients';\nimport { jsonaDataFormatter } from '~/utils/jsonaDataFormatter';\nimport { ASSET_TYPES } from '~/constants';\n\nconst getParentAssetKey = assetType => {\n if (assetType === ASSET_TYPES.intervention_unit.type) {\n return 'intervention_unit_id';\n }\n return assetType;\n};\n\nexport function useSecondaryAssetSelectData({\n appKey,\n assetType,\n assetId,\n company,\n parentAssetType,\n parentAssetId,\n queryParams,\n assetFields,\n activeWellId,\n isRequiredAssetId,\n}) {\n const [assets, setAssets] = useState([]);\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n setLoading(true);\n async function loadAssets() {\n const response = await jsonApi.mapAssetGetRequest(assetType)({\n ...getRequestOptions(assetType, assetFields),\n per_page: 10000,\n company: company !== 'all' ? company : null,\n [getParentAssetKey(parentAssetType)]: parentAssetId,\n ...(appKey && { app_key: appKey }),\n ...queryParams,\n });\n\n const deserializedResponse = jsonaDataFormatter.deserialize(response);\n\n setAssets(\n deserializedResponse\n .map(asset => formatAsset({ asset, activeWellId, isRequiredAssetId }))\n .sort(sortAsset)\n );\n setLoading(false);\n }\n loadAssets();\n }, [assetType, assetId, parentAssetType, parentAssetId, appKey, activeWellId, company]);\n\n return { assets, loading };\n}\n\nconst getAssetFields = (assetType, assetFields) => {\n if (assetType === ASSET_TYPES.pad.type) {\n return [...assetFields, 'pad.active', 'pad.parent_frac_fleet_id', 'pad.current'];\n } else if (assetType === ASSET_TYPES.intervention_unit.type) {\n return [...assetFields, 'intervention_unit.active', 'intervention_unit.current'];\n }\n\n return assetFields;\n};\n\nexport function usePrimaryAssetSelectData({\n appKey,\n assetType,\n company,\n groups,\n isRequiredAssetId,\n parentAssetId,\n parentAssetType,\n searchText,\n assetFields,\n currentValue,\n setCurrentOption,\n onActiveAssetIdChange,\n}) {\n const [assets, setAssets] = useState([]);\n const [loading, setLoading] = useState(false);\n const prevCompany = useRef(null);\n\n const loadAssets = async group => {\n try {\n const currentAssetType = group?.type || assetType;\n const requestParams = { per_page: 10000 };\n if (parentAssetType && parentAssetId) requestParams[parentAssetType] = parentAssetId;\n if (company && company !== 'all') requestParams.company = company;\n if (searchText) requestParams.search = searchText;\n if (appKey) requestParams.app_key = appKey;\n\n prevCompany.current = company;\n\n const requestPromise = jsonApi.mapAssetGetRequest(currentAssetType)({\n ...getRequestOptions(currentAssetType, getAssetFields(currentAssetType, assetFields)),\n ...requestParams,\n });\n\n const response = await requestPromise;\n const deserializedResponse = jsonaDataFormatter.deserialize(response);\n\n const responseAssets = deserializedResponse\n .map(asset =>\n formatAsset({ asset, group: group?.name, isRequiredAssetId, isPrimaryAsset: true })\n )\n .filter(Boolean)\n .sort(sortAsset);\n\n if (prevCompany.current === company) {\n setAssets(prevState => [...prevState, ...responseAssets]);\n }\n if (currentValue && currentAssetType === assetType) {\n const currentAsset = responseAssets.find(\n asset => currentValue === asset.id || (asset.assetId && currentValue === asset.assetId)\n );\n if (!isEmpty(currentAsset)) {\n setCurrentOption(currentAsset);\n }\n\n if (currentAssetType === ASSET_TYPES.rig.type) {\n onActiveAssetIdChange(currentAsset?.activeWellId);\n }\n }\n } catch (e) {\n console.error(e);\n }\n };\n\n useEffect(() => {\n if (company) {\n setAssets([]);\n }\n }, [company]);\n\n useEffect(() => {\n const loadEverything = async () => {\n try {\n setLoading(true);\n\n if (groups) {\n await Promise.all(groups.map(group => loadAssets(group)));\n } else {\n await loadAssets();\n }\n } catch (e) {\n console.error(e);\n } finally {\n setLoading(false);\n }\n };\n\n loadEverything();\n }, [assetType, parentAssetType, parentAssetId, company, appKey, groups?.length]);\n\n return { assets: loading ? [] : assets, loading };\n}\n"],"names":["getParentAssetKey","assetType","ASSET_TYPES","intervention_unit","type","getAssetFields","assetFields","pad","concat","_toConsumableArray","_ref2","_ref3","appKey","company","groups","isRequiredAssetId","parentAssetId","parentAssetType","searchText","currentValue","setCurrentOption","onActiveAssetIdChange","useState","_useState6","_slicedToArray","_useState5","assets","setAssets","_useState8","_useState7","loading","setLoading","prevCompany","useRef","loadAssets","_asyncToGenerator","_regeneratorRuntime","mark","group","currentAssetType","requestParams","requestPromise","response","deserializedResponse","responseAssets","currentAsset","wrap","_context2","prev","next","per_page","search","app_key","current","jsonApi","mapAssetGetRequest","getRequestOptions","sent","jsonaDataFormatter","deserialize","map","asset","formatAsset","name","isPrimaryAsset","filter","Boolean","sort","sortAsset","prevState","find","id","assetId","isEmpty","rig","activeWellId","t0","console","error","stop","_callee2","_x","apply","this","arguments","useEffect","_ref4","loadEverything","_callee3","_context3","Promise","all","finish","length","_ref","queryParams","_useState2","_useState","_useState4","_useState3","_loadAssets","_callee","_context","_defineProperty"],"mappings":"8sEASA,IAAMA,EAAoB,SAAAC,GACxB,OAAIA,IAAcC,EAAAA,YAAYC,kBAAkBC,KACvC,uBAEFH,CACT,EA4CA,IAAMI,EAAiB,SAACJ,EAAWK,GACjC,OAAIL,IAAcC,EAAAA,YAAYK,IAAIH,KAChC,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U,MAAA,SAAAwD,GAAA,OAAA,OAAAA,EAAAtD,KAAAsD,EAAArD,MAAA,KAAA,EAAA,OAAAqD,EAAArD,KAAA,EACyBK,EAA0BC,mBAACtD,EAA3BqD,CAClBE,EAAAA,EAAAA,EAAAA,GAAAA,EAAAA,kBAAkBvD,EAAWK,IAAY,CAAA,EAAAiG,EAAAA,QAAA,CAC5CrD,SAAU,IACVrC,QAAqB,QAAZA,EAAoBA,EAAU,MACtCb,EAAkBiB,GAAmBD,GAClCJ,GAAU,CAAEwC,QAASxC,IACtBmF,IACH,KAAA,EAPIrD,EAAQ4D,EAAA7C,KASRd,EAAuBe,EAAkBA,mBAACC,YAAYjB,GAE5Df,EACEgB,EACGiB,KAAI,SAAAC,GAAK,OAAIC,cAAY,CAAED,MAAAA,EAAOc,aAAAA,EAAc5D,kBAAAA,GAAoB,IACpEoD,KAAKC,EAASA,YAEnBrC,GAAW,GAAO,KAAA,EAAA,IAAA,MAAA,OAAAuE,EAAAvB,OAAA,GAAAsB,EACnB,MAAAnB,MAAAC,KAAAC,UAAA,CAnBDrD,GAAW,GAAM,WACQqE,EAAAlB,MAAAC,KAAAC,UAAA,CAmBzBlD,EACF,GAAG,CAACjC,EAAWuE,EAASvD,EAAiBD,EAAeJ,EAAQ+D,EAAc9D,IAEvE,CAAEa,OAAAA,EAAQI,QAAAA,EACnB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/asyncToGenerator"),r=require("@babel/runtime/helpers/toConsumableArray"),s=require("@babel/runtime/helpers/slicedToArray"),n=require("@babel/runtime/regenerator"),i=require("react"),a=require("lodash"),u=require("../utils/index.js");require("uuid"),require("lodash/set"),require("lodash/get"),require("lodash/unset"),require("moment");var o=require("../../../clients/jsonApi/index.js");require("../../../clients/subscriptions/constants.js"),require("../../../clients/subscriptions.v1.js"),require("../../../clients/subscriptions/subscriptions-client.factory.js"),require("../../../clients/api/apiCore.js"),require("../../../clients/constants.js"),require("../../../clients/sso/auth0.js"),require("../../../clients/sso/oauth2.js");var c=require("../../../utils/jsonaDataFormatter.js"),l=require("../../AssetEditor/constants.js");require("../../../constants/goals.js"),require("../../../constants/segment.js"),require("../../../constants/alerts.js"),require("../../../constants/apps.js"),require("../../../constants/drillstring.js"),require("../../../constants/completion.js"),require("../../../constants/appPackages.js"),require("../../../constants/notifications.js"),require("../../../constants/feed.js"),require("../../../constants/bha.js");var p=require("../../../constants/assetTypes.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("../../../constants/corvaCompanyId.js"),require("../../GradientManager/configuration/constants.js");var f=d(e),q=d(t),j=d(r),y=d(s),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/asyncToGenerator"),r=require("@babel/runtime/helpers/toConsumableArray"),s=require("@babel/runtime/helpers/slicedToArray"),n=require("@babel/runtime/regenerator"),i=require("react"),a=require("lodash"),u=require("../utils/index.js");require("uuid"),require("lodash/set"),require("lodash/get"),require("lodash/unset"),require("moment");var o=require("../../../clients/jsonApi/index.js");require("../../../clients/subscriptions/constants.js"),require("../../../clients/subscriptions.v1.js"),require("../../../clients/subscriptions/subscriptions-client.factory.js"),require("../../../clients/api/apiCore.js"),require("../../../clients/constants.js"),require("../../../clients/sso/auth0.js"),require("../../../clients/sso/oauth2.js"),require("../../../clients/api/rateLimiter.js");var c=require("../../../utils/jsonaDataFormatter.js"),l=require("../../AssetEditor/constants.js");require("../../../constants/goals.js"),require("../../../constants/segment.js"),require("../../../constants/alerts.js"),require("../../../constants/apps.js"),require("../../../constants/drillstring.js"),require("../../../constants/completion.js"),require("../../../constants/appPackages.js"),require("../../../constants/notifications.js"),require("../../../constants/feed.js"),require("../../../constants/bha.js");var p=require("../../../constants/assetTypes.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("../../../constants/corvaCompanyId.js"),require("../../GradientManager/configuration/constants.js");var f=d(e),q=d(t),j=d(r),y=d(s),m=d(n);function v(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?v(Object(r),!0).forEach((function(t){f.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):v(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}exports.usePrimaryAssetSelectData=function(e){var t,r,s=e.appKey,n=e.assetType,d=e.company,f=e.groups,v=e.isRequiredAssetId,g=e.parentAssetId,h=e.parentAssetType,A=e.searchValue,P=e.assetFields,O=e.currentValue,E=e.setCurrentOption,S=e.scrollPage,R=e.onActiveAssetIdChange,_=e.isDrillingPlatformApp,x=i.useState([]),D=y.default(x,2),T=D[0],w=D[1],I=i.useState(!1),k=y.default(I,2),C=k[0],G=k[1],F=i.useRef(null),Y=i.useRef(null),z=i.useRef(null),M=i.useRef(null),V=n===p.ASSET_TYPES.pad.type?[].concat(j.default(P),["pad.active","pad.parent_frac_fleet_id"]):P,W=(t=q.default(m.default.mark((function e(t){var r,i,p,f,q,y,P,O=arguments;return m.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=O.length>1&&void 0!==O[1]&&O[1],e.prev=1,i=(null==t?void 0:t.type)||n,G(!0),p={per_page:l.PER_PAGE,page:S},h&&g&&(p[h]=g),d&&"all"!==d&&(p.company=d),A&&(p.search=A),s&&(p.app_key=s),F.current=d,f=o.mapAssetGetRequest(i)(b(b({},u.getRequestOptions(i,V)),p)),e.next=13,f;case 13:q=e.sent,y=c.jsonaDataFormatter.deserialize(q),P=a.map(y,(function(e){return u.formatAsset({asset:e,group:null==t?void 0:t.name,isRequiredAssetId:v,isPrimaryAsset:!0,isDrillingPlatformApp:_})})).sort(u.sortAsset),F.current===d&&w(r?function(e){return a.uniqBy([].concat(j.default(e),j.default(P)),"id")}:P),e.next=22;break;case 19:e.prev=19,e.t0=e.catch(1),console.error(e.t0);case 22:return e.prev=22,G(!1),e.finish(22);case 25:case"end":return e.stop()}}),e,null,[[1,19,22,25]])}))),function(e){return t.apply(this,arguments)}),B=(r=q.default(m.default.mark((function e(){var t,r,s,i,l,d,f,q;return m.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.mapAssetGetRequest(n)(b(b({},u.getRequestOptions(n,V)),{},{ids:O}));case 2:if(t=e.sent,!a.isEmpty(t.data)){e.next=7;break}return e.next=6,o.getAssets(b(b({},u.getRequestOptions(n,V)),{},{ids:O}));case 6:t=e.sent;case 7:r=c.jsonaDataFormatter.deserialize(t),s=u.formatAsset({asset:r[0],isPrimaryAsset:!0,isRequiredAssetId:v,isDrillingPlatformApp:_}),E(s),n===p.ASSET_TYPES.rig.type?(f=_?Number(null===(i=t)||void 0===i||null===(l=i.included)||void 0===l||null===(d=l[0])||void 0===d?void 0:d.id):(null==s?void 0:s.activeWellId)||null,R(f)):n===p.ASSET_TYPES.intervention_unit.type&&(q=(null==s?void 0:s.activeWellId)||null,R(q));case 11:case"end":return e.stop()}}),e)}))),function(){return r.apply(this,arguments)});return i.useEffect((function(){d&&w([])}),[d]),i.useEffect((function(){var e=z.current!==A,t=M.current!==S,r=!e&&t&&S>1&&(M.current||0)<S;e&&(z.current=A),t&&(M.current=S),f?f.forEach((function(e){W(e,r)})):(n&&Y.current&&Y.current!==n&&w([]),Y.current=n,W(null,r))}),[n,h,g,d,s,null==f?void 0:f.length,A,S]),i.useEffect((function(){O&&B()}),[]),{assets:T,loading:C}};
|
|
2
2
|
//# sourceMappingURL=usePrimaryAssetSelectData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePrimaryAssetSelectData.js","sources":["../../../../../src/components/AssetEditorV2/effects/usePrimaryAssetSelectData.js"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { isEmpty, map, uniqBy } from 'lodash';\n\nimport { formatAsset, getRequestOptions, sortAsset } from '../utils';\n\nimport { jsonApi } from '~/clients';\nimport { jsonaDataFormatter } from '~/utils/jsonaDataFormatter';\nimport { PER_PAGE } from '~/components/AssetEditor/constants';\nimport { ASSET_TYPES } from '~/constants';\n\nexport function usePrimaryAssetSelectData({\n appKey,\n assetType,\n company,\n groups,\n isRequiredAssetId,\n parentAssetId,\n parentAssetType,\n searchValue,\n assetFields,\n currentValue,\n setCurrentOption,\n scrollPage,\n onActiveAssetIdChange,\n isDrillingPlatformApp,\n}) {\n const [assets, setAssets] = useState([]);\n const [loading, setLoading] = useState(false);\n const prevCompany = useRef(null);\n const prevAssetType = useRef(null);\n const prevSearchValue = useRef(null);\n const prevScrollPage = useRef(null);\n\n const assetFieldsByAssetType =\n assetType === ASSET_TYPES.pad.type\n ? [...assetFields, 'pad.active', 'pad.parent_frac_fleet_id']\n : assetFields;\n\n const loadAssets = async (group, shouldAppend = false) => {\n try {\n const currentAssetType = group?.type || assetType;\n setLoading(true);\n const requestParams = { per_page: PER_PAGE, page: scrollPage };\n if (parentAssetType && parentAssetId) requestParams[parentAssetType] = parentAssetId;\n if (company && company !== 'all') requestParams.company = company;\n if (searchValue) requestParams.search = searchValue;\n if (appKey) requestParams.app_key = appKey;\n\n prevCompany.current = company;\n const requestPromise = jsonApi.mapAssetGetRequest(currentAssetType)({\n ...getRequestOptions(currentAssetType, assetFieldsByAssetType),\n ...requestParams,\n });\n\n const response = await requestPromise;\n const deserializedResponse = jsonaDataFormatter.deserialize(response);\n\n const responseAssets = map(deserializedResponse, asset =>\n formatAsset({\n asset,\n group: group?.name,\n isRequiredAssetId,\n isPrimaryAsset: true,\n isDrillingPlatformApp,\n })\n ).sort(sortAsset);\n\n if (prevCompany.current === company) {\n if (shouldAppend) {\n setAssets(prevState => uniqBy([...prevState, ...responseAssets], 'id'));\n } else {\n setAssets(responseAssets);\n }\n }\n } catch (e) {\n console.error(e);\n } finally {\n setLoading(false);\n }\n };\n\n const loadCurrentOption = async () => {\n let response = await jsonApi.mapAssetGetRequest(assetType)({\n ...getRequestOptions(assetType, assetFieldsByAssetType),\n ids: currentValue,\n });\n if (isEmpty(response.data)) {\n // NOTE: Try fetch current option from v2/assets\n response = await jsonApi.getAssets({\n ...getRequestOptions(assetType, assetFieldsByAssetType),\n ids: currentValue,\n });\n }\n const deserializedResponse = jsonaDataFormatter.deserialize(response);\n\n const formattedAsset = formatAsset({\n asset: deserializedResponse[0],\n isPrimaryAsset: true,\n isRequiredAssetId,\n isDrillingPlatformApp,\n });\n\n setCurrentOption(formattedAsset);\n if (assetType === ASSET_TYPES.rig.type) {\n const activeWellId = isDrillingPlatformApp\n ? Number(response?.included?.[0]?.id)\n : formattedAsset?.activeWellId || null;\n onActiveAssetIdChange(activeWellId);\n } else if (assetType === ASSET_TYPES.intervention_unit.type) {\n const activeWellId = formattedAsset?.activeWellId || null;\n onActiveAssetIdChange(activeWellId);\n }\n };\n\n useEffect(() => {\n if (company) {\n setAssets([]);\n }\n }, [company]);\n\n useEffect(() => {\n // Check if searchValue changed - if so, reset assets and don't append\n const searchValueChanged = prevSearchValue.current !== searchValue;\n const scrollPageChanged = prevScrollPage.current !== scrollPage;\n // Only append for pagination: searchValue didn't change AND scrollPage increased\n const isPagination =\n !searchValueChanged &&\n scrollPageChanged &&\n scrollPage > 1 &&\n (prevScrollPage.current || 0) < scrollPage;\n\n if (searchValueChanged) {\n prevSearchValue.current = searchValue;\n }\n if (scrollPageChanged) {\n prevScrollPage.current = scrollPage;\n }\n\n if (groups) {\n groups.forEach(group => {\n loadAssets(group, isPagination);\n });\n return;\n }\n if (!!assetType && !!prevAssetType.current && prevAssetType.current !== assetType) {\n setAssets([]);\n }\n prevAssetType.current = assetType;\n loadAssets(null, isPagination);\n }, [\n assetType,\n parentAssetType,\n parentAssetId,\n company,\n appKey,\n groups?.length,\n searchValue,\n scrollPage,\n ]);\n\n useEffect(() => {\n if (currentValue) {\n loadCurrentOption();\n }\n }, []);\n\n return { assets, loading };\n}\n"],"names":["_ref","_ref2","_ref3","appKey","assetType","company","groups","isRequiredAssetId","parentAssetId","parentAssetType","searchValue","assetFields","currentValue","setCurrentOption","scrollPage","onActiveAssetIdChange","isDrillingPlatformApp","useState","_useState2","_slicedToArray","_useState","assets","setAssets","_useState4","_useState3","loading","setLoading","prevCompany","useRef","prevAssetType","prevSearchValue","prevScrollPage","assetFieldsByAssetType","ASSET_TYPES","pad","type","concat","_toConsumableArray","loadAssets","_asyncToGenerator","_regeneratorRuntime","mark","group","shouldAppend","currentAssetType","requestParams","requestPromise","response","deserializedResponse","responseAssets","_args","arguments","wrap","_context","prev","next","per_page","PER_PAGE","page","search","app_key","current","jsonApi","_objectSpread","getRequestOptions","sent","jsonaDataFormatter","deserialize","map","asset","formatAsset","name","isPrimaryAsset","sort","sortAsset","prevState","uniqBy","t0","console","error","finish","stop","_callee","_x","apply","this","loadCurrentOption","_callee2","formattedAsset","_response","_response$included","_response$included$","activeWellId","_activeWellId","_context2","ids","isEmpty","data","getAssets","rig","Number","included","id","intervention_unit","useEffect","searchValueChanged","scrollPageChanged","isPagination","forEach","length"],"mappings":"6uEAUO,SAeJA,GAAA,IAaeC,EA2CUC,EAtE1BC,IAAAA,OACAC,IAAAA,UACAC,IAAAA,QACAC,IAAAA,OACAC,IAAAA,kBACAC,IAAAA,cACAC,IAAAA,gBACAC,IAAAA,YACAC,IAAAA,YACAC,IAAAA,aACAC,IAAAA,iBACAC,IAAAA,WACAC,IAAAA,sBACAC,IAAAA,sBAE4BC,EAAAA,EAAQA,SAAC,IAAGC,EAAAC,EAAAA,QAAAC,EAAA,GAAjCC,EAAMH,EAAA,GAAEI,EAASJ,EAAA,GACMD,EAAAA,EAAQA,UAAC,GAAMM,EAAAJ,EAAAA,QAAAK,EAAA,GAAtCC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components/AssetEditorV2/effects/usePrimaryAssetSelectData.js"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport { isEmpty, map, uniqBy } from 'lodash';\n\nimport { formatAsset, getRequestOptions, sortAsset } from '../utils';\n\nimport { jsonApi } from '~/clients';\nimport { jsonaDataFormatter } from '~/utils/jsonaDataFormatter';\nimport { PER_PAGE } from '~/components/AssetEditor/constants';\nimport { ASSET_TYPES } from '~/constants';\n\nexport function usePrimaryAssetSelectData({\n appKey,\n assetType,\n company,\n groups,\n isRequiredAssetId,\n parentAssetId,\n parentAssetType,\n searchValue,\n assetFields,\n currentValue,\n setCurrentOption,\n scrollPage,\n onActiveAssetIdChange,\n isDrillingPlatformApp,\n}) {\n const [assets, setAssets] = useState([]);\n const [loading, setLoading] = useState(false);\n const prevCompany = useRef(null);\n const prevAssetType = useRef(null);\n const prevSearchValue = useRef(null);\n const prevScrollPage = useRef(null);\n\n const assetFieldsByAssetType =\n assetType === ASSET_TYPES.pad.type\n ? [...assetFields, 'pad.active', 'pad.parent_frac_fleet_id']\n : assetFields;\n\n const loadAssets = async (group, shouldAppend = false) => {\n try {\n const currentAssetType = group?.type || assetType;\n setLoading(true);\n const requestParams = { per_page: PER_PAGE, page: scrollPage };\n if (parentAssetType && parentAssetId) requestParams[parentAssetType] = parentAssetId;\n if (company && company !== 'all') requestParams.company = company;\n if (searchValue) requestParams.search = searchValue;\n if (appKey) requestParams.app_key = appKey;\n\n prevCompany.current = company;\n const requestPromise = jsonApi.mapAssetGetRequest(currentAssetType)({\n ...getRequestOptions(currentAssetType, assetFieldsByAssetType),\n ...requestParams,\n });\n\n const response = await requestPromise;\n const deserializedResponse = jsonaDataFormatter.deserialize(response);\n\n const responseAssets = map(deserializedResponse, asset =>\n formatAsset({\n asset,\n group: group?.name,\n isRequiredAssetId,\n isPrimaryAsset: true,\n isDrillingPlatformApp,\n })\n ).sort(sortAsset);\n\n if (prevCompany.current === company) {\n if (shouldAppend) {\n setAssets(prevState => uniqBy([...prevState, ...responseAssets], 'id'));\n } else {\n setAssets(responseAssets);\n }\n }\n } catch (e) {\n console.error(e);\n } finally {\n setLoading(false);\n }\n };\n\n const loadCurrentOption = async () => {\n let response = await jsonApi.mapAssetGetRequest(assetType)({\n ...getRequestOptions(assetType, assetFieldsByAssetType),\n ids: currentValue,\n });\n if (isEmpty(response.data)) {\n // NOTE: Try fetch current option from v2/assets\n response = await jsonApi.getAssets({\n ...getRequestOptions(assetType, assetFieldsByAssetType),\n ids: currentValue,\n });\n }\n const deserializedResponse = jsonaDataFormatter.deserialize(response);\n\n const formattedAsset = formatAsset({\n asset: deserializedResponse[0],\n isPrimaryAsset: true,\n isRequiredAssetId,\n isDrillingPlatformApp,\n });\n\n setCurrentOption(formattedAsset);\n if (assetType === ASSET_TYPES.rig.type) {\n const activeWellId = isDrillingPlatformApp\n ? Number(response?.included?.[0]?.id)\n : formattedAsset?.activeWellId || null;\n onActiveAssetIdChange(activeWellId);\n } else if (assetType === ASSET_TYPES.intervention_unit.type) {\n const activeWellId = formattedAsset?.activeWellId || null;\n onActiveAssetIdChange(activeWellId);\n }\n };\n\n useEffect(() => {\n if (company) {\n setAssets([]);\n }\n }, [company]);\n\n useEffect(() => {\n // Check if searchValue changed - if so, reset assets and don't append\n const searchValueChanged = prevSearchValue.current !== searchValue;\n const scrollPageChanged = prevScrollPage.current !== scrollPage;\n // Only append for pagination: searchValue didn't change AND scrollPage increased\n const isPagination =\n !searchValueChanged &&\n scrollPageChanged &&\n scrollPage > 1 &&\n (prevScrollPage.current || 0) < scrollPage;\n\n if (searchValueChanged) {\n prevSearchValue.current = searchValue;\n }\n if (scrollPageChanged) {\n prevScrollPage.current = scrollPage;\n }\n\n if (groups) {\n groups.forEach(group => {\n loadAssets(group, isPagination);\n });\n return;\n }\n if (!!assetType && !!prevAssetType.current && prevAssetType.current !== assetType) {\n setAssets([]);\n }\n prevAssetType.current = assetType;\n loadAssets(null, isPagination);\n }, [\n assetType,\n parentAssetType,\n parentAssetId,\n company,\n appKey,\n groups?.length,\n searchValue,\n scrollPage,\n ]);\n\n useEffect(() => {\n if (currentValue) {\n loadCurrentOption();\n }\n }, []);\n\n return { assets, loading };\n}\n"],"names":["_ref","_ref2","_ref3","appKey","assetType","company","groups","isRequiredAssetId","parentAssetId","parentAssetType","searchValue","assetFields","currentValue","setCurrentOption","scrollPage","onActiveAssetIdChange","isDrillingPlatformApp","useState","_useState2","_slicedToArray","_useState","assets","setAssets","_useState4","_useState3","loading","setLoading","prevCompany","useRef","prevAssetType","prevSearchValue","prevScrollPage","assetFieldsByAssetType","ASSET_TYPES","pad","type","concat","_toConsumableArray","loadAssets","_asyncToGenerator","_regeneratorRuntime","mark","group","shouldAppend","currentAssetType","requestParams","requestPromise","response","deserializedResponse","responseAssets","_args","arguments","wrap","_context","prev","next","per_page","PER_PAGE","page","search","app_key","current","jsonApi","_objectSpread","getRequestOptions","sent","jsonaDataFormatter","deserialize","map","asset","formatAsset","name","isPrimaryAsset","sort","sortAsset","prevState","uniqBy","t0","console","error","finish","stop","_callee","_x","apply","this","loadCurrentOption","_callee2","formattedAsset","_response","_response$included","_response$included$","activeWellId","_activeWellId","_context2","ids","isEmpty","data","getAssets","rig","Number","included","id","intervention_unit","useEffect","searchValueChanged","scrollPageChanged","isPagination","forEach","length"],"mappings":"4xEAUO,SAeJA,GAAA,IAaeC,EA2CUC,EAtE1BC,IAAAA,OACAC,IAAAA,UACAC,IAAAA,QACAC,IAAAA,OACAC,IAAAA,kBACAC,IAAAA,cACAC,IAAAA,gBACAC,IAAAA,YACAC,IAAAA,YACAC,IAAAA,aACAC,IAAAA,iBACAC,IAAAA,WACAC,IAAAA,sBACAC,IAAAA,sBAE4BC,EAAAA,EAAQA,SAAC,IAAGC,EAAAC,EAAAA,QAAAC,EAAA,GAAjCC,EAAMH,EAAA,GAAEI,EAASJ,EAAA,GACMD,EAAAA,EAAQA,UAAC,GAAMM,EAAAJ,EAAAA,QAAAK,EAAA,GAAtCC,EAAOF,EAAA,GAAEG,E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react"),i=require("prop-types"),o=require("react-player"),n=require("classnames"),t=require("@material-ui/core/styles"),r=require("@material-ui/core"),c=require("@material-ui/icons/Image"),a=require("@material-ui/icons/Fullscreen"),l=require("@material-ui/core/colors/grey"),u=require("../NewDocumentViewer/NewDocumentViewer.js"),m=require("../NewDocumentViewer/icons/UnavailableFileIcon.js"),d=require("./styles.css.js"),p=require("../FileTypeIcon.js"),q=require("../ImageViewer/index.js"),j=require("../IconButton/index.js"),h=require("../../utils/mobileDetect.js"),I=require("../../utils/fileExtension.js"),g=require("../../utils/filePreview.js"),f=require("../../icons/iconParkIcons.js");require("../../icons/customIcons/icons/AddMessage.js"),require("../../icons/customIcons/icons/Attention.js"),require("../../icons/customIcons/icons/Collapse.js"),require("../../icons/customIcons/icons/Dashboard.js"),require("../../icons/customIcons/icons/Expand.js"),require("../../icons/customIcons/icons/FolderClosed.js"),require("../../icons/customIcons/icons/FolderClosedFilled.js"),require("../../icons/customIcons/icons/FolderOpened.js"),require("../../icons/customIcons/icons/GreaterOrEqual.js"),require("../../icons/customIcons/icons/LessOrEqual.js"),require("../../icons/customIcons/icons/Search.js"),require("../../icons/customIcons/icons/SearchOne.js"),require("../../icons/customIcons/icons/Wellhub.js"),require("../../icons/customIcons/icons/MultiRuler.js"),require("../../icons/customIcons/icons/Checkbox.js"),require("../../icons/customIcons/icons/CheckboxChecked.js"),require("../../icons/customIcons/icons/CheckboxIndeterminate.js"),require("../../icons/customIcons/icons/Radio.js"),require("../../icons/customIcons/icons/RadioChecked.js"),require("../../icons/customIcons/icons/SimulFrac.js"),require("../../icons/customIcons/icons/ZipperFrac.js"),require("../../icons/customIcons/icons/CautionFilled.js"),require("../../icons/customIcons/icons/MoreApp.js"),require("../../icons/customIcons/icons/Pad.js"),require("../../icons/customIcons/icons/DrilloutUnit.js"),require("../../icons/customIcons/icons/FracFleet.js"),require("../../icons/customIcons/icons/Global.js"),require("../../icons/customIcons/icons/Program.js"),require("../../icons/customIcons/icons/Rig.js"),require("../../icons/customIcons/icons/Well.js"),require("../../icons/customIcons/icons/Gap.js"),require("../../icons/customIcons/icons/Pin.js"),require("../../icons/customIcons/icons/CloseOneFilled.js"),require("../../icons/customIcons/icons/AttentionFilled.js"),require("../../icons/customIcons/icons/CheckOneFilled.js"),require("../../icons/customIcons/icons/Archive.js"),require("../../icons/customIcons/icons/ArchiveCancel.js"),require("../../icons/customIcons/icons/Unarchive.js"),require("../../icons/customIcons/icons/Archived.js"),require("../../icons/customIcons/icons/InterventionUnit.js"),require("../../icons/customIcons/icons/CloudDelete.js"),require("../../icons/customIcons/icons/Lasso.js"),require("../../icons/customIcons/icons/Radius.js"),require("../../icons/customIcons/icons/ErrorOps.js"),require("../../icons/customIcons/icons/DataTypeOps.js"),require("../../icons/customIcons/icons/FalsePositiveOps.js"),require("../../icons/customIcons/icons/CalibrationOps.js"),require("../../icons/customIcons/icons/CriticalOps.js"),require("../../icons/customIcons/icons/Company.js"),require("../../icons/customIcons/icons/ArchiveOne.js"),require("../../icons/customIcons/icons/ParseBotFusion.js"),require("../../icons/customIcons/icons/Connect.js"),require("../../icons/customIcons/icons/PuzzleOne.js"),require("../../icons/customIcons/icons/Feed.js"),require("../../icons/customIcons/icons/Prompt.js"),require("../../icons/customIcons/icons/Companies.js"),require("../../icons/customIcons/icons/ClipboardAi.js"),require("../../icons/customIcons/icons/Key.js"),require("../../icons/customIcons/icons/AtSignCrossed.js"),require("../../icons/customIcons/icons/MappingManual.js"),require("../../icons/customIcons/icons/Mapping.js"),require("../../icons/customIcons/icons/Metrics.js"),require("../../icons/customIcons/icons/Drops.js"),require("../../icons/customIcons/icons/ClipboardSearch.js"),require("../../icons/customIcons/icons/Template.js"),require("../../icons/customIcons/icons/ClipboardMetrics.js"),require("../../icons/customIcons/icons/ClipboardBuilder.js"),require("../../icons/customIcons/icons/UnitConversion.js"),require("../../icons/customIcons/icons/NPT.js"),require("../../clients/subscriptions/constants.js"),require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/helpers/defineProperty"),require("@babel/runtime/regenerator"),require("querystring"),require("uuid/v1"),require("lodash"),require("../../clients/subscriptions.v1.js"),require("../../clients/jsonApi/index.js"),require("../../clients/subscriptions/subscriptions-client.factory.js"),require("immutable"),require("query-string"),require("../../constants/goals.js"),require("../../constants/segment.js"),require("../../constants/alerts.js"),require("../../constants/apps.js"),require("../../constants/drillstring.js"),require("../../constants/completion.js"),require("../../constants/appPackages.js"),require("../../constants/notifications.js"),require("../../constants/feed.js"),require("../../constants/bha.js"),require("../../constants/corvaCompanyId.js"),require("../GradientManager/configuration/constants.js");var v=require("../../effects/useSignedURL.js");require("../../utils/index.js"),require("uuid"),require("jsona"),require("../../utils/env.js"),require("../StatusBadge/constants.js"),require("@babel/runtime/helpers/toConsumableArray"),require("lodash/set"),require("lodash/get"),require("lodash/unset"),require("moment"),require("../../clients/api/apiCore.js"),require("../../clients/constants.js"),require("../../clients/sso/auth0.js"),require("../../clients/sso/oauth2.js"),require("lodash/isEmpty"),require("lodash/sortBy"),require("../../constants/streamSourceType.js"),require("../DevCenter/DevCenterAppContainer/components/CommentsSwitch/CommentsSwitchContext.js"),require("../../componentsV2/AppCommonsProvider/AppCommonsProvider.js"),require("../../componentsV2/AppCommonsProvider/AppCommonsContext.js"),require("../../componentsV2/AppSettings/AppSettingsPinningContext.js");var b=require("../../utils/main.js"),x=require("react/jsx-runtime");function C(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var N=C(e),w=C(i),y=C(o),A=C(n),F=C(c),P=C(a),S=C(l),D=S.default[200],O=S.default[400],z={label:"small",value:135},U={label:"medium",value:300},W={fileImage:function(e,s){return{maxWidth:"100%",borderRadius:4,overflow:"hidden",maxHeight:s===z.label?z.value:U.value,display:e?"initial":"none",cursor:"pointer"}},fileDownloadWrapper:{padding:"10px 10px 10px 5px",border:"1px solid #616161",borderRadius:3,maxWidth:500,width:"75%"},imagePlaceholder:{position:"relative",backgroundColor:D,borderRadius:3,marginTop:10,height:135,width:135}},R=function(e){var s=v(e.attachmentFileName)||e.attachmentUrl;return x.jsxs(x.Fragment,{children:[x.jsxs("div",{onClick:e.openLightbox,className:d.cAttachmentImg,children:[x.jsx("img",{"data-testid":"".concat("Attachment","_image"),src:s,style:W.fileImage(e.imageIsLoaded,e.size),alt:"Attachment",onLoad:e.setImageIsLoaded}),x.jsx("div",{"data-testid":"".concat("Attachment","_button"),className:d.cAttachmentImgPreviwBtn,children:x.jsx(P.default,{})})]}),!e.imageIsLoaded&&x.jsx("div",{style:W.imagePlaceholder,children:x.jsx(F.default,{"data-testid":"".concat("Attachment","_placeholder"),className:e.classes.imageIconRoot,htmlColor:O,fontSize:"large"})}),e.lightboxIsOpen&&x.jsx(q,{mainSrc:s,imagePadding:50,onAfterOpen:e.handleLightboxOpen,onCloseRequest:e.handleLightboxClose})]})},L=function(e){var s=b.default.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl),i=v(e.attachmentFileName,"inline"),o=v(e.attachmentFileName,"attachment"),n=g.getIsPreviewUnavailable(s);return x.jsxs("div",{className:d.cAttachmentFileWrapper,children:[x.jsxs("div",{className:A.default(d.cAttachmentFileDownloadWrapper,n&&e.classes.disabledPreview),style:W.fileDownloadWrapper,onClick:function(){n||e.openPreview()},children:[n?x.jsx(m.UnavailableFileIcon,{className:e.classes.unavailableFileIcon}):x.jsx(p,{fileName:e.displayName||e.attachmentUrl,className:d.cAttachmentFileDownloadWrapperFileIcon,size:e.small?25:50}),x.jsxs("div",{className:e.classes.titleContainer,children:[n&&x.jsx("div",{className:e.classes.caption,children:"Preview unavailable"}),x.jsx("div",{"data-testid":"".concat("Attachment","_name"),className:A.default(d.cAttachmentFileDownloadWrapperFileName,n&&e.classes.fileName),children:x.jsx(r.Typography,{variant:"subtitle2",noWrap:!0,className:e.classes.unavailableFileName,children:s})})]}),x.jsx(u,{fileUrl:i,classes:{root:e.classes.dialogRoot,paper:h.isNativeDetected?e.classes.nativeDialog:e.classes.dialog},fileName:s,fileSize:e.attachmentSize,onClose:e.closePreview,open:e.previewIsOpen})]}),x.jsx("a",{download:e.displayName,href:o,className:d.cAttachmentFileDownloadWrapperForm,children:x.jsx(j,{"data-testid":"".concat("Attachment","_downloadButton"),className:e.classes.downloadIcon,type:"submit",children:x.jsx(f.DownloadIcon,{size:24,className:e.classes.downloadIcon})})})]})};function k(e){var i=s.useState(!1),o=N.default(i,2),n=o[0],t=o[1],r=s.useState(!1),c=N.default(r,2),a=c[0],l=c[1],u=s.useState(!1),m=N.default(u,2),p=m[0],q=m[1],j=e.displayName||e.attachmentUrl||e.fileName,g=I.getIsImage(j),f=I.getIsVideo(j),b=v(!e.attachmentUrl&&e.fileName),C=e.attachmentUrl||b,w=s.useCallback((function(e){return e.preventDefault()}),[]);return g?x.jsx("div",{className:d.cAttachment,children:x.jsx(R,{size:e.size,openLightbox:function(){return l(!0)},attachmentFileName:e.fileName,attachmentUrl:e.attachmentUrl,setImageIsLoaded:function(){return t(!0)},imageIsLoaded:n,lightboxIsOpen:a,handleLightboxOpen:function(){h.isNativeDetected&&document.documentElement.addEventListener("touchmove",w,{passive:!1})},handleLightboxClose:function(){h.isNativeDetected&&document.documentElement.removeEventListener("touchmove",w),l(!1)},classes:e.classes})}):f&&y.default.canPlay(C)?x.jsx("div",{className:d.cAttachment,children:x.jsx(y.default,{"data-testid":"".concat("Attachment","_player"),className:d.cAttachmentReactPlayer,url:C,config:{file:{attributes:{preload:"metadata"}}},controls:!0,height:e.size===z.label?z.value:U.value,width:null})}):x.jsx("div",{className:d.cAttachment,children:x.jsx(L,{attachmentUrl:C,attachmentFileName:e.fileName,attachmentSize:e.attachmentSize,displayName:e.displayName,openPreview:function(){return q(!0)},closePreview:function(e){e.stopPropagation(),q(!1)},previewIsOpen:p,classes:e.classes,small:e.small})})}k.propTypes={attachmentUrl:w.default.string.isRequired,attachmentSize:w.default.number,displayName:w.default.string,fileName:w.default.string,size:w.default.oneOf([z.label,U.label]),classes:w.default.shape({}).isRequired,small:w.default.bool},k.defaultProps={displayName:null,fileName:null,attachmentSize:void 0,size:U.label,small:!1};var E=t.withStyles((function(e){return{imageIconRoot:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},dialog:{width:"95%",height:"95%",maxWidth:"100%",position:"relative"},nativeDialog:{width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",margin:0},dialogRoot:{backgroundColor:"rgba(0, 0, 0, 0.85)"},fileName:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:400},downloadIcon:{color:e.palette.primary.text3},disabledPreview:{backgroundColor:e.palette.primary.text9},unavailableFileIcon:{marginRight:12,minWidth:32},titleContainer:{display:"flex",flexDirection:"column",width:"100%"},caption:{fontSize:12,fontWeight:400,width:"fit-content"},unavailableFileName:{fontSize:12,fontWeight:400}}}))(k);module.exports=E;
|
|
1
|
+
"use strict";var e=require("@babel/runtime/helpers/slicedToArray"),s=require("react"),i=require("prop-types"),o=require("react-player"),n=require("classnames"),t=require("@material-ui/core/styles"),r=require("@material-ui/core"),c=require("@material-ui/icons/Image"),a=require("@material-ui/icons/Fullscreen"),l=require("@material-ui/core/colors/grey"),u=require("../NewDocumentViewer/NewDocumentViewer.js"),m=require("../NewDocumentViewer/icons/UnavailableFileIcon.js"),d=require("./styles.css.js"),p=require("../FileTypeIcon.js"),q=require("../ImageViewer/index.js"),j=require("../IconButton/index.js"),h=require("../../utils/mobileDetect.js"),I=require("../../utils/fileExtension.js"),g=require("../../utils/filePreview.js"),f=require("../../icons/iconParkIcons.js");require("../../icons/customIcons/icons/AddMessage.js"),require("../../icons/customIcons/icons/Attention.js"),require("../../icons/customIcons/icons/Collapse.js"),require("../../icons/customIcons/icons/Dashboard.js"),require("../../icons/customIcons/icons/Expand.js"),require("../../icons/customIcons/icons/FolderClosed.js"),require("../../icons/customIcons/icons/FolderClosedFilled.js"),require("../../icons/customIcons/icons/FolderOpened.js"),require("../../icons/customIcons/icons/GreaterOrEqual.js"),require("../../icons/customIcons/icons/LessOrEqual.js"),require("../../icons/customIcons/icons/Search.js"),require("../../icons/customIcons/icons/SearchOne.js"),require("../../icons/customIcons/icons/Wellhub.js"),require("../../icons/customIcons/icons/MultiRuler.js"),require("../../icons/customIcons/icons/Checkbox.js"),require("../../icons/customIcons/icons/CheckboxChecked.js"),require("../../icons/customIcons/icons/CheckboxIndeterminate.js"),require("../../icons/customIcons/icons/Radio.js"),require("../../icons/customIcons/icons/RadioChecked.js"),require("../../icons/customIcons/icons/SimulFrac.js"),require("../../icons/customIcons/icons/ZipperFrac.js"),require("../../icons/customIcons/icons/CautionFilled.js"),require("../../icons/customIcons/icons/MoreApp.js"),require("../../icons/customIcons/icons/Pad.js"),require("../../icons/customIcons/icons/DrilloutUnit.js"),require("../../icons/customIcons/icons/FracFleet.js"),require("../../icons/customIcons/icons/Global.js"),require("../../icons/customIcons/icons/Program.js"),require("../../icons/customIcons/icons/Rig.js"),require("../../icons/customIcons/icons/Well.js"),require("../../icons/customIcons/icons/Gap.js"),require("../../icons/customIcons/icons/Pin.js"),require("../../icons/customIcons/icons/CloseOneFilled.js"),require("../../icons/customIcons/icons/AttentionFilled.js"),require("../../icons/customIcons/icons/CheckOneFilled.js"),require("../../icons/customIcons/icons/Archive.js"),require("../../icons/customIcons/icons/ArchiveCancel.js"),require("../../icons/customIcons/icons/Unarchive.js"),require("../../icons/customIcons/icons/Archived.js"),require("../../icons/customIcons/icons/InterventionUnit.js"),require("../../icons/customIcons/icons/CloudDelete.js"),require("../../icons/customIcons/icons/Lasso.js"),require("../../icons/customIcons/icons/Radius.js"),require("../../icons/customIcons/icons/ErrorOps.js"),require("../../icons/customIcons/icons/DataTypeOps.js"),require("../../icons/customIcons/icons/FalsePositiveOps.js"),require("../../icons/customIcons/icons/CalibrationOps.js"),require("../../icons/customIcons/icons/CriticalOps.js"),require("../../icons/customIcons/icons/Company.js"),require("../../icons/customIcons/icons/ArchiveOne.js"),require("../../icons/customIcons/icons/ParseBotFusion.js"),require("../../icons/customIcons/icons/Connect.js"),require("../../icons/customIcons/icons/PuzzleOne.js"),require("../../icons/customIcons/icons/Feed.js"),require("../../icons/customIcons/icons/Prompt.js"),require("../../icons/customIcons/icons/Companies.js"),require("../../icons/customIcons/icons/ClipboardAi.js"),require("../../icons/customIcons/icons/Key.js"),require("../../icons/customIcons/icons/AtSignCrossed.js"),require("../../icons/customIcons/icons/MappingManual.js"),require("../../icons/customIcons/icons/Mapping.js"),require("../../icons/customIcons/icons/Metrics.js"),require("../../icons/customIcons/icons/Drops.js"),require("../../icons/customIcons/icons/ClipboardSearch.js"),require("../../icons/customIcons/icons/Template.js"),require("../../icons/customIcons/icons/ClipboardMetrics.js"),require("../../icons/customIcons/icons/ClipboardBuilder.js"),require("../../icons/customIcons/icons/UnitConversion.js"),require("../../icons/customIcons/icons/NPT.js"),require("../../clients/subscriptions/constants.js"),require("@babel/runtime/helpers/asyncToGenerator"),require("@babel/runtime/helpers/defineProperty"),require("@babel/runtime/regenerator"),require("querystring"),require("uuid/v1"),require("lodash"),require("../../clients/subscriptions.v1.js"),require("../../clients/jsonApi/index.js"),require("../../clients/subscriptions/subscriptions-client.factory.js"),require("immutable"),require("query-string"),require("../../constants/goals.js"),require("../../constants/segment.js"),require("../../constants/alerts.js"),require("../../constants/apps.js"),require("../../constants/drillstring.js"),require("../../constants/completion.js"),require("../../constants/appPackages.js"),require("../../constants/notifications.js"),require("../../constants/feed.js"),require("../../constants/bha.js"),require("../../constants/corvaCompanyId.js"),require("../GradientManager/configuration/constants.js");var v=require("../../effects/useSignedURL.js");require("../../utils/index.js"),require("uuid"),require("jsona"),require("../../utils/env.js"),require("../StatusBadge/constants.js"),require("@babel/runtime/helpers/toConsumableArray"),require("lodash/set"),require("lodash/get"),require("lodash/unset"),require("moment"),require("../../clients/api/apiCore.js"),require("../../clients/constants.js"),require("../../clients/sso/auth0.js"),require("../../clients/sso/oauth2.js"),require("../../clients/api/rateLimiter.js"),require("lodash/isEmpty"),require("lodash/sortBy"),require("../../constants/streamSourceType.js"),require("../DevCenter/DevCenterAppContainer/components/CommentsSwitch/CommentsSwitchContext.js"),require("../../componentsV2/AppCommonsProvider/AppCommonsProvider.js"),require("../../componentsV2/AppCommonsProvider/AppCommonsContext.js"),require("../../componentsV2/AppSettings/AppSettingsPinningContext.js");var b=require("../../utils/main.js"),x=require("react/jsx-runtime");function C(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var N=C(e),w=C(i),y=C(o),A=C(n),F=C(c),P=C(a),S=C(l),D=S.default[200],O=S.default[400],z={label:"small",value:135},U={label:"medium",value:300},W={fileImage:function(e,s){return{maxWidth:"100%",borderRadius:4,overflow:"hidden",maxHeight:s===z.label?z.value:U.value,display:e?"initial":"none",cursor:"pointer"}},fileDownloadWrapper:{padding:"10px 10px 10px 5px",border:"1px solid #616161",borderRadius:3,maxWidth:500,width:"75%"},imagePlaceholder:{position:"relative",backgroundColor:D,borderRadius:3,marginTop:10,height:135,width:135}},L=function(e){var s=v(e.attachmentFileName)||e.attachmentUrl;return x.jsxs(x.Fragment,{children:[x.jsxs("div",{onClick:e.openLightbox,className:d.cAttachmentImg,children:[x.jsx("img",{"data-testid":"".concat("Attachment","_image"),src:s,style:W.fileImage(e.imageIsLoaded,e.size),alt:"Attachment",onLoad:e.setImageIsLoaded}),x.jsx("div",{"data-testid":"".concat("Attachment","_button"),className:d.cAttachmentImgPreviwBtn,children:x.jsx(P.default,{})})]}),!e.imageIsLoaded&&x.jsx("div",{style:W.imagePlaceholder,children:x.jsx(F.default,{"data-testid":"".concat("Attachment","_placeholder"),className:e.classes.imageIconRoot,htmlColor:O,fontSize:"large"})}),e.lightboxIsOpen&&x.jsx(q,{mainSrc:s,imagePadding:50,onAfterOpen:e.handleLightboxOpen,onCloseRequest:e.handleLightboxClose})]})},R=function(e){var s=b.default.getFileNameWithExtensionFromPath(e.displayName||e.attachmentUrl),i=v(e.attachmentFileName,"inline"),o=v(e.attachmentFileName,"attachment"),n=g.getIsPreviewUnavailable(s);return x.jsxs("div",{className:d.cAttachmentFileWrapper,children:[x.jsxs("div",{className:A.default(d.cAttachmentFileDownloadWrapper,n&&e.classes.disabledPreview),style:W.fileDownloadWrapper,onClick:function(){n||e.openPreview()},children:[n?x.jsx(m.UnavailableFileIcon,{className:e.classes.unavailableFileIcon}):x.jsx(p,{fileName:e.displayName||e.attachmentUrl,className:d.cAttachmentFileDownloadWrapperFileIcon,size:e.small?25:50}),x.jsxs("div",{className:e.classes.titleContainer,children:[n&&x.jsx("div",{className:e.classes.caption,children:"Preview unavailable"}),x.jsx("div",{"data-testid":"".concat("Attachment","_name"),className:A.default(d.cAttachmentFileDownloadWrapperFileName,n&&e.classes.fileName),children:x.jsx(r.Typography,{variant:"subtitle2",noWrap:!0,className:e.classes.unavailableFileName,children:s})})]}),x.jsx(u,{fileUrl:i,classes:{root:e.classes.dialogRoot,paper:h.isNativeDetected?e.classes.nativeDialog:e.classes.dialog},fileName:s,fileSize:e.attachmentSize,onClose:e.closePreview,open:e.previewIsOpen})]}),x.jsx("a",{download:e.displayName,href:o,className:d.cAttachmentFileDownloadWrapperForm,children:x.jsx(j,{"data-testid":"".concat("Attachment","_downloadButton"),className:e.classes.downloadIcon,type:"submit",children:x.jsx(f.DownloadIcon,{size:24,className:e.classes.downloadIcon})})})]})};function k(e){var i=s.useState(!1),o=N.default(i,2),n=o[0],t=o[1],r=s.useState(!1),c=N.default(r,2),a=c[0],l=c[1],u=s.useState(!1),m=N.default(u,2),p=m[0],q=m[1],j=e.displayName||e.attachmentUrl||e.fileName,g=I.getIsImage(j),f=I.getIsVideo(j),b=v(!e.attachmentUrl&&e.fileName),C=e.attachmentUrl||b,w=s.useCallback((function(e){return e.preventDefault()}),[]);return g?x.jsx("div",{className:d.cAttachment,children:x.jsx(L,{size:e.size,openLightbox:function(){return l(!0)},attachmentFileName:e.fileName,attachmentUrl:e.attachmentUrl,setImageIsLoaded:function(){return t(!0)},imageIsLoaded:n,lightboxIsOpen:a,handleLightboxOpen:function(){h.isNativeDetected&&document.documentElement.addEventListener("touchmove",w,{passive:!1})},handleLightboxClose:function(){h.isNativeDetected&&document.documentElement.removeEventListener("touchmove",w),l(!1)},classes:e.classes})}):f&&y.default.canPlay(C)?x.jsx("div",{className:d.cAttachment,children:x.jsx(y.default,{"data-testid":"".concat("Attachment","_player"),className:d.cAttachmentReactPlayer,url:C,config:{file:{attributes:{preload:"metadata"}}},controls:!0,height:e.size===z.label?z.value:U.value,width:null})}):x.jsx("div",{className:d.cAttachment,children:x.jsx(R,{attachmentUrl:C,attachmentFileName:e.fileName,attachmentSize:e.attachmentSize,displayName:e.displayName,openPreview:function(){return q(!0)},closePreview:function(e){e.stopPropagation(),q(!1)},previewIsOpen:p,classes:e.classes,small:e.small})})}k.propTypes={attachmentUrl:w.default.string.isRequired,attachmentSize:w.default.number,displayName:w.default.string,fileName:w.default.string,size:w.default.oneOf([z.label,U.label]),classes:w.default.shape({}).isRequired,small:w.default.bool},k.defaultProps={displayName:null,fileName:null,attachmentSize:void 0,size:U.label,small:!1};var E=t.withStyles((function(e){return{imageIconRoot:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},dialog:{width:"95%",height:"95%",maxWidth:"100%",position:"relative"},nativeDialog:{width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%",margin:0},dialogRoot:{backgroundColor:"rgba(0, 0, 0, 0.85)"},fileName:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontWeight:400},downloadIcon:{color:e.palette.primary.text3},disabledPreview:{backgroundColor:e.palette.primary.text9},unavailableFileIcon:{marginRight:12,minWidth:32},titleContainer:{display:"flex",flexDirection:"column",width:"100%"},caption:{fontSize:12,fontWeight:400,width:"fit-content"},unavailableFileName:{fontSize:12,fontWeight:400}}}))(k);module.exports=E;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/Attachment/index.js"],"sourcesContent":["import { useState, useCallback } from 'react';\nimport PropTypes from 'prop-types';\nimport ReactPlayer from 'react-player';\nimport classNames from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\nimport { Typography } from '@material-ui/core';\nimport ImageIcon from '@material-ui/icons/Image';\nimport FullSizeIcon from '@material-ui/icons/Fullscreen';\nimport grey from '@material-ui/core/colors/grey';\n\nimport { NewDocumentViewer } from '../NewDocumentViewer';\nimport { UnavailableFileIcon } from '../NewDocumentViewer/icons/UnavailableFileIcon';\n\nimport styles from './styles.css';\n\nimport FileTypeIcon from '~components/FileTypeIcon';\nimport ImageViewer from '~components/ImageViewer';\nimport IconButton from '~components/IconButton';\nimport { isNativeDetected } from '~/utils/mobileDetect';\nimport { getIsVideo, getIsImage } from '~/utils/fileExtension';\nimport { getIsPreviewUnavailable } from '~/utils/filePreview';\nimport { DownloadIcon } from '~/icons';\nimport { useSignedURL } from '~/effects';\nimport utils from '~utils/main'; // question here\n\nconst PAGE_NAME = 'Attachment';\n\nconst grey200 = grey[200];\nconst grey400 = grey[400];\n\nconst SIZES = {\n small: { label: 'small', value: 135 },\n medium: { label: 'medium', value: 300 },\n};\n\nconst style = {\n fileImage: (imageIsLoaded, size) => ({\n maxWidth: '100%',\n borderRadius: 4,\n overflow: 'hidden',\n // NOTE: Makes one-line comment with image fits into comments container. Equals to\n // imagePlaceholder height\n maxHeight: size === SIZES.small.label ? SIZES.small.value : SIZES.medium.value,\n display: imageIsLoaded ? 'initial' : 'none',\n cursor: 'pointer',\n }),\n fileDownloadWrapper: {\n padding: '10px 10px 10px 5px',\n border: `1px solid #616161`,\n borderRadius: 3,\n maxWidth: 500, // NOTE: Corresponds to react-player max width\n width: '75%',\n },\n imagePlaceholder: {\n position: 'relative',\n backgroundColor: grey200,\n borderRadius: 3,\n marginTop: 10,\n height: 135,\n width: 135,\n },\n};\n\nconst muiStyles = theme => ({\n imageIconRoot: {\n position: 'absolute',\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n },\n dialog: {\n width: '95%',\n height: '95%',\n maxWidth: '100%',\n position: 'relative',\n },\n nativeDialog: {\n width: '100%',\n height: '100%',\n maxWidth: '100%',\n maxHeight: '100%',\n margin: 0,\n },\n dialogRoot: {\n // NOTE: Make background color similar to lightbox\n backgroundColor: 'rgba(0, 0, 0, 0.85)',\n },\n fileName: {\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n textOverflow: 'ellipsis',\n fontWeight: 400,\n },\n downloadIcon: {\n color: theme.palette.primary.text3,\n },\n disabledPreview: {\n backgroundColor: theme.palette.primary.text9,\n },\n unavailableFileIcon: {\n marginRight: 12,\n minWidth: 32,\n },\n titleContainer: {\n display: 'flex',\n flexDirection: 'column',\n width: '100%',\n },\n caption: {\n fontSize: 12,\n fontWeight: 400,\n width: 'fit-content',\n },\n unavailableFileName: {\n fontSize: 12,\n fontWeight: 400,\n },\n});\n\n/* eslint-disable react/prop-types */\nconst ImageAttachment = props => {\n const downloadLink = useSignedURL(props.attachmentFileName) || props.attachmentUrl;\n return (\n <>\n <div onClick={props.openLightbox} className={styles.cAttachmentImg}>\n <img\n data-testid={`${PAGE_NAME}_image`}\n src={downloadLink}\n style={style.fileImage(props.imageIsLoaded, props.size)}\n alt=\"Attachment\"\n onLoad={props.setImageIsLoaded}\n />\n <div data-testid={`${PAGE_NAME}_button`} className={styles.cAttachmentImgPreviwBtn}>\n <FullSizeIcon />\n </div>\n </div>\n\n {!props.imageIsLoaded && (\n <div style={style.imagePlaceholder}>\n <ImageIcon\n data-testid={`${PAGE_NAME}_placeholder`}\n className={props.classes.imageIconRoot}\n htmlColor={grey400}\n fontSize=\"large\"\n />\n </div>\n )}\n\n {props.lightboxIsOpen && (\n <ImageViewer\n mainSrc={downloadLink}\n imagePadding={50}\n onAfterOpen={props.handleLightboxOpen}\n onCloseRequest={props.handleLightboxClose}\n />\n )}\n </>\n );\n};\n\nconst FileAttachment = props => {\n const fileName = utils.getFileNameWithExtensionFromPath(props.displayName || props.attachmentUrl);\n\n const previewUrl = useSignedURL(props.attachmentFileName, 'inline');\n const downloadUrl = useSignedURL(props.attachmentFileName, 'attachment');\n\n const isPreviewUnavailable = getIsPreviewUnavailable(fileName);\n\n const handleFilePreviewOpen = () => {\n if (isPreviewUnavailable) return;\n props.openPreview();\n };\n\n return (\n <div className={styles.cAttachmentFileWrapper}>\n <div\n className={classNames(\n styles.cAttachmentFileDownloadWrapper,\n isPreviewUnavailable && props.classes.disabledPreview\n )}\n style={style.fileDownloadWrapper}\n onClick={handleFilePreviewOpen}\n >\n {isPreviewUnavailable ? (\n <UnavailableFileIcon className={props.classes.unavailableFileIcon} />\n ) : (\n <FileTypeIcon\n fileName={props.displayName || props.attachmentUrl}\n className={styles.cAttachmentFileDownloadWrapperFileIcon}\n size={props.small ? 25 : 50}\n />\n )}\n <div className={props.classes.titleContainer}>\n {isPreviewUnavailable && <div className={props.classes.caption}>Preview unavailable</div>}\n <div\n data-testid={`${PAGE_NAME}_name`}\n className={classNames(\n styles.cAttachmentFileDownloadWrapperFileName,\n isPreviewUnavailable && props.classes.fileName\n )}\n >\n <Typography variant=\"subtitle2\" noWrap className={props.classes.unavailableFileName}>\n {fileName}\n </Typography>\n </div>\n </div>\n <NewDocumentViewer\n fileUrl={previewUrl}\n classes={{\n root: props.classes.dialogRoot,\n paper: isNativeDetected ? props.classes.nativeDialog : props.classes.dialog,\n }}\n fileName={fileName}\n fileSize={props.attachmentSize}\n onClose={props.closePreview}\n open={props.previewIsOpen}\n />\n </div>\n <a\n download={props.displayName}\n href={downloadUrl}\n className={styles.cAttachmentFileDownloadWrapperForm}\n >\n <IconButton\n data-testid={`${PAGE_NAME}_downloadButton`}\n className={props.classes.downloadIcon}\n type=\"submit\"\n >\n <DownloadIcon size={24} className={props.classes.downloadIcon} />\n </IconButton>\n </a>\n </div>\n );\n};\n\n/* eslint-enable react/prop-types */\n\nfunction Attachment(props) {\n const [isImageLoaded, setIsImageLoaded] = useState(false);\n const [isLightboxOpen, setIsLightboxOpen] = useState(false);\n const [isPreviewOpen, setIsPreviewOpen] = useState(false);\n\n const fileName = props.displayName || props.attachmentUrl || props.fileName;\n const isImage = getIsImage(fileName);\n const isVideo = getIsVideo(fileName);\n\n // Don't fetch download link if attachmentUrl is provided\n const downloadLink = useSignedURL(!props.attachmentUrl && props.fileName);\n const attachmentUrl = props.attachmentUrl || downloadLink;\n const preventIOSScroll = useCallback(e => e.preventDefault(), []);\n\n // NOTE: iOS WebView has a bug when background content of React Modal is scrollable\n // Source: https://github.com/reactjs/react-modal/issues/369\n const handleLightboxOpen = () => {\n if (isNativeDetected) {\n // document.documentElement.style.overflowY = 'hidden';\n document.documentElement.addEventListener('touchmove', preventIOSScroll, {\n passive: false,\n });\n }\n };\n\n const handleLightboxClose = () => {\n if (isNativeDetected) {\n // document.documentElement.style.overflowY = 'visible';\n document.documentElement.removeEventListener('touchmove', preventIOSScroll);\n }\n setIsLightboxOpen(false);\n };\n\n const openLightbox = () => setIsLightboxOpen(true);\n const setImageLoaded = () => setIsImageLoaded(true);\n const openPreview = () => setIsPreviewOpen(true);\n const closePreview = e => {\n e.stopPropagation();\n setIsPreviewOpen(false);\n };\n\n if (isImage)\n return (\n <div className={styles.cAttachment}>\n <ImageAttachment\n size={props.size}\n openLightbox={openLightbox}\n attachmentFileName={props.fileName}\n attachmentUrl={props.attachmentUrl}\n setImageIsLoaded={setImageLoaded}\n imageIsLoaded={isImageLoaded}\n lightboxIsOpen={isLightboxOpen}\n handleLightboxOpen={handleLightboxOpen}\n handleLightboxClose={handleLightboxClose}\n classes={props.classes}\n />\n </div>\n );\n\n if (isVideo && ReactPlayer.canPlay(attachmentUrl))\n return (\n <div className={styles.cAttachment}>\n <ReactPlayer\n data-testid={`${PAGE_NAME}_player`}\n className={styles.cAttachmentReactPlayer}\n url={attachmentUrl}\n config={{ file: { attributes: { preload: 'metadata' } } }}\n controls\n height={props.size === SIZES.small.label ? SIZES.small.value : SIZES.medium.value}\n width={null}\n />\n </div>\n );\n\n return (\n <div className={styles.cAttachment}>\n <FileAttachment\n attachmentUrl={attachmentUrl}\n attachmentFileName={props.fileName}\n attachmentSize={props.attachmentSize}\n displayName={props.displayName}\n openPreview={openPreview}\n closePreview={closePreview}\n previewIsOpen={isPreviewOpen}\n classes={props.classes}\n small={props.small}\n />\n </div>\n );\n}\n\nAttachment.propTypes = {\n attachmentUrl: PropTypes.string.isRequired,\n attachmentSize: PropTypes.number,\n displayName: PropTypes.string,\n fileName: PropTypes.string,\n size: PropTypes.oneOf([SIZES.small.label, SIZES.medium.label]),\n classes: PropTypes.shape({}).isRequired,\n small: PropTypes.bool,\n};\n\nAttachment.defaultProps = {\n displayName: null,\n fileName: null,\n attachmentSize: undefined,\n size: SIZES.medium.label,\n small: false,\n};\n\nexport default withStyles(muiStyles)(Attachment);\n"],"names":["grey200","grey","grey400","SIZES","label","value","style","fileImage","imageIsLoaded","size","maxWidth","borderRadius","overflow","maxHeight","display","cursor","fileDownloadWrapper","padding","border","width","imagePlaceholder","position","backgroundColor","marginTop","height","ImageAttachment","props","downloadLink","useSignedURL","attachmentFileName","attachmentUrl","_jsxs","_Fragment","children","jsxs","onClick","openLightbox","className","styles","cAttachmentImg","_jsx","jsx","concat","src","alt","onLoad","setImageIsLoaded","cAttachmentImgPreviwBtn","FullSizeIcon","ImageIcon","classes","imageIconRoot","htmlColor","fontSize","lightboxIsOpen","ImageViewer","mainSrc","imagePadding","onAfterOpen","handleLightboxOpen","onCloseRequest","handleLightboxClose","FileAttachment","fileName","utils","getFileNameWithExtensionFromPath","displayName","previewUrl","downloadUrl","isPreviewUnavailable","getIsPreviewUnavailable","cAttachmentFileWrapper","classNames","cAttachmentFileDownloadWrapper","disabledPreview","openPreview","UnavailableFileIcon","unavailableFileIcon","FileTypeIcon","cAttachmentFileDownloadWrapperFileIcon","small","titleContainer","caption","cAttachmentFileDownloadWrapperFileName","Typography","variant","noWrap","unavailableFileName","NewDocumentViewer","fileUrl","root","dialogRoot","paper","isNativeDetected","nativeDialog","dialog","fileSize","attachmentSize","onClose","closePreview","open","previewIsOpen","download","href","cAttachmentFileDownloadWrapperForm","IconButton","downloadIcon","type","DownloadIcon","Attachment","useState","_useState2","_slicedToArray","_useState","isImageLoaded","setIsImageLoaded","_useState4","_useState3","isLightboxOpen","setIsLightboxOpen","_useState6","_useState5","isPreviewOpen","setIsPreviewOpen","isImage","getIsImage","isVideo","getIsVideo","preventIOSScroll","useCallback","e","preventDefault","cAttachment","document","documentElement","addEventListener","passive","removeEventListener","ReactPlayer","canPlay","cAttachmentReactPlayer","url","config","file","attributes","preload","controls","stopPropagation","propTypes","PropTypes","string","isRequired","number","oneOf","shape","bool","defaultProps","undefined","Attachment$1","withStyles","theme","top","left","transform","margin","whiteSpace","textOverflow","fontWeight","color","palette","primary","text3","text9","marginRight","minWidth","flexDirection"],"mappings":"05MA2BMA,EAAUC,EAAAA,QAAK,KACfC,EAAUD,EAAAA,QAAK,KAEfE,EACG,CAAEC,MAAO,QAASC,MAAO,KAD5BF,EAEI,CAAEC,MAAO,SAAUC,MAAO,KAG9BC,EAAQ,CACZC,UAAW,SAACC,EAAeC,GAAI,MAAM,CACnCC,SAAU,OACVC,aAAc,EACdC,SAAU,SAGVC,UAAWJ,IAASN,EAAYC,MAAQD,EAAYE,MAAQF,EAAaE,MACzES,QAASN,EAAgB,UAAY,OACrCO,OAAQ,UACR,EACFC,oBAAqB,CACnBC,QAAS,qBACTC,OAA2B,oBAC3BP,aAAc,EACdD,SAAU,IACVS,MAAO,OAETC,iBAAkB,CAChBC,SAAU,WACVC,gBAAiBtB,EACjBW,aAAc,EACdY,UAAW,GACXC,OAAQ,IACRL,MAAO,MA6DLM,EAAkB,SAAAC,GACtB,IAAMC,EAAeC,EAAaF,EAAMG,qBAAuBH,EAAMI,cACrE,OACEC,EAAAA,KAAAC,EAAAA,SAAA,CAAAC,SACE,CAAAF,EAAAG,KAAA,MAAA,CAAKC,QAAST,EAAMU,aAAcC,UAAWC,EAAOC,eAAeN,SACjE,CAAAO,EAAAC,IAAA,MAAA,CACE,cAAA,GAAAC,OArGQ,aAqG0B,UAClCC,I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MAAO,eAEToE,oBAAqB,CACnBlC,SAAU,GACVkH,WAAY,KAEf,GAqOcR,CAAsBlD"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/Attachment/index.js"],"sourcesContent":["import { useState, useCallback } from 'react';\nimport PropTypes from 'prop-types';\nimport ReactPlayer from 'react-player';\nimport classNames from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\nimport { Typography } from '@material-ui/core';\nimport ImageIcon from '@material-ui/icons/Image';\nimport FullSizeIcon from '@material-ui/icons/Fullscreen';\nimport grey from '@material-ui/core/colors/grey';\n\nimport { NewDocumentViewer } from '../NewDocumentViewer';\nimport { UnavailableFileIcon } from '../NewDocumentViewer/icons/UnavailableFileIcon';\n\nimport styles from './styles.css';\n\nimport FileTypeIcon from '~components/FileTypeIcon';\nimport ImageViewer from '~components/ImageViewer';\nimport IconButton from '~components/IconButton';\nimport { isNativeDetected } from '~/utils/mobileDetect';\nimport { getIsVideo, getIsImage } from '~/utils/fileExtension';\nimport { getIsPreviewUnavailable } from '~/utils/filePreview';\nimport { DownloadIcon } from '~/icons';\nimport { useSignedURL } from '~/effects';\nimport utils from '~utils/main'; // question here\n\nconst PAGE_NAME = 'Attachment';\n\nconst grey200 = grey[200];\nconst grey400 = grey[400];\n\nconst SIZES = {\n small: { label: 'small', value: 135 },\n medium: { label: 'medium', value: 300 },\n};\n\nconst style = {\n fileImage: (imageIsLoaded, size) => ({\n maxWidth: '100%',\n borderRadius: 4,\n overflow: 'hidden',\n // NOTE: Makes one-line comment with image fits into comments container. Equals to\n // imagePlaceholder height\n maxHeight: size === SIZES.small.label ? SIZES.small.value : SIZES.medium.value,\n display: imageIsLoaded ? 'initial' : 'none',\n cursor: 'pointer',\n }),\n fileDownloadWrapper: {\n padding: '10px 10px 10px 5px',\n border: `1px solid #616161`,\n borderRadius: 3,\n maxWidth: 500, // NOTE: Corresponds to react-player max width\n width: '75%',\n },\n imagePlaceholder: {\n position: 'relative',\n backgroundColor: grey200,\n borderRadius: 3,\n marginTop: 10,\n height: 135,\n width: 135,\n },\n};\n\nconst muiStyles = theme => ({\n imageIconRoot: {\n position: 'absolute',\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n },\n dialog: {\n width: '95%',\n height: '95%',\n maxWidth: '100%',\n position: 'relative',\n },\n nativeDialog: {\n width: '100%',\n height: '100%',\n maxWidth: '100%',\n maxHeight: '100%',\n margin: 0,\n },\n dialogRoot: {\n // NOTE: Make background color similar to lightbox\n backgroundColor: 'rgba(0, 0, 0, 0.85)',\n },\n fileName: {\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n textOverflow: 'ellipsis',\n fontWeight: 400,\n },\n downloadIcon: {\n color: theme.palette.primary.text3,\n },\n disabledPreview: {\n backgroundColor: theme.palette.primary.text9,\n },\n unavailableFileIcon: {\n marginRight: 12,\n minWidth: 32,\n },\n titleContainer: {\n display: 'flex',\n flexDirection: 'column',\n width: '100%',\n },\n caption: {\n fontSize: 12,\n fontWeight: 400,\n width: 'fit-content',\n },\n unavailableFileName: {\n fontSize: 12,\n fontWeight: 400,\n },\n});\n\n/* eslint-disable react/prop-types */\nconst ImageAttachment = props => {\n const downloadLink = useSignedURL(props.attachmentFileName) || props.attachmentUrl;\n return (\n <>\n <div onClick={props.openLightbox} className={styles.cAttachmentImg}>\n <img\n data-testid={`${PAGE_NAME}_image`}\n src={downloadLink}\n style={style.fileImage(props.imageIsLoaded, props.size)}\n alt=\"Attachment\"\n onLoad={props.setImageIsLoaded}\n />\n <div data-testid={`${PAGE_NAME}_button`} className={styles.cAttachmentImgPreviwBtn}>\n <FullSizeIcon />\n </div>\n </div>\n\n {!props.imageIsLoaded && (\n <div style={style.imagePlaceholder}>\n <ImageIcon\n data-testid={`${PAGE_NAME}_placeholder`}\n className={props.classes.imageIconRoot}\n htmlColor={grey400}\n fontSize=\"large\"\n />\n </div>\n )}\n\n {props.lightboxIsOpen && (\n <ImageViewer\n mainSrc={downloadLink}\n imagePadding={50}\n onAfterOpen={props.handleLightboxOpen}\n onCloseRequest={props.handleLightboxClose}\n />\n )}\n </>\n );\n};\n\nconst FileAttachment = props => {\n const fileName = utils.getFileNameWithExtensionFromPath(props.displayName || props.attachmentUrl);\n\n const previewUrl = useSignedURL(props.attachmentFileName, 'inline');\n const downloadUrl = useSignedURL(props.attachmentFileName, 'attachment');\n\n const isPreviewUnavailable = getIsPreviewUnavailable(fileName);\n\n const handleFilePreviewOpen = () => {\n if (isPreviewUnavailable) return;\n props.openPreview();\n };\n\n return (\n <div className={styles.cAttachmentFileWrapper}>\n <div\n className={classNames(\n styles.cAttachmentFileDownloadWrapper,\n isPreviewUnavailable && props.classes.disabledPreview\n )}\n style={style.fileDownloadWrapper}\n onClick={handleFilePreviewOpen}\n >\n {isPreviewUnavailable ? (\n <UnavailableFileIcon className={props.classes.unavailableFileIcon} />\n ) : (\n <FileTypeIcon\n fileName={props.displayName || props.attachmentUrl}\n className={styles.cAttachmentFileDownloadWrapperFileIcon}\n size={props.small ? 25 : 50}\n />\n )}\n <div className={props.classes.titleContainer}>\n {isPreviewUnavailable && <div className={props.classes.caption}>Preview unavailable</div>}\n <div\n data-testid={`${PAGE_NAME}_name`}\n className={classNames(\n styles.cAttachmentFileDownloadWrapperFileName,\n isPreviewUnavailable && props.classes.fileName\n )}\n >\n <Typography variant=\"subtitle2\" noWrap className={props.classes.unavailableFileName}>\n {fileName}\n </Typography>\n </div>\n </div>\n <NewDocumentViewer\n fileUrl={previewUrl}\n classes={{\n root: props.classes.dialogRoot,\n paper: isNativeDetected ? props.classes.nativeDialog : props.classes.dialog,\n }}\n fileName={fileName}\n fileSize={props.attachmentSize}\n onClose={props.closePreview}\n open={props.previewIsOpen}\n />\n </div>\n <a\n download={props.displayName}\n href={downloadUrl}\n className={styles.cAttachmentFileDownloadWrapperForm}\n >\n <IconButton\n data-testid={`${PAGE_NAME}_downloadButton`}\n className={props.classes.downloadIcon}\n type=\"submit\"\n >\n <DownloadIcon size={24} className={props.classes.downloadIcon} />\n </IconButton>\n </a>\n </div>\n );\n};\n\n/* eslint-enable react/prop-types */\n\nfunction Attachment(props) {\n const [isImageLoaded, setIsImageLoaded] = useState(false);\n const [isLightboxOpen, setIsLightboxOpen] = useState(false);\n const [isPreviewOpen, setIsPreviewOpen] = useState(false);\n\n const fileName = props.displayName || props.attachmentUrl || props.fileName;\n const isImage = getIsImage(fileName);\n const isVideo = getIsVideo(fileName);\n\n // Don't fetch download link if attachmentUrl is provided\n const downloadLink = useSignedURL(!props.attachmentUrl && props.fileName);\n const attachmentUrl = props.attachmentUrl || downloadLink;\n const preventIOSScroll = useCallback(e => e.preventDefault(), []);\n\n // NOTE: iOS WebView has a bug when background content of React Modal is scrollable\n // Source: https://github.com/reactjs/react-modal/issues/369\n const handleLightboxOpen = () => {\n if (isNativeDetected) {\n // document.documentElement.style.overflowY = 'hidden';\n document.documentElement.addEventListener('touchmove', preventIOSScroll, {\n passive: false,\n });\n }\n };\n\n const handleLightboxClose = () => {\n if (isNativeDetected) {\n // document.documentElement.style.overflowY = 'visible';\n document.documentElement.removeEventListener('touchmove', preventIOSScroll);\n }\n setIsLightboxOpen(false);\n };\n\n const openLightbox = () => setIsLightboxOpen(true);\n const setImageLoaded = () => setIsImageLoaded(true);\n const openPreview = () => setIsPreviewOpen(true);\n const closePreview = e => {\n e.stopPropagation();\n setIsPreviewOpen(false);\n };\n\n if (isImage)\n return (\n <div className={styles.cAttachment}>\n <ImageAttachment\n size={props.size}\n openLightbox={openLightbox}\n attachmentFileName={props.fileName}\n attachmentUrl={props.attachmentUrl}\n setImageIsLoaded={setImageLoaded}\n imageIsLoaded={isImageLoaded}\n lightboxIsOpen={isLightboxOpen}\n handleLightboxOpen={handleLightboxOpen}\n handleLightboxClose={handleLightboxClose}\n classes={props.classes}\n />\n </div>\n );\n\n if (isVideo && ReactPlayer.canPlay(attachmentUrl))\n return (\n <div className={styles.cAttachment}>\n <ReactPlayer\n data-testid={`${PAGE_NAME}_player`}\n className={styles.cAttachmentReactPlayer}\n url={attachmentUrl}\n config={{ file: { attributes: { preload: 'metadata' } } }}\n controls\n height={props.size === SIZES.small.label ? SIZES.small.value : SIZES.medium.value}\n width={null}\n />\n </div>\n );\n\n return (\n <div className={styles.cAttachment}>\n <FileAttachment\n attachmentUrl={attachmentUrl}\n attachmentFileName={props.fileName}\n attachmentSize={props.attachmentSize}\n displayName={props.displayName}\n openPreview={openPreview}\n closePreview={closePreview}\n previewIsOpen={isPreviewOpen}\n classes={props.classes}\n small={props.small}\n />\n </div>\n );\n}\n\nAttachment.propTypes = {\n attachmentUrl: PropTypes.string.isRequired,\n attachmentSize: PropTypes.number,\n displayName: PropTypes.string,\n fileName: PropTypes.string,\n size: PropTypes.oneOf([SIZES.small.label, SIZES.medium.label]),\n classes: PropTypes.shape({}).isRequired,\n small: PropTypes.bool,\n};\n\nAttachment.defaultProps = {\n displayName: null,\n fileName: null,\n attachmentSize: undefined,\n size: SIZES.medium.label,\n small: false,\n};\n\nexport default withStyles(muiStyles)(Attachment);\n"],"names":["grey200","grey","grey400","SIZES","label","value","style","fileImage","imageIsLoaded","size","maxWidth","borderRadius","overflow","maxHeight","display","cursor","fileDownloadWrapper","padding","border","width","imagePlaceholder","position","backgroundColor","marginTop","height","ImageAttachment","props","downloadLink","useSignedURL","attachmentFileName","attachmentUrl","_jsxs","_Fragment","children","jsxs","onClick","openLightbox","className","styles","cAttachmentImg","_jsx","jsx","concat","src","alt","onLoad","setImageIsLoaded","cAttachmentImgPreviwBtn","FullSizeIcon","ImageIcon","classes","imageIconRoot","htmlColor","fontSize","lightboxIsOpen","ImageViewer","mainSrc","imagePadding","onAfterOpen","handleLightboxOpen","onCloseRequest","handleLightboxClose","FileAttachment","fileName","utils","getFileNameWithExtensionFromPath","displayName","previewUrl","downloadUrl","isPreviewUnavailable","getIsPreviewUnavailable","cAttachmentFileWrapper","classNames","cAttachmentFileDownloadWrapper","disabledPreview","openPreview","UnavailableFileIcon","unavailableFileIcon","FileTypeIcon","cAttachmentFileDownloadWrapperFileIcon","small","titleContainer","caption","cAttachmentFileDownloadWrapperFileName","Typography","variant","noWrap","unavailableFileName","NewDocumentViewer","fileUrl","root","dialogRoot","paper","isNativeDetected","nativeDialog","dialog","fileSize","attachmentSize","onClose","closePreview","open","previewIsOpen","download","href","cAttachmentFileDownloadWrapperForm","IconButton","downloadIcon","type","DownloadIcon","Attachment","useState","_useState2","_slicedToArray","_useState","isImageLoaded","setIsImageLoaded","_useState4","_useState3","isLightboxOpen","setIsLightboxOpen","_useState6","_useState5","isPreviewOpen","setIsPreviewOpen","isImage","getIsImage","isVideo","getIsVideo","preventIOSScroll","useCallback","e","preventDefault","cAttachment","document","documentElement","addEventListener","passive","removeEventListener","ReactPlayer","canPlay","cAttachmentReactPlayer","url","config","file","attributes","preload","controls","stopPropagation","propTypes","PropTypes","string","isRequired","number","oneOf","shape","bool","defaultProps","undefined","Attachment$1","withStyles","theme","top","left","transform","margin","whiteSpace","textOverflow","fontWeight","color","palette","primary","text3","text9","marginRight","minWidth","flexDirection"],"mappings":"s8MA2BMA,EAAUC,EAAAA,QAAK,KACfC,EAAUD,EAAAA,QAAK,KAEfE,EACG,CAAEC,MAAO,QAASC,MAAO,KAD5BF,EAEI,CAAEC,MAAO,SAAUC,MAAO,KAG9BC,EAAQ,CACZC,UAAW,SAACC,EAAeC,GAAI,MAAM,CACnCC,SAAU,OACVC,aAAc,EACdC,SAAU,SAGVC,UAAWJ,IAASN,EAAYC,MAAQD,EAAYE,MAAQF,EAAaE,MACzES,QAASN,EAAgB,UAAY,OACrCO,OAAQ,UACR,EACFC,oBAAqB,CACnBC,QAAS,qBACTC,OAA2B,oBAC3BP,aAAc,EACdD,SAAU,IACVS,MAAO,OAETC,iBAAkB,CAChBC,SAAU,WACVC,gBAAiBtB,EACjBW,aAAc,EACdY,UAAW,GACXC,OAAQ,IACRL,MAAO,MA6DLM,EAAkB,SAAAC,GACtB,IAAMC,EAAeC,EAAaF,EAAMG,qBAAuBH,EAAMI,cACrE,OACEC,EA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