@ynput/ayon-frontend-shared 0.2.26 → 0.2.28
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/dist/DetailsPanel.cjs.js +1 -1
- package/dist/DetailsPanel.es.js +25 -22
- package/dist/DetailsPanel.es.js.map +1 -1
- package/dist/Views.cjs.js +1 -1
- package/dist/Views.cjs.js.map +1 -1
- package/dist/Views.es.js +13 -11
- package/dist/Views.es.js.map +1 -1
- package/dist/api.cjs.js +1 -1
- package/dist/api.es.js +153 -151
- package/dist/components.cjs.js +1 -1
- package/dist/components.es.js +62 -51
- package/dist/components.es.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +12 -6
- package/dist/index.es.js.map +1 -1
- package/dist/shared/src/api/generated/entityLists.cjs.js.map +1 -1
- package/dist/shared/src/api/generated/entityLists.es.js.map +1 -1
- package/dist/shared/src/api/generated/users.cjs.js.map +1 -1
- package/dist/shared/src/api/generated/users.es.js.map +1 -1
- package/dist/shared/src/api/generated/views.cjs.js.map +1 -1
- package/dist/shared/src/api/generated/views.es.js.map +1 -1
- package/dist/shared/src/api/queries/entityLists/getLists.cjs.js +1 -1
- package/dist/shared/src/api/queries/entityLists/getLists.cjs.js.map +1 -1
- package/dist/shared/src/api/queries/entityLists/getLists.es.js +142 -117
- package/dist/shared/src/api/queries/entityLists/getLists.es.js.map +1 -1
- package/dist/shared/src/api/queries/entityLists/updateLists.cjs.js +1 -1
- package/dist/shared/src/api/queries/entityLists/updateLists.cjs.js.map +1 -1
- package/dist/shared/src/api/queries/entityLists/updateLists.es.js +110 -95
- package/dist/shared/src/api/queries/entityLists/updateLists.es.js.map +1 -1
- package/dist/shared/src/api/queries/users/getUsers.cjs.js +1 -1
- package/dist/shared/src/api/queries/users/getUsers.cjs.js.map +1 -1
- package/dist/shared/src/api/queries/users/getUsers.es.js +21 -17
- package/dist/shared/src/api/queries/users/getUsers.es.js.map +1 -1
- package/dist/shared/src/components/AccessUser/AccessUser.cjs.js +2 -0
- package/dist/shared/src/components/AccessUser/AccessUser.cjs.js.map +1 -0
- package/dist/shared/src/components/AccessUser/AccessUser.es.js +33 -0
- package/dist/shared/src/components/AccessUser/AccessUser.es.js.map +1 -0
- package/dist/shared/src/components/AccessUser/AccessUser.styled.cjs.js +42 -0
- package/dist/shared/src/components/AccessUser/AccessUser.styled.cjs.js.map +1 -0
- package/dist/shared/src/components/AccessUser/AccessUser.styled.es.js +46 -0
- package/dist/shared/src/components/AccessUser/AccessUser.styled.es.js.map +1 -0
- package/dist/shared/src/components/DetailsMetaData/DetailsMetaData.cjs.js +34 -0
- package/dist/shared/src/components/DetailsMetaData/DetailsMetaData.cjs.js.map +1 -0
- package/dist/shared/src/components/DetailsMetaData/DetailsMetaData.es.js +46 -0
- package/dist/shared/src/components/DetailsMetaData/DetailsMetaData.es.js.map +1 -0
- package/dist/shared/src/components/DetailsPanelAttributes/DetailsPanelAttributesEditor.cjs.js +20 -10
- package/dist/shared/src/components/DetailsPanelAttributes/DetailsPanelAttributesEditor.cjs.js.map +1 -1
- package/dist/shared/src/components/DetailsPanelAttributes/DetailsPanelAttributesEditor.es.js +81 -67
- package/dist/shared/src/components/DetailsPanelAttributes/DetailsPanelAttributesEditor.es.js.map +1 -1
- package/dist/shared/src/components/DetailsPanelAttributes/components/RenderFieldWidget.cjs.js +3 -3
- package/dist/shared/src/components/DetailsPanelAttributes/components/RenderFieldWidget.cjs.js.map +1 -1
- package/dist/shared/src/components/DetailsPanelAttributes/components/RenderFieldWidget.es.js +59 -52
- package/dist/shared/src/components/DetailsPanelAttributes/components/RenderFieldWidget.es.js.map +1 -1
- package/dist/shared/src/components/EntityPanelUploader/EntityPanelUploader.cjs.js +1 -1
- package/dist/shared/src/components/EntityPanelUploader/EntityPanelUploader.cjs.js.map +1 -1
- package/dist/shared/src/components/EntityPanelUploader/EntityPanelUploader.es.js +5 -2
- package/dist/shared/src/components/EntityPanelUploader/EntityPanelUploader.es.js.map +1 -1
- package/dist/shared/src/components/LinksManager/AddNewLinks.cjs.js +1 -1
- package/dist/shared/src/components/LinksManager/AddNewLinks.cjs.js.map +1 -1
- package/dist/shared/src/components/LinksManager/AddNewLinks.es.js +5 -2
- package/dist/shared/src/components/LinksManager/AddNewLinks.es.js.map +1 -1
- package/dist/shared/src/components/LinksManager/hooks/useUpdateLinks.cjs.js +1 -1
- package/dist/shared/src/components/LinksManager/hooks/useUpdateLinks.cjs.js.map +1 -1
- package/dist/shared/src/components/LinksManager/hooks/useUpdateLinks.es.js +5 -2
- package/dist/shared/src/components/LinksManager/hooks/useUpdateLinks.es.js.map +1 -1
- package/dist/shared/src/components/ListAttributeForm/ListAttributeForm.cjs.js +2 -0
- package/dist/shared/src/components/ListAttributeForm/ListAttributeForm.cjs.js.map +1 -0
- package/dist/shared/src/components/ListAttributeForm/ListAttributeForm.es.js +205 -0
- package/dist/shared/src/components/ListAttributeForm/ListAttributeForm.es.js.map +1 -0
- package/dist/shared/src/components/ListMetaData/ListMetaData.cjs.js +2 -0
- package/dist/shared/src/components/ListMetaData/ListMetaData.cjs.js.map +1 -0
- package/dist/shared/src/components/ListMetaData/ListMetaData.es.js +25 -0
- package/dist/shared/src/components/ListMetaData/ListMetaData.es.js.map +1 -0
- package/dist/shared/src/components/Powerpack/PowerpackButton.cjs.js +3 -3
- package/dist/shared/src/components/Powerpack/PowerpackButton.cjs.js.map +1 -1
- package/dist/shared/src/components/Powerpack/PowerpackButton.es.js +5 -5
- package/dist/shared/src/components/Powerpack/PowerpackButton.es.js.map +1 -1
- package/dist/shared/src/components/Powerpack/PowerpackDialog.cjs.js +1 -1
- package/dist/shared/src/components/Powerpack/PowerpackDialog.cjs.js.map +1 -1
- package/dist/shared/src/components/Powerpack/PowerpackDialog.es.js +5 -2
- package/dist/shared/src/components/Powerpack/PowerpackDialog.es.js.map +1 -1
- package/dist/shared/src/components/Powerpack/RequiredPowerpackVersion.cjs.js +9 -0
- package/dist/shared/src/components/Powerpack/RequiredPowerpackVersion.cjs.js.map +1 -0
- package/dist/shared/src/components/Powerpack/RequiredPowerpackVersion.es.js +25 -0
- package/dist/shared/src/components/Powerpack/RequiredPowerpackVersion.es.js.map +1 -0
- package/dist/shared/src/components/ProjectTableSettings/ProjectTableSettings.cjs.js +1 -1
- package/dist/shared/src/components/ProjectTableSettings/ProjectTableSettings.cjs.js.map +1 -1
- package/dist/shared/src/components/ProjectTableSettings/ProjectTableSettings.es.js +7 -4
- package/dist/shared/src/components/ProjectTableSettings/ProjectTableSettings.es.js.map +1 -1
- package/dist/shared/src/components/ProjectTableSettings/TableSettingsFallback.cjs.js +1 -1
- package/dist/shared/src/components/ProjectTableSettings/TableSettingsFallback.cjs.js.map +1 -1
- package/dist/shared/src/components/ProjectTableSettings/TableSettingsFallback.es.js +18 -21
- package/dist/shared/src/components/ProjectTableSettings/TableSettingsFallback.es.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/ReviewablesList.cjs.js +1 -1
- package/dist/shared/src/components/ReviewablesList/ReviewablesList.cjs.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/ReviewablesList.es.js +5 -2
- package/dist/shared/src/components/ReviewablesList/ReviewablesList.es.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/ReviewablesUpload.cjs.js +1 -1
- package/dist/shared/src/components/ReviewablesList/ReviewablesUpload.cjs.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/ReviewablesUpload.es.js +6 -3
- package/dist/shared/src/components/ReviewablesList/ReviewablesUpload.es.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/SortableReviewableCard.cjs.js +1 -1
- package/dist/shared/src/components/ReviewablesList/SortableReviewableCard.cjs.js.map +1 -1
- package/dist/shared/src/components/ReviewablesList/SortableReviewableCard.es.js +5 -2
- package/dist/shared/src/components/ReviewablesList/SortableReviewableCard.es.js.map +1 -1
- package/dist/shared/src/components/ShareOptionIcon/ShareOptionIcon.cjs.js +2 -0
- package/dist/shared/src/components/ShareOptionIcon/ShareOptionIcon.cjs.js.map +1 -0
- package/dist/shared/src/components/ShareOptionIcon/ShareOptionIcon.es.js +17 -0
- package/dist/shared/src/components/ShareOptionIcon/ShareOptionIcon.es.js.map +1 -0
- package/dist/shared/src/components/SimpleFormDialog/SimpleFormDialog.cjs.js +2 -2
- package/dist/shared/src/components/SimpleFormDialog/SimpleFormDialog.cjs.js.map +1 -1
- package/dist/shared/src/components/SimpleFormDialog/SimpleFormDialog.es.js +5 -2
- package/dist/shared/src/components/SimpleFormDialog/SimpleFormDialog.es.js.map +1 -1
- package/dist/shared/src/components/VersionUploader/components/UploadVersionForm.cjs.js +1 -1
- package/dist/shared/src/components/VersionUploader/components/UploadVersionForm.cjs.js.map +1 -1
- package/dist/shared/src/components/VersionUploader/components/UploadVersionForm.es.js +5 -2
- package/dist/shared/src/components/VersionUploader/components/UploadVersionForm.es.js.map +1 -1
- package/dist/shared/src/containers/Actions/ActionConfigDialog.cjs.js +1 -1
- package/dist/shared/src/containers/Actions/ActionConfigDialog.cjs.js.map +1 -1
- package/dist/shared/src/containers/Actions/ActionConfigDialog.es.js +5 -2
- package/dist/shared/src/containers/Actions/ActionConfigDialog.es.js.map +1 -1
- package/dist/shared/src/containers/Actions/InteractiveActionDialog.cjs.js +1 -1
- package/dist/shared/src/containers/Actions/InteractiveActionDialog.cjs.js.map +1 -1
- package/dist/shared/src/containers/Actions/InteractiveActionDialog.es.js +5 -2
- package/dist/shared/src/containers/Actions/InteractiveActionDialog.es.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanel.cjs.js +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanel.cjs.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanel.es.js +146 -157
- package/dist/shared/src/containers/DetailsPanel/DetailsPanel.es.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanel.styled.cjs.js +7 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanel.styled.cjs.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanel.styled.es.js +13 -6
- package/dist/shared/src/containers/DetailsPanel/DetailsPanel.styled.es.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFiles/DetailsPanelFiles.cjs.js +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFiles/DetailsPanelFiles.cjs.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFiles/DetailsPanelFiles.es.js +5 -2
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFiles/DetailsPanelFiles.es.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFloating/DetailsPanelFloating.cjs.js +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFloating/DetailsPanelFloating.cjs.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFloating/DetailsPanelFloating.es.js +6 -3
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelFloating/DetailsPanelFloating.es.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelHeader/DetailsPanelHeader.cjs.js +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelHeader/DetailsPanelHeader.cjs.js.map +1 -1
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelHeader/DetailsPanelHeader.es.js +6 -3
- package/dist/shared/src/containers/DetailsPanel/DetailsPanelHeader/DetailsPanelHeader.es.js.map +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/EntityPickerDialog.cjs.js +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/EntityPickerDialog.cjs.js.map +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/EntityPickerDialog.es.js +5 -2
- package/dist/shared/src/containers/EntityPickerDialog/EntityPickerDialog.es.js.map +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTable.cjs.js +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTable.cjs.js.map +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTable.es.js +5 -2
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTable.es.js.map +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTableHeader.cjs.js +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTableHeader.cjs.js.map +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTableHeader.es.js +5 -2
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTableHeader.es.js.map +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTableSearch.cjs.js +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTableSearch.cjs.js.map +1 -1
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTableSearch.es.js +5 -2
- package/dist/shared/src/containers/EntityPickerDialog/components/EntityTypeTableSearch.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.es.js +413 -396
- package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.styled.cjs.js +104 -25
- package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.styled.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.styled.es.js +131 -52
- package/dist/shared/src/containers/ProjectTreeTable/ProjectTreeTable.styled.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/buildTreeTableColumns.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/buildTreeTableColumns.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/buildTreeTableColumns.es.js +136 -129
- package/dist/shared/src/containers/ProjectTreeTable/buildTreeTableColumns.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/components/ColumnHeaderMenu.cjs.js +16 -53
- package/dist/shared/src/containers/ProjectTreeTable/components/ColumnHeaderMenu.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/components/ColumnHeaderMenu.es.js +100 -120
- package/dist/shared/src/containers/ProjectTreeTable/components/ColumnHeaderMenu.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/components/GroupSettingsFallback.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/components/GroupSettingsFallback.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/components/GroupSettingsFallback.es.js +5 -2
- package/dist/shared/src/containers/ProjectTreeTable/components/GroupSettingsFallback.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/components/HeaderActionButton.cjs.js +7 -3
- package/dist/shared/src/containers/ProjectTreeTable/components/HeaderActionButton.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/components/HeaderActionButton.es.js +12 -8
- package/dist/shared/src/containers/ProjectTreeTable/components/HeaderActionButton.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/CellEditingProvider.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/CellEditingProvider.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/CellEditingProvider.es.js +5 -2
- package/dist/shared/src/containers/ProjectTreeTable/context/CellEditingProvider.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/ClipboardContext.cjs.js +3 -3
- package/dist/shared/src/containers/ProjectTreeTable/context/ClipboardContext.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/ClipboardContext.es.js +250 -235
- package/dist/shared/src/containers/ProjectTreeTable/context/ClipboardContext.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectDataContext.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectDataContext.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectDataContext.es.js +24 -21
- package/dist/shared/src/containers/ProjectTreeTable/context/ProjectDataContext.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectionCellsProvider.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectionCellsProvider.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectionCellsProvider.es.js +5 -2
- package/dist/shared/src/containers/ProjectTreeTable/context/SelectionCellsProvider.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/clipboard/clipboardTypes.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/clipboard/clipboardTypes.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/clipboard/clipboardValidation.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/clipboard/clipboardValidation.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/context/clipboard/clipboardValidation.es.js +10 -10
- package/dist/shared/src/containers/ProjectTreeTable/context/clipboard/clipboardValidation.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useAttributesList.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useAttributesList.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useAttributesList.es.js +13 -9
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useAttributesList.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useCellContextMenu.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useCellContextMenu.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useCellContextMenu.es.js +65 -60
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useCellContextMenu.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useCheckSelectedCellsVisible.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useCheckSelectedCellsVisible.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useCheckSelectedCellsVisible.es.js +5 -2
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useCheckSelectedCellsVisible.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useGetGroupedFields.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useGetGroupedFields.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useGetGroupedFields.es.js +5 -2
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useGetGroupedFields.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useKeyboardNavigation.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useKeyboardNavigation.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useKeyboardNavigation.es.js +5 -2
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useKeyboardNavigation.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useMoveEntities.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useMoveEntities.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useMoveEntities.es.js +5 -2
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useMoveEntities.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/usePasteLinks.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/usePasteLinks.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/usePasteLinks.es.js +5 -2
- package/dist/shared/src/containers/ProjectTreeTable/hooks/usePasteLinks.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useQueryFilters.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useQueryFilters.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useQueryFilters.es.js +5 -2
- package/dist/shared/src/containers/ProjectTreeTable/hooks/useQueryFilters.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/utils/cellUtils.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/utils/cellUtils.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/utils/cellUtils.es.js +16 -13
- package/dist/shared/src/containers/ProjectTreeTable/utils/cellUtils.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/utils/getReadOnlyLists.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/utils/getReadOnlyLists.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/utils/getReadOnlyLists.es.js +41 -14
- package/dist/shared/src/containers/ProjectTreeTable/utils/getReadOnlyLists.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/widgets/BooleanWidget.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/widgets/BooleanWidget.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/widgets/BooleanWidget.es.js +7 -7
- package/dist/shared/src/containers/ProjectTreeTable/widgets/BooleanWidget.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/widgets/CellWidget.cjs.js +2 -2
- package/dist/shared/src/containers/ProjectTreeTable/widgets/CellWidget.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/widgets/CellWidget.es.js +110 -104
- package/dist/shared/src/containers/ProjectTreeTable/widgets/CellWidget.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/widgets/EnumCellValue.cjs.js +2 -2
- package/dist/shared/src/containers/ProjectTreeTable/widgets/EnumCellValue.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/widgets/EnumCellValue.es.js +8 -8
- package/dist/shared/src/containers/ProjectTreeTable/widgets/EnumCellValue.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/widgets/EnumWidget.cjs.js +2 -2
- package/dist/shared/src/containers/ProjectTreeTable/widgets/EnumWidget.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/widgets/EnumWidget.es.js +44 -43
- package/dist/shared/src/containers/ProjectTreeTable/widgets/EnumWidget.es.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/widgets/LinksWidget.cjs.js +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/widgets/LinksWidget.cjs.js.map +1 -1
- package/dist/shared/src/containers/ProjectTreeTable/widgets/LinksWidget.es.js +7 -4
- package/dist/shared/src/containers/ProjectTreeTable/widgets/LinksWidget.es.js.map +1 -1
- package/dist/shared/src/containers/RepresentationsList/RepresentationsList.cjs.js +1 -1
- package/dist/shared/src/containers/RepresentationsList/RepresentationsList.cjs.js.map +1 -1
- package/dist/shared/src/containers/RepresentationsList/RepresentationsList.es.js +5 -2
- package/dist/shared/src/containers/RepresentationsList/RepresentationsList.es.js.map +1 -1
- package/dist/shared/src/containers/SimpleTable/SimpleTable.cjs.js +1 -1
- package/dist/shared/src/containers/SimpleTable/SimpleTable.cjs.js.map +1 -1
- package/dist/shared/src/containers/SimpleTable/SimpleTable.es.js +118 -103
- package/dist/shared/src/containers/SimpleTable/SimpleTable.es.js.map +1 -1
- package/dist/shared/src/containers/SimpleTable/SimpleTable.styled.cjs.js +16 -4
- package/dist/shared/src/containers/SimpleTable/SimpleTable.styled.cjs.js.map +1 -1
- package/dist/shared/src/containers/SimpleTable/SimpleTable.styled.es.js +13 -1
- package/dist/shared/src/containers/SimpleTable/SimpleTable.styled.es.js.map +1 -1
- package/dist/shared/src/containers/SimpleTable/SimpleTableRowTemplate.cjs.js +1 -1
- package/dist/shared/src/containers/SimpleTable/SimpleTableRowTemplate.cjs.js.map +1 -1
- package/dist/shared/src/containers/SimpleTable/SimpleTableRowTemplate.es.js +62 -50
- package/dist/shared/src/containers/SimpleTable/SimpleTableRowTemplate.es.js.map +1 -1
- package/dist/shared/src/containers/Views/context/ViewsContext.cjs.js.map +1 -1
- package/dist/shared/src/containers/Views/context/ViewsContext.es.js.map +1 -1
- package/dist/shared/src/containers/Views/hooks/pages/useReportsViewSettings.cjs.js +2 -0
- package/dist/shared/src/containers/Views/hooks/pages/useReportsViewSettings.cjs.js.map +1 -0
- package/dist/shared/src/containers/Views/hooks/pages/useReportsViewSettings.es.js +64 -0
- package/dist/shared/src/containers/Views/hooks/pages/useReportsViewSettings.es.js.map +1 -0
- package/dist/shared/src/context/MenuContext.cjs.js +2 -0
- package/dist/shared/src/context/MenuContext.cjs.js.map +1 -0
- package/dist/shared/src/context/MenuContext.es.js +28 -0
- package/dist/shared/src/context/MenuContext.es.js.map +1 -0
- package/dist/shared/src/context/PowerpackContext.cjs.js +1 -1
- package/dist/shared/src/context/PowerpackContext.cjs.js.map +1 -1
- package/dist/shared/src/context/PowerpackContext.es.js +20 -15
- package/dist/shared/src/context/PowerpackContext.es.js.map +1 -1
- package/dist/shared/src/context/RemoteModulesContext.cjs.js +1 -1
- package/dist/shared/src/context/RemoteModulesContext.cjs.js.map +1 -1
- package/dist/shared/src/context/RemoteModulesContext.es.js +19 -19
- package/dist/shared/src/context/RemoteModulesContext.es.js.map +1 -1
- package/dist/shared/src/hooks/useLoadModule.cjs.js.map +1 -1
- package/dist/shared/src/hooks/useLoadModule.es.js.map +1 -1
- package/dist/src/components/Menu/MenuComponents/Menu.cjs.js +2 -0
- package/dist/src/components/Menu/MenuComponents/Menu.cjs.js.map +1 -0
- package/dist/src/components/Menu/MenuComponents/Menu.es.js +55 -0
- package/dist/src/components/Menu/MenuComponents/Menu.es.js.map +1 -0
- package/dist/src/components/Menu/MenuComponents/Menu.styled.cjs.js +254 -0
- package/dist/src/components/Menu/MenuComponents/Menu.styled.cjs.js.map +1 -0
- package/dist/src/components/Menu/MenuComponents/Menu.styled.es.js +265 -0
- package/dist/src/components/Menu/MenuComponents/Menu.styled.es.js.map +1 -0
- package/dist/src/components/Menu/MenuComponents/MenuContainer2.cjs.js +2 -0
- package/dist/src/components/Menu/MenuComponents/MenuContainer2.cjs.js.map +1 -0
- package/dist/src/components/Menu/MenuComponents/MenuContainer2.es.js +80 -0
- package/dist/src/components/Menu/MenuComponents/MenuContainer2.es.js.map +1 -0
- package/dist/src/components/Menu/MenuComponents/MenuItem.cjs.js +2 -0
- package/dist/src/components/Menu/MenuComponents/MenuItem.cjs.js.map +1 -0
- package/dist/src/components/Menu/MenuComponents/MenuItem.es.js +59 -0
- package/dist/src/components/Menu/MenuComponents/MenuItem.es.js.map +1 -0
- package/dist/src/components/Menu/MenuComponents/MenuList.cjs.js +2 -0
- package/dist/src/components/Menu/MenuComponents/MenuList.cjs.js.map +1 -0
- package/dist/src/components/Menu/MenuComponents/MenuList.es.js +112 -0
- package/dist/src/components/Menu/MenuComponents/MenuList.es.js.map +1 -0
- package/dist/src/components/Menu/MenuComponents/useMenuPosition.cjs.js +2 -0
- package/dist/src/components/Menu/MenuComponents/useMenuPosition.cjs.js.map +1 -0
- package/dist/src/components/Menu/MenuComponents/useMenuPosition.es.js +35 -0
- package/dist/src/components/Menu/MenuComponents/useMenuPosition.es.js.map +1 -0
- package/dist/types/api/generated/entityLists.d.ts +8 -8
- package/dist/types/api/generated/users.d.ts +18 -14
- package/dist/types/api/generated/views.d.ts +47 -9
- package/dist/types/api/queries/entityLists/getLists.d.ts +133 -0
- package/dist/types/api/queries/entityLists/types.d.ts +2 -1
- package/dist/types/api/queries/permissions/getPermissions.d.ts +22 -22
- package/dist/types/api/queries/users/getUsers.d.ts +132 -0
- package/dist/types/api/queries/users/updateUsers.d.ts +3 -3
- package/dist/types/components/AccessUser/AccessUser.d.ts +22 -0
- package/dist/types/components/AccessUser/AccessUser.styled.d.ts +1 -0
- package/dist/types/components/AccessUser/index.d.ts +1 -0
- package/dist/types/components/DetailsMetaData/DetailsMetaData.d.ts +8 -0
- package/dist/types/components/DetailsMetaData/index.d.ts +1 -0
- package/dist/types/components/DetailsPanelAttributes/DetailsPanelAttributesEditor.d.ts +4 -0
- package/dist/types/components/ListAttributeForm/ListAttributeForm.d.ts +13 -0
- package/dist/types/components/ListAttributeForm/index.d.ts +1 -0
- package/dist/types/components/ListMetaData/ListMetaData.d.ts +8 -0
- package/dist/types/components/ListMetaData/index.d.ts +1 -0
- package/dist/types/components/Powerpack/RequiredPowerpackVersion.d.ts +5 -0
- package/dist/types/components/Powerpack/index.d.ts +1 -0
- package/dist/types/components/ShareOptionIcon/ShareOptionIcon.d.ts +10 -0
- package/dist/types/components/ShareOptionIcon/index.d.ts +2 -0
- package/dist/types/components/index.d.ts +4 -0
- package/dist/types/containers/DetailsPanel/DetailsPanel.styled.d.ts +7 -0
- package/dist/types/containers/ProjectTreeTable/ProjectTreeTable.styled.d.ts +3 -1
- package/dist/types/containers/ProjectTreeTable/components/ColumnHeaderMenu.d.ts +4 -1
- package/dist/types/containers/ProjectTreeTable/context/ProjectDataContext.d.ts +1 -0
- package/dist/types/containers/ProjectTreeTable/context/clipboard/clipboardTypes.d.ts +3 -1
- package/dist/types/containers/ProjectTreeTable/hooks/useAttributesList.d.ts +1 -0
- package/dist/types/containers/ProjectTreeTable/utils/getReadOnlyLists.d.ts +1 -1
- package/dist/types/containers/ProjectTreeTable/widgets/BooleanWidget.d.ts +1 -0
- package/dist/types/containers/ProjectTreeTable/widgets/EnumCellValue.d.ts +2 -2
- package/dist/types/containers/SimpleTable/SimpleTable.d.ts +3 -0
- package/dist/types/containers/SimpleTable/SimpleTableRowTemplate.d.ts +5 -1
- package/dist/types/containers/Views/hooks/pages/useReportsViewSettings.d.ts +11 -0
- package/dist/types/containers/Views/index.d.ts +6 -2
- package/dist/types/context/MenuContext.d.ts +12 -0
- package/dist/types/context/PowerpackContext.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMoveEntities.cjs.js","sources":["../../../../../../src/containers/ProjectTreeTable/hooks/useMoveEntities.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react'\nimport { toast } from 'react-toastify'\nimport {\n OperationModel,\n OperationResponseModel,\n useUpdateOverviewEntitiesMutation,\n useGetFolderListQuery,\n} from '@shared/api'\nimport { useProjectTableContext } from '@shared/containers'\nimport {\n useMoveEntityContext,\n EntityMoveData,\n MultiEntityMoveData,\n} from '@shared/context/MoveEntityContext'\n\nexport type EntityType = 'folder' | 'task'\n\ninterface UseMoveEntitiesProps {\n projectName: string\n}\n\nexport const useMoveEntities = ({ projectName }: UseMoveEntitiesProps) => {\n const {\n movingEntities,\n isEntityPickerOpen,\n openMoveDialog,\n closeMoveDialog,\n setEntityPickerOpen,\n clearMovingEntities,\n } = useMoveEntityContext()\n const [updateOverviewEntities] = useUpdateOverviewEntitiesMutation()\n\n // Get project context for entity data\n const { tableData, getEntityById } = useProjectTableContext()\n\n // Get folder data to check hasVersions property\n const { data: { folders = [] } = {} } = useGetFolderListQuery(\n { projectName: projectName || '', attrib: true },\n { skip: !projectName },\n )\n\n // Action dispatchers\n const openMoveDialogHandler = useCallback(\n (entityData: EntityMoveData | MultiEntityMoveData) => {\n openMoveDialog(entityData)\n },\n [openMoveDialog],\n )\n\n const closeMoveDialogHandler = useCallback(() => {\n closeMoveDialog()\n }, [closeMoveDialog])\n\n // Move submit handler\n const handleMoveSubmit = useCallback(\n async (selectedFolderIds: string[]) => {\n if (!movingEntities || selectedFolderIds.length === 0) return\n\n const targetFolderId = selectedFolderIds[0]\n setEntityPickerOpen(false)\n\n try {\n // Prepare move operations for all entities\n const moveOperations: OperationModel[] = movingEntities.entities.map(\n (entity: EntityMoveData, index: number) => ({\n id: `move-${entity.entityId}-${Date.now()}-${index}`,\n type: 'update',\n entityType: entity.entityType,\n entityId: entity.entityId,\n data:\n entity.entityType === 'folder'\n ? { parentId: targetFolderId }\n : { folderId: targetFolderId },\n }),\n )\n\n // Use the mutation with built-in optimistic updates and rollback\n const result = await updateOverviewEntities({\n projectName,\n operationsRequestModel: {\n operations: moveOperations,\n },\n }).unwrap()\n\n // Check for any failed operations\n const failedOperations =\n result?.operations?.filter((op: OperationResponseModel) => op.success === false) || []\n\n if (failedOperations.length > 0) {\n const errorDetails = failedOperations.map((op) => op.detail).join(', ')\n throw new Error(errorDetails || 'Some move operations failed')\n }\n } catch (error: any) {\n console.error('Failed to move entity:', error)\n\n // Extract and improve error message\n let errorMessage =\n error?.data?.detail || error?.error || error?.message || 'Failed to move entities'\n\n // Improve specific error messages for better UX\n if (errorMessage.includes('already exists')) {\n // For multiple entities, provide a more general message\n if (movingEntities.entities.length > 1) {\n errorMessage = `Cannot move some entities - one or more entities with the same name already exist in the target location`\n } else {\n const entity = movingEntities.entities[0]\n if (entity.entityType === 'task') {\n // Extract task name from error message if possible\n const nameMatch = errorMessage.match(/name '.*?, (.+?)' already exists/)\n const taskName = nameMatch ? nameMatch[1] : 'this task'\n errorMessage = `Cannot move \"${taskName}\" - a task with this name already exists in the target folder`\n } else {\n // Extract folder name from error message if possible\n const nameMatch = errorMessage.match(/name '.*?, (.+?)' already exists/)\n const folderName = nameMatch ? nameMatch[1] : 'this folder'\n errorMessage = `Cannot move \"${folderName}\" - a folder with this name already exists in the target location`\n }\n }\n }\n\n toast.error(errorMessage)\n } finally {\n clearMovingEntities()\n setEntityPickerOpen(false)\n }\n },\n [\n movingEntities,\n projectName,\n updateOverviewEntities,\n openMoveDialog,\n closeMoveDialog,\n setEntityPickerOpen,\n clearMovingEntities,\n ],\n )\n\n // Move to root handler\n const handleMoveToRoot = useCallback(async () => {\n if (!movingEntities) return\n\n setEntityPickerOpen(false)\n\n try {\n // Prepare move operations for all entities to move to root (null parentId/folderId)\n const moveOperations: OperationModel[] = movingEntities.entities.map(\n (entity: EntityMoveData, index: number) => ({\n id: `move-to-root-${entity.entityId}-${Date.now()}-${index}`,\n type: 'update',\n entityType: entity.entityType,\n entityId: entity.entityId,\n data: entity.entityType === 'folder' ? { parentId: null } : { folderId: null },\n }),\n )\n\n // Use the mutation with built-in optimistic updates and rollback\n const result = await updateOverviewEntities({\n projectName,\n operationsRequestModel: {\n operations: moveOperations,\n },\n }).unwrap()\n\n // Check for any failed operations\n const failedOperations =\n result?.operations?.filter((op: OperationResponseModel) => op.success === false) || []\n\n if (failedOperations.length > 0) {\n const errorDetails = failedOperations.map((op) => op.detail).join(', ')\n throw new Error(errorDetails || 'Some move operations failed')\n }\n } catch (error: any) {\n console.error('Failed to move entities to root:', error)\n\n // Extract and improve error message\n let errorMessage =\n error?.data?.detail || error?.error || error?.message || 'Failed to move entities to root'\n\n toast.error(errorMessage)\n } finally {\n clearMovingEntities()\n setEntityPickerOpen(false)\n }\n }, [\n movingEntities,\n projectName,\n updateOverviewEntities,\n openMoveDialog,\n closeMoveDialog,\n setEntityPickerOpen,\n clearMovingEntities,\n ])\n\n // Get disabled folder IDs\n const getDisabledFolderIds = useCallback((): string[] => {\n if (!movingEntities) return []\n const disabledIds: string[] = []\n\n // Add the entities being moved themselves to prevent moving to themselves\n movingEntities.entities.forEach((entity: EntityMoveData) => {\n disabledIds.push(entity.entityId)\n })\n\n // Add folders where name conflicts would occur\n folders.forEach((targetFolder) => {\n // Check if any moving entity has the same name as existing children in this folder\n const hasNameConflict = movingEntities.entities.some((movingEntity: EntityMoveData) => {\n // Get the name of the entity being moved\n const movingEntityData = getEntityById(movingEntity.entityId)\n if (!movingEntityData?.name) return false\n\n // Find all entities that would be siblings in the target folder\n const existingSiblings = tableData.filter((entity) => {\n // For folders, check parentId\n if (movingEntity.entityType === 'folder') {\n return entity.entityType === 'folder' && entity.parentId === targetFolder.id\n }\n // For tasks, check folderId\n if (movingEntity.entityType === 'task') {\n return entity.entityType === 'task' && entity.folderId === targetFolder.id\n }\n return false\n })\n\n // Check if any sibling has the same name (excluding the entity being moved itself)\n return existingSiblings.some(\n (sibling) =>\n sibling.name === movingEntityData.name && sibling.entityId !== movingEntity.entityId,\n )\n })\n\n if (hasNameConflict) {\n disabledIds.push(targetFolder.id)\n }\n })\n\n return [...new Set(disabledIds)]\n }, [movingEntities, folders, tableData, getEntityById])\n\n // Get disabled message for a folder\n const getDisabledMessage = useCallback(\n (folderId: string): string | undefined => {\n if (!movingEntities) return undefined\n\n // 1. Check if this folder is the entity being moved itself.\n const isEntityItself = movingEntities.entities.some(\n (entity: EntityMoveData) => entity.entityType === 'folder' && entity.entityId === folderId,\n )\n\n if (isEntityItself) {\n return 'Cannot move folder to itself'\n }\n\n // 2. Check if this is the current parent folder.\n const isCurrentParent = movingEntities.entities.some(\n (entity: EntityMoveData) => entity.currentParentId === folderId,\n )\n\n if (isCurrentParent) {\n return 'Cannot move to the same location'\n }\n\n // 4. Check for name conflicts - entity with same name already exists in target folder\n const targetFolder = folders.find((folder) => folder.id === folderId)\n if (targetFolder) {\n const conflictingEntity = movingEntities.entities.find((movingEntity: EntityMoveData) => {\n // Get the name of the entity being moved\n const movingEntityData = getEntityById(movingEntity.entityId)\n if (!movingEntityData?.name) return false\n\n // Find all entities that would be siblings in the target folder\n const existingSiblings = tableData.filter((entity) => {\n // For folders, check parentId\n if (movingEntity.entityType === 'folder') {\n return entity.entityType === 'folder' && entity.parentId === targetFolder.id\n }\n // For tasks, check folderId\n if (movingEntity.entityType === 'task') {\n return entity.entityType === 'task' && entity.folderId === targetFolder.id\n }\n return false\n })\n\n // Check if any sibling has the same name (excluding the entity being moved itself)\n return existingSiblings.some(\n (sibling) =>\n sibling.name === movingEntityData.name && sibling.entityId !== movingEntity.entityId,\n )\n })\n\n if (conflictingEntity) {\n const entityData = getEntityById(conflictingEntity.entityId)\n const entityName = entityData?.name || 'Entity'\n return `Cannot move \"${entityName}\" - an entity with the same name already exists in this folder`\n }\n }\n\n // 5. Check if the target is a child folder (simplified check)\n const isChildFolder = movingEntities.entities.some(\n (entity: EntityMoveData) => entity.entityType === 'folder',\n )\n\n if (isChildFolder) {\n return 'Cannot move folder to its child'\n }\n\n // Default message\n return 'Cannot move to this location'\n },\n [movingEntities, folders, tableData, getEntityById],\n )\n\n // Check if we can show \"Move to root\" option\n const canMoveToRoot = useMemo(() => {\n return (\n movingEntities?.entities.every((entity: EntityMoveData) => entity.entityType === 'folder') ||\n false\n )\n }, [movingEntities])\n\n return {\n // State\n movingEntities,\n isEntityPickerOpen,\n\n // Actions (keeping legacy names for compatibility)\n isDialogOpen: isEntityPickerOpen,\n openMoveDialog: openMoveDialogHandler,\n closeMoveDialog: closeMoveDialogHandler,\n handleMoveSubmit,\n handleMoveToRoot,\n getDisabledFolderIds,\n getDisabledMessage,\n canMoveToRoot,\n }\n}\n"],"names":["useMoveEntities","projectName","movingEntities","isEntityPickerOpen","openMoveDialog","closeMoveDialog","setEntityPickerOpen","clearMovingEntities","useMoveEntityContext","updateOverviewEntities","useUpdateOverviewEntitiesMutation","tableData","getEntityById","useProjectTableContext","folders","useGetFolderListQuery","openMoveDialogHandler","useCallback","entityData","closeMoveDialogHandler","handleMoveSubmit","selectedFolderIds","targetFolderId","moveOperations","entity","index","result","failedOperations","_a","op","errorDetails","error","errorMessage","_b","nameMatch","toast","handleMoveToRoot","getDisabledFolderIds","disabledIds","targetFolder","movingEntity","movingEntityData","sibling","getDisabledMessage","folderId","folder","conflictingEntity","canMoveToRoot","useMemo"],"mappings":"mmXAqBO,MAAMA,EAAkB,CAAC,CAAE,YAAAC,KAAwC,CAClE,KAAA,CACJ,eAAAC,EACA,mBAAAC,EACA,eAAAC,EACA,gBAAAC,EACA,oBAAAC,EACA,oBAAAC,GACEC,uBAAqB,EACnB,CAACC,CAAsB,EAAIC,oCAAkC,EAG7D,CAAE,UAAAC,EAAW,cAAAC,CAAc,EAAIC,yBAAuB,EAGtD,CAAE,KAAM,CAAE,QAAAC,EAAU,CAAA,CAAG,EAAI,CAAC,CAAA,EAAMC,EAAA,sBACtC,CAAE,YAAad,GAAe,GAAI,OAAQ,EAAK,EAC/C,CAAE,KAAM,CAACA,CAAY,CACvB,EAGMe,EAAwBC,EAAA,YAC3BC,GAAqD,CACpDd,EAAec,CAAU,CAC3B,EACA,CAACd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GAAiC,CAEjF,MAAAC,EAAmB7B,EAAc4B,EAAa,QAAQ,EACxD,OAACC,GAAA,MAAAA,EAAkB,KAGE9B,EAAU,OAAQa,GAErCgB,EAAa,aAAe,SACvBhB,EAAO,aAAe,UAAYA,EAAO,WAAae,EAAa,GAGxEC,EAAa,aAAe,OACvBhB,EAAO,aAAe,QAAUA,EAAO,WAAae,EAAa,GAEnE,EACR,EAGuB,KACrBG,GACCA,EAAQ,OAASD,EAAiB,MAAQC,EAAQ,WAAaF,EAAa,QAChF,EAnBoC,EAmBpC,CACD,EAED,GAAIM,EAAmB,CACf,MAAA5B,EAAaN,EAAckC,EAAkB,QAAQ,EAE3D,MAAO,iBADY5B,GAAA,YAAAA,EAAY,OAAQ,QACN,gEAAA,CACnC,CAQF,OAJsBhB,EAAe,SAAS,KAC3CsB,GAA2BA,EAAO,aAAe,QACpD,EAGS,kCAIF,8BACT,EACA,CAACtB,EAAgBY,EAASH,EAAWC,CAAa,CACpD,EAGMmC,EAAgBC,EAAAA,QAAQ,KAE1B9C,GAAA,YAAAA,EAAgB,SAAS,MAAOsB,GAA2BA,EAAO,aAAe,YACjF,GAED,CAACtB,CAAc,CAAC,EAEZ,MAAA,CAEL,eAAAA,EACA,mBAAAC,EAGA,aAAcA,EACd,eAAgBa,EAChB,gBAAiBG,EACjB,iBAAAC,EACA,iBAAAgB,EACA,qBAAAC,EACA,mBAAAM,EACA,cAAAI,CACF,CACF"}
|
|
1
|
+
{"version":3,"file":"useMoveEntities.cjs.js","sources":["../../../../../../src/containers/ProjectTreeTable/hooks/useMoveEntities.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react'\nimport { toast } from 'react-toastify'\nimport {\n OperationModel,\n OperationResponseModel,\n useUpdateOverviewEntitiesMutation,\n useGetFolderListQuery,\n} from '@shared/api'\nimport { useProjectTableContext } from '@shared/containers'\nimport {\n useMoveEntityContext,\n EntityMoveData,\n MultiEntityMoveData,\n} from '@shared/context/MoveEntityContext'\n\nexport type EntityType = 'folder' | 'task'\n\ninterface UseMoveEntitiesProps {\n projectName: string\n}\n\nexport const useMoveEntities = ({ projectName }: UseMoveEntitiesProps) => {\n const {\n movingEntities,\n isEntityPickerOpen,\n openMoveDialog,\n closeMoveDialog,\n setEntityPickerOpen,\n clearMovingEntities,\n } = useMoveEntityContext()\n const [updateOverviewEntities] = useUpdateOverviewEntitiesMutation()\n\n // Get project context for entity data\n const { tableData, getEntityById } = useProjectTableContext()\n\n // Get folder data to check hasVersions property\n const { data: { folders = [] } = {} } = useGetFolderListQuery(\n { projectName: projectName || '', attrib: true },\n { skip: !projectName },\n )\n\n // Action dispatchers\n const openMoveDialogHandler = useCallback(\n (entityData: EntityMoveData | MultiEntityMoveData) => {\n openMoveDialog(entityData)\n },\n [openMoveDialog],\n )\n\n const closeMoveDialogHandler = useCallback(() => {\n closeMoveDialog()\n }, [closeMoveDialog])\n\n // Move submit handler\n const handleMoveSubmit = useCallback(\n async (selectedFolderIds: string[]) => {\n if (!movingEntities || selectedFolderIds.length === 0) return\n\n const targetFolderId = selectedFolderIds[0]\n setEntityPickerOpen(false)\n\n try {\n // Prepare move operations for all entities\n const moveOperations: OperationModel[] = movingEntities.entities.map(\n (entity: EntityMoveData, index: number) => ({\n id: `move-${entity.entityId}-${Date.now()}-${index}`,\n type: 'update',\n entityType: entity.entityType,\n entityId: entity.entityId,\n data:\n entity.entityType === 'folder'\n ? { parentId: targetFolderId }\n : { folderId: targetFolderId },\n }),\n )\n\n // Use the mutation with built-in optimistic updates and rollback\n const result = await updateOverviewEntities({\n projectName,\n operationsRequestModel: {\n operations: moveOperations,\n },\n }).unwrap()\n\n // Check for any failed operations\n const failedOperations =\n result?.operations?.filter((op: OperationResponseModel) => op.success === false) || []\n\n if (failedOperations.length > 0) {\n const errorDetails = failedOperations.map((op) => op.detail).join(', ')\n throw new Error(errorDetails || 'Some move operations failed')\n }\n } catch (error: any) {\n console.error('Failed to move entity:', error)\n\n // Extract and improve error message\n let errorMessage =\n error?.data?.detail || error?.error || error?.message || 'Failed to move entities'\n\n // Improve specific error messages for better UX\n if (errorMessage.includes('already exists')) {\n // For multiple entities, provide a more general message\n if (movingEntities.entities.length > 1) {\n errorMessage = `Cannot move some entities - one or more entities with the same name already exist in the target location`\n } else {\n const entity = movingEntities.entities[0]\n if (entity.entityType === 'task') {\n // Extract task name from error message if possible\n const nameMatch = errorMessage.match(/name '.*?, (.+?)' already exists/)\n const taskName = nameMatch ? nameMatch[1] : 'this task'\n errorMessage = `Cannot move \"${taskName}\" - a task with this name already exists in the target folder`\n } else {\n // Extract folder name from error message if possible\n const nameMatch = errorMessage.match(/name '.*?, (.+?)' already exists/)\n const folderName = nameMatch ? nameMatch[1] : 'this folder'\n errorMessage = `Cannot move \"${folderName}\" - a folder with this name already exists in the target location`\n }\n }\n }\n\n toast.error(errorMessage)\n } finally {\n clearMovingEntities()\n setEntityPickerOpen(false)\n }\n },\n [\n movingEntities,\n projectName,\n updateOverviewEntities,\n openMoveDialog,\n closeMoveDialog,\n setEntityPickerOpen,\n clearMovingEntities,\n ],\n )\n\n // Move to root handler\n const handleMoveToRoot = useCallback(async () => {\n if (!movingEntities) return\n\n setEntityPickerOpen(false)\n\n try {\n // Prepare move operations for all entities to move to root (null parentId/folderId)\n const moveOperations: OperationModel[] = movingEntities.entities.map(\n (entity: EntityMoveData, index: number) => ({\n id: `move-to-root-${entity.entityId}-${Date.now()}-${index}`,\n type: 'update',\n entityType: entity.entityType,\n entityId: entity.entityId,\n data: entity.entityType === 'folder' ? { parentId: null } : { folderId: null },\n }),\n )\n\n // Use the mutation with built-in optimistic updates and rollback\n const result = await updateOverviewEntities({\n projectName,\n operationsRequestModel: {\n operations: moveOperations,\n },\n }).unwrap()\n\n // Check for any failed operations\n const failedOperations =\n result?.operations?.filter((op: OperationResponseModel) => op.success === false) || []\n\n if (failedOperations.length > 0) {\n const errorDetails = failedOperations.map((op) => op.detail).join(', ')\n throw new Error(errorDetails || 'Some move operations failed')\n }\n } catch (error: any) {\n console.error('Failed to move entities to root:', error)\n\n // Extract and improve error message\n let errorMessage =\n error?.data?.detail || error?.error || error?.message || 'Failed to move entities to root'\n\n toast.error(errorMessage)\n } finally {\n clearMovingEntities()\n setEntityPickerOpen(false)\n }\n }, [\n movingEntities,\n projectName,\n updateOverviewEntities,\n openMoveDialog,\n closeMoveDialog,\n setEntityPickerOpen,\n clearMovingEntities,\n ])\n\n // Get disabled folder IDs\n const getDisabledFolderIds = useCallback((): string[] => {\n if (!movingEntities) return []\n const disabledIds: string[] = []\n\n // Add the entities being moved themselves to prevent moving to themselves\n movingEntities.entities.forEach((entity: EntityMoveData) => {\n disabledIds.push(entity.entityId)\n })\n\n // Add folders where name conflicts would occur\n folders.forEach((targetFolder) => {\n // Check if any moving entity has the same name as existing children in this folder\n const hasNameConflict = movingEntities.entities.some((movingEntity: EntityMoveData) => {\n // Get the name of the entity being moved\n const movingEntityData = getEntityById(movingEntity.entityId)\n if (!movingEntityData?.name) return false\n\n // Find all entities that would be siblings in the target folder\n const existingSiblings = tableData.filter((entity) => {\n // For folders, check parentId\n if (movingEntity.entityType === 'folder') {\n return entity.entityType === 'folder' && entity.parentId === targetFolder.id\n }\n // For tasks, check folderId\n if (movingEntity.entityType === 'task') {\n return entity.entityType === 'task' && entity.folderId === targetFolder.id\n }\n return false\n })\n\n // Check if any sibling has the same name (excluding the entity being moved itself)\n return existingSiblings.some(\n (sibling) =>\n sibling.name === movingEntityData.name && sibling.entityId !== movingEntity.entityId,\n )\n })\n\n if (hasNameConflict) {\n disabledIds.push(targetFolder.id)\n }\n })\n\n return [...new Set(disabledIds)]\n }, [movingEntities, folders, tableData, getEntityById])\n\n // Get disabled message for a folder\n const getDisabledMessage = useCallback(\n (folderId: string): string | undefined => {\n if (!movingEntities) return undefined\n\n // 1. Check if this folder is the entity being moved itself.\n const isEntityItself = movingEntities.entities.some(\n (entity: EntityMoveData) => entity.entityType === 'folder' && entity.entityId === folderId,\n )\n\n if (isEntityItself) {\n return 'Cannot move folder to itself'\n }\n\n // 2. Check if this is the current parent folder.\n const isCurrentParent = movingEntities.entities.some(\n (entity: EntityMoveData) => entity.currentParentId === folderId,\n )\n\n if (isCurrentParent) {\n return 'Cannot move to the same location'\n }\n\n // 4. Check for name conflicts - entity with same name already exists in target folder\n const targetFolder = folders.find((folder) => folder.id === folderId)\n if (targetFolder) {\n const conflictingEntity = movingEntities.entities.find((movingEntity: EntityMoveData) => {\n // Get the name of the entity being moved\n const movingEntityData = getEntityById(movingEntity.entityId)\n if (!movingEntityData?.name) return false\n\n // Find all entities that would be siblings in the target folder\n const existingSiblings = tableData.filter((entity) => {\n // For folders, check parentId\n if (movingEntity.entityType === 'folder') {\n return entity.entityType === 'folder' && entity.parentId === targetFolder.id\n }\n // For tasks, check folderId\n if (movingEntity.entityType === 'task') {\n return entity.entityType === 'task' && entity.folderId === targetFolder.id\n }\n return false\n })\n\n // Check if any sibling has the same name (excluding the entity being moved itself)\n return existingSiblings.some(\n (sibling) =>\n sibling.name === movingEntityData.name && sibling.entityId !== movingEntity.entityId,\n )\n })\n\n if (conflictingEntity) {\n const entityData = getEntityById(conflictingEntity.entityId)\n const entityName = entityData?.name || 'Entity'\n return `Cannot move \"${entityName}\" - an entity with the same name already exists in this folder`\n }\n }\n\n // 5. Check if the target is a child folder (simplified check)\n const isChildFolder = movingEntities.entities.some(\n (entity: EntityMoveData) => entity.entityType === 'folder',\n )\n\n if (isChildFolder) {\n return 'Cannot move folder to its child'\n }\n\n // Default message\n return 'Cannot move to this location'\n },\n [movingEntities, folders, tableData, getEntityById],\n )\n\n // Check if we can show \"Move to root\" option\n const canMoveToRoot = useMemo(() => {\n return (\n movingEntities?.entities.every((entity: EntityMoveData) => entity.entityType === 'folder') ||\n false\n )\n }, [movingEntities])\n\n return {\n // State\n movingEntities,\n isEntityPickerOpen,\n\n // Actions (keeping legacy names for compatibility)\n isDialogOpen: isEntityPickerOpen,\n openMoveDialog: openMoveDialogHandler,\n closeMoveDialog: closeMoveDialogHandler,\n handleMoveSubmit,\n handleMoveToRoot,\n getDisabledFolderIds,\n getDisabledMessage,\n canMoveToRoot,\n }\n}\n"],"names":["useMoveEntities","projectName","movingEntities","isEntityPickerOpen","openMoveDialog","closeMoveDialog","setEntityPickerOpen","clearMovingEntities","useMoveEntityContext","updateOverviewEntities","useUpdateOverviewEntitiesMutation","tableData","getEntityById","useProjectTableContext","folders","useGetFolderListQuery","openMoveDialogHandler","useCallback","entityData","closeMoveDialogHandler","handleMoveSubmit","selectedFolderIds","targetFolderId","moveOperations","entity","index","result","failedOperations","_a","op","errorDetails","error","errorMessage","_b","nameMatch","toast","handleMoveToRoot","getDisabledFolderIds","disabledIds","targetFolder","movingEntity","movingEntityData","sibling","getDisabledMessage","folderId","folder","conflictingEntity","canMoveToRoot","useMemo"],"mappings":"8yXAqBO,MAAMA,EAAkB,CAAC,CAAE,YAAAC,KAAwC,CAClE,KAAA,CACJ,eAAAC,EACA,mBAAAC,EACA,eAAAC,EACA,gBAAAC,EACA,oBAAAC,EACA,oBAAAC,GACEC,uBAAqB,EACnB,CAACC,CAAsB,EAAIC,oCAAkC,EAG7D,CAAE,UAAAC,EAAW,cAAAC,CAAc,EAAIC,yBAAuB,EAGtD,CAAE,KAAM,CAAE,QAAAC,EAAU,CAAA,CAAG,EAAI,CAAC,CAAA,EAAMC,EAAA,sBACtC,CAAE,YAAad,GAAe,GAAI,OAAQ,EAAK,EAC/C,CAAE,KAAM,CAACA,CAAY,CACvB,EAGMe,EAAwBC,EAAA,YAC3BC,GAAqD,CACpDd,EAAec,CAAU,CAC3B,EACA,CAACd,CAAc,CACjB,EAEMe,EAAyBF,EAAAA,YAAY,IAAM,CAC/BZ,EAAA,CAAA,EACf,CAACA,CAAe,CAAC,EAGde,EAAmBH,EAAA,YACvB,MAAOI,GAAgC,SACrC,GAAI,CAACnB,GAAkBmB,EAAkB,SAAW,EAAG,OAEjD,MAAAC,EAAiBD,EAAkB,CAAC,EAC1Cf,EAAoB,EAAK,EAErB,GAAA,CAEI,MAAAiB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GACCA,EAAQ,OAASD,EAAiB,MAAQC,EAAQ,WAAaF,EAAa,QAChF,EAnBoC,EAmBpC,CACD,EAED,GAAIM,EAAmB,CACf,MAAA5B,EAAaN,EAAckC,EAAkB,QAAQ,EAE3D,MAAO,iBADY5B,GAAA,YAAAA,EAAY,OAAQ,QACN,gEAAA,CACnC,CAQF,OAJsBhB,EAAe,SAAS,KAC3CsB,GAA2BA,EAAO,aAAe,QACpD,EAGS,kCAIF,8BACT,EACA,CAACtB,EAAgBY,EAASH,EAAWC,CAAa,CACpD,EAGMmC,EAAgBC,EAAAA,QAAQ,KAE1B9C,GAAA,YAAAA,EAAgB,SAAS,MAAOsB,GAA2BA,EAAO,aAAe,YACjF,GAED,CAACtB,CAAc,CAAC,EAEZ,MAAA,CAEL,eAAAA,EACA,mBAAAC,EAGA,aAAcA,EACd,eAAgBa,EAChB,gBAAiBG,EACjB,iBAAAC,EACA,iBAAAgB,EACA,qBAAAC,EACA,mBAAAM,EACA,cAAAI,CACF,CACF"}
|
|
@@ -165,6 +165,7 @@ import "../../../components/Powerpack/PowerpackButton.es.js";
|
|
|
165
165
|
import "../../../components/Powerpack/PricingLink.es.js";
|
|
166
166
|
import "../../../components/Powerpack/PowerpackDialog.styled.es.js";
|
|
167
167
|
import "../../../components/Powerpack/CTAButton.es.js";
|
|
168
|
+
import "../../../components/Powerpack/RequiredPowerpackVersion.es.js";
|
|
168
169
|
import "../../../components/SettingsPanel/SettingsPanel.es.js";
|
|
169
170
|
import "../../../components/SettingsPanel/SettingsPanelItemTemplate.es.js";
|
|
170
171
|
import "../../../components/AttributeEditor/components/MinMaxField.es.js";
|
|
@@ -178,6 +179,8 @@ import "../../../components/Feedback/SupportBubble.es.js";
|
|
|
178
179
|
import "../../../components/Chips/Chips.es.js";
|
|
179
180
|
import "../../../components/LinksManager/LinksManager.styled.es.js";
|
|
180
181
|
import "../../EntityPickerDialog/EntityPickerDialog.es.js";
|
|
182
|
+
import "../../../components/DetailsMetaData/DetailsMetaData.es.js";
|
|
183
|
+
import "../../../components/AccessUser/AccessUser.es.js";
|
|
181
184
|
import "../../../components/LinksManager/LinksManagerDialog.es.js";
|
|
182
185
|
import "../context/DetailsPanelEntityContext.es.js";
|
|
183
186
|
import "../context/SelectedRowsContext.es.js";
|
|
@@ -208,7 +211,7 @@ import "../../Views/context/ViewsContext.es.js";
|
|
|
208
211
|
import "../../Views/Views.styled.es.js";
|
|
209
212
|
import "../../Views/ViewsMenuContainer/ViewsMenuContainer.es.js";
|
|
210
213
|
import "../../Views/ViewsMenu/ViewsMenu.es.js";
|
|
211
|
-
const
|
|
214
|
+
const Pr = ({ projectName: l }) => {
|
|
212
215
|
const {
|
|
213
216
|
movingEntities: o,
|
|
214
217
|
isEntityPickerOpen: T,
|
|
@@ -376,6 +379,6 @@ const Sr = ({ projectName: l }) => {
|
|
|
376
379
|
};
|
|
377
380
|
};
|
|
378
381
|
export {
|
|
379
|
-
|
|
382
|
+
Pr as useMoveEntities
|
|
380
383
|
};
|
|
381
384
|
//# sourceMappingURL=useMoveEntities.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMoveEntities.es.js","sources":["../../../../../../src/containers/ProjectTreeTable/hooks/useMoveEntities.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react'\nimport { toast } from 'react-toastify'\nimport {\n OperationModel,\n OperationResponseModel,\n useUpdateOverviewEntitiesMutation,\n useGetFolderListQuery,\n} from '@shared/api'\nimport { useProjectTableContext } from '@shared/containers'\nimport {\n useMoveEntityContext,\n EntityMoveData,\n MultiEntityMoveData,\n} from '@shared/context/MoveEntityContext'\n\nexport type EntityType = 'folder' | 'task'\n\ninterface UseMoveEntitiesProps {\n projectName: string\n}\n\nexport const useMoveEntities = ({ projectName }: UseMoveEntitiesProps) => {\n const {\n movingEntities,\n isEntityPickerOpen,\n openMoveDialog,\n closeMoveDialog,\n setEntityPickerOpen,\n clearMovingEntities,\n } = useMoveEntityContext()\n const [updateOverviewEntities] = useUpdateOverviewEntitiesMutation()\n\n // Get project context for entity data\n const { tableData, getEntityById } = useProjectTableContext()\n\n // Get folder data to check hasVersions property\n const { data: { folders = [] } = {} } = useGetFolderListQuery(\n { projectName: projectName || '', attrib: true },\n { skip: !projectName },\n )\n\n // Action dispatchers\n const openMoveDialogHandler = useCallback(\n (entityData: EntityMoveData | MultiEntityMoveData) => {\n openMoveDialog(entityData)\n },\n [openMoveDialog],\n )\n\n const closeMoveDialogHandler = useCallback(() => {\n closeMoveDialog()\n }, [closeMoveDialog])\n\n // Move submit handler\n const handleMoveSubmit = useCallback(\n async (selectedFolderIds: string[]) => {\n if (!movingEntities || selectedFolderIds.length === 0) return\n\n const targetFolderId = selectedFolderIds[0]\n setEntityPickerOpen(false)\n\n try {\n // Prepare move operations for all entities\n const moveOperations: OperationModel[] = movingEntities.entities.map(\n (entity: EntityMoveData, index: number) => ({\n id: `move-${entity.entityId}-${Date.now()}-${index}`,\n type: 'update',\n entityType: entity.entityType,\n entityId: entity.entityId,\n data:\n entity.entityType === 'folder'\n ? { parentId: targetFolderId }\n : { folderId: targetFolderId },\n }),\n )\n\n // Use the mutation with built-in optimistic updates and rollback\n const result = await updateOverviewEntities({\n projectName,\n operationsRequestModel: {\n operations: moveOperations,\n },\n }).unwrap()\n\n // Check for any failed operations\n const failedOperations =\n result?.operations?.filter((op: OperationResponseModel) => op.success === false) || []\n\n if (failedOperations.length > 0) {\n const errorDetails = failedOperations.map((op) => op.detail).join(', ')\n throw new Error(errorDetails || 'Some move operations failed')\n }\n } catch (error: any) {\n console.error('Failed to move entity:', error)\n\n // Extract and improve error message\n let errorMessage =\n error?.data?.detail || error?.error || error?.message || 'Failed to move entities'\n\n // Improve specific error messages for better UX\n if (errorMessage.includes('already exists')) {\n // For multiple entities, provide a more general message\n if (movingEntities.entities.length > 1) {\n errorMessage = `Cannot move some entities - one or more entities with the same name already exist in the target location`\n } else {\n const entity = movingEntities.entities[0]\n if (entity.entityType === 'task') {\n // Extract task name from error message if possible\n const nameMatch = errorMessage.match(/name '.*?, (.+?)' already exists/)\n const taskName = nameMatch ? nameMatch[1] : 'this task'\n errorMessage = `Cannot move \"${taskName}\" - a task with this name already exists in the target folder`\n } else {\n // Extract folder name from error message if possible\n const nameMatch = errorMessage.match(/name '.*?, (.+?)' already exists/)\n const folderName = nameMatch ? nameMatch[1] : 'this folder'\n errorMessage = `Cannot move \"${folderName}\" - a folder with this name already exists in the target location`\n }\n }\n }\n\n toast.error(errorMessage)\n } finally {\n clearMovingEntities()\n setEntityPickerOpen(false)\n }\n },\n [\n movingEntities,\n projectName,\n updateOverviewEntities,\n openMoveDialog,\n closeMoveDialog,\n setEntityPickerOpen,\n clearMovingEntities,\n ],\n )\n\n // Move to root handler\n const handleMoveToRoot = useCallback(async () => {\n if (!movingEntities) return\n\n setEntityPickerOpen(false)\n\n try {\n // Prepare move operations for all entities to move to root (null parentId/folderId)\n const moveOperations: OperationModel[] = movingEntities.entities.map(\n (entity: EntityMoveData, index: number) => ({\n id: `move-to-root-${entity.entityId}-${Date.now()}-${index}`,\n type: 'update',\n entityType: entity.entityType,\n entityId: entity.entityId,\n data: entity.entityType === 'folder' ? { parentId: null } : { folderId: null },\n }),\n )\n\n // Use the mutation with built-in optimistic updates and rollback\n const result = await updateOverviewEntities({\n projectName,\n operationsRequestModel: {\n operations: moveOperations,\n },\n }).unwrap()\n\n // Check for any failed operations\n const failedOperations =\n result?.operations?.filter((op: OperationResponseModel) => op.success === false) || []\n\n if (failedOperations.length > 0) {\n const errorDetails = failedOperations.map((op) => op.detail).join(', ')\n throw new Error(errorDetails || 'Some move operations failed')\n }\n } catch (error: any) {\n console.error('Failed to move entities to root:', error)\n\n // Extract and improve error message\n let errorMessage =\n error?.data?.detail || error?.error || error?.message || 'Failed to move entities to root'\n\n toast.error(errorMessage)\n } finally {\n clearMovingEntities()\n setEntityPickerOpen(false)\n }\n }, [\n movingEntities,\n projectName,\n updateOverviewEntities,\n openMoveDialog,\n closeMoveDialog,\n setEntityPickerOpen,\n clearMovingEntities,\n ])\n\n // Get disabled folder IDs\n const getDisabledFolderIds = useCallback((): string[] => {\n if (!movingEntities) return []\n const disabledIds: string[] = []\n\n // Add the entities being moved themselves to prevent moving to themselves\n movingEntities.entities.forEach((entity: EntityMoveData) => {\n disabledIds.push(entity.entityId)\n })\n\n // Add folders where name conflicts would occur\n folders.forEach((targetFolder) => {\n // Check if any moving entity has the same name as existing children in this folder\n const hasNameConflict = movingEntities.entities.some((movingEntity: EntityMoveData) => {\n // Get the name of the entity being moved\n const movingEntityData = getEntityById(movingEntity.entityId)\n if (!movingEntityData?.name) return false\n\n // Find all entities that would be siblings in the target folder\n const existingSiblings = tableData.filter((entity) => {\n // For folders, check parentId\n if (movingEntity.entityType === 'folder') {\n return entity.entityType === 'folder' && entity.parentId === targetFolder.id\n }\n // For tasks, check folderId\n if (movingEntity.entityType === 'task') {\n return entity.entityType === 'task' && entity.folderId === targetFolder.id\n }\n return false\n })\n\n // Check if any sibling has the same name (excluding the entity being moved itself)\n return existingSiblings.some(\n (sibling) =>\n sibling.name === movingEntityData.name && sibling.entityId !== movingEntity.entityId,\n )\n })\n\n if (hasNameConflict) {\n disabledIds.push(targetFolder.id)\n }\n })\n\n return [...new Set(disabledIds)]\n }, [movingEntities, folders, tableData, getEntityById])\n\n // Get disabled message for a folder\n const getDisabledMessage = useCallback(\n (folderId: string): string | undefined => {\n if (!movingEntities) return undefined\n\n // 1. Check if this folder is the entity being moved itself.\n const isEntityItself = movingEntities.entities.some(\n (entity: EntityMoveData) => entity.entityType === 'folder' && entity.entityId === folderId,\n )\n\n if (isEntityItself) {\n return 'Cannot move folder to itself'\n }\n\n // 2. Check if this is the current parent folder.\n const isCurrentParent = movingEntities.entities.some(\n (entity: EntityMoveData) => entity.currentParentId === folderId,\n )\n\n if (isCurrentParent) {\n return 'Cannot move to the same location'\n }\n\n // 4. Check for name conflicts - entity with same name already exists in target folder\n const targetFolder = folders.find((folder) => folder.id === folderId)\n if (targetFolder) {\n const conflictingEntity = movingEntities.entities.find((movingEntity: EntityMoveData) => {\n // Get the name of the entity being moved\n const movingEntityData = getEntityById(movingEntity.entityId)\n if (!movingEntityData?.name) return false\n\n // Find all entities that would be siblings in the target folder\n const existingSiblings = tableData.filter((entity) => {\n // For folders, check parentId\n if (movingEntity.entityType === 'folder') {\n return entity.entityType === 'folder' && entity.parentId === targetFolder.id\n }\n // For tasks, check folderId\n if (movingEntity.entityType === 'task') {\n return entity.entityType === 'task' && entity.folderId === targetFolder.id\n }\n return false\n })\n\n // Check if any sibling has the same name (excluding the entity being moved itself)\n return existingSiblings.some(\n (sibling) =>\n sibling.name === movingEntityData.name && sibling.entityId !== movingEntity.entityId,\n )\n })\n\n if (conflictingEntity) {\n const entityData = getEntityById(conflictingEntity.entityId)\n const entityName = entityData?.name || 'Entity'\n return `Cannot move \"${entityName}\" - an entity with the same name already exists in this folder`\n }\n }\n\n // 5. Check if the target is a child folder (simplified check)\n const isChildFolder = movingEntities.entities.some(\n (entity: EntityMoveData) => entity.entityType === 'folder',\n )\n\n if (isChildFolder) {\n return 'Cannot move folder to its child'\n }\n\n // Default message\n return 'Cannot move to this location'\n },\n [movingEntities, folders, tableData, getEntityById],\n )\n\n // Check if we can show \"Move to root\" option\n const canMoveToRoot = useMemo(() => {\n return (\n movingEntities?.entities.every((entity: EntityMoveData) => entity.entityType === 'folder') ||\n false\n )\n }, [movingEntities])\n\n return {\n // State\n movingEntities,\n isEntityPickerOpen,\n\n // Actions (keeping legacy names for compatibility)\n isDialogOpen: isEntityPickerOpen,\n openMoveDialog: openMoveDialogHandler,\n closeMoveDialog: closeMoveDialogHandler,\n handleMoveSubmit,\n handleMoveToRoot,\n getDisabledFolderIds,\n getDisabledMessage,\n canMoveToRoot,\n }\n}\n"],"names":["useMoveEntities","projectName","movingEntities","isEntityPickerOpen","openMoveDialog","closeMoveDialog","setEntityPickerOpen","clearMovingEntities","useMoveEntityContext","updateOverviewEntities","useUpdateOverviewEntitiesMutation","tableData","getEntityById","useProjectTableContext","folders","useGetFolderListQuery","openMoveDialogHandler","useCallback","entityData","closeMoveDialogHandler","handleMoveSubmit","selectedFolderIds","targetFolderId","moveOperations","entity","index","result","failedOperations","_a","op","errorDetails","error","errorMessage","_b","nameMatch","toast","handleMoveToRoot","getDisabledFolderIds","disabledIds","targetFolder","movingEntity","movingEntityData","sibling","getDisabledMessage","folderId","folder","conflictingEntity","canMoveToRoot","useMemo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBO,MAAMA,KAAkB,CAAC,EAAE,aAAAC,QAAwC;AAClE,QAAA;AAAA,IACJ,gBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,qBAAAC;AAAA,MACEC,EAAqB,GACnB,CAACC,CAAsB,IAAIC,EAAkC,GAG7D,EAAE,WAAAC,GAAW,eAAAC,EAAc,IAAIC,EAAuB,GAGtD,EAAE,MAAM,EAAE,SAAAC,IAAU,CAAA,EAAG,IAAI,CAAC,EAAA,IAAMC;AAAA,IACtC,EAAE,aAAad,KAAe,IAAI,QAAQ,GAAK;AAAA,IAC/C,EAAE,MAAM,CAACA,EAAY;AAAA,EACvB,GAGMe,IAAwBC;AAAA,IAC5B,CAACC,MAAqD;AACpD,MAAAd,EAAec,CAAU;AAAA,IAC3B;AAAA,IACA,CAACd,CAAc;AAAA,EACjB,GAEMe,IAAyBF,EAAY,MAAM;AAC/B,IAAAZ,EAAA;AAAA,EAAA,GACf,CAACA,CAAe,CAAC,GAGde,IAAmBH;AAAA,IACvB,OAAOI,MAAgC;;AACrC,UAAI,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IAEL,gBAAAA;AAAA,IACA,oBAAAC;AAAA;AAAA,IAGA,cAAcA;AAAA,IACd,gBAAgBa;AAAA,IAChB,iBAAiBG;AAAA,IACjB,kBAAAC;AAAA,IACA,kBAAAgB;AAAA,IACA,sBAAAC;AAAA,IACA,oBAAAM;AAAA,IACA,eAAAI;AAAA,EACF;AACF;"}
|
|
1
|
+
{"version":3,"file":"useMoveEntities.es.js","sources":["../../../../../../src/containers/ProjectTreeTable/hooks/useMoveEntities.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react'\nimport { toast } from 'react-toastify'\nimport {\n OperationModel,\n OperationResponseModel,\n useUpdateOverviewEntitiesMutation,\n useGetFolderListQuery,\n} from '@shared/api'\nimport { useProjectTableContext } from '@shared/containers'\nimport {\n useMoveEntityContext,\n EntityMoveData,\n MultiEntityMoveData,\n} from '@shared/context/MoveEntityContext'\n\nexport type EntityType = 'folder' | 'task'\n\ninterface UseMoveEntitiesProps {\n projectName: string\n}\n\nexport const useMoveEntities = ({ projectName }: UseMoveEntitiesProps) => {\n const {\n movingEntities,\n isEntityPickerOpen,\n openMoveDialog,\n closeMoveDialog,\n setEntityPickerOpen,\n clearMovingEntities,\n } = useMoveEntityContext()\n const [updateOverviewEntities] = useUpdateOverviewEntitiesMutation()\n\n // Get project context for entity data\n const { tableData, getEntityById } = useProjectTableContext()\n\n // Get folder data to check hasVersions property\n const { data: { folders = [] } = {} } = useGetFolderListQuery(\n { projectName: projectName || '', attrib: true },\n { skip: !projectName },\n )\n\n // Action dispatchers\n const openMoveDialogHandler = useCallback(\n (entityData: EntityMoveData | MultiEntityMoveData) => {\n openMoveDialog(entityData)\n },\n [openMoveDialog],\n )\n\n const closeMoveDialogHandler = useCallback(() => {\n closeMoveDialog()\n }, [closeMoveDialog])\n\n // Move submit handler\n const handleMoveSubmit = useCallback(\n async (selectedFolderIds: string[]) => {\n if (!movingEntities || selectedFolderIds.length === 0) return\n\n const targetFolderId = selectedFolderIds[0]\n setEntityPickerOpen(false)\n\n try {\n // Prepare move operations for all entities\n const moveOperations: OperationModel[] = movingEntities.entities.map(\n (entity: EntityMoveData, index: number) => ({\n id: `move-${entity.entityId}-${Date.now()}-${index}`,\n type: 'update',\n entityType: entity.entityType,\n entityId: entity.entityId,\n data:\n entity.entityType === 'folder'\n ? { parentId: targetFolderId }\n : { folderId: targetFolderId },\n }),\n )\n\n // Use the mutation with built-in optimistic updates and rollback\n const result = await updateOverviewEntities({\n projectName,\n operationsRequestModel: {\n operations: moveOperations,\n },\n }).unwrap()\n\n // Check for any failed operations\n const failedOperations =\n result?.operations?.filter((op: OperationResponseModel) => op.success === false) || []\n\n if (failedOperations.length > 0) {\n const errorDetails = failedOperations.map((op) => op.detail).join(', ')\n throw new Error(errorDetails || 'Some move operations failed')\n }\n } catch (error: any) {\n console.error('Failed to move entity:', error)\n\n // Extract and improve error message\n let errorMessage =\n error?.data?.detail || error?.error || error?.message || 'Failed to move entities'\n\n // Improve specific error messages for better UX\n if (errorMessage.includes('already exists')) {\n // For multiple entities, provide a more general message\n if (movingEntities.entities.length > 1) {\n errorMessage = `Cannot move some entities - one or more entities with the same name already exist in the target location`\n } else {\n const entity = movingEntities.entities[0]\n if (entity.entityType === 'task') {\n // Extract task name from error message if possible\n const nameMatch = errorMessage.match(/name '.*?, (.+?)' already exists/)\n const taskName = nameMatch ? nameMatch[1] : 'this task'\n errorMessage = `Cannot move \"${taskName}\" - a task with this name already exists in the target folder`\n } else {\n // Extract folder name from error message if possible\n const nameMatch = errorMessage.match(/name '.*?, (.+?)' already exists/)\n const folderName = nameMatch ? nameMatch[1] : 'this folder'\n errorMessage = `Cannot move \"${folderName}\" - a folder with this name already exists in the target location`\n }\n }\n }\n\n toast.error(errorMessage)\n } finally {\n clearMovingEntities()\n setEntityPickerOpen(false)\n }\n },\n [\n movingEntities,\n projectName,\n updateOverviewEntities,\n openMoveDialog,\n closeMoveDialog,\n setEntityPickerOpen,\n clearMovingEntities,\n ],\n )\n\n // Move to root handler\n const handleMoveToRoot = useCallback(async () => {\n if (!movingEntities) return\n\n setEntityPickerOpen(false)\n\n try {\n // Prepare move operations for all entities to move to root (null parentId/folderId)\n const moveOperations: OperationModel[] = movingEntities.entities.map(\n (entity: EntityMoveData, index: number) => ({\n id: `move-to-root-${entity.entityId}-${Date.now()}-${index}`,\n type: 'update',\n entityType: entity.entityType,\n entityId: entity.entityId,\n data: entity.entityType === 'folder' ? { parentId: null } : { folderId: null },\n }),\n )\n\n // Use the mutation with built-in optimistic updates and rollback\n const result = await updateOverviewEntities({\n projectName,\n operationsRequestModel: {\n operations: moveOperations,\n },\n }).unwrap()\n\n // Check for any failed operations\n const failedOperations =\n result?.operations?.filter((op: OperationResponseModel) => op.success === false) || []\n\n if (failedOperations.length > 0) {\n const errorDetails = failedOperations.map((op) => op.detail).join(', ')\n throw new Error(errorDetails || 'Some move operations failed')\n }\n } catch (error: any) {\n console.error('Failed to move entities to root:', error)\n\n // Extract and improve error message\n let errorMessage =\n error?.data?.detail || error?.error || error?.message || 'Failed to move entities to root'\n\n toast.error(errorMessage)\n } finally {\n clearMovingEntities()\n setEntityPickerOpen(false)\n }\n }, [\n movingEntities,\n projectName,\n updateOverviewEntities,\n openMoveDialog,\n closeMoveDialog,\n setEntityPickerOpen,\n clearMovingEntities,\n ])\n\n // Get disabled folder IDs\n const getDisabledFolderIds = useCallback((): string[] => {\n if (!movingEntities) return []\n const disabledIds: string[] = []\n\n // Add the entities being moved themselves to prevent moving to themselves\n movingEntities.entities.forEach((entity: EntityMoveData) => {\n disabledIds.push(entity.entityId)\n })\n\n // Add folders where name conflicts would occur\n folders.forEach((targetFolder) => {\n // Check if any moving entity has the same name as existing children in this folder\n const hasNameConflict = movingEntities.entities.some((movingEntity: EntityMoveData) => {\n // Get the name of the entity being moved\n const movingEntityData = getEntityById(movingEntity.entityId)\n if (!movingEntityData?.name) return false\n\n // Find all entities that would be siblings in the target folder\n const existingSiblings = tableData.filter((entity) => {\n // For folders, check parentId\n if (movingEntity.entityType === 'folder') {\n return entity.entityType === 'folder' && entity.parentId === targetFolder.id\n }\n // For tasks, check folderId\n if (movingEntity.entityType === 'task') {\n return entity.entityType === 'task' && entity.folderId === targetFolder.id\n }\n return false\n })\n\n // Check if any sibling has the same name (excluding the entity being moved itself)\n return existingSiblings.some(\n (sibling) =>\n sibling.name === movingEntityData.name && sibling.entityId !== movingEntity.entityId,\n )\n })\n\n if (hasNameConflict) {\n disabledIds.push(targetFolder.id)\n }\n })\n\n return [...new Set(disabledIds)]\n }, [movingEntities, folders, tableData, getEntityById])\n\n // Get disabled message for a folder\n const getDisabledMessage = useCallback(\n (folderId: string): string | undefined => {\n if (!movingEntities) return undefined\n\n // 1. Check if this folder is the entity being moved itself.\n const isEntityItself = movingEntities.entities.some(\n (entity: EntityMoveData) => entity.entityType === 'folder' && entity.entityId === folderId,\n )\n\n if (isEntityItself) {\n return 'Cannot move folder to itself'\n }\n\n // 2. Check if this is the current parent folder.\n const isCurrentParent = movingEntities.entities.some(\n (entity: EntityMoveData) => entity.currentParentId === folderId,\n )\n\n if (isCurrentParent) {\n return 'Cannot move to the same location'\n }\n\n // 4. Check for name conflicts - entity with same name already exists in target folder\n const targetFolder = folders.find((folder) => folder.id === folderId)\n if (targetFolder) {\n const conflictingEntity = movingEntities.entities.find((movingEntity: EntityMoveData) => {\n // Get the name of the entity being moved\n const movingEntityData = getEntityById(movingEntity.entityId)\n if (!movingEntityData?.name) return false\n\n // Find all entities that would be siblings in the target folder\n const existingSiblings = tableData.filter((entity) => {\n // For folders, check parentId\n if (movingEntity.entityType === 'folder') {\n return entity.entityType === 'folder' && entity.parentId === targetFolder.id\n }\n // For tasks, check folderId\n if (movingEntity.entityType === 'task') {\n return entity.entityType === 'task' && entity.folderId === targetFolder.id\n }\n return false\n })\n\n // Check if any sibling has the same name (excluding the entity being moved itself)\n return existingSiblings.some(\n (sibling) =>\n sibling.name === movingEntityData.name && sibling.entityId !== movingEntity.entityId,\n )\n })\n\n if (conflictingEntity) {\n const entityData = getEntityById(conflictingEntity.entityId)\n const entityName = entityData?.name || 'Entity'\n return `Cannot move \"${entityName}\" - an entity with the same name already exists in this folder`\n }\n }\n\n // 5. Check if the target is a child folder (simplified check)\n const isChildFolder = movingEntities.entities.some(\n (entity: EntityMoveData) => entity.entityType === 'folder',\n )\n\n if (isChildFolder) {\n return 'Cannot move folder to its child'\n }\n\n // Default message\n return 'Cannot move to this location'\n },\n [movingEntities, folders, tableData, getEntityById],\n )\n\n // Check if we can show \"Move to root\" option\n const canMoveToRoot = useMemo(() => {\n return (\n movingEntities?.entities.every((entity: EntityMoveData) => entity.entityType === 'folder') ||\n false\n )\n }, [movingEntities])\n\n return {\n // State\n movingEntities,\n isEntityPickerOpen,\n\n // Actions (keeping legacy names for compatibility)\n isDialogOpen: isEntityPickerOpen,\n openMoveDialog: openMoveDialogHandler,\n closeMoveDialog: closeMoveDialogHandler,\n handleMoveSubmit,\n handleMoveToRoot,\n getDisabledFolderIds,\n getDisabledMessage,\n canMoveToRoot,\n }\n}\n"],"names":["useMoveEntities","projectName","movingEntities","isEntityPickerOpen","openMoveDialog","closeMoveDialog","setEntityPickerOpen","clearMovingEntities","useMoveEntityContext","updateOverviewEntities","useUpdateOverviewEntitiesMutation","tableData","getEntityById","useProjectTableContext","folders","useGetFolderListQuery","openMoveDialogHandler","useCallback","entityData","closeMoveDialogHandler","handleMoveSubmit","selectedFolderIds","targetFolderId","moveOperations","entity","index","result","failedOperations","_a","op","errorDetails","error","errorMessage","_b","nameMatch","toast","handleMoveToRoot","getDisabledFolderIds","disabledIds","targetFolder","movingEntity","movingEntityData","sibling","getDisabledMessage","folderId","folder","conflictingEntity","canMoveToRoot","useMemo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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D,iBAACC,KAAA,QAAAA,EAAkB,OAGE9B,EAAU,OAAO,CAACa,MAErCgB,EAAa,eAAe,WACvBhB,EAAO,eAAe,YAAYA,EAAO,aAAae,EAAa,KAGxEC,EAAa,eAAe,SACvBhB,EAAO,eAAe,UAAUA,EAAO,aAAae,EAAa,KAEnE,EACR,EAGuB;AAAA,YACtB,CAACG,MACCA,EAAQ,SAASD,EAAiB,QAAQC,EAAQ,aAAaF,EAAa;AAAA,UAChF,IAnBoC;AAAA,QAmBpC,CACD;AAED,YAAIM,GAAmB;AACf,gBAAA5B,IAAaN,EAAckC,EAAkB,QAAQ;AAE3D,iBAAO,iBADY5B,KAAA,gBAAAA,EAAY,SAAQ,QACN;AAAA,QAAA;AAAA,MACnC;AAQF,aAJsBhB,EAAe,SAAS;AAAA,QAC5C,CAACsB,MAA2BA,EAAO,eAAe;AAAA,MACpD,IAGS,oCAIF;AAAA,IACT;AAAA,IACA,CAACtB,GAAgBY,GAASH,GAAWC,CAAa;AAAA,EACpD,GAGMmC,IAAgBC,EAAQ,OAE1B9C,KAAA,gBAAAA,EAAgB,SAAS,MAAM,CAACsB,MAA2BA,EAAO,eAAe,cACjF,IAED,CAACtB,CAAc,CAAC;AAEZ,SAAA;AAAA;AAAA,IAEL,gBAAAA;AAAA,IACA,oBAAAC;AAAA;AAAA,IAGA,cAAcA;AAAA,IACd,gBAAgBa;AAAA,IAChB,iBAAiBG;AAAA,IACjB,kBAAAC;AAAA,IACA,kBAAAgB;AAAA,IACA,sBAAAC;AAAA,IACA,oBAAAM;AAAA,IACA,eAAAI;AAAA,EACF;AACF;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const N=require("react");require("../../../api/base/client.cjs.js");require("../../../api/generated/graphql.cjs.js");require("../../../api/generated/graphqlLinks.cjs.js");require("../../../api/generated/access.cjs.js");require("../../../api/generated/actions.cjs.js");require("../../../api/generated/activityFeed.cjs.js");require("../../../api/generated/addons.cjs.js");require("../../../api/generated/anatomy.cjs.js");require("../../../api/generated/attributes.cjs.js");require("../../../api/generated/authentication.cjs.js");require("../../../api/generated/bundles.cjs.js");require("../../../api/generated/configuration.cjs.js");require("../../../api/generated/desktop.cjs.js");require("../../../api/generated/entityLists.cjs.js");require("../../../api/generated/events.cjs.js");require("../../../api/generated/files.cjs.js");require("../../../api/generated/folders.cjs.js");require("../../../api/generated/inbox.cjs.js");require("../../../api/generated/links.cjs.js");require("../../../api/generated/market.cjs.js");require("../../../api/generated/onboarding.cjs.js");require("../../../api/generated/operations.cjs.js");require("../../../api/generated/products.cjs.js");require("../../../api/generated/projectDashboard.cjs.js");require("../../../api/generated/projects.cjs.js");require("../../../api/generated/reviewables.cjs.js");require("../../../api/generated/services.cjs.js");require("../../../api/generated/system.cjs.js");require("../../../api/generated/tasks.cjs.js");require("../../../api/generated/teams.cjs.js");require("../../../api/generated/thumbnails.cjs.js");require("../../../api/generated/uRIs.cjs.js");require("../../../api/generated/users.cjs.js");require("../../../api/generated/versions.cjs.js");require("../../../api/generated/workfiles.cjs.js");require("../../../api/generated/ynputCloud.cjs.js");require("../../../api/generated/grouping.cjs.js");require("../../../api/generated/views.cjs.js");require("../../../api/queries/actions/getActions.cjs.js");require("../../../api/queries/activities/getActivities.cjs.js");require("../../../api/queries/activities/updateActivities.cjs.js");require("../../../api/queries/activities/updateReaction.cjs.js");require("../../../api/queries/activities/getMentions.cjs.js");require("../../../api/queries/addons/getAddons.cjs.js");require("../../../api/queries/addons/updateAddons.cjs.js");require("../../../api/queries/attributes/getAttributes.cjs.js");require("../../../api/queries/attributes/updateAttributes.cjs.js");require("../../../api/queries/authentication/getAuthentication.cjs.js");require("../../../api/queries/cloud/cloud.cjs.js");require("../../../api/queries/entities/getEntity.cjs.js");require("../../../api/queries/entities/getEntityPanel.cjs.js");require("../../../api/queries/entities/updateEntity.cjs.js");require("../../../api/queries/entityLists/getLists.cjs.js");require("../../../api/queries/entityLists/updateLists.cjs.js");require("../../../api/queries/entityLists/getListsAttributes.cjs.js");require("../../../api/queries/entityLists/updateListsAttributes.cjs.js");require("../../../api/queries/folders/getFolders.cjs.js");require("../../../api/queries/grouping/getGrouping.cjs.js");const M=require("../../../api/queries/links/updateLinks.cjs.js");require("../../../api/queries/links/getLinks.cjs.js");require("../../../api/queries/links/getEntityLinks.cjs.js");require("../../../api/queries/overview/getOverview.cjs.js");require("../../../api/queries/overview/updateOverview.cjs.js");require("../../../api/queries/permissions/getPermissions.cjs.js");require("../../../api/queries/products/createProduct.cjs.js");require("../../../api/queries/project/getProject.cjs.js");require("../../../api/queries/project/updateProject.cjs.js");require("../../../api/queries/review/getReview.cjs.js");require("../../../api/queries/review/updateReview.cjs.js");require("../../../api/queries/share/share.cjs.js");require("../../../api/queries/system/getSystem.cjs.js");require("../../../api/queries/userDashboard/getUserDashboard.cjs.js");require("../../../api/queries/users/getUsers.cjs.js");require("../../../api/queries/users/updateUsers.cjs.js");require("../../../api/queries/versions/updateVersions.cjs.js");require("../../../api/queries/views/getViews.cjs.js");require("../../../api/queries/views/updateViews.cjs.js");require("../../../api/queries/watchers/getWatchers.cjs.js");const o=require("../../../components/LinksManager/utils/linkUpdates.cjs.js"),x=require("../context/ProjectTableContext.cjs.js");require("lodash");const A=require("react-toastify"),b=require("../../../util/getEntityId.cjs.js");require("../../../util/pubsub.cjs.js");require("../../ContextMenu/ContextMenuContext.cjs.js");require("../../../../../_virtual/jsx-runtime.cjs.js");require("@ynput/ayon-react-components");;/* empty css */require("clsx");require("react-dom");require("../../Feed/context/FeedContext.cjs.js");require("../../Feed/components/Tooltips/UserTooltip/UserTooltip.styled.cjs.js");require("../../Feed/components/Tooltips/EntityTooltip/EntityTooltip.styled.cjs.js");require("../../Feed/components/FileUploadPreview/FileUploadPreview.styled.cjs.js");require("../../Feed/components/FileUploadPreview/Mimes/TextMime.cjs.js");require("react-markdown");require("remark-emoji");require("remark-gfm");require("remark-directive");require("remark-directive-rehype");require("../../Feed/components/CommentInput/CommentInput.cjs.js");require("../../Feed/components/ReactionContainer/Reactions.styled.cjs.js");require("../../Feed/components/FilesGrid/FilesGrid.styled.cjs.js");require("../../Feed/components/FileUploadCard/FileUploadCard.styled.cjs.js");require("../../../context/RemoteModulesContext.cjs.js");require("../../../context/DetailsPanelContext.cjs.js");require("../../../context/ThumbnailUploaderContext.cjs.js");require("../../../context/SettingsPanelContext.cjs.js");require("../../../context/pip/PiPProvider.cjs.js");require("../../../context/pip/PiPWrapper.cjs.js");require("../../../context/AddonProjectContext.cjs.js");require("../../../context/AddonContext.cjs.js");require("../../../context/PowerpackContext.cjs.js");require("../../../context/MoveEntityContext.cjs.js");require("../../Feed/components/CommentInput/quillToMarkdown.cjs.js");require("../../Feed/components/ActivityComment/ActivityComment.styled.cjs.js");require("../../Feed/components/ActivityCheckbox/ActivityCheckbox.styled.cjs.js");require("../../Feed/components/ActivityReference/ActivityReference.styled.cjs.js");require("react-router-dom");require("../../Feed/components/ActivityStatus/ActivityStatus.cjs.js");require("../../Feed/components/ActivityHeader/ActivityHeader.styled.cjs.js");require("../../Feed/components/ActivityDate.cjs.js");require("../../Feed/components/ActivityStatusChange/ActivityStatusChange.styled.cjs.js");require("../../Feed/components/ActivityAssigneeChange/ActivityAssigneeChange.styled.cjs.js");require("../../Feed/components/ActivityVersions/ActivityVersions.styled.cjs.js");require("../../Feed/components/ActivityGroup/ActivityGroup.styled.cjs.js");require("../../Feed/Feed.styled.cjs.js");require("date-fns");require("../../../components/EmptyPlaceholder/EmptyPlaceholder.cjs.js");require("../../../components/EmptyPlaceholder/EmptyPlaceholderFlex.styled.cjs.js");require("../ProjectTreeTable.cjs.js");const R=require("../context/CellEditingContext.cjs.js");require("@tanstack/react-table");require("../widgets/CollapsedWidget.cjs.js");require("../widgets/DateWidget.cjs.js");require("../widgets/EnumWidget.cjs.js");require("../widgets/TextWidget.cjs.js");require("../widgets/BooleanWidget.cjs.js");require("../widgets/CellWidget.cjs.js");require("../widgets/EntityNameWidget.cjs.js");require("../widgets/GroupHeaderWidget.cjs.js");require("../widgets/ThumbnailWidget.cjs.js");require("../../../components/ThumbnailSimple/ThumbnailSimple.cjs.js");require("@dnd-kit/core");require("@dnd-kit/sortable");require("../../../components/ReviewablesList/ReviewablesList.styled.cjs.js");require("../../../components/ReviewablesList/ReviewablesUpload.styled.cjs.js");require("axios");require("../../../components/ReviewableCard/ReviewableCard.cjs.js");require("../../../components/ReviewableProgressCard/ReviewableProgressCard.styled.cjs.js");require("../../../components/FileThumbnail/FileThumbnail.cjs.js");require("../../../components/Thumbnail/Thumbnail.styled.cjs.js");require("../../../components/Thumbnail/StackedThumbnails.cjs.js");require("../../../components/EntityPanelUploader/EntityPanelUploader.styled.cjs.js");require("../../../components/SimpleFormDialog/SimpleFormDialog.cjs.js");require("../../../components/EntityPath/EntityPath.styled.cjs.js");require("../../../components/EntityPath/SegmentProvider.cjs.js");require("../../../components/DetailsPanelAttributes/DetailsPanelAttributesEditor.cjs.js");require("../../../../../_virtual/runtime.cjs.js");require("../../../../../_virtual/semver.cjs.js");require("react-redux");require("custom-protocol-check");require("../../../components/Watchers/Watchers.cjs.js");require("../../../components/ProjectTableSettings/ProjectTableSettings.cjs.js");require("../../../components/Powerpack/PowerpackButton.cjs.js");require("../../../components/Powerpack/PricingLink.cjs.js");require("../../../components/Powerpack/PowerpackDialog.styled.cjs.js");require("../../../components/Powerpack/CTAButton.cjs.js");require("../../../components/SettingsPanel/SettingsPanel.cjs.js");require("../../../components/SettingsPanel/SettingsPanelItemTemplate.cjs.js");require("../../../components/AttributeEditor/components/MinMaxField.cjs.js");require("../../../components/EnumEditor/EnumEditor.styled.cjs.js");require("../../../components/SearchFilter/filterDates.cjs.js");require("../../../components/Badge/Badge.cjs.js");require("../../../components/VersionUploader/components/UploadVersionDialog.cjs.js");require("../../../components/VersionUploader/context/VersionUploadContext.cjs.js");require("../../../components/Feedback/FeedbackContext.cjs.js");require("../../../components/Feedback/SupportBubble.cjs.js");require("../../../components/Chips/Chips.cjs.js");require("../../../components/LinksManager/LinksManager.styled.cjs.js");require("../../EntityPickerDialog/EntityPickerDialog.cjs.js");require("../../../components/LinksManager/LinksManagerDialog.cjs.js");require("../context/DetailsPanelEntityContext.cjs.js");require("../context/SelectedRowsContext.cjs.js");require("../ProjectTreeTable.styled.cjs.js");require("../components/SelectionCell.cjs.js");require("../components/RowSelectionHeader.cjs.js");require("../context/SelectionCellsContext.cjs.js");require("../widgets/LoadMoreWidget.cjs.js");require("../context/ProjectTableQueriesContext.cjs.js");require("../context/ClipboardContext.cjs.js");require("../context/ColumnSettingsContext.cjs.js");require("../components/GroupSettingsFallback.cjs.js");require("../context/ProjectDataContext.cjs.js");require("../components/HeaderActionButton.cjs.js");require("../components/ColumnHeaderMenu.cjs.js");require("../../DetailsPanel/DetailsPanel.styled.cjs.js");require("../../DetailsPanel/FeedFilters/FeedFilters.styled.cjs.js");require("../../DetailsPanel/DetailsPanelHeader/DetailsPanelHeader.styled.cjs.js");require("../../../components/PlayableIcon/PlayableIcon.cjs.js");require("../../DetailsPanel/DetailsPanelFiles/DetailsPanelFiles.cjs.js");require("../../DetailsPanel/DetailsPanelSlideOut/DetailsPanelSlideOut.styled.cjs.js");require("../../DetailsPanel/DetailsPanelFloating/DetailsPanelFloating.styled.cjs.js");require("../../Actions/Actions.styled.cjs.js");require("../../Actions/ActionsDropdown/ActionsDropdown.cjs.js");require("../../Actions/ActionIcon.cjs.js");require("../../Views/context/ViewsContext.cjs.js");require("../../Views/Views.styled.cjs.js");require("../../Views/ViewsMenuContainer/ViewsMenuContainer.cjs.js");require("../../Views/ViewsMenu/ViewsMenu.cjs.js");require("uuid");const S=$=>{const{getEntityById:L,projectName:v}=x.useProjectTableContext(),s=v,{history:I}=R.useCellEditing(),[f]=M.useDeleteEntityLinkMutation(),[g]=M.useCreateEntityLinkMutation();return{pasteTableLinks:N.useCallback(async P=>{if(!s||!P.length)return;const c=new Map;for(const i of P){const u=`${i.sourceEntityId}-${i.linkType}-${i.direction}`;c.has(u)||c.set(u,[]),c.get(u).push(i)}const k=[],a=[],d=[];for(const[,i]of c){const{sourceEntityId:u}=i[0],n=new Set;if(i.forEach(q=>q.targetEntityIds.forEach(e=>n.add(e))),n.has(u)){A.toast.error("You can't link an entity to itself");return}}for(const[i,u]of c){const n=u[0],{sourceEntityId:q,sourceEntityType:e,linkType:y,direction:p,targetEntityType:h,operation:j}=n,m=new Set;u.forEach(r=>{r.targetEntityIds.forEach(t=>m.add(t))});const l=[],T=[],C=L(q);if(!C){console.warn(`Entity not found: ${q}`);continue}const E=C.links;if(j==="replace"){if(Array.isArray(E))for(const r of E)r.entityType===h&&r.direction===p&&r.linkType===y.split("|")[0]&&T.push({id:r.id,target:{entityId:r.node.id,entityType:r.entityType},source:{entityId:q,entityType:e},linkType:y,direction:p,projectName:s});for(const r of m){const t=b.getEntityId();l.push({targetEntityId:r,linkId:t,sourceEntityId:q,sourceEntityType:e,targetEntityType:h,linkType:y,direction:p,projectName:s})}}else if(j==="merge"){const r=new Set;Array.isArray(E)&&E.forEach(t=>{t.entityType===h&&t.direction===p&&t.linkType===y&&r.add(t.node.id)}),console.log(r);for(const t of m)if(!r.has(t)){const w=b.getEntityId();l.push({targetEntityId:t,linkId:w,sourceEntityId:q,sourceEntityType:e,targetEntityType:h,linkType:y,direction:p,projectName:s})}}T.length>0&&(k.push(o.removeMultipleLinks(T,f)),d.push(...T)),l.length>0&&(k.push(o.addMultipleLinks(l,g)),a.push(...l))}try{if(await Promise.all(k),I&&(a.length>0||d.length>0)){const i=a.map(e=>({id:e.linkId,projectName:e.projectName,linkType:e.linkType,direction:e.direction,target:{entityId:e.targetEntityId,entityType:e.targetEntityType},source:{entityId:e.sourceEntityId,entityType:e.sourceEntityType}})),u=d.map(e=>({targetEntityId:e.target.entityId,linkId:e.id,sourceEntityId:e.source.entityId,sourceEntityType:e.source.entityType,targetEntityType:e.target.entityType,linkType:e.linkType,direction:e.direction,projectName:e.projectName})),n=()=>{const e=[];i.length&&e.push(o.removeMultipleLinks(i,f)),u.length&&e.push(o.addMultipleLinks(u,g)),e.length&&Promise.all(e).catch(()=>{})},q=()=>{const e=[];d.length&&e.push(o.removeMultipleLinks(d,f)),a.length&&e.push(o.addMultipleLinks(a,g)),e.length&&Promise.all(e).catch(()=>{})};I.pushHistory([n],[q])}}catch(i){throw i}},[s,L,f,g,I])}};module.exports=S;
|
|
1
|
+
"use strict";const N=require("react");require("../../../api/base/client.cjs.js");require("../../../api/generated/graphql.cjs.js");require("../../../api/generated/graphqlLinks.cjs.js");require("../../../api/generated/access.cjs.js");require("../../../api/generated/actions.cjs.js");require("../../../api/generated/activityFeed.cjs.js");require("../../../api/generated/addons.cjs.js");require("../../../api/generated/anatomy.cjs.js");require("../../../api/generated/attributes.cjs.js");require("../../../api/generated/authentication.cjs.js");require("../../../api/generated/bundles.cjs.js");require("../../../api/generated/configuration.cjs.js");require("../../../api/generated/desktop.cjs.js");require("../../../api/generated/entityLists.cjs.js");require("../../../api/generated/events.cjs.js");require("../../../api/generated/files.cjs.js");require("../../../api/generated/folders.cjs.js");require("../../../api/generated/inbox.cjs.js");require("../../../api/generated/links.cjs.js");require("../../../api/generated/market.cjs.js");require("../../../api/generated/onboarding.cjs.js");require("../../../api/generated/operations.cjs.js");require("../../../api/generated/products.cjs.js");require("../../../api/generated/projectDashboard.cjs.js");require("../../../api/generated/projects.cjs.js");require("../../../api/generated/reviewables.cjs.js");require("../../../api/generated/services.cjs.js");require("../../../api/generated/system.cjs.js");require("../../../api/generated/tasks.cjs.js");require("../../../api/generated/teams.cjs.js");require("../../../api/generated/thumbnails.cjs.js");require("../../../api/generated/uRIs.cjs.js");require("../../../api/generated/users.cjs.js");require("../../../api/generated/versions.cjs.js");require("../../../api/generated/workfiles.cjs.js");require("../../../api/generated/ynputCloud.cjs.js");require("../../../api/generated/grouping.cjs.js");require("../../../api/generated/views.cjs.js");require("../../../api/queries/actions/getActions.cjs.js");require("../../../api/queries/activities/getActivities.cjs.js");require("../../../api/queries/activities/updateActivities.cjs.js");require("../../../api/queries/activities/updateReaction.cjs.js");require("../../../api/queries/activities/getMentions.cjs.js");require("../../../api/queries/addons/getAddons.cjs.js");require("../../../api/queries/addons/updateAddons.cjs.js");require("../../../api/queries/attributes/getAttributes.cjs.js");require("../../../api/queries/attributes/updateAttributes.cjs.js");require("../../../api/queries/authentication/getAuthentication.cjs.js");require("../../../api/queries/cloud/cloud.cjs.js");require("../../../api/queries/entities/getEntity.cjs.js");require("../../../api/queries/entities/getEntityPanel.cjs.js");require("../../../api/queries/entities/updateEntity.cjs.js");require("../../../api/queries/entityLists/getLists.cjs.js");require("../../../api/queries/entityLists/updateLists.cjs.js");require("../../../api/queries/entityLists/getListsAttributes.cjs.js");require("../../../api/queries/entityLists/updateListsAttributes.cjs.js");require("../../../api/queries/folders/getFolders.cjs.js");require("../../../api/queries/grouping/getGrouping.cjs.js");const M=require("../../../api/queries/links/updateLinks.cjs.js");require("../../../api/queries/links/getLinks.cjs.js");require("../../../api/queries/links/getEntityLinks.cjs.js");require("../../../api/queries/overview/getOverview.cjs.js");require("../../../api/queries/overview/updateOverview.cjs.js");require("../../../api/queries/permissions/getPermissions.cjs.js");require("../../../api/queries/products/createProduct.cjs.js");require("../../../api/queries/project/getProject.cjs.js");require("../../../api/queries/project/updateProject.cjs.js");require("../../../api/queries/review/getReview.cjs.js");require("../../../api/queries/review/updateReview.cjs.js");require("../../../api/queries/share/share.cjs.js");require("../../../api/queries/system/getSystem.cjs.js");require("../../../api/queries/userDashboard/getUserDashboard.cjs.js");require("../../../api/queries/users/getUsers.cjs.js");require("../../../api/queries/users/updateUsers.cjs.js");require("../../../api/queries/versions/updateVersions.cjs.js");require("../../../api/queries/views/getViews.cjs.js");require("../../../api/queries/views/updateViews.cjs.js");require("../../../api/queries/watchers/getWatchers.cjs.js");const o=require("../../../components/LinksManager/utils/linkUpdates.cjs.js"),x=require("../context/ProjectTableContext.cjs.js");require("lodash");const A=require("react-toastify"),b=require("../../../util/getEntityId.cjs.js");require("../../../util/pubsub.cjs.js");require("../../ContextMenu/ContextMenuContext.cjs.js");require("../../../../../_virtual/jsx-runtime.cjs.js");require("@ynput/ayon-react-components");;/* empty css */require("clsx");require("react-dom");require("../../Feed/context/FeedContext.cjs.js");require("../../Feed/components/Tooltips/UserTooltip/UserTooltip.styled.cjs.js");require("../../Feed/components/Tooltips/EntityTooltip/EntityTooltip.styled.cjs.js");require("../../Feed/components/FileUploadPreview/FileUploadPreview.styled.cjs.js");require("../../Feed/components/FileUploadPreview/Mimes/TextMime.cjs.js");require("react-markdown");require("remark-emoji");require("remark-gfm");require("remark-directive");require("remark-directive-rehype");require("../../Feed/components/CommentInput/CommentInput.cjs.js");require("../../Feed/components/ReactionContainer/Reactions.styled.cjs.js");require("../../Feed/components/FilesGrid/FilesGrid.styled.cjs.js");require("../../Feed/components/FileUploadCard/FileUploadCard.styled.cjs.js");require("../../../context/RemoteModulesContext.cjs.js");require("../../../context/DetailsPanelContext.cjs.js");require("../../../context/ThumbnailUploaderContext.cjs.js");require("../../../context/SettingsPanelContext.cjs.js");require("../../../context/pip/PiPProvider.cjs.js");require("../../../context/pip/PiPWrapper.cjs.js");require("../../../context/AddonProjectContext.cjs.js");require("../../../context/AddonContext.cjs.js");require("../../../context/PowerpackContext.cjs.js");require("../../../context/MoveEntityContext.cjs.js");require("../../Feed/components/CommentInput/quillToMarkdown.cjs.js");require("../../Feed/components/ActivityComment/ActivityComment.styled.cjs.js");require("../../Feed/components/ActivityCheckbox/ActivityCheckbox.styled.cjs.js");require("../../Feed/components/ActivityReference/ActivityReference.styled.cjs.js");require("react-router-dom");require("../../Feed/components/ActivityStatus/ActivityStatus.cjs.js");require("../../Feed/components/ActivityHeader/ActivityHeader.styled.cjs.js");require("../../Feed/components/ActivityDate.cjs.js");require("../../Feed/components/ActivityStatusChange/ActivityStatusChange.styled.cjs.js");require("../../Feed/components/ActivityAssigneeChange/ActivityAssigneeChange.styled.cjs.js");require("../../Feed/components/ActivityVersions/ActivityVersions.styled.cjs.js");require("../../Feed/components/ActivityGroup/ActivityGroup.styled.cjs.js");require("../../Feed/Feed.styled.cjs.js");require("date-fns");require("../../../components/EmptyPlaceholder/EmptyPlaceholder.cjs.js");require("../../../components/EmptyPlaceholder/EmptyPlaceholderFlex.styled.cjs.js");require("../ProjectTreeTable.cjs.js");const R=require("../context/CellEditingContext.cjs.js");require("@tanstack/react-table");require("../widgets/CollapsedWidget.cjs.js");require("../widgets/DateWidget.cjs.js");require("../widgets/EnumWidget.cjs.js");require("../widgets/TextWidget.cjs.js");require("../widgets/BooleanWidget.cjs.js");require("../widgets/CellWidget.cjs.js");require("../widgets/EntityNameWidget.cjs.js");require("../widgets/GroupHeaderWidget.cjs.js");require("../widgets/ThumbnailWidget.cjs.js");require("../../../components/ThumbnailSimple/ThumbnailSimple.cjs.js");require("@dnd-kit/core");require("@dnd-kit/sortable");require("../../../components/ReviewablesList/ReviewablesList.styled.cjs.js");require("../../../components/ReviewablesList/ReviewablesUpload.styled.cjs.js");require("axios");require("../../../components/ReviewableCard/ReviewableCard.cjs.js");require("../../../components/ReviewableProgressCard/ReviewableProgressCard.styled.cjs.js");require("../../../components/FileThumbnail/FileThumbnail.cjs.js");require("../../../components/Thumbnail/Thumbnail.styled.cjs.js");require("../../../components/Thumbnail/StackedThumbnails.cjs.js");require("../../../components/EntityPanelUploader/EntityPanelUploader.styled.cjs.js");require("../../../components/SimpleFormDialog/SimpleFormDialog.cjs.js");require("../../../components/EntityPath/EntityPath.styled.cjs.js");require("../../../components/EntityPath/SegmentProvider.cjs.js");require("../../../components/DetailsPanelAttributes/DetailsPanelAttributesEditor.cjs.js");require("../../../../../_virtual/runtime.cjs.js");require("../../../../../_virtual/semver.cjs.js");require("react-redux");require("custom-protocol-check");require("../../../components/Watchers/Watchers.cjs.js");require("../../../components/ProjectTableSettings/ProjectTableSettings.cjs.js");require("../../../components/Powerpack/PowerpackButton.cjs.js");require("../../../components/Powerpack/PricingLink.cjs.js");require("../../../components/Powerpack/PowerpackDialog.styled.cjs.js");require("../../../components/Powerpack/CTAButton.cjs.js");require("../../../components/Powerpack/RequiredPowerpackVersion.cjs.js");require("../../../components/SettingsPanel/SettingsPanel.cjs.js");require("../../../components/SettingsPanel/SettingsPanelItemTemplate.cjs.js");require("../../../components/AttributeEditor/components/MinMaxField.cjs.js");require("../../../components/EnumEditor/EnumEditor.styled.cjs.js");require("../../../components/SearchFilter/filterDates.cjs.js");require("../../../components/Badge/Badge.cjs.js");require("../../../components/VersionUploader/components/UploadVersionDialog.cjs.js");require("../../../components/VersionUploader/context/VersionUploadContext.cjs.js");require("../../../components/Feedback/FeedbackContext.cjs.js");require("../../../components/Feedback/SupportBubble.cjs.js");require("../../../components/Chips/Chips.cjs.js");require("../../../components/LinksManager/LinksManager.styled.cjs.js");require("../../EntityPickerDialog/EntityPickerDialog.cjs.js");require("../../../components/DetailsMetaData/DetailsMetaData.cjs.js");require("../../../components/AccessUser/AccessUser.cjs.js");require("../../../components/LinksManager/LinksManagerDialog.cjs.js");require("../context/DetailsPanelEntityContext.cjs.js");require("../context/SelectedRowsContext.cjs.js");require("../ProjectTreeTable.styled.cjs.js");require("../components/SelectionCell.cjs.js");require("../components/RowSelectionHeader.cjs.js");require("../context/SelectionCellsContext.cjs.js");require("../widgets/LoadMoreWidget.cjs.js");require("../context/ProjectTableQueriesContext.cjs.js");require("../context/ClipboardContext.cjs.js");require("../context/ColumnSettingsContext.cjs.js");require("../components/GroupSettingsFallback.cjs.js");require("../context/ProjectDataContext.cjs.js");require("../components/HeaderActionButton.cjs.js");require("../components/ColumnHeaderMenu.cjs.js");require("../../DetailsPanel/DetailsPanel.styled.cjs.js");require("../../DetailsPanel/FeedFilters/FeedFilters.styled.cjs.js");require("../../DetailsPanel/DetailsPanelHeader/DetailsPanelHeader.styled.cjs.js");require("../../../components/PlayableIcon/PlayableIcon.cjs.js");require("../../DetailsPanel/DetailsPanelFiles/DetailsPanelFiles.cjs.js");require("../../DetailsPanel/DetailsPanelSlideOut/DetailsPanelSlideOut.styled.cjs.js");require("../../DetailsPanel/DetailsPanelFloating/DetailsPanelFloating.styled.cjs.js");require("../../Actions/Actions.styled.cjs.js");require("../../Actions/ActionsDropdown/ActionsDropdown.cjs.js");require("../../Actions/ActionIcon.cjs.js");require("../../Views/context/ViewsContext.cjs.js");require("../../Views/Views.styled.cjs.js");require("../../Views/ViewsMenuContainer/ViewsMenuContainer.cjs.js");require("../../Views/ViewsMenu/ViewsMenu.cjs.js");require("uuid");const S=$=>{const{getEntityById:L,projectName:v}=x.useProjectTableContext(),s=v,{history:I}=R.useCellEditing(),[f]=M.useDeleteEntityLinkMutation(),[g]=M.useCreateEntityLinkMutation();return{pasteTableLinks:N.useCallback(async P=>{if(!s||!P.length)return;const c=new Map;for(const i of P){const u=`${i.sourceEntityId}-${i.linkType}-${i.direction}`;c.has(u)||c.set(u,[]),c.get(u).push(i)}const k=[],a=[],d=[];for(const[,i]of c){const{sourceEntityId:u}=i[0],n=new Set;if(i.forEach(q=>q.targetEntityIds.forEach(e=>n.add(e))),n.has(u)){A.toast.error("You can't link an entity to itself");return}}for(const[i,u]of c){const n=u[0],{sourceEntityId:q,sourceEntityType:e,linkType:y,direction:p,targetEntityType:h,operation:j}=n,m=new Set;u.forEach(r=>{r.targetEntityIds.forEach(t=>m.add(t))});const l=[],T=[],C=L(q);if(!C){console.warn(`Entity not found: ${q}`);continue}const E=C.links;if(j==="replace"){if(Array.isArray(E))for(const r of E)r.entityType===h&&r.direction===p&&r.linkType===y.split("|")[0]&&T.push({id:r.id,target:{entityId:r.node.id,entityType:r.entityType},source:{entityId:q,entityType:e},linkType:y,direction:p,projectName:s});for(const r of m){const t=b.getEntityId();l.push({targetEntityId:r,linkId:t,sourceEntityId:q,sourceEntityType:e,targetEntityType:h,linkType:y,direction:p,projectName:s})}}else if(j==="merge"){const r=new Set;Array.isArray(E)&&E.forEach(t=>{t.entityType===h&&t.direction===p&&t.linkType===y&&r.add(t.node.id)}),console.log(r);for(const t of m)if(!r.has(t)){const w=b.getEntityId();l.push({targetEntityId:t,linkId:w,sourceEntityId:q,sourceEntityType:e,targetEntityType:h,linkType:y,direction:p,projectName:s})}}T.length>0&&(k.push(o.removeMultipleLinks(T,f)),d.push(...T)),l.length>0&&(k.push(o.addMultipleLinks(l,g)),a.push(...l))}try{if(await Promise.all(k),I&&(a.length>0||d.length>0)){const i=a.map(e=>({id:e.linkId,projectName:e.projectName,linkType:e.linkType,direction:e.direction,target:{entityId:e.targetEntityId,entityType:e.targetEntityType},source:{entityId:e.sourceEntityId,entityType:e.sourceEntityType}})),u=d.map(e=>({targetEntityId:e.target.entityId,linkId:e.id,sourceEntityId:e.source.entityId,sourceEntityType:e.source.entityType,targetEntityType:e.target.entityType,linkType:e.linkType,direction:e.direction,projectName:e.projectName})),n=()=>{const e=[];i.length&&e.push(o.removeMultipleLinks(i,f)),u.length&&e.push(o.addMultipleLinks(u,g)),e.length&&Promise.all(e).catch(()=>{})},q=()=>{const e=[];d.length&&e.push(o.removeMultipleLinks(d,f)),a.length&&e.push(o.addMultipleLinks(a,g)),e.length&&Promise.all(e).catch(()=>{})};I.pushHistory([n],[q])}}catch(i){throw i}},[s,L,f,g,I])}};module.exports=S;
|
|
2
2
|
//# sourceMappingURL=usePasteLinks.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePasteLinks.cjs.js","sources":["../../../../../../src/containers/ProjectTreeTable/hooks/usePasteLinks.ts"],"sourcesContent":["import { useCallback } from 'react'\nimport { useCreateEntityLinkMutation, useDeleteEntityLinkMutation } from '@shared/api'\nimport {\n addMultipleLinks,\n removeMultipleLinks,\n LinkToAdd,\n LinkToRemove,\n} from '@shared/components/LinksManager/utils/linkUpdates'\nimport { useProjectTableContext } from '../context/ProjectTableContext'\nimport { getEntityId } from '@shared/util'\nimport { PasteMethod } from '../context'\nimport { useCellEditing } from '@shared/containers'\nimport { toast } from 'react-toastify'\n\n/**\n * Represents a link update operation for table links\n */\nexport type LinkUpdate = {\n /** Row ID in the table */\n rowId: string\n /** ID of the source entity (the entity that will have links) */\n sourceEntityId: string\n /** Type of the source entity (e.g., 'folder', 'task') */\n sourceEntityType: string\n /** Type of link (e.g., 'workflow', 'dependency') */\n linkType: string\n /** Direction of the link from source entity perspective */\n direction: 'in' | 'out'\n /** Type of the target entities that will be linked */\n targetEntityType: string\n /**\n * Operation type:\n * - 'replace': Remove all existing links of this type and add new ones\n * - 'merge': Keep existing links and add new ones (skip duplicates)\n */\n operation: PasteMethod\n /** Array of target entity IDs to link to */\n targetEntityIds: string[]\n}\n\nexport type PasteTableLinks = (linkUpdates: LinkUpdate[]) => Promise<void>\n\ninterface usePasteLinksProps {\n projectName?: string\n}\n\nconst usePasteLinks = (props?: usePasteLinksProps) => {\n const { getEntityById, projectName: contextProjectName } = useProjectTableContext()\n const projectName = props?.projectName || contextProjectName\n const { history } = useCellEditing()\n\n // Add mutation hooks for link operations\n const [deleteLink] = useDeleteEntityLinkMutation()\n const [addLink] = useCreateEntityLinkMutation()\n\n // Handle link updates using the utility functions\n const pasteTableLinks = useCallback<PasteTableLinks>(\n async (linkUpdates: LinkUpdate[]) => {\n if (!projectName || !linkUpdates.length) return\n\n // Group operations by entity and link type for processing\n const operationsToProcess = new Map<string, LinkUpdate[]>()\n\n for (const update of linkUpdates) {\n const key = `${update.sourceEntityId}-${update.linkType}-${update.direction}`\n if (!operationsToProcess.has(key)) {\n operationsToProcess.set(key, [])\n }\n operationsToProcess.get(key)!.push(update)\n }\n\n const updatePromises: Promise<void>[] = []\n // Collect all adds/removes across all operations to build a single history entry\n const addedInPaste: LinkToAdd[] = []\n const removedInPaste: LinkToRemove[] = []\n\n // Pre-flight validation: detect any self-referential links across the whole paste\n for (const [, updates] of operationsToProcess) {\n const { sourceEntityId } = updates[0]\n const targets = new Set<string>()\n updates.forEach((u) => u.targetEntityIds.forEach((id) => targets.add(id)))\n if (targets.has(sourceEntityId)) {\n toast.error(\"You can't link an entity to itself\")\n return\n }\n }\n // Process each unique entity-linkType-direction combination\n for (const [key, updates] of operationsToProcess) {\n const firstUpdate = updates[0]\n const {\n sourceEntityId,\n sourceEntityType,\n linkType,\n direction,\n targetEntityType,\n operation,\n } = firstUpdate\n\n // Collect all target entity IDs from all updates for this combination\n const allTargetEntityIds = new Set<string>()\n updates.forEach((update) => {\n update.targetEntityIds.forEach((id) => allTargetEntityIds.add(id))\n })\n\n const linksToAdd: LinkToAdd[] = []\n const linksToRemove: LinkToRemove[] = []\n\n // Get current links for this entity and link type\n const entityData = getEntityById(sourceEntityId)\n if (!entityData) {\n console.warn(`Entity not found: ${sourceEntityId}`)\n continue\n }\n\n // Get current links for this link type and direction\n const currentLinks = entityData.links\n\n if (operation === 'replace') {\n // Remove all current links of this (linkType + direction + targetEntityType) only.\n if (Array.isArray(currentLinks)) {\n for (const link of currentLinks) {\n if (\n link.entityType === targetEntityType &&\n link.direction === direction &&\n link.linkType === linkType.split('|')[0]\n ) {\n linksToRemove.push({\n id: link.id,\n target: {\n entityId: link.node.id,\n entityType: link.entityType,\n },\n source: { entityId: sourceEntityId, entityType: sourceEntityType },\n linkType,\n direction,\n projectName,\n })\n }\n }\n }\n\n // Add all new links\n for (const targetEntityId of allTargetEntityIds) {\n const linkId = getEntityId()\n\n linksToAdd.push({\n targetEntityId,\n linkId,\n sourceEntityId,\n sourceEntityType,\n targetEntityType,\n linkType,\n direction,\n projectName,\n })\n }\n } else if (operation === 'merge') {\n // Get existing target entity IDs for this (linkType + direction + targetEntityType)\n const existingTargetIds = new Set<string>()\n if (Array.isArray(currentLinks)) {\n currentLinks.forEach((link) => {\n if (\n link.entityType === targetEntityType &&\n link.direction === direction &&\n link.linkType === linkType\n ) {\n existingTargetIds.add(link.node.id)\n }\n })\n }\n\n console.log(existingTargetIds)\n\n // Only add links that don't already exist\n for (const targetEntityId of allTargetEntityIds) {\n if (!existingTargetIds.has(targetEntityId)) {\n const linkId = getEntityId()\n\n linksToAdd.push({\n targetEntityId,\n linkId,\n sourceEntityId,\n sourceEntityType,\n targetEntityType,\n linkType,\n direction,\n projectName,\n })\n }\n }\n }\n\n if (linksToRemove.length > 0) {\n updatePromises.push(removeMultipleLinks(linksToRemove, deleteLink))\n removedInPaste.push(...linksToRemove)\n }\n if (linksToAdd.length > 0) {\n updatePromises.push(addMultipleLinks(linksToAdd, addLink))\n addedInPaste.push(...linksToAdd)\n }\n }\n try {\n // Execute all link operations in parallel\n await Promise.all(updatePromises)\n\n // Push a single history entry that undoes BOTH: remove added links and re-add removed links\n if (history && (addedInPaste.length > 0 || removedInPaste.length > 0)) {\n // Prepare inverse operations for undo\n const addedToRemove: LinkToRemove[] = addedInPaste.map((link) => ({\n id: link.linkId,\n projectName: link.projectName,\n linkType: link.linkType,\n direction: link.direction,\n target: { entityId: link.targetEntityId, entityType: link.targetEntityType },\n source: { entityId: link.sourceEntityId, entityType: link.sourceEntityType },\n }))\n\n const removedToAdd: LinkToAdd[] = removedInPaste.map((link) => ({\n targetEntityId: link.target.entityId,\n linkId: link.id,\n sourceEntityId: link.source.entityId,\n sourceEntityType: link.source.entityType,\n targetEntityType: link.target.entityType,\n linkType: link.linkType,\n direction: link.direction,\n projectName: link.projectName,\n }))\n\n // Single callbacks to keep history atomic\n const undoCallback = () => {\n const tasks: Promise<void>[] = []\n if (addedToRemove.length) tasks.push(removeMultipleLinks(addedToRemove, deleteLink))\n if (removedToAdd.length) tasks.push(addMultipleLinks(removedToAdd, addLink))\n if (tasks.length) Promise.all(tasks).catch(() => {})\n }\n\n const redoCallback = () => {\n const tasks: Promise<void>[] = []\n if (removedInPaste.length) tasks.push(removeMultipleLinks(removedInPaste, deleteLink))\n if (addedInPaste.length) tasks.push(addMultipleLinks(addedInPaste, addLink))\n if (tasks.length) Promise.all(tasks).catch(() => {})\n }\n\n history.pushHistory([undoCallback], [redoCallback])\n }\n } catch (error) {\n throw error\n }\n },\n [projectName, getEntityById, deleteLink, addLink, history],\n )\n\n return { pasteTableLinks }\n}\n\nexport default usePasteLinks\n"],"names":["usePasteLinks","props","getEntityById","contextProjectName","useProjectTableContext","projectName","history","useCellEditing","deleteLink","useDeleteEntityLinkMutation","addLink","useCreateEntityLinkMutation","useCallback","linkUpdates","operationsToProcess","update","key","updatePromises","addedInPaste","removedInPaste","updates","sourceEntityId","targets","u","id","toast","firstUpdate","sourceEntityType","linkType","direction","targetEntityType","operation","allTargetEntityIds","linksToAdd","linksToRemove","entityData","currentLinks","link","targetEntityId","linkId","getEntityId","existingTargetIds","removeMultipleLinks","addMultipleLinks","addedToRemove","removedToAdd","undoCallback","tasks","redoCallback","error"],"mappings":"mpXA8CM,MAAAA,EAAiBC,GAA+B,CACpD,KAAM,CAAE,cAAAC,EAAe,YAAaC,CAAA,EAAuBC,EAAAA,uBAAuB,EAC5EC,EAAoCF,EACpC,CAAE,QAAAG,CAAQ,EAAIC,iBAAe,EAG7B,CAACC,CAAU,EAAIC,8BAA4B,EAC3C,CAACC,CAAO,EAAIC,8BAA4B,EAuM9C,MAAO,CAAE,gBApMeC,EAAA,YACtB,MAAOC,GAA8B,CACnC,GAAI,CAACR,GAAe,CAACQ,EAAY,OAAQ,OAGnC,MAAAC,MAA0B,IAEhC,UAAWC,KAAUF,EAAa,CAC1B,MAAAG,EAAM,GAAGD,EAAO,cAAc,IAAIA,EAAO,QAAQ,IAAIA,EAAO,SAAS,GACtED,EAAoB,IAAIE,CAAG,GACVF,EAAA,IAAIE,EAAK,EAAE,EAEjCF,EAAoB,IAAIE,CAAG,EAAG,KAAKD,CAAM,CAAA,CAG3C,MAAME,EAAkC,CAAC,EAEnCC,EAA4B,CAAC,EAC7BC,EAAiC,CAAC,EAGxC,SAAW,CAAA,CAAGC,CAAO,IAAKN,EAAqB,CAC7C,KAAM,CAAE,eAAAO,CAAA,EAAmBD,EAAQ,CAAC,EAC9BE,MAAc,IAEhB,GADJF,EAAQ,QAASG,GAAMA,EAAE,gBAAgB,QAASC,GAAOF,EAAQ,IAAIE,CAAE,CAAC,CAAC,EACrEF,EAAQ,IAAID,CAAc,EAAG,CAC/BI,EAAA,MAAM,MAAM,oCAAoC,EAChD,M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AAepC,CAAU,CAAC,EAC/EqC,EAAa,QAAQE,EAAM,KAAKJ,mBAAiBE,EAAcnC,CAAO,CAAC,EACvEqC,EAAM,QAAQ,QAAQ,IAAIA,CAAK,EAAE,MAAM,IAAM,CAAA,CAAE,CACrD,EAEMC,EAAe,IAAM,CACzB,MAAMD,EAAyB,CAAC,EAC5B5B,EAAe,QAAQ4B,EAAM,KAAKL,sBAAoBvB,EAAgBX,CAAU,CAAC,EACjFU,EAAa,QAAQ6B,EAAM,KAAKJ,mBAAiBzB,EAAcR,CAAO,CAAC,EACvEqC,EAAM,QAAQ,QAAQ,IAAIA,CAAK,EAAE,MAAM,IAAM,CAAA,CAAE,CACrD,EAEAzC,EAAQ,YAAY,CAACwC,CAAY,EAAG,CAACE,CAAY,CAAC,CAAA,QAE7CC,EAAO,CACR,MAAAA,CAAA,CAEV,EACA,CAAC5C,EAAaH,EAAeM,EAAYE,EAASJ,CAAO,CAC3D,CAEyB,CAC3B"}
|
|
1
|
+
{"version":3,"file":"usePasteLinks.cjs.js","sources":["../../../../../../src/containers/ProjectTreeTable/hooks/usePasteLinks.ts"],"sourcesContent":["import { useCallback } from 'react'\nimport { useCreateEntityLinkMutation, useDeleteEntityLinkMutation } from '@shared/api'\nimport {\n addMultipleLinks,\n removeMultipleLinks,\n LinkToAdd,\n LinkToRemove,\n} from '@shared/components/LinksManager/utils/linkUpdates'\nimport { useProjectTableContext } from '../context/ProjectTableContext'\nimport { getEntityId } from '@shared/util'\nimport { PasteMethod } from '../context'\nimport { useCellEditing } from '@shared/containers'\nimport { toast } from 'react-toastify'\n\n/**\n * Represents a link update operation for table links\n */\nexport type LinkUpdate = {\n /** Row ID in the table */\n rowId: string\n /** ID of the source entity (the entity that will have links) */\n sourceEntityId: string\n /** Type of the source entity (e.g., 'folder', 'task') */\n sourceEntityType: string\n /** Type of link (e.g., 'workflow', 'dependency') */\n linkType: string\n /** Direction of the link from source entity perspective */\n direction: 'in' | 'out'\n /** Type of the target entities that will be linked */\n targetEntityType: string\n /**\n * Operation type:\n * - 'replace': Remove all existing links of this type and add new ones\n * - 'merge': Keep existing links and add new ones (skip duplicates)\n */\n operation: PasteMethod\n /** Array of target entity IDs to link to */\n targetEntityIds: string[]\n}\n\nexport type PasteTableLinks = (linkUpdates: LinkUpdate[]) => Promise<void>\n\ninterface usePasteLinksProps {\n projectName?: string\n}\n\nconst usePasteLinks = (props?: usePasteLinksProps) => {\n const { getEntityById, projectName: contextProjectName } = useProjectTableContext()\n const projectName = props?.projectName || contextProjectName\n const { history } = useCellEditing()\n\n // Add mutation hooks for link operations\n const [deleteLink] = useDeleteEntityLinkMutation()\n const [addLink] = useCreateEntityLinkMutation()\n\n // Handle link updates using the utility functions\n const pasteTableLinks = useCallback<PasteTableLinks>(\n async (linkUpdates: LinkUpdate[]) => {\n if (!projectName || !linkUpdates.length) return\n\n // Group operations by entity and link type for processing\n const operationsToProcess = new Map<string, LinkUpdate[]>()\n\n for (const update of linkUpdates) {\n const key = `${update.sourceEntityId}-${update.linkType}-${update.direction}`\n if (!operationsToProcess.has(key)) {\n operationsToProcess.set(key, [])\n }\n operationsToProcess.get(key)!.push(update)\n }\n\n const updatePromises: Promise<void>[] = []\n // Collect all adds/removes across all operations to build a single history entry\n const addedInPaste: LinkToAdd[] = []\n const removedInPaste: LinkToRemove[] = []\n\n // Pre-flight validation: detect any self-referential links across the whole paste\n for (const [, updates] of operationsToProcess) {\n const { sourceEntityId } = updates[0]\n const targets = new Set<string>()\n updates.forEach((u) => u.targetEntityIds.forEach((id) => targets.add(id)))\n if (targets.has(sourceEntityId)) {\n toast.error(\"You can't link an entity to itself\")\n return\n }\n }\n // Process each unique entity-linkType-direction combination\n for (const [key, updates] of operationsToProcess) {\n const firstUpdate = updates[0]\n const {\n sourceEntityId,\n sourceEntityType,\n linkType,\n direction,\n targetEntityType,\n operation,\n } = firstUpdate\n\n // Collect all target entity IDs from all updates for this combination\n const allTargetEntityIds = new Set<string>()\n updates.forEach((update) => {\n update.targetEntityIds.forEach((id) => allTargetEntityIds.add(id))\n })\n\n const linksToAdd: LinkToAdd[] = []\n const linksToRemove: LinkToRemove[] = []\n\n // Get current links for this entity and link type\n const entityData = getEntityById(sourceEntityId)\n if (!entityData) {\n console.warn(`Entity not found: ${sourceEntityId}`)\n continue\n }\n\n // Get current links for this link type and direction\n const currentLinks = entityData.links\n\n if (operation === 'replace') {\n // Remove all current links of this (linkType + direction + targetEntityType) only.\n if (Array.isArray(currentLinks)) {\n for (const link of currentLinks) {\n if (\n link.entityType === targetEntityType &&\n link.direction === direction &&\n link.linkType === linkType.split('|')[0]\n ) {\n linksToRemove.push({\n id: link.id,\n target: {\n entityId: link.node.id,\n entityType: link.entityType,\n },\n source: { entityId: sourceEntityId, entityType: sourceEntityType },\n linkType,\n direction,\n projectName,\n })\n }\n }\n }\n\n // Add all new links\n for (const targetEntityId of allTargetEntityIds) {\n const linkId = getEntityId()\n\n linksToAdd.push({\n targetEntityId,\n linkId,\n sourceEntityId,\n sourceEntityType,\n targetEntityType,\n linkType,\n direction,\n projectName,\n })\n }\n } else if (operation === 'merge') {\n // Get existing target entity IDs for this (linkType + direction + targetEntityType)\n const existingTargetIds = new Set<string>()\n if (Array.isArray(currentLinks)) {\n currentLinks.forEach((link) => {\n if (\n link.entityType === targetEntityType &&\n link.direction === direction &&\n link.linkType === linkType\n ) {\n existingTargetIds.add(link.node.id)\n }\n })\n }\n\n console.log(existingTargetIds)\n\n // Only add links that don't already exist\n for (const targetEntityId of allTargetEntityIds) {\n if (!existingTargetIds.has(targetEntityId)) {\n const linkId = getEntityId()\n\n linksToAdd.push({\n targetEntityId,\n linkId,\n sourceEntityId,\n sourceEntityType,\n targetEntityType,\n linkType,\n direction,\n projectName,\n })\n }\n }\n }\n\n if (linksToRemove.length > 0) {\n updatePromises.push(removeMultipleLinks(linksToRemove, deleteLink))\n removedInPaste.push(...linksToRemove)\n }\n if (linksToAdd.length > 0) {\n updatePromises.push(addMultipleLinks(linksToAdd, addLink))\n addedInPaste.push(...linksToAdd)\n }\n }\n try {\n // Execute all link operations in parallel\n await Promise.all(updatePromises)\n\n // Push a single history entry that undoes BOTH: remove added links and re-add removed links\n if (history && (addedInPaste.length > 0 || removedInPaste.length > 0)) {\n // Prepare inverse operations for undo\n const addedToRemove: LinkToRemove[] = addedInPaste.map((link) => ({\n id: link.linkId,\n projectName: link.projectName,\n linkType: link.linkType,\n direction: link.direction,\n target: { entityId: link.targetEntityId, entityType: link.targetEntityType },\n source: { entityId: link.sourceEntityId, entityType: link.sourceEntityType },\n }))\n\n const removedToAdd: LinkToAdd[] = removedInPaste.map((link) => ({\n targetEntityId: link.target.entityId,\n linkId: link.id,\n sourceEntityId: link.source.entityId,\n sourceEntityType: link.source.entityType,\n targetEntityType: link.target.entityType,\n linkType: link.linkType,\n direction: link.direction,\n projectName: link.projectName,\n }))\n\n // Single callbacks to keep history atomic\n const undoCallback = () => {\n const tasks: Promise<void>[] = []\n if (addedToRemove.length) tasks.push(removeMultipleLinks(addedToRemove, deleteLink))\n if (removedToAdd.length) tasks.push(addMultipleLinks(removedToAdd, addLink))\n if (tasks.length) Promise.all(tasks).catch(() => {})\n }\n\n const redoCallback = () => {\n const tasks: Promise<void>[] = []\n if (removedInPaste.length) tasks.push(removeMultipleLinks(removedInPaste, deleteLink))\n if (addedInPaste.length) tasks.push(addMultipleLinks(addedInPaste, addLink))\n if (tasks.length) Promise.all(tasks).catch(() => {})\n }\n\n history.pushHistory([undoCallback], [redoCallback])\n }\n } catch (error) {\n throw error\n }\n },\n [projectName, getEntityById, deleteLink, addLink, history],\n )\n\n return { pasteTableLinks }\n}\n\nexport default usePasteLinks\n"],"names":["usePasteLinks","props","getEntityById","contextProjectName","useProjectTableContext","projectName","history","useCellEditing","deleteLink","useDeleteEntityLinkMutation","addLink","useCreateEntityLinkMutation","useCallback","linkUpdates","operationsToProcess","update","key","updatePromises","addedInPaste","removedInPaste","updates","sourceEntityId","targets","u","id","toast","firstUpdate","sourceEntityType","linkType","direction","targetEntityType","operation","allTargetEntityIds","linksToAdd","linksToRemove","entityData","currentLinks","link","targetEntityId","linkId","getEntityId","existingTargetIds","removeMultipleLinks","addMultipleLinks","addedToRemove","removedToAdd","undoCallback","tasks","redoCallback","error"],"mappings":"81XA8CM,MAAAA,EAAiBC,GAA+B,CACpD,KAAM,CAAE,cAAAC,EAAe,YAAaC,CAAA,EAAuBC,EAAAA,uBAAuB,EAC5EC,EAAoCF,EACpC,CAAE,QAAAG,CAAQ,EAAIC,iBAAe,EAG7B,CAACC,CAAU,EAAIC,8BAA4B,EAC3C,CAACC,CAAO,EAAIC,8BAA4B,EAuM9C,MAAO,CAAE,gBApMeC,EAAA,YACtB,MAAOC,GAA8B,CACnC,GAAI,CAACR,GAAe,CAACQ,EAAY,OAAQ,OAGnC,MAAAC,MAA0B,IAEhC,UAAWC,KAAUF,EAAa,CAC1B,MAAAG,EAAM,GAAGD,EAAO,cAAc,IAAIA,EAAO,QAAQ,IAAIA,EAAO,SAAS,GACtED,EAAoB,IAAIE,CAAG,GACVF,EAAA,IAAIE,EAAK,EAAE,EAEjCF,EAAoB,IAAIE,CAAG,EAAG,KAAKD,CAAM,CAAA,CAG3C,MAAME,EAAkC,CAAC,EAEnCC,EAA4B,CAAC,EAC7BC,EAAiC,CAAC,EAGxC,SAAW,CAAA,CAAGC,CAAO,IAAKN,EAAqB,CAC7C,KAAM,CAAE,eAAAO,CAAA,EAAmBD,EAAQ,CAAC,EAC9BE,MAAc,IAEhB,GADJF,EAAQ,QAASG,GAAMA,EAAE,gBAAgB,QAASC,GAAOF,EAAQ,IAAIE,CAAE,CAAC,CAAC,EACrEF,EAAQ,IAAID,CAAc,EAAG,CAC/BI,EAAA,MAAM,MAAM,oCAAoC,EAChD,MAAA,CACF,CAGF,SAAW,CAACT,EAAKI,CAAO,IAAKN,EAAqB,CAC1C,MAAAY,EAAcN,EAAQ,CAAC,EACvB,CACJ,eAAAC,EACA,iBAAAM,EACA,SAAAC,EACA,UAAAC,EACA,iBAAAC,EACA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EAEMC,EAAe,IAAM,CACzB,MAAMD,EAAyB,CAAC,EAC5B5B,EAAe,QAAQ4B,EAAM,KAAKL,sBAAoBvB,EAAgBX,CAAU,CAAC,EACjFU,EAAa,QAAQ6B,EAAM,KAAKJ,mBAAiBzB,EAAcR,CAAO,CAAC,EACvEqC,EAAM,QAAQ,QAAQ,IAAIA,CAAK,EAAE,MAAM,IAAM,CAAA,CAAE,CACrD,EAEAzC,EAAQ,YAAY,CAACwC,CAAY,EAAG,CAACE,CAAY,CAAC,CAAA,QAE7CC,EAAO,CACR,MAAAA,CAAA,CAEV,EACA,CAAC5C,EAAaH,EAAeM,EAAYE,EAASJ,CAAO,CAC3D,CAEyB,CAC3B"}
|
|
@@ -167,6 +167,7 @@ import "../../../components/Powerpack/PowerpackButton.es.js";
|
|
|
167
167
|
import "../../../components/Powerpack/PricingLink.es.js";
|
|
168
168
|
import "../../../components/Powerpack/PowerpackDialog.styled.es.js";
|
|
169
169
|
import "../../../components/Powerpack/CTAButton.es.js";
|
|
170
|
+
import "../../../components/Powerpack/RequiredPowerpackVersion.es.js";
|
|
170
171
|
import "../../../components/SettingsPanel/SettingsPanel.es.js";
|
|
171
172
|
import "../../../components/SettingsPanel/SettingsPanelItemTemplate.es.js";
|
|
172
173
|
import "../../../components/AttributeEditor/components/MinMaxField.es.js";
|
|
@@ -180,6 +181,8 @@ import "../../../components/Feedback/SupportBubble.es.js";
|
|
|
180
181
|
import "../../../components/Chips/Chips.es.js";
|
|
181
182
|
import "../../../components/LinksManager/LinksManager.styled.es.js";
|
|
182
183
|
import "../../EntityPickerDialog/EntityPickerDialog.es.js";
|
|
184
|
+
import "../../../components/DetailsMetaData/DetailsMetaData.es.js";
|
|
185
|
+
import "../../../components/AccessUser/AccessUser.es.js";
|
|
183
186
|
import "../../../components/LinksManager/LinksManagerDialog.es.js";
|
|
184
187
|
import "../context/DetailsPanelEntityContext.es.js";
|
|
185
188
|
import "../context/SelectedRowsContext.es.js";
|
|
@@ -210,7 +213,7 @@ import "../../Views/Views.styled.es.js";
|
|
|
210
213
|
import "../../Views/ViewsMenuContainer/ViewsMenuContainer.es.js";
|
|
211
214
|
import "../../Views/ViewsMenu/ViewsMenu.es.js";
|
|
212
215
|
import "uuid";
|
|
213
|
-
const
|
|
216
|
+
const Yr = (B) => {
|
|
214
217
|
const { getEntityById: j, projectName: C } = S(), n = C, { history: E } = R(), [u] = x(), [l] = $();
|
|
215
218
|
return { pasteTableLinks: M(
|
|
216
219
|
async (w) => {
|
|
@@ -332,6 +335,6 @@ const Rr = (B) => {
|
|
|
332
335
|
) };
|
|
333
336
|
};
|
|
334
337
|
export {
|
|
335
|
-
|
|
338
|
+
Yr as default
|
|
336
339
|
};
|
|
337
340
|
//# sourceMappingURL=usePasteLinks.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePasteLinks.es.js","sources":["../../../../../../src/containers/ProjectTreeTable/hooks/usePasteLinks.ts"],"sourcesContent":["import { useCallback } from 'react'\nimport { useCreateEntityLinkMutation, useDeleteEntityLinkMutation } from '@shared/api'\nimport {\n addMultipleLinks,\n removeMultipleLinks,\n LinkToAdd,\n LinkToRemove,\n} from '@shared/components/LinksManager/utils/linkUpdates'\nimport { useProjectTableContext } from '../context/ProjectTableContext'\nimport { getEntityId } from '@shared/util'\nimport { PasteMethod } from '../context'\nimport { useCellEditing } from '@shared/containers'\nimport { toast } from 'react-toastify'\n\n/**\n * Represents a link update operation for table links\n */\nexport type LinkUpdate = {\n /** Row ID in the table */\n rowId: string\n /** ID of the source entity (the entity that will have links) */\n sourceEntityId: string\n /** Type of the source entity (e.g., 'folder', 'task') */\n sourceEntityType: string\n /** Type of link (e.g., 'workflow', 'dependency') */\n linkType: string\n /** Direction of the link from source entity perspective */\n direction: 'in' | 'out'\n /** Type of the target entities that will be linked */\n targetEntityType: string\n /**\n * Operation type:\n * - 'replace': Remove all existing links of this type and add new ones\n * - 'merge': Keep existing links and add new ones (skip duplicates)\n */\n operation: PasteMethod\n /** Array of target entity IDs to link to */\n targetEntityIds: string[]\n}\n\nexport type PasteTableLinks = (linkUpdates: LinkUpdate[]) => Promise<void>\n\ninterface usePasteLinksProps {\n projectName?: string\n}\n\nconst usePasteLinks = (props?: usePasteLinksProps) => {\n const { getEntityById, projectName: contextProjectName } = useProjectTableContext()\n const projectName = props?.projectName || contextProjectName\n const { history } = useCellEditing()\n\n // Add mutation hooks for link operations\n const [deleteLink] = useDeleteEntityLinkMutation()\n const [addLink] = useCreateEntityLinkMutation()\n\n // Handle link updates using the utility functions\n const pasteTableLinks = useCallback<PasteTableLinks>(\n async (linkUpdates: LinkUpdate[]) => {\n if (!projectName || !linkUpdates.length) return\n\n // Group operations by entity and link type for processing\n const operationsToProcess = new Map<string, LinkUpdate[]>()\n\n for (const update of linkUpdates) {\n const key = `${update.sourceEntityId}-${update.linkType}-${update.direction}`\n if (!operationsToProcess.has(key)) {\n operationsToProcess.set(key, [])\n }\n operationsToProcess.get(key)!.push(update)\n }\n\n const updatePromises: Promise<void>[] = []\n // Collect all adds/removes across all operations to build a single history entry\n const addedInPaste: LinkToAdd[] = []\n const removedInPaste: LinkToRemove[] = []\n\n // Pre-flight validation: detect any self-referential links across the whole paste\n for (const [, updates] of operationsToProcess) {\n const { sourceEntityId } = updates[0]\n const targets = new Set<string>()\n updates.forEach((u) => u.targetEntityIds.forEach((id) => targets.add(id)))\n if (targets.has(sourceEntityId)) {\n toast.error(\"You can't link an entity to itself\")\n return\n }\n }\n // Process each unique entity-linkType-direction combination\n for (const [key, updates] of operationsToProcess) {\n const firstUpdate = updates[0]\n const {\n sourceEntityId,\n sourceEntityType,\n linkType,\n direction,\n targetEntityType,\n operation,\n } = firstUpdate\n\n // Collect all target entity IDs from all updates for this combination\n const allTargetEntityIds = new Set<string>()\n updates.forEach((update) => {\n update.targetEntityIds.forEach((id) => allTargetEntityIds.add(id))\n })\n\n const linksToAdd: LinkToAdd[] = []\n const linksToRemove: LinkToRemove[] = []\n\n // Get current links for this entity and link type\n const entityData = getEntityById(sourceEntityId)\n if (!entityData) {\n console.warn(`Entity not found: ${sourceEntityId}`)\n continue\n }\n\n // Get current links for this link type and direction\n const currentLinks = entityData.links\n\n if (operation === 'replace') {\n // Remove all current links of this (linkType + direction + targetEntityType) only.\n if (Array.isArray(currentLinks)) {\n for (const link of currentLinks) {\n if (\n link.entityType === targetEntityType &&\n link.direction === direction &&\n link.linkType === linkType.split('|')[0]\n ) {\n linksToRemove.push({\n id: link.id,\n target: {\n entityId: link.node.id,\n entityType: link.entityType,\n },\n source: { entityId: sourceEntityId, entityType: sourceEntityType },\n linkType,\n direction,\n projectName,\n })\n }\n }\n }\n\n // Add all new links\n for (const targetEntityId of allTargetEntityIds) {\n const linkId = getEntityId()\n\n linksToAdd.push({\n targetEntityId,\n linkId,\n sourceEntityId,\n sourceEntityType,\n targetEntityType,\n linkType,\n direction,\n projectName,\n })\n }\n } else if (operation === 'merge') {\n // Get existing target entity IDs for this (linkType + direction + targetEntityType)\n const existingTargetIds = new Set<string>()\n if (Array.isArray(currentLinks)) {\n currentLinks.forEach((link) => {\n if (\n link.entityType === targetEntityType &&\n link.direction === direction &&\n link.linkType === linkType\n ) {\n existingTargetIds.add(link.node.id)\n }\n })\n }\n\n console.log(existingTargetIds)\n\n // Only add links that don't already exist\n for (const targetEntityId of allTargetEntityIds) {\n if (!existingTargetIds.has(targetEntityId)) {\n const linkId = getEntityId()\n\n linksToAdd.push({\n targetEntityId,\n linkId,\n sourceEntityId,\n sourceEntityType,\n targetEntityType,\n linkType,\n direction,\n projectName,\n })\n }\n }\n }\n\n if (linksToRemove.length > 0) {\n updatePromises.push(removeMultipleLinks(linksToRemove, deleteLink))\n removedInPaste.push(...linksToRemove)\n }\n if (linksToAdd.length > 0) {\n updatePromises.push(addMultipleLinks(linksToAdd, addLink))\n addedInPaste.push(...linksToAdd)\n }\n }\n try {\n // Execute all link operations in parallel\n await Promise.all(updatePromises)\n\n // Push a single history entry that undoes BOTH: remove added links and re-add removed links\n if (history && (addedInPaste.length > 0 || removedInPaste.length > 0)) {\n // Prepare inverse operations for undo\n const addedToRemove: LinkToRemove[] = addedInPaste.map((link) => ({\n id: link.linkId,\n projectName: link.projectName,\n linkType: link.linkType,\n direction: link.direction,\n target: { entityId: link.targetEntityId, entityType: link.targetEntityType },\n source: { entityId: link.sourceEntityId, entityType: link.sourceEntityType },\n }))\n\n const removedToAdd: LinkToAdd[] = removedInPaste.map((link) => ({\n targetEntityId: link.target.entityId,\n linkId: link.id,\n sourceEntityId: link.source.entityId,\n sourceEntityType: link.source.entityType,\n targetEntityType: link.target.entityType,\n linkType: link.linkType,\n direction: link.direction,\n projectName: link.projectName,\n }))\n\n // Single callbacks to keep history atomic\n const undoCallback = () => {\n const tasks: Promise<void>[] = []\n if (addedToRemove.length) tasks.push(removeMultipleLinks(addedToRemove, deleteLink))\n if (removedToAdd.length) tasks.push(addMultipleLinks(removedToAdd, addLink))\n if (tasks.length) Promise.all(tasks).catch(() => {})\n }\n\n const redoCallback = () => {\n const tasks: Promise<void>[] = []\n if (removedInPaste.length) tasks.push(removeMultipleLinks(removedInPaste, deleteLink))\n if (addedInPaste.length) tasks.push(addMultipleLinks(addedInPaste, addLink))\n if (tasks.length) Promise.all(tasks).catch(() => {})\n }\n\n history.pushHistory([undoCallback], [redoCallback])\n }\n } catch (error) {\n throw error\n }\n },\n [projectName, getEntityById, deleteLink, addLink, history],\n )\n\n return { pasteTableLinks }\n}\n\nexport default usePasteLinks\n"],"names":["usePasteLinks","props","getEntityById","contextProjectName","useProjectTableContext","projectName","history","useCellEditing","deleteLink","useDeleteEntityLinkMutation","addLink","useCreateEntityLinkMutation","useCallback","linkUpdates","operationsToProcess","update","key","updatePromises","addedInPaste","removedInPaste","updates","sourceEntityId","targets","u","id","toast","firstUpdate","sourceEntityType","linkType","direction","targetEntityType","operation","allTargetEntityIds","linksToAdd","linksToRemove","entityData","currentLinks","link","targetEntityId","linkId","getEntityId","existingTargetIds","removeMultipleLinks","addMultipleLinks","added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jectTreeTable/hooks/usePasteLinks.ts"],"sourcesContent":["import { useCallback } from 'react'\nimport { useCreateEntityLinkMutation, useDeleteEntityLinkMutation } from '@shared/api'\nimport {\n addMultipleLinks,\n removeMultipleLinks,\n LinkToAdd,\n LinkToRemove,\n} from '@shared/components/LinksManager/utils/linkUpdates'\nimport { useProjectTableContext } from '../context/ProjectTableContext'\nimport { getEntityId } from '@shared/util'\nimport { PasteMethod } from '../context'\nimport { useCellEditing } from '@shared/containers'\nimport { toast } from 'react-toastify'\n\n/**\n * Represents a link update operation for table links\n */\nexport type LinkUpdate = {\n /** Row ID in the table */\n rowId: string\n /** ID of the source entity (the entity that will have links) */\n sourceEntityId: string\n /** Type of the source entity (e.g., 'folder', 'task') */\n sourceEntityType: string\n /** Type of link (e.g., 'workflow', 'dependency') */\n linkType: string\n /** Direction of the link from source entity perspective */\n direction: 'in' | 'out'\n /** Type of the target entities that will be linked */\n targetEntityType: string\n /**\n * Operation type:\n * - 'replace': Remove all existing links of this type and add new ones\n * - 'merge': Keep existing links and add new ones (skip duplicates)\n */\n operation: PasteMethod\n /** Array of target entity IDs to link to */\n targetEntityIds: string[]\n}\n\nexport type PasteTableLinks = (linkUpdates: LinkUpdate[]) => Promise<void>\n\ninterface usePasteLinksProps {\n projectName?: string\n}\n\nconst usePasteLinks = (props?: usePasteLinksProps) => {\n const { getEntityById, projectName: contextProjectName } = useProjectTableContext()\n const projectName = props?.projectName || contextProjectName\n const { history } = useCellEditing()\n\n // Add mutation hooks for link operations\n const [deleteLink] = useDeleteEntityLinkMutation()\n const [addLink] = useCreateEntityLinkMutation()\n\n // Handle link updates using the utility functions\n const pasteTableLinks = useCallback<PasteTableLinks>(\n async (linkUpdates: LinkUpdate[]) => {\n if (!projectName || !linkUpdates.length) return\n\n // Group operations by entity and link type for processing\n const operationsToProcess = new Map<string, LinkUpdate[]>()\n\n for (const update of linkUpdates) {\n const key = `${update.sourceEntityId}-${update.linkType}-${update.direction}`\n if (!operationsToProcess.has(key)) {\n operationsToProcess.set(key, [])\n }\n operationsToProcess.get(key)!.push(update)\n }\n\n const updatePromises: Promise<void>[] = []\n // Collect all adds/removes across all operations to build a single history entry\n const addedInPaste: LinkToAdd[] = []\n const removedInPaste: LinkToRemove[] = []\n\n // Pre-flight validation: detect any self-referential links across the whole paste\n for (const [, updates] of operationsToProcess) {\n const { sourceEntityId } = updates[0]\n const targets = new Set<string>()\n updates.forEach((u) => u.targetEntityIds.forEach((id) => targets.add(id)))\n if (targets.has(sourceEntityId)) {\n toast.error(\"You can't link an entity to itself\")\n return\n }\n }\n // Process each unique entity-linkType-direction combination\n for (const [key, updates] of operationsToProcess) {\n const firstUpdate = updates[0]\n const {\n sourceEntityId,\n sourceEntityType,\n linkType,\n direction,\n targetEntityType,\n operation,\n } = firstUpdate\n\n // Collect all target entity IDs from all updates for this combination\n const allTargetEntityIds = new Set<string>()\n updates.forEach((update) => {\n update.targetEntityIds.forEach((id) => allTargetEntityIds.add(id))\n })\n\n const linksToAdd: LinkToAdd[] = []\n const linksToRemove: LinkToRemove[] = []\n\n // Get current links for this entity and link type\n const entityData = getEntityById(sourceEntityId)\n if (!entityData) {\n console.warn(`Entity not found: ${sourceEntityId}`)\n continue\n }\n\n // Get current links for this link type and direction\n const currentLinks = entityData.links\n\n if (operation === 'replace') {\n // Remove all current links of this (linkType + direction + targetEntityType) only.\n if (Array.isArray(currentLinks)) {\n for (const link of currentLinks) {\n if (\n link.entityType === targetEntityType &&\n link.direction === direction &&\n link.linkType === linkType.split('|')[0]\n ) {\n linksToRemove.push({\n id: link.id,\n target: {\n entityId: link.node.id,\n entityType: link.entityType,\n },\n source: { entityId: sourceEntityId, entityType: sourceEntityType },\n linkType,\n direction,\n projectName,\n })\n }\n }\n }\n\n // Add all new links\n for (const targetEntityId of allTargetEntityIds) {\n const linkId = getEntityId()\n\n linksToAdd.push({\n targetEntityId,\n linkId,\n sourceEntityId,\n sourceEntityType,\n targetEntityType,\n linkType,\n direction,\n projectName,\n })\n }\n } else if (operation === 'merge') {\n // Get existing target entity IDs for this (linkType + direction + targetEntityType)\n const existingTargetIds = new Set<string>()\n if (Array.isArray(currentLinks)) {\n currentLinks.forEach((link) => {\n if (\n link.entityType === targetEntityType &&\n link.direction === direction &&\n link.linkType === linkType\n ) {\n existingTargetIds.add(link.node.id)\n }\n })\n }\n\n console.log(existingTargetIds)\n\n // Only add links that don't already exist\n for (const targetEntityId of allTargetEntityIds) {\n if (!existingTargetIds.has(targetEntityId)) {\n const linkId = getEntityId()\n\n linksToAdd.push({\n targetEntityId,\n linkId,\n sourceEntityId,\n sourceEntityType,\n targetEntityType,\n linkType,\n direction,\n projectName,\n })\n }\n }\n }\n\n if (linksToRemove.length > 0) {\n updatePromises.push(removeMultipleLinks(linksToRemove, deleteLink))\n removedInPaste.push(...linksToRemove)\n }\n if (linksToAdd.length > 0) {\n updatePromises.push(addMultipleLinks(linksToAdd, addLink))\n addedInPaste.push(...linksToAdd)\n }\n }\n try {\n // Execute all link operations in parallel\n await Promise.all(updatePromises)\n\n // Push a single history entry that undoes BOTH: remove added links and re-add removed links\n if (history && (addedInPaste.length > 0 || removedInPaste.length > 0)) {\n // Prepare inverse operations for undo\n const addedToRemove: LinkToRemove[] = addedInPaste.map((link) => ({\n id: link.linkId,\n projectName: link.projectName,\n linkType: link.linkType,\n direction: link.direction,\n target: { entityId: link.targetEntityId, entityType: link.targetEntityType },\n source: { entityId: link.sourceEntityId, entityType: link.sourceEntityType },\n }))\n\n const removedToAdd: LinkToAdd[] = removedInPaste.map((link) => ({\n targetEntityId: link.target.entityId,\n linkId: link.id,\n sourceEntityId: link.source.entityId,\n sourceEntityType: link.source.entityType,\n targetEntityType: link.target.entityType,\n linkType: link.linkType,\n direction: link.direction,\n projectName: link.projectName,\n }))\n\n // Single callbacks to keep history atomic\n const undoCallback = () => {\n const tasks: Promise<void>[] = []\n if (addedToRemove.length) tasks.push(removeMultipleLinks(addedToRemove, deleteLink))\n if (removedToAdd.length) tasks.push(addMultipleLinks(removedToAdd, addLink))\n if (tasks.length) Promise.all(tasks).catch(() => {})\n }\n\n const redoCallback = () => {\n const tasks: Promise<void>[] = []\n if (removedInPaste.length) tasks.push(removeMultipleLinks(removedInPaste, deleteLink))\n if (addedInPaste.length) tasks.push(addMultipleLinks(addedInPaste, addLink))\n if (tasks.length) Promise.all(tasks).catch(() => {})\n }\n\n history.pushHistory([undoCallback], [redoCallback])\n }\n } catch (error) {\n throw error\n }\n },\n [projectName, getEntityById, deleteLink, addLink, history],\n )\n\n return { pasteTableLinks }\n}\n\nexport default usePasteLinks\n"],"names":["usePasteLinks","props","getEntityById","contextProjectName","useProjectTableContext","projectName","history","useCellEditing","deleteLink","useDeleteEntityLinkMutation","addLink","useCreateEntityLinkMutation","useCallback","linkUpdates","operationsToProcess","update","key","updatePromises","addedInPaste","removedInPaste","updates","sourceEntityId","targets","u","id","toast","firstUpdate","sourceEntityType","linkType","direction","targetEntityType","operation","allTargetEntityIds","linksToAdd","linksToRemove","entityData","currentLinks","link","targetEntityId","linkId","getEntityId","existingTargetIds","removeMultipleLinks","addMultipleLinks","addedToRemove","removedToAdd","undoCallback","tasks","redoCallback","error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CM,MAAAA,KAAgB,CAACC,MAA+B;AACpD,QAAM,EAAE,eAAAC,GAAe,aAAaC,EAAA,IAAuBC,EAAuB,GAC5EC,IAAoCF,GACpC,EAAE,SAAAG,EAAQ,IAAIC,EAAe,GAG7B,CAACC,CAAU,IAAIC,EAA4B,GAC3C,CAACC,CAAO,IAAIC,EAA4B;AAuM9C,SAAO,EAAE,iBApMeC;AAAA,IACt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