synapse-react-client 4.0.35 → 4.0.36
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/SWC.index.js +1 -1
- package/dist/aridhia-queries/AridhiaKeyFactory.d.ts +24 -0
- package/dist/aridhia-queries/AridhiaKeyFactory.d.ts.map +1 -0
- package/dist/aridhia-queries/AridhiaKeyFactory.js +49 -0
- package/dist/aridhia-queries/AridhiaKeyFactory.js.map +1 -0
- package/dist/aridhia-queries/FairFormPayload.d.ts +45 -0
- package/dist/aridhia-queries/FairFormPayload.d.ts.map +1 -0
- package/dist/aridhia-queries/FairFormPayload.js +0 -0
- package/dist/aridhia-queries/TransferType.d.ts +10 -0
- package/dist/aridhia-queries/TransferType.d.ts.map +1 -0
- package/dist/aridhia-queries/TransferType.js +0 -0
- package/dist/aridhia-queries/aridhiaTokenExchange.js +6 -6
- package/dist/aridhia-queries/index.d.ts +12 -0
- package/dist/aridhia-queries/index.d.ts.map +1 -1
- package/dist/aridhia-queries/index.js +12 -2
- package/dist/aridhia-queries/useAridhiaQuery.d.ts +37 -0
- package/dist/aridhia-queries/useAridhiaQuery.d.ts.map +1 -0
- package/dist/aridhia-queries/useAridhiaQuery.js +71 -0
- package/dist/aridhia-queries/useAridhiaQuery.js.map +1 -0
- package/dist/aridhia-queries/useGetAridhiaDatasetCatalogue.d.ts +6 -0
- package/dist/aridhia-queries/useGetAridhiaDatasetCatalogue.d.ts.map +1 -0
- package/dist/aridhia-queries/useGetAridhiaDatasetCatalogue.js +13 -0
- package/dist/aridhia-queries/useGetAridhiaDatasetCatalogue.js.map +1 -0
- package/dist/aridhia-queries/useGetAridhiaDatasetSettings.d.ts +6 -0
- package/dist/aridhia-queries/useGetAridhiaDatasetSettings.d.ts.map +1 -0
- package/dist/aridhia-queries/useGetAridhiaDatasetSettings.js +13 -0
- package/dist/aridhia-queries/useGetAridhiaDatasetSettings.js.map +1 -0
- package/dist/aridhia-queries/useGetAridhiaDictionaries.d.ts +6 -0
- package/dist/aridhia-queries/useGetAridhiaDictionaries.d.ts.map +1 -0
- package/dist/aridhia-queries/useGetAridhiaDictionaries.js +13 -0
- package/dist/aridhia-queries/useGetAridhiaDictionaries.js.map +1 -0
- package/dist/aridhia-queries/useGetAridhiaRequests.d.ts +5 -4
- package/dist/aridhia-queries/useGetAridhiaRequests.d.ts.map +1 -1
- package/dist/aridhia-queries/useGetAridhiaRequests.js +11 -18
- package/dist/aridhia-queries/useGetAridhiaRequests.js.map +1 -1
- package/dist/aridhia-queries/useGetAridhiaWorkflow.d.ts +13 -0
- package/dist/aridhia-queries/useGetAridhiaWorkflow.d.ts.map +1 -0
- package/dist/aridhia-queries/useGetAridhiaWorkflow.js +19 -0
- package/dist/aridhia-queries/useGetAridhiaWorkflow.js.map +1 -0
- package/dist/aridhia-queries/useGetAridhiaWorkspaceLocations.d.ts +6 -0
- package/dist/aridhia-queries/useGetAridhiaWorkspaceLocations.d.ts.map +1 -0
- package/dist/aridhia-queries/useGetAridhiaWorkspaceLocations.js +13 -0
- package/dist/aridhia-queries/useGetAridhiaWorkspaceLocations.js.map +1 -0
- package/dist/aridhia-queries/useGetAridhiaWorkspaceRequestForm.d.ts +19 -0
- package/dist/aridhia-queries/useGetAridhiaWorkspaceRequestForm.d.ts.map +1 -0
- package/dist/aridhia-queries/useGetAridhiaWorkspaceRequestForm.js +17 -0
- package/dist/aridhia-queries/useGetAridhiaWorkspaceRequestForm.js.map +1 -0
- package/dist/aridhia-queries/useGetAridhiaWorkspaces.d.ts +6 -0
- package/dist/aridhia-queries/useGetAridhiaWorkspaces.d.ts.map +1 -0
- package/dist/aridhia-queries/useGetAridhiaWorkspaces.js +19 -0
- package/dist/aridhia-queries/useGetAridhiaWorkspaces.js.map +1 -0
- package/dist/aridhia-queries/useSubmitAridhiaDar.d.ts +27 -0
- package/dist/aridhia-queries/useSubmitAridhiaDar.d.ts.map +1 -0
- package/dist/aridhia-queries/useSubmitAridhiaDar.js +38 -0
- package/dist/aridhia-queries/useSubmitAridhiaDar.js.map +1 -0
- package/dist/components/AccessRequirement/EntityActionsRequired.d.ts +0 -1
- package/dist/components/AccessRequirement/EntityActionsRequired.d.ts.map +1 -1
- package/dist/components/AccessRequirement/EntityActionsRequired.js +3 -6
- package/dist/components/AccessRequirement/EntityActionsRequired.js.map +1 -1
- package/dist/components/AccessRequirementList/AccessRequirementList.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/AccessRequirementList.js +116 -115
- package/dist/components/AccessRequirementList/AccessRequirementList.js.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/EDucPreviewStep/EDucPreviewStep.d.ts.map +1 -1
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/EDucPreviewStep/EDucPreviewStep.js +67 -57
- package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/EDucPreviewStep/EDucPreviewStep.js.map +1 -1
- package/dist/components/Aridhia/aridhiaAccessStatusUtils.d.ts +3 -3
- package/dist/components/Aridhia/aridhiaAccessStatusUtils.d.ts.map +1 -1
- package/dist/components/Aridhia/aridhiaAccessStatusUtils.js +1 -1
- package/dist/components/Aridhia/aridhiaAccessStatusUtils.js.map +1 -1
- package/dist/components/CardContainer/CardConfiguration.d.ts +8 -0
- package/dist/components/CardContainer/CardConfiguration.d.ts.map +1 -1
- package/dist/components/ChangePassword/ChangePasswordWithToken.d.ts.map +1 -1
- package/dist/components/ChangePassword/ChangePasswordWithToken.js +58 -23
- package/dist/components/ChangePassword/ChangePasswordWithToken.js.map +1 -1
- package/dist/components/ChangePassword/useChangePasswordFormState.d.ts.map +1 -1
- package/dist/components/ChangePassword/useChangePasswordFormState.js +13 -3
- package/dist/components/ChangePassword/useChangePasswordFormState.js.map +1 -1
- package/dist/components/CreateTableViewWizard/TableNameForm.d.ts.map +1 -1
- package/dist/components/CreateTableViewWizard/TableNameForm.js +11 -14
- package/dist/components/CreateTableViewWizard/TableNameForm.js.map +1 -1
- package/dist/components/DataGrid/SyncGridWithSourceButton.d.ts +1 -1
- package/dist/components/DataGrid/SyncGridWithSourceButton.d.ts.map +1 -1
- package/dist/components/DataGrid/SyncGridWithSourceButton.js +55 -61
- package/dist/components/DataGrid/SyncGridWithSourceButton.js.map +1 -1
- package/dist/components/DataGrid/components/contextMenu.d.ts.map +1 -1
- package/dist/components/DataGrid/components/contextMenu.js +15 -15
- package/dist/components/DataGrid/components/contextMenu.js.map +1 -1
- package/dist/components/DataGrid/useMergeGridWithSource.d.ts +1 -5
- package/dist/components/DataGrid/useMergeGridWithSource.d.ts.map +1 -1
- package/dist/components/DataGrid/useMergeGridWithSource.js +21 -28
- package/dist/components/DataGrid/useMergeGridWithSource.js.map +1 -1
- package/dist/components/DatasetHosting/DatasetDownloadButton.d.ts +35 -0
- package/dist/components/DatasetHosting/DatasetDownloadButton.d.ts.map +1 -0
- package/dist/components/DatasetHosting/DatasetDownloadButton.js +132 -0
- package/dist/components/DatasetHosting/DatasetDownloadButton.js.map +1 -0
- package/dist/components/DatasetHosting/DatasetHosting.d.ts +91 -0
- package/dist/components/DatasetHosting/DatasetHosting.d.ts.map +1 -0
- package/dist/components/DatasetHosting/DatasetHosting.js +58 -0
- package/dist/components/DatasetHosting/DatasetHosting.js.map +1 -0
- package/dist/components/DatasetHosting/index.d.ts +5 -0
- package/dist/components/DatasetHosting/index.d.ts.map +1 -0
- package/dist/components/DatasetHosting/index.js +3 -0
- package/dist/components/DownloadCart/ActionRequiredListItem.d.ts +0 -2
- package/dist/components/DownloadCart/ActionRequiredListItem.d.ts.map +1 -1
- package/dist/components/DownloadCart/ActionRequiredListItem.js +2 -3
- package/dist/components/DownloadCart/ActionRequiredListItem.js.map +1 -1
- package/dist/components/DownloadCart/DownloadCartPage.d.ts +1 -2
- package/dist/components/DownloadCart/DownloadCartPage.d.ts.map +1 -1
- package/dist/components/DownloadCart/DownloadCartPage.js +49 -49
- package/dist/components/DownloadCart/DownloadCartPage.js.map +1 -1
- package/dist/components/DownloadCart/DownloadListActionsRequired.d.ts +1 -5
- package/dist/components/DownloadCart/DownloadListActionsRequired.d.ts.map +1 -1
- package/dist/components/DownloadCart/DownloadListActionsRequired.js +5 -6
- package/dist/components/DownloadCart/DownloadListActionsRequired.js.map +1 -1
- package/dist/components/DownloadCart/RequestDownloadCard.d.ts +0 -2
- package/dist/components/DownloadCart/RequestDownloadCard.d.ts.map +1 -1
- package/dist/components/DownloadCart/RequestDownloadCard.js +28 -32
- package/dist/components/DownloadCart/RequestDownloadCard.js.map +1 -1
- package/dist/components/DownloadCart/TableQueryActionsRequired.d.ts +0 -2
- package/dist/components/DownloadCart/TableQueryActionsRequired.d.ts.map +1 -1
- package/dist/components/DownloadCart/TableQueryActionsRequired.js +7 -8
- package/dist/components/DownloadCart/TableQueryActionsRequired.js.map +1 -1
- package/dist/components/DownloadCart/index.d.ts +1 -2
- package/dist/components/DownloadCart/index.d.ts.map +1 -1
- package/dist/components/GenericCard/CardActionButtonStyleContext.d.ts +10 -0
- package/dist/components/GenericCard/CardActionButtonStyleContext.d.ts.map +1 -0
- package/dist/components/GenericCard/CardActionButtonStyleContext.js +10 -0
- package/dist/components/GenericCard/CardActionButtonStyleContext.js.map +1 -0
- package/dist/components/GenericCard/DuoTermTags/DuoTermTags.js +41 -41
- package/dist/components/GenericCard/GenericCardActionButton.d.ts +5 -0
- package/dist/components/GenericCard/GenericCardActionButton.d.ts.map +1 -1
- package/dist/components/GenericCard/GenericCardActionButton.js +28 -11
- package/dist/components/GenericCard/GenericCardActionButton.js.map +1 -1
- package/dist/components/GenericCard/TableRowGenericCard.d.ts +24 -0
- package/dist/components/GenericCard/TableRowGenericCard.d.ts.map +1 -1
- package/dist/components/GenericCard/TableRowGenericCard.js +205 -190
- package/dist/components/GenericCard/TableRowGenericCard.js.map +1 -1
- package/dist/components/JSONArrayEditor/JSONArrayEditor.d.ts.map +1 -1
- package/dist/components/JSONArrayEditor/JSONArrayEditor.js +42 -42
- package/dist/components/JSONArrayEditor/JSONArrayEditor.js.map +1 -1
- package/dist/components/JsonSchemaForm/JsonSchemaForm.css +1 -0
- package/dist/components/JsonSchemaForm/JsonSchemaForm.d.ts.map +1 -1
- package/dist/components/JsonSchemaForm/JsonSchemaForm.js +13 -12
- package/dist/components/JsonSchemaForm/JsonSchemaForm.js.map +1 -1
- package/dist/components/JsonSchemaForm/JsonSchemaForm.module.js +5 -0
- package/dist/components/JsonSchemaForm/JsonSchemaForm.module.js.map +1 -0
- package/dist/components/JsonSchemaForm/JsonSchemaForm.module.scss +109 -0
- package/dist/components/QueryBuilder/QueryBuilderTypes.d.ts +39 -0
- package/dist/components/QueryBuilder/QueryBuilderTypes.d.ts.map +1 -0
- package/dist/components/QueryBuilder/QueryBuilderTypes.js +11 -0
- package/dist/components/QueryBuilder/QueryBuilderTypes.js.map +1 -0
- package/dist/components/QueryBuilder/queryBuilderTranslation.d.ts +48 -0
- package/dist/components/QueryBuilder/queryBuilderTranslation.d.ts.map +1 -0
- package/dist/components/QueryBuilder/queryBuilderTranslation.js +256 -0
- package/dist/components/QueryBuilder/queryBuilderTranslation.js.map +1 -0
- package/dist/components/QueryContext/QueryContext.d.ts +0 -1
- package/dist/components/QueryContext/QueryContext.d.ts.map +1 -1
- package/dist/components/QueryContext/QueryContext.js.map +1 -1
- package/dist/components/QueryWrapper/QueryWrapper.d.ts +0 -1
- package/dist/components/QueryWrapper/QueryWrapper.d.ts.map +1 -1
- package/dist/components/QueryWrapper/QueryWrapper.js +52 -53
- package/dist/components/QueryWrapper/QueryWrapper.js.map +1 -1
- package/dist/components/QueryWrapperErrorBoundary.d.ts.map +1 -1
- package/dist/components/QueryWrapperErrorBoundary.js +4 -11
- package/dist/components/QueryWrapperErrorBoundary.js.map +1 -1
- package/dist/components/QueryWrapperPlotNav/QueryWrapperPlotNav.d.ts +0 -1
- package/dist/components/QueryWrapperPlotNav/QueryWrapperPlotNav.d.ts.map +1 -1
- package/dist/components/QueryWrapperPlotNav/QueryWrapperPlotNav.js.map +1 -1
- package/dist/components/SchemaDrivenAnnotationEditor/SchemaDrivenAnnotationEditor.js +123 -123
- package/dist/components/SchemaDrivenAnnotationEditor/SchemaDrivenAnnotationEditor.js.map +1 -1
- package/dist/components/SearchQueryWrapper/SearchQueryWrapper.d.ts.map +1 -1
- package/dist/components/SearchQueryWrapper/SearchQueryWrapper.js +0 -1
- package/dist/components/SearchQueryWrapper/SearchQueryWrapper.js.map +1 -1
- package/dist/components/ShareThisPage/ShareThisPage.js +30 -29
- package/dist/components/ShareThisPage/ShareThisPage.js.map +1 -1
- package/dist/components/SynapseChat/GridAgentChat.d.ts.map +1 -1
- package/dist/components/SynapseChat/GridAgentChat.js +29 -31
- package/dist/components/SynapseChat/GridAgentChat.js.map +1 -1
- package/dist/components/SynapseTable/SynapseTable.d.ts.map +1 -1
- package/dist/components/SynapseTable/SynapseTable.js +2 -1
- package/dist/components/SynapseTable/SynapseTable.js.map +1 -1
- package/dist/components/SynapseTable/export/ExternalPlatformActionsRequiredPrecheck.d.ts.map +1 -1
- package/dist/components/SynapseTable/export/ExternalPlatformActionsRequiredPrecheck.js +29 -30
- package/dist/components/SynapseTable/export/ExternalPlatformActionsRequiredPrecheck.js.map +1 -1
- package/dist/components/TanStackTable/StyledTanStackTable.d.ts +7 -0
- package/dist/components/TanStackTable/StyledTanStackTable.d.ts.map +1 -1
- package/dist/components/TanStackTable/StyledTanStackTable.js +68 -48
- package/dist/components/TanStackTable/StyledTanStackTable.js.map +1 -1
- package/dist/components/TanStackTable/useSyncedTopScrollbar.d.ts +13 -0
- package/dist/components/TanStackTable/useSyncedTopScrollbar.d.ts.map +1 -0
- package/dist/components/TanStackTable/useSyncedTopScrollbar.js +32 -0
- package/dist/components/TanStackTable/useSyncedTopScrollbar.js.map +1 -0
- package/dist/components/dataaccess/UserAccessRequestHistory/InFlightEDucSignaturesTable.d.ts.map +1 -1
- package/dist/components/dataaccess/UserAccessRequestHistory/InFlightEDucSignaturesTable.js +36 -34
- package/dist/components/dataaccess/UserAccessRequestHistory/InFlightEDucSignaturesTable.js.map +1 -1
- package/dist/components/dataaccess/UserAccessRequestHistory/UserAccessRequestHistoryPage.js +1 -1
- package/dist/components/dataaccess/UserAccessRequestHistory/UserAccessRequestHistoryPage.js.map +1 -1
- package/dist/components/doi/CreateOrUpdateDoiModal.d.ts.map +1 -1
- package/dist/components/doi/CreateOrUpdateDoiModal.js +10 -13
- package/dist/components/doi/CreateOrUpdateDoiModal.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +143 -140
- package/dist/components/menu/DropdownMenu.d.ts.map +1 -1
- package/dist/components/menu/DropdownMenu.js +6 -6
- package/dist/components/menu/DropdownMenu.js.map +1 -1
- package/dist/features/entity/metadata-task/components/MetadataTasksPage.js +5 -5
- package/dist/index.js +161 -159
- package/dist/index.js.map +1 -1
- package/dist/mocks/msw/handlers/dataAccessRequestHandlers.d.ts.map +1 -1
- package/dist/mocks/msw/handlers/dataAccessRequestHandlers.js +30 -26
- package/dist/mocks/msw/handlers/dataAccessRequestHandlers.js.map +1 -1
- package/dist/mocks/msw/handlers/resetTwoFactorAuthHandlers.d.ts +1 -0
- package/dist/mocks/msw/handlers/resetTwoFactorAuthHandlers.d.ts.map +1 -1
- package/dist/mocks/msw/handlers/resetTwoFactorAuthHandlers.js +7 -1
- package/dist/mocks/msw/handlers/resetTwoFactorAuthHandlers.js.map +1 -1
- package/dist/mocks/msw/handlers/userProfileHandlers.d.ts.map +1 -1
- package/dist/mocks/msw/handlers/userProfileHandlers.js +4 -0
- package/dist/mocks/msw/handlers/userProfileHandlers.js.map +1 -1
- package/dist/style/components/_all.scss +0 -1
- package/dist/style/components/_cards.scss +4 -2
- package/dist/style/main.css +1 -1
- package/dist/synapse-queries/KeyFactory.d.ts +1 -0
- package/dist/synapse-queries/KeyFactory.d.ts.map +1 -1
- package/dist/synapse-queries/KeyFactory.js +3 -0
- package/dist/synapse-queries/KeyFactory.js.map +1 -1
- package/dist/synapse-queries/dataaccess/index.js +4 -4
- package/dist/synapse-queries/dataaccess/useEDuc.d.ts +7 -0
- package/dist/synapse-queries/dataaccess/useEDuc.d.ts.map +1 -1
- package/dist/synapse-queries/dataaccess/useEDuc.js +11 -3
- package/dist/synapse-queries/dataaccess/useEDuc.js.map +1 -1
- package/dist/synapse-queries/index.js +190 -189
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/APIConstants.d.ts +1 -0
- package/dist/utils/APIConstants.d.ts.map +1 -1
- package/dist/utils/APIConstants.js +2 -2
- package/dist/utils/APIConstants.js.map +1 -1
- package/dist/utils/featureflag/FeatureFlags.d.ts +1 -4
- package/dist/utils/featureflag/FeatureFlags.d.ts.map +1 -1
- package/dist/utils/featureflag/FeatureFlags.js +1 -1
- package/dist/utils/featureflag/FeatureFlags.js.map +1 -1
- package/dist/utils/functions/RegularExpressions.d.ts +10 -0
- package/dist/utils/functions/RegularExpressions.d.ts.map +1 -1
- package/dist/utils/functions/RegularExpressions.js +7 -1
- package/dist/utils/functions/RegularExpressions.js.map +1 -1
- package/dist/utils/functions/SqlFunctions.d.ts.map +1 -1
- package/dist/utils/functions/SqlFunctions.js +19 -3
- package/dist/utils/functions/SqlFunctions.js.map +1 -1
- package/dist/utils/index.js +16 -16
- package/dist/utils/types/IsType.d.ts +4 -1
- package/dist/utils/types/IsType.d.ts.map +1 -1
- package/dist/utils/types/IsType.js +4 -4
- package/dist/utils/types/IsType.js.map +1 -1
- package/dist/utils/types/index.js +2 -2
- package/package.json +7 -7
- package/dist/components/DataGrid/useMergeGridWithRecordSet.d.ts +0 -12
- package/dist/components/DataGrid/useMergeGridWithRecordSet.d.ts.map +0 -1
- package/dist/components/DataGrid/useMergeGridWithRecordSet.js +0 -25
- package/dist/components/DataGrid/useMergeGridWithRecordSet.js.map +0 -1
- package/dist/style/components/_annotations.scss +0 -110
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChangePasswordFormState.js","names":[],"sources":["../../../src/components/ChangePassword/useChangePasswordFormState.tsx"],"sourcesContent":["import { useChangePassword, useResetTwoFactorAuth } from '@/synapse-queries'\nimport appendFinalQueryParamKey from '@/utils/appendFinalQueryParamKey'\nimport { useOneSageURL } from '@/utils/hooks'\nimport { Alert, Typography } from '@mui/material'\nimport { TwoFactorAuthErrorResponse } from '@sage-bionetworks/synapse-client/generated/models/TwoFactorAuthErrorResponse'\nimport {\n ChangePasswordWithCurrentPassword,\n ChangePasswordWithToken as ChangePasswordWithTokenObject,\n ChangePasswordWithTwoFactorAuthToken,\n PasswordResetSignedToken,\n TwoFactorAuthOtpType,\n TwoFactorAuthResetRequest,\n} from '@sage-bionetworks/synapse-types'\nimport { useCallback, useState } from 'react'\nimport { ONE_TIME_PASSWORD_STEP, OneTimePasswordForm } from '../Authentication'\nimport {\n RECOVERY_CODE_GUIDANCE_TEXT_SHORT,\n TOTP_GUIDANCE_TEXT,\n} from '../Authentication/Constants'\n\nexport const TWO_FACTOR_AUTH_CHANGE_PASSWORD_PROMPT =\n 'Two-factor authentication is required to change your password. Your password has not yet been changed.'\n\nexport type UseChangePasswordFormStateOptions = {\n hideReset2FA?: boolean\n onChangePasswordSuccess?: () => void\n}\n\n/**\n * Hook that handles submitting a change password request and prompting the user for 2FA if necessary.\n * @param options\n */\nexport default function useChangePasswordFormState(\n options?: UseChangePasswordFormStateOptions,\n) {\n const defaultTwoFactorAuthResetUrl = useOneSageURL('/reset2FA')\n const twoFactorAuthResetUri = appendFinalQueryParamKey(\n defaultTwoFactorAuthResetUrl,\n 'twoFAResetToken',\n )\n\n // Store current and new password in state so that we can re-use it if 2FA is required\n const [currentPassword, setCurrentPassword] = useState<string>('')\n const [newPassword, setNewPassword] = useState<string>('')\n const [twoFactorAuthErrorResponse, setTwoFactorAuthErrorResponse] = useState<\n TwoFactorAuthErrorResponse | undefined\n >()\n const [otpStep, setOtpStep] =\n useState<ONE_TIME_PASSWORD_STEP>('VERIFICATION_CODE')\n const [successfullyChangedPassword, setSuccessfullyChangedPassword] =\n useState(false)\n const {\n mutate: changePassword,\n isPending,\n error,\n } = useChangePassword({\n onSuccess: maybeTwoFactorResponse => {\n if (maybeTwoFactorResponse) {\n // We store the 2FA Error Response in state because the `changePasswordResult` may change before we are done with the 2FA code,\n // e.g. if the user enters the wrong 2FA code\n setTwoFactorAuthErrorResponse(maybeTwoFactorResponse)\n } else {\n setSuccessfullyChangedPassword(true)\n setTwoFactorAuthErrorResponse(undefined)\n if (options?.onChangePasswordSuccess) {\n options.onChangePasswordSuccess()\n }\n }\n },\n })\n\n const handleChangePasswordWithCurrentPassword = useCallback(\n (username: string, currentPassword: string, newPassword: string) => {\n setCurrentPassword(currentPassword)\n setNewPassword(newPassword)\n const changeRequest: ChangePasswordWithCurrentPassword = {\n username,\n currentPassword,\n newPassword,\n concreteType:\n 'org.sagebionetworks.repo.model.auth.ChangePasswordWithCurrentPassword',\n }\n changePassword(changeRequest)\n },\n [changePassword],\n )\n\n const handleChangePasswordWithResetToken = useCallback(\n (newPassword: string, passwordChangeToken: PasswordResetSignedToken) => {\n setNewPassword(newPassword)\n const changeRequest: ChangePasswordWithTokenObject = {\n newPassword,\n concreteType:\n 'org.sagebionetworks.repo.model.auth.ChangePasswordWithToken',\n passwordChangeToken: passwordChangeToken,\n }\n changePassword(changeRequest)\n },\n [changePassword],\n )\n\n const handleChangePasswordWithOtp = useCallback(\n (newPassword: string, code: string, otpType: TwoFactorAuthOtpType) => {\n if (twoFactorAuthErrorResponse) {\n const changeRequest: ChangePasswordWithTwoFactorAuthToken = {\n newPassword,\n concreteType:\n 'org.sagebionetworks.repo.model.auth.ChangePasswordWithTwoFactorAuthToken',\n userId: twoFactorAuthErrorResponse.userId!,\n twoFaToken: twoFactorAuthErrorResponse.twoFaToken!,\n otpType: otpType,\n otpCode: code,\n }\n changePassword(changeRequest)\n }\n },\n [changePassword, twoFactorAuthErrorResponse],\n )\n const promptForTwoFactorAuth = Boolean(twoFactorAuthErrorResponse)\n const {\n mutate: resetTwoFactorAuth,\n isSuccess: twoFactorAuthResetIsSuccess,\n isPending: twoFactorAuthResetIsPending,\n } = useResetTwoFactorAuth()\n\n const beginTwoFactorAuthReset = useCallback(\n (twoFaResetEndpoint: string) => {\n if (twoFactorAuthErrorResponse) {\n const request: TwoFactorAuthResetRequest = {\n userId: twoFactorAuthErrorResponse.userId!,\n twoFaResetEndpoint: twoFaResetEndpoint,\n // When attempting to reset 2FA while resetting a password, the current password must be used to request 2FA reset\n password: currentPassword,\n }\n resetTwoFactorAuth(request)\n }\n },\n [currentPassword, resetTwoFactorAuth, twoFactorAuthErrorResponse],\n )\n\n const TwoFactorAuthPrompt = useCallback(() => {\n if (!promptForTwoFactorAuth) {\n return <></>\n }\n return (\n <>\n {otpStep === 'VERIFICATION_CODE' && (\n <Typography variant={'body1'} sx={{ my: 2 }} align={'center'}>\n {TOTP_GUIDANCE_TEXT}\n </Typography>\n )}\n {otpStep === 'RECOVERY_CODE' && (\n <Typography variant={'body1'} sx={{ my: 2 }} align={'center'}>\n {RECOVERY_CODE_GUIDANCE_TEXT_SHORT}\n </Typography>\n )}\n <OneTimePasswordForm\n step={otpStep}\n onClickUseTOTP={() => {\n setOtpStep('VERIFICATION_CODE')\n }}\n onClickUseBackupCode={() => {\n setOtpStep('RECOVERY_CODE')\n }}\n loginIsPending={isPending}\n onSubmit={(code, otpType) =>\n handleChangePasswordWithOtp(newPassword, code, otpType)\n }\n hideReset2FA={options?.hideReset2FA}\n onClickPromptReset2FA={() => {\n setOtpStep('DISABLE_2FA_PROMPT')\n }}\n onClickReset2FA={() => {\n beginTwoFactorAuthReset(twoFactorAuthResetUri)\n }}\n twoFactorAuthResetIsPending={twoFactorAuthResetIsPending}\n twoFactorAuthResetIsSuccess={twoFactorAuthResetIsSuccess}\n />\n {(otpStep === 'RECOVERY_CODE' || otpStep === 'VERIFICATION_CODE') && (\n <Alert severity={'info'} sx={{ my: 2 }}>\n {TWO_FACTOR_AUTH_CHANGE_PASSWORD_PROMPT}\n </Alert>\n )}\n {otpStep === 'DISABLE_2FA_PROMPT' && twoFactorAuthResetIsSuccess && (\n <Alert severity={'warning'} sx={{ my: 2 }}>\n <strong>Your password has not been changed.</strong> To disable\n two-factor authentication, you may be required to enter your current\n password after clicking the link sent to your email address.\n </Alert>\n )}\n </>\n )\n }, [\n beginTwoFactorAuthReset,\n handleChangePasswordWithOtp,\n isPending,\n newPassword,\n options?.hideReset2FA,\n otpStep,\n promptForTwoFactorAuth,\n twoFactorAuthResetIsPending,\n twoFactorAuthResetIsSuccess,\n twoFactorAuthResetUri,\n ])\n\n return {\n successfullyChangedPassword,\n isPending,\n error,\n promptForTwoFactorAuth,\n TwoFactorAuthPrompt: TwoFactorAuthPrompt,\n handleChangePasswordWithCurrentPassword,\n handleChangePasswordWithResetToken,\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,IAAa,IACX;AAWF,SAAwB,EACtB,GACA;CAEA,IAAM,IAAwB,EADO,EAAc,WAEjD,GACA,iBACF,GAGM,CAAC,GAAiB,KAAsB,EAAiB,EAAE,GAC3D,CAAC,GAAa,KAAkB,EAAiB,EAAE,GACnD,CAAC,GAA4B,KAAiC,EAElE,GACI,CAAC,GAAS,KACd,EAAiC,mBAAmB,GAChD,CAAC,GAA6B,KAClC,EAAS,EAAK,GACV,EACJ,QAAQ,GACR,cACA,aACE,EAAkB,EACpB,YAAW,MAA0B;EACnC,AAAI,IAGF,EAA8B,CAAsB,KAEpD,EAA+B,EAAI,GACnC,EAA8B,KAAA,CAAS,GACnC,GAAS,2BACX,EAAQ,wBAAwB;CAGtC,EACF,CAAC,GAEK,IAA0C,GAC7C,GAAkB,GAAyB,MAAwB;EAUlE,AATA,EAAmB,CAAe,GAClC,EAAe,CAAW,GAQ1B,EAAe;GANb;GACA;GACA;GACA,cACE;EAEW,CAAa;CAC9B,GACA,CAAC,CAAc,CACjB,GAEM,IAAqC,GACxC,GAAqB,MAAkD;EAQtE,AAPA,EAAe,CAAW,GAO1B,EAAe;GALb;GACA,c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ACE,kBAAC,UAAD,EAAA,UAAQ,sCAA2C,CAAA,GAAC,+IAG/C;;EAET,EAAA,CAAA,IAhDK,kBAAA,GAAA,CAAI,CAAA,GAkDZ;GACD;GACA;GACA;GACA;GACA,GAAS;GACT;GACA;GACA;GACA;GACA;EACF,CAOuB;EACrB;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"useChangePasswordFormState.js","names":[],"sources":["../../../src/components/ChangePassword/useChangePasswordFormState.tsx"],"sourcesContent":["import { useChangePassword, useResetTwoFactorAuth } from '@/synapse-queries'\nimport appendFinalQueryParamKey from '@/utils/appendFinalQueryParamKey'\nimport { useOneSageURL } from '@/utils/hooks'\nimport { Alert, Typography } from '@mui/material'\nimport { TwoFactorAuthErrorResponse } from '@sage-bionetworks/synapse-client/generated/models/TwoFactorAuthErrorResponse'\nimport {\n ChangePasswordWithCurrentPassword,\n ChangePasswordWithToken as ChangePasswordWithTokenObject,\n ChangePasswordWithTwoFactorAuthToken,\n PasswordResetSignedToken,\n TwoFactorAuthOtpType,\n TwoFactorAuthResetRequest,\n} from '@sage-bionetworks/synapse-types'\nimport { useCallback, useState } from 'react'\nimport { ONE_TIME_PASSWORD_STEP, OneTimePasswordForm } from '../Authentication'\nimport {\n RECOVERY_CODE_GUIDANCE_TEXT_SHORT,\n TOTP_GUIDANCE_TEXT,\n} from '../Authentication/Constants'\n\nexport const TWO_FACTOR_AUTH_CHANGE_PASSWORD_PROMPT =\n 'Two-factor authentication is required to change your password. Your password has not yet been changed.'\n\nexport type UseChangePasswordFormStateOptions = {\n hideReset2FA?: boolean\n onChangePasswordSuccess?: () => void\n}\n\n/**\n * Hook that handles submitting a change password request and prompting the user for 2FA if necessary.\n * @param options\n */\nexport default function useChangePasswordFormState(\n options?: UseChangePasswordFormStateOptions,\n) {\n const defaultTwoFactorAuthResetUrl = useOneSageURL('/reset2FA')\n const twoFactorAuthResetUri = appendFinalQueryParamKey(\n defaultTwoFactorAuthResetUrl,\n 'twoFAResetToken',\n )\n\n // Store current and new password in state so that we can re-use the current password if 2FA is required\n const [currentPassword, setCurrentPassword] = useState<string>('')\n const [newPassword, setNewPassword] = useState<string>('')\n const [twoFactorAuthErrorResponse, setTwoFactorAuthErrorResponse] = useState<\n TwoFactorAuthErrorResponse | undefined\n >()\n const [otpStep, setOtpStep] =\n useState<ONE_TIME_PASSWORD_STEP>('VERIFICATION_CODE')\n const [successfullyChangedPassword, setSuccessfullyChangedPassword] =\n useState(false)\n const {\n mutate: changePassword,\n isPending,\n error,\n } = useChangePassword({\n onSuccess: maybeTwoFactorResponse => {\n if (maybeTwoFactorResponse) {\n // We store the 2FA Error Response in state because the `changePasswordResult` may change before we are done with the 2FA code,\n // e.g. if the user enters the wrong 2FA code\n setTwoFactorAuthErrorResponse(maybeTwoFactorResponse)\n } else {\n setSuccessfullyChangedPassword(true)\n setTwoFactorAuthErrorResponse(undefined)\n if (options?.onChangePasswordSuccess) {\n options.onChangePasswordSuccess()\n }\n }\n },\n })\n\n const handleChangePasswordWithCurrentPassword = useCallback(\n (username: string, currentPassword: string, newPassword: string) => {\n setCurrentPassword(currentPassword)\n setNewPassword(newPassword)\n const changeRequest: ChangePasswordWithCurrentPassword = {\n username,\n currentPassword,\n newPassword,\n concreteType:\n 'org.sagebionetworks.repo.model.auth.ChangePasswordWithCurrentPassword',\n }\n changePassword(changeRequest)\n },\n [changePassword],\n )\n\n const handleChangePasswordWithResetToken = useCallback(\n (newPassword: string, passwordChangeToken: PasswordResetSignedToken) => {\n setNewPassword(newPassword)\n const changeRequest: ChangePasswordWithTokenObject = {\n newPassword,\n concreteType:\n 'org.sagebionetworks.repo.model.auth.ChangePasswordWithToken',\n passwordChangeToken: passwordChangeToken,\n }\n changePassword(changeRequest)\n },\n [changePassword],\n )\n\n const handleChangePasswordWithOtp = useCallback(\n (newPassword: string, code: string, otpType: TwoFactorAuthOtpType) => {\n if (twoFactorAuthErrorResponse) {\n const changeRequest: ChangePasswordWithTwoFactorAuthToken = {\n newPassword,\n concreteType:\n 'org.sagebionetworks.repo.model.auth.ChangePasswordWithTwoFactorAuthToken',\n userId: twoFactorAuthErrorResponse.userId!,\n twoFaToken: twoFactorAuthErrorResponse.twoFaToken!,\n otpType: otpType,\n otpCode: code,\n }\n changePassword(changeRequest)\n }\n },\n [changePassword, twoFactorAuthErrorResponse],\n )\n const promptForTwoFactorAuth = Boolean(twoFactorAuthErrorResponse)\n const {\n mutate: resetTwoFactorAuth,\n isSuccess: twoFactorAuthResetIsSuccess,\n isPending: twoFactorAuthResetIsPending,\n error: twoFactorAuthResetError,\n } = useResetTwoFactorAuth()\n\n const beginTwoFactorAuthReset = useCallback(\n (twoFaResetEndpoint: string) => {\n if (twoFactorAuthErrorResponse) {\n const request: TwoFactorAuthResetRequest = {\n userId: twoFactorAuthErrorResponse.userId!,\n twoFaResetEndpoint: twoFaResetEndpoint,\n // The 2fa/reset endpoint only accepts a twoFaToken minted for an AUTHENTICATION (login) challenge;\n // the token from a change-password 2FA challenge is scoped to PASSWORD_CHANGE and is rejected there.\n // The current password is therefore the only credential this flow can present.\n password: currentPassword,\n }\n resetTwoFactorAuth(request)\n }\n },\n [currentPassword, resetTwoFactorAuth, twoFactorAuthErrorResponse],\n )\n\n const TwoFactorAuthPrompt = useCallback(() => {\n if (!promptForTwoFactorAuth) {\n return <></>\n }\n return (\n <>\n {otpStep === 'VERIFICATION_CODE' && (\n <Typography variant={'body1'} sx={{ my: 2 }} align={'center'}>\n {TOTP_GUIDANCE_TEXT}\n </Typography>\n )}\n {otpStep === 'RECOVERY_CODE' && (\n <Typography variant={'body1'} sx={{ my: 2 }} align={'center'}>\n {RECOVERY_CODE_GUIDANCE_TEXT_SHORT}\n </Typography>\n )}\n <OneTimePasswordForm\n step={otpStep}\n onClickUseTOTP={() => {\n setOtpStep('VERIFICATION_CODE')\n }}\n onClickUseBackupCode={() => {\n setOtpStep('RECOVERY_CODE')\n }}\n loginIsPending={isPending}\n onSubmit={(code, otpType) =>\n handleChangePasswordWithOtp(newPassword, code, otpType)\n }\n hideReset2FA={options?.hideReset2FA}\n onClickPromptReset2FA={() => {\n setOtpStep('DISABLE_2FA_PROMPT')\n }}\n onClickReset2FA={() => {\n beginTwoFactorAuthReset(twoFactorAuthResetUri)\n }}\n twoFactorAuthResetIsPending={twoFactorAuthResetIsPending}\n twoFactorAuthResetIsSuccess={twoFactorAuthResetIsSuccess}\n />\n {(otpStep === 'RECOVERY_CODE' || otpStep === 'VERIFICATION_CODE') && (\n <Alert severity={'info'} sx={{ my: 2 }}>\n {TWO_FACTOR_AUTH_CHANGE_PASSWORD_PROMPT}\n </Alert>\n )}\n {otpStep === 'DISABLE_2FA_PROMPT' && twoFactorAuthResetIsSuccess && (\n <Alert severity={'warning'} sx={{ my: 2 }}>\n <strong>Your password has not been changed.</strong> To disable\n two-factor authentication, you may be required to enter your current\n password after clicking the link sent to your email address.\n </Alert>\n )}\n {otpStep === 'DISABLE_2FA_PROMPT' && twoFactorAuthResetError && (\n <Alert severity={'error'} sx={{ my: 2 }}>\n Failed to reset two-factor authentication:{' '}\n {twoFactorAuthResetError.reason}\n </Alert>\n )}\n </>\n )\n }, [\n beginTwoFactorAuthReset,\n handleChangePasswordWithOtp,\n isPending,\n newPassword,\n options?.hideReset2FA,\n otpStep,\n promptForTwoFactorAuth,\n twoFactorAuthResetError,\n twoFactorAuthResetIsPending,\n twoFactorAuthResetIsSuccess,\n twoFactorAuthResetUri,\n ])\n\n return {\n successfullyChangedPassword,\n isPending,\n error,\n promptForTwoFactorAuth,\n TwoFactorAuthPrompt: TwoFactorAuthPrompt,\n handleChangePasswordWithCurrentPassword,\n handleChangePasswordWithResetToken,\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,IAAa,IACX;AAWF,SAAwB,EACtB,GACA;CAEA,IAAM,IAAwB,EADO,EAAc,WAEjD,GACA,iBACF,GAGM,CAAC,GAAiB,KAAsB,EAAiB,EAAE,GAC3D,CAAC,GAAa,KAAkB,EAAiB,EAAE,GACnD,CAAC,GAA4B,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I,EAAE,IAAI,EAAE;IAAG,OAAO;;GAExC,CAAA;GAEd,kBAAC,GAAD;IACE,MAAM;IACN,sBAAsB;KACpB,EAAW,mBAAmB;IAChC;IACA,4BAA4B;KAC1B,EAAW,eAAe;IAC5B;IACA,gBAAgB;IAChB,WAAW,GAAM,MACf,EAA4B,GAAa,GAAM,CAAO;IAExD,cAAc,GAAS;IACvB,6BAA6B;KAC3B,EAAW,oBAAoB;IACjC;IACA,uBAAuB;KACrB,EAAwB,CAAqB;IAC/C;IAC6B;IACA;GAC9B,CAAA;IACC,MAAY,mBAAmB,MAAY,wBAC3C,kBAAC,GAAD;IAAO,UAAU;IAAQ,IAAI,EAAE,IAAI,EAAE;;GAE9B,CAAA;GAER,MAAY,wBAAwB,KACnC,kBAAC,GAAD;IAAO,UAAU;IAAW,IAAI,EAAE,IAAI,EAAE;cAAxC,CACE,kBAAC,UAAD,EAAA,UAAQ,sCAA2C,CAAA,GAAC,+IAG/C;;GAER,MAAY,wBAAwB,KACnC,kBAAC,GAAD;IAAO,UAAU;IAAS,IAAI,EAAE,IAAI,EAAE;cAAtC;KAAyC;KACI;KAC1C,EAAwB;IACpB;;EAET,EAAA,CAAA,IAtDK,kBAAA,GAAA,CAAI,CAAA,GAwDZ;GACD;GACA;GACA;GACA;GACA,GAAS;GACT;GACA;GACA;GACA;GACA;GACA;EACF,CAOuB;EACrB;EACA;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableNameForm.d.ts","sourceRoot":"","sources":["../../../src/components/CreateTableViewWizard/TableNameForm.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TableNameForm.d.ts","sourceRoot":"","sources":["../../../src/components/CreateTableViewWizard/TableNameForm.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAEhD,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAA;IACzC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAA;CAC7D,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,KAAK,EAAE,kBAAkB,2CA0B9D"}
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
3
|
-
import { FeatureFlagEnum as t } from "../../utils/featureflag/FeatureFlags.js";
|
|
4
|
-
import { TextField as n } from "@mui/material";
|
|
5
|
-
import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
1
|
+
import { TextField as e } from "@mui/material";
|
|
2
|
+
import { Fragment as t, jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
6
3
|
//#region src/components/CreateTableViewWizard/TableNameForm.tsx
|
|
7
|
-
function
|
|
8
|
-
let { name:
|
|
9
|
-
return /* @__PURE__ */
|
|
4
|
+
function i(i) {
|
|
5
|
+
let { name: a, setName: o, description: s, setDescription: c } = i;
|
|
6
|
+
return /* @__PURE__ */ r(t, { children: [/* @__PURE__ */ n(e, {
|
|
10
7
|
required: !0,
|
|
11
8
|
label: "Name",
|
|
12
|
-
value:
|
|
9
|
+
value: a,
|
|
13
10
|
onChange: (e) => {
|
|
14
|
-
|
|
11
|
+
o(e.target.value);
|
|
15
12
|
},
|
|
16
13
|
fullWidth: !0
|
|
17
|
-
}),
|
|
14
|
+
}), /* @__PURE__ */ n(e, {
|
|
18
15
|
label: "Description",
|
|
19
|
-
value:
|
|
16
|
+
value: s,
|
|
20
17
|
onChange: (e) => {
|
|
21
|
-
|
|
18
|
+
c(e.target.value || void 0);
|
|
22
19
|
},
|
|
23
20
|
fullWidth: !0,
|
|
24
21
|
multiline: !0,
|
|
@@ -27,6 +24,6 @@ function o(o) {
|
|
|
27
24
|
})] });
|
|
28
25
|
}
|
|
29
26
|
//#endregion
|
|
30
|
-
export {
|
|
27
|
+
export { i as default };
|
|
31
28
|
|
|
32
29
|
//# sourceMappingURL=TableNameForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableNameForm.js","names":[],"sources":["../../../src/components/CreateTableViewWizard/TableNameForm.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"TableNameForm.js","names":[],"sources":["../../../src/components/CreateTableViewWizard/TableNameForm.tsx"],"sourcesContent":["import { TextField } from '@mui/material'\nimport { Dispatch, SetStateAction } from 'react'\n\ntype TableNameFormProps = {\n name: string\n setName: Dispatch<SetStateAction<string>>\n description: string | undefined\n setDescription: Dispatch<SetStateAction<string | undefined>>\n}\n\n/**\n * React component for the naming a new table or view.\n * Renders UI to provide the name and description of a table or view.\n */\nexport default function TableNameForm(props: TableNameFormProps) {\n const { name, setName, description, setDescription } = props\n return (\n <>\n <TextField\n required\n label={'Name'}\n value={name}\n onChange={e => {\n setName(e.target.value)\n }}\n fullWidth\n />\n <TextField\n label={'Description'}\n value={description}\n onChange={e => {\n setDescription(e.target.value || undefined)\n }}\n fullWidth\n multiline\n rows={3}\n sx={{ my: 2 }}\n />\n </>\n )\n}\n"],"mappings":";;;AAcA,SAAwB,EAAc,GAA2B;CAC/D,IAAM,EAAE,SAAM,YAAS,gBAAa,sBAAmB;CACvD,OACE,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,GAAD;EACE,UAAA;EACA,OAAO;EACP,OAAO;EACP,WAAU,MAAK;GACb,EAAQ,EAAE,OAAO,KAAK;EACxB;EACA,WAAA;CACD,CAAA,GACD,kBAAC,GAAD;EACE,OAAO;EACP,OAAO;EACP,WAAU,MAAK;GACb,EAAe,EAAE,OAAO,SAAS,KAAA,CAAS;EAC5C;EACA,WAAA;EACA,WAAA;EACA,MAAM;EACN,IAAI,EAAE,IAAI,EAAE;CACb,CAAA,CACD,EAAA,CAAA;AAEN"}
|
|
@@ -22,7 +22,7 @@ export declare function shouldPullBeforePush(gridSession: GridSession, sourceEnt
|
|
|
22
22
|
* Determines the button label and tooltip copy for the sync button based on whether the
|
|
23
23
|
* user should PULL before PULL_PUSH, and the source entity's type.
|
|
24
24
|
*/
|
|
25
|
-
export declare function getSyncButtonLabels(shouldPull: boolean, sourceEntityType: EntityType | undefined
|
|
25
|
+
export declare function getSyncButtonLabels(shouldPull: boolean, sourceEntityType: EntityType | undefined): {
|
|
26
26
|
buttonText: string;
|
|
27
27
|
tooltipText: string;
|
|
28
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncGridWithSourceButton.d.ts","sourceRoot":"","sources":["../../../src/components/DataGrid/SyncGridWithSourceButton.tsx"],"names":[],"mappings":"AACA,OAA+B,EAC7B,mBAAmB,EACpB,MAAM,8CAA8C,CAAA;
|
|
1
|
+
{"version":3,"file":"SyncGridWithSourceButton.d.ts","sourceRoot":"","sources":["../../../src/components/DataGrid/SyncGridWithSourceButton.tsx"],"names":[],"mappings":"AACA,OAA+B,EAC7B,mBAAmB,EACpB,MAAM,8CAA8C,CAAA;AAOrD,OAAO,EACL,MAAM,EACN,UAAU,EAEV,WAAW,EAIX,uBAAuB,EACvB,uBAAuB,EAExB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,4DAA4D,CAAA;AAErF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,WAAW,EAAE,WAAW,CAAA;CACzB,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,KAAK,EAAE,6BAA6B,2CAqErC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,MAAM,GAAG,IAAI,EAC3B,yBAAyB,EAAE,uBAAuB,GAAG,IAAI,GACxD,OAAO,CAqBT;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,OAAO,EACnB,gBAAgB,EAAE,UAAU,GAAG,SAAS,GACvC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAoB7C;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,UAAU,GAAG,SAAS,EACxC,UAAU,EAAE,OAAO,GAClB,mBAAmB,CAOrB;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,uBAAuB,EAC/B,QAAQ,CAAC,EAAE,QAAQ,QAmBpB"}
|
|
@@ -1,81 +1,75 @@
|
|
|
1
1
|
import { displayToast as e } from "../ToastMessage/ToastMessage.js";
|
|
2
2
|
import { convertToEntityType as t } from "../../utils/functions/EntityTypeUtils.js";
|
|
3
3
|
import { useGetEntity as n } from "../../synapse-queries/entity/useEntity.js";
|
|
4
|
-
import {
|
|
5
|
-
import "../../synapse-queries/featureflags/index.js";
|
|
6
|
-
import { useGetSchemaBinding as i } from "../../synapse-queries/jsonschema/useEntityBoundSchema.js";
|
|
4
|
+
import { useGetSchemaBinding as r } from "../../synapse-queries/jsonschema/useEntityBoundSchema.js";
|
|
7
5
|
import "../../synapse-queries/index.js";
|
|
8
|
-
import { FeatureFlagEnum as a } from "../../utils/featureflag/FeatureFlags.js";
|
|
9
6
|
import "../index.js";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { Skeleton as
|
|
13
|
-
import { jsx as
|
|
14
|
-
import { EntityType as
|
|
15
|
-
import { CloudDownloadTwoTone as
|
|
16
|
-
import { c as
|
|
7
|
+
import i from "./components/GridMenuButton/GridMenuButton.js";
|
|
8
|
+
import a from "./useMergeGridWithSource.js";
|
|
9
|
+
import { Skeleton as o, Tooltip as s } from "@mui/material";
|
|
10
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
11
|
+
import { EntityType as l, instanceOfEntityUpdateResults as u, instanceOfRecordSet as d, instanceOfUploadToTableResult as f } from "@sage-bionetworks/synapse-client";
|
|
12
|
+
import { CloudDownloadTwoTone as p, CloudSyncTwoTone as m } from "@mui/icons-material";
|
|
13
|
+
import { c as h } from "react/compiler-runtime";
|
|
17
14
|
//#region src/components/DataGrid/SyncGridWithSourceButton.tsx
|
|
18
|
-
function
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
let { data:
|
|
22
|
-
|
|
23
|
-
onSuccess:
|
|
24
|
-
onError:
|
|
25
|
-
},
|
|
26
|
-
let { mutate:
|
|
27
|
-
if (
|
|
15
|
+
function g(e) {
|
|
16
|
+
let l = h(19), { gridSession: u } = e, { data: d, isLoading: f } = n(u.sourceEntityId), g = !!u.sourceEntityId, S;
|
|
17
|
+
l[0] === g ? S = l[1] : (S = { enabled: g }, l[0] = g, l[1] = S);
|
|
18
|
+
let { data: C, isLoading: w } = r(u.sourceEntityId ?? "", S), T = d?.concreteType ? t(d.concreteType) : void 0, E;
|
|
19
|
+
l[2] === Symbol.for("react.memo_cache_sentinel") ? (E = {
|
|
20
|
+
onSuccess: v,
|
|
21
|
+
onError: _
|
|
22
|
+
}, l[2] = E) : E = l[2];
|
|
23
|
+
let { mutate: D, isPending: O } = a(E), k = d !== void 0 && C !== void 0 && y(u, d, C), { buttonText: A, tooltipText: j } = b(k, T);
|
|
24
|
+
if (f || w) {
|
|
28
25
|
let e;
|
|
29
|
-
return
|
|
26
|
+
return l[3] === Symbol.for("react.memo_cache_sentinel") ? (e = /* @__PURE__ */ c(o, { width: "100px" }), l[3] = e) : e = l[3], e;
|
|
30
27
|
}
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
let
|
|
38
|
-
|
|
39
|
-
startIcon:
|
|
40
|
-
loading:
|
|
41
|
-
onClick:
|
|
28
|
+
let M;
|
|
29
|
+
l[4] === k ? M = l[5] : (M = c(k ? p : m, {}), l[4] = k, l[5] = M);
|
|
30
|
+
let N;
|
|
31
|
+
l[6] !== u || l[7] !== D || l[8] !== k || l[9] !== T ? (N = () => {
|
|
32
|
+
D(x(u, T, k));
|
|
33
|
+
}, l[6] = u, l[7] = D, l[8] = k, l[9] = T, l[10] = N) : N = l[10];
|
|
34
|
+
let P;
|
|
35
|
+
l[11] !== A || l[12] !== O || l[13] !== M || l[14] !== N ? (P = /* @__PURE__ */ c(i, {
|
|
36
|
+
startIcon: M,
|
|
37
|
+
loading: O,
|
|
38
|
+
onClick: N,
|
|
42
39
|
variant: "contained",
|
|
43
|
-
children:
|
|
44
|
-
}),
|
|
45
|
-
let
|
|
46
|
-
return
|
|
47
|
-
title:
|
|
40
|
+
children: A
|
|
41
|
+
}), l[11] = A, l[12] = O, l[13] = M, l[14] = N, l[15] = P) : P = l[15];
|
|
42
|
+
let F;
|
|
43
|
+
return l[16] !== P || l[17] !== j ? (F = /* @__PURE__ */ c(s, {
|
|
44
|
+
title: j,
|
|
48
45
|
describeChild: !0,
|
|
49
|
-
children:
|
|
50
|
-
}),
|
|
46
|
+
children: P
|
|
47
|
+
}), l[16] = P, l[17] = j, l[18] = F) : F = l[18], F;
|
|
51
48
|
}
|
|
52
|
-
function
|
|
49
|
+
function _(t) {
|
|
53
50
|
return e(t.message, "danger");
|
|
54
51
|
}
|
|
55
|
-
function
|
|
56
|
-
bb14: switch (
|
|
52
|
+
function v(e, t) {
|
|
53
|
+
bb14: switch (e.type) {
|
|
57
54
|
case "synchronize":
|
|
58
|
-
|
|
55
|
+
S(e.data, t.syncType);
|
|
59
56
|
break bb14;
|
|
60
57
|
case "tableUpdateTransaction":
|
|
61
|
-
|
|
62
|
-
break bb14;
|
|
63
|
-
case "recordset_overwrite":
|
|
64
|
-
e("Successfully updated RecordSet.", "success");
|
|
58
|
+
C(e.data);
|
|
65
59
|
break bb14;
|
|
66
60
|
default:
|
|
67
61
|
}
|
|
68
62
|
}
|
|
69
|
-
function
|
|
70
|
-
if (!(t != null &&
|
|
63
|
+
function y(e, t, n) {
|
|
64
|
+
if (!(t != null && d(t))) return !1;
|
|
71
65
|
let r = e.sourceEntityVersionNumber != null && t.versionNumber != null && e.sourceEntityVersionNumber < t.versionNumber, i = n != null && e.gridJsonSchema$Id !== n.jsonSchemaVersionInfo?.$id;
|
|
72
66
|
return r || i;
|
|
73
67
|
}
|
|
74
|
-
function
|
|
68
|
+
function b(e, t) {
|
|
75
69
|
return e ? {
|
|
76
70
|
buttonText: "Import latest changes",
|
|
77
71
|
tooltipText: "Imports any recent changes into this Curator session. Your changes will not yet be applied."
|
|
78
|
-
} : t ===
|
|
72
|
+
} : t === l.table ? {
|
|
79
73
|
buttonText: "Apply changes",
|
|
80
74
|
tooltipText: "Applies any changes made in this Curator session to the source"
|
|
81
75
|
} : {
|
|
@@ -83,7 +77,7 @@ function S(e, t, n) {
|
|
|
83
77
|
tooltipText: "Applies any changes made in this Curator session, and imports any recent changes into this Curator session."
|
|
84
78
|
};
|
|
85
79
|
}
|
|
86
|
-
function
|
|
80
|
+
function x(e, t, n) {
|
|
87
81
|
return {
|
|
88
82
|
gridSessionId: e.sessionId,
|
|
89
83
|
sourceEntityId: e.sourceEntityId,
|
|
@@ -91,25 +85,25 @@ function C(e, t, n) {
|
|
|
91
85
|
syncType: n ? "PULL" : "PULL_PUSH"
|
|
92
86
|
};
|
|
93
87
|
}
|
|
94
|
-
function
|
|
95
|
-
t.errorMessages == null || t.errorMessages.length === 0 ? e(n === "PULL" ? "Successfully imported latest changes." : "Successfully synchronized changes.", "success") : e(/* @__PURE__ */
|
|
88
|
+
function S(t, n) {
|
|
89
|
+
t.errorMessages == null || t.errorMessages.length === 0 ? e(n === "PULL" ? "Successfully imported latest changes." : "Successfully synchronized changes.", "success") : e(/* @__PURE__ */ c("ul", { children: t.errorMessages.map((e, t) => /* @__PURE__ */ c("li", { children: e }, t)) }), "warning", { title: "Some changes could not be applied" });
|
|
96
90
|
}
|
|
97
|
-
function
|
|
91
|
+
function C(t) {
|
|
98
92
|
if (t.results?.length) {
|
|
99
93
|
let n = t.results[0];
|
|
100
|
-
if (
|
|
101
|
-
let t =
|
|
94
|
+
if (u(n)) {
|
|
95
|
+
let t = w(n).join("\n");
|
|
102
96
|
t ? e(`Some changes could not be applied:\n${t}`, "danger") : e("Changes applied successfully", "success");
|
|
103
|
-
} else if (
|
|
97
|
+
} else if (f(n)) {
|
|
104
98
|
let t = n.rowsProcessed?.toLocaleString();
|
|
105
99
|
e(`Successfully updated ${t} rows.`, "success");
|
|
106
100
|
}
|
|
107
101
|
}
|
|
108
102
|
}
|
|
109
|
-
function
|
|
103
|
+
function w(e) {
|
|
110
104
|
return e.updateResults?.filter((e) => !!e.failureCode).map((e) => `${e.entityId}: ${e.failureMessage} (code: ${e.failureCode})`) ?? [];
|
|
111
105
|
}
|
|
112
106
|
//#endregion
|
|
113
|
-
export {
|
|
107
|
+
export { x as buildMergeGridVariables, g as default, b as getSyncButtonLabels, S as onSynchronizeSuccess, y as shouldPullBeforePush };
|
|
114
108
|
|
|
115
109
|
//# sourceMappingURL=SyncGridWithSourceButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncGridWithSourceButton.js","names":["GridMenuButton","useMergeGridWithSource","MergeGridWithSource","displayToast","useGetEntity","useGetSchemaBinding","useGetFeatureFlag","FeatureFlagEnum","convertToEntityType","CloudDownloadTwoTone","CloudSyncTwoTone","Skeleton","Tooltip","Entity","EntityType","EntityUpdateResults","GridSession","instanceOfEntityUpdateResults","instanceOfRecordSet","instanceOfUploadToTableResult","JsonSchemaObjectBinding","SynchronizeGridResponse","TableUpdateTransactionResponse","SyncType","SyncGridWithSourceButtonProps","gridSession","SyncGridWithSourceButton","props","$","_c","data","entity","isLoading","entityLoading","sourceEntityId","t0","t1","enabled","sourceEntitySchemaBinding","schemaBindingIsLoading","sourceEntityType","concreteType","undefined","enableRecordSetSync","ENABLE_RECORDSET_SYNCHRONIZATION","t2","Symbol","for","onSuccess","_temp","onError","_temp2","mutate","mergeGrid","isPending","shouldPull","shouldPullBeforePush","buttonText","tooltipText","getSyncButtonLabels","isLoadingPrerequisiteData","t3","t4","buildMergeGridVariables","t5","t6","e","message","result","variables","bb14","type","onSynchronizeSuccess","syncType","onMergeTableSuccess","sourceEntity","isPullSupported","isSourceEntityUpdated","sourceEntityVersionNumber","versionNumber","isSchemaBindingUpdated","gridJsonSchema$Id","jsonSchemaVersionInfo","$id","table","recordset","gridSessionId","sessionId","errorMessages","length","map","msg","index","title","results","updateResult","failureMessages","getEntityUpdateResultsErrorMessages","join","rowsUpdatedStr","rowsProcessed","toLocaleString","updateResults","filter","failureCode","r","entityId","failureMessage"],"sources":["../../../src/components/DataGrid/SyncGridWithSourceButton.tsx"],"sourcesContent":["import GridMenuButton from '@/components/DataGrid/components/GridMenuButton/GridMenuButton'\nimport useMergeGridWithSource, {\n MergeGridWithSource,\n} from '@/components/DataGrid/useMergeGridWithSource'\nimport { displayToast } from '@/components/index'\nimport { useGetEntity } from '@/synapse-queries'\nimport { useGetSchemaBinding } from '@/synapse-queries/jsonschema/useEntityBoundSchema'\nimport { useGetFeatureFlag } from '@/synapse-queries/featureflags'\nimport { FeatureFlagEnum } from '@/utils/featureflag/FeatureFlags'\nimport { convertToEntityType } from '@/utils/functions/EntityTypeUtils'\nimport { CloudDownloadTwoTone, CloudSyncTwoTone } from '@mui/icons-material'\nimport { Skeleton, Tooltip } from '@mui/material'\nimport {\n Entity,\n EntityType,\n EntityUpdateResults,\n GridSession,\n instanceOfEntityUpdateResults,\n instanceOfRecordSet,\n instanceOfUploadToTableResult,\n JsonSchemaObjectBinding,\n SynchronizeGridResponse,\n TableUpdateTransactionResponse,\n} from '@sage-bionetworks/synapse-client'\nimport { SyncType } from '@sage-bionetworks/synapse-client/generated/models/SyncType'\n\nexport type SyncGridWithSourceButtonProps = {\n gridSession: GridSession\n}\n\nexport default function SyncGridWithSourceButton(\n props: SyncGridWithSourceButtonProps,\n) {\n const { gridSession } = props\n\n const { data: entity, isLoading: entityLoading } = useGetEntity(\n gridSession.sourceEntityId,\n )\n\n const { data: sourceEntitySchemaBinding, isLoading: schemaBindingIsLoading } =\n useGetSchemaBinding(gridSession.sourceEntityId ?? '', {\n enabled: !!gridSession.sourceEntityId,\n })\n\n const sourceEntityType = entity?.concreteType\n ? convertToEntityType(entity.concreteType)\n : undefined\n\n const enableRecordSetSync = useGetFeatureFlag(\n FeatureFlagEnum.ENABLE_RECORDSET_SYNCHRONIZATION,\n )\n\n const { mutate: mergeGrid, isPending } = useMergeGridWithSource({\n onSuccess: (result, variables) => {\n switch (result.type) {\n case 'synchronize':\n onSynchronizeSuccess(result.data, variables.syncType)\n break\n case 'tableUpdateTransaction':\n onMergeTableSuccess(result.data)\n break\n case 'recordset_overwrite':\n displayToast('Successfully updated RecordSet.', 'success')\n break\n default:\n result satisfies never\n }\n },\n onError: e => displayToast(e.message, 'danger'),\n })\n\n // At this time, only RecordSet sync supports PULL.\n // If the RecordSet source or JSON Schema has been updated since this grid was created,\n // we have the user PULL the latest changes before enabling a full PULL_PUSH, so they\n // have an opportunity to handle and fix unexpected merge outcomes.\n const shouldPull =\n enableRecordSetSync &&\n entity !== undefined &&\n sourceEntitySchemaBinding !== undefined &&\n shouldPullBeforePush(gridSession, entity, sourceEntitySchemaBinding)\n\n const { buttonText, tooltipText } = getSyncButtonLabels(\n shouldPull,\n sourceEntityType,\n enableRecordSetSync,\n )\n\n const isLoadingPrerequisiteData = entityLoading || schemaBindingIsLoading\n\n if (isLoadingPrerequisiteData) {\n return <Skeleton width=\"100px\" />\n }\n\n return (\n <Tooltip title={tooltipText} describeChild>\n <GridMenuButton\n startIcon={shouldPull ? <CloudDownloadTwoTone /> : <CloudSyncTwoTone />}\n loading={isPending}\n onClick={() => {\n mergeGrid(\n buildMergeGridVariables(gridSession, sourceEntityType, shouldPull),\n )\n }}\n variant=\"contained\"\n >\n {buttonText}\n </GridMenuButton>\n </Tooltip>\n )\n}\n\n/**\n * If the source data or JSON Schema has been updated since this grid was created, we have\n * the user PULL the latest changes before enabling a full PULL_PUSH, so they have an\n * opportunity to handle unexpected merge outcomes.\n *\n * This only applies to source types that support the PULL SyncType.\n *\n * @param gridSession The grid session to check.\n * @param sourceEntity The source entity to check.\n * @param sourceEntitySchemaBinding The source entity's schema binding to check.\n * @returns True if the user should PULL before PULL_PUSH, false otherwise.\n */\nexport function shouldPullBeforePush(\n gridSession: GridSession,\n sourceEntity: Entity | null,\n sourceEntitySchemaBinding: JsonSchemaObjectBinding | null,\n): boolean {\n // Currently, only RecordSet supports PULL\n const isPullSupported =\n sourceEntity != null && instanceOfRecordSet(sourceEntity)\n if (!isPullSupported) {\n return false\n }\n\n // Guide the user to PULL first if the source was updated since the grid was\n // created/synced, or if the JSON Schema binding has updated.\n const isSourceEntityUpdated =\n gridSession.sourceEntityVersionNumber != null &&\n sourceEntity.versionNumber != null &&\n gridSession.sourceEntityVersionNumber < sourceEntity.versionNumber\n\n const isSchemaBindingUpdated =\n sourceEntitySchemaBinding != null &&\n gridSession.gridJsonSchema$Id !==\n sourceEntitySchemaBinding.jsonSchemaVersionInfo?.$id\n\n return isSourceEntityUpdated || isSchemaBindingUpdated\n}\n\n/**\n * Determines the button label and tooltip copy for the sync button based on whether the\n * user should PULL before PULL_PUSH, and the source entity's type.\n */\nexport function getSyncButtonLabels(\n shouldPull: boolean,\n sourceEntityType: EntityType | undefined,\n enableRecordSetSync: boolean,\n): { buttonText: string; tooltipText: string } {\n if (shouldPull) {\n return {\n buttonText: 'Import latest changes',\n tooltipText:\n 'Imports any recent changes into this Curator session. Your changes will not yet be applied.',\n }\n }\n if (\n sourceEntityType === EntityType.table ||\n (sourceEntityType === EntityType.recordset && !enableRecordSetSync)\n ) {\n return {\n buttonText: 'Apply changes',\n tooltipText:\n 'Applies any changes made in this Curator session to the source',\n }\n }\n return {\n buttonText: 'Sync changes',\n tooltipText:\n 'Applies any changes made in this Curator session, and imports any recent changes into this Curator session.',\n }\n}\n\n/**\n * Builds the variables passed to the merge grid mutation for the given grid session,\n * source entity type, and whether the user should PULL before PULL_PUSH.\n */\nexport function buildMergeGridVariables(\n gridSession: GridSession,\n sourceEntityType: EntityType | undefined,\n shouldPull: boolean,\n): MergeGridWithSource {\n return {\n gridSessionId: gridSession.sessionId!,\n sourceEntityId: gridSession.sourceEntityId!,\n sourceEntityType,\n syncType: shouldPull ? 'PULL' : 'PULL_PUSH',\n }\n}\n\nexport function onSynchronizeSuccess(\n result: SynchronizeGridResponse,\n syncType?: SyncType,\n) {\n if (result.errorMessages == null || result.errorMessages.length === 0) {\n if (syncType === 'PULL') {\n displayToast('Successfully imported latest changes.', 'success')\n } else {\n displayToast('Successfully synchronized changes.', 'success')\n }\n } else {\n displayToast(\n <ul>\n {result.errorMessages.map((msg, index) => (\n <li key={index}>{msg}</li>\n ))}\n </ul>,\n 'warning',\n { title: 'Some changes could not be applied' },\n )\n }\n}\n\nfunction onMergeTableSuccess(result: TableUpdateTransactionResponse) {\n if (result.results?.length) {\n // There should only be one result since the CSV upload is done in one step\n const updateResult = result.results[0]\n if (instanceOfEntityUpdateResults(updateResult)) {\n // This is an update to the contents of a View\n const failureMessages =\n getEntityUpdateResultsErrorMessages(updateResult).join('\\n')\n\n if (failureMessages) {\n displayToast(\n `Some changes could not be applied:\\n${failureMessages}`,\n 'danger',\n )\n } else {\n displayToast('Changes applied successfully', 'success')\n }\n } else if (instanceOfUploadToTableResult(updateResult)) {\n // This is an update to a TableEntity\n const rowsUpdatedStr = updateResult.rowsProcessed?.toLocaleString()\n displayToast(`Successfully updated ${rowsUpdatedStr} rows.`, 'success')\n }\n }\n}\n\nfunction getEntityUpdateResultsErrorMessages(\n results: EntityUpdateResults,\n): string[] {\n return (\n results.updateResults\n ?.filter(e => !!e.failureCode)\n .map(\n r => `${r.entityId}: ${r.failureMessage} (code: ${r.failureCode})`,\n ) ?? []\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA8BA,SAAe0B,EAAAC,GAAA;CAAA,IAAAC,IAAAC,EAAA,EAAA,GAGb,EAAAJ,mBAAwBE,GAExB,EAAAG,MA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B4E,CAAY,GAAG;GAEtD,IAAMI,IAAiBJ,EAAaK,eAAeC,eAAe;GAClElG,EAAa,wBAAwBgG,EAAc,SAAU,SAAS;EACxE;CACF;AACF;AAEA,SAASF,EACPH,GACU;CACV,OACEA,EAAQQ,eACJC,QAAOrC,MAAK,CAAC,CAACA,EAAEsC,WAAW,EAC5Bd,KACCe,MAAK,GAAGA,EAAEC,SAAQ,IAAKD,EAAEE,eAAc,UAAWF,EAAED,YAAW,EACjE,KAAK,CAAA;AAEX"}
|
|
1
|
+
{"version":3,"file":"SyncGridWithSourceButton.js","names":["GridMenuButton","useMergeGridWithSource","MergeGridWithSource","displayToast","useGetEntity","useGetSchemaBinding","convertToEntityType","CloudDownloadTwoTone","CloudSyncTwoTone","Skeleton","Tooltip","Entity","EntityType","EntityUpdateResults","GridSession","instanceOfEntityUpdateResults","instanceOfRecordSet","instanceOfUploadToTableResult","JsonSchemaObjectBinding","SynchronizeGridResponse","TableUpdateTransactionResponse","SyncType","SyncGridWithSourceButtonProps","gridSession","SyncGridWithSourceButton","props","$","_c","data","entity","isLoading","entityLoading","sourceEntityId","t0","t1","enabled","sourceEntitySchemaBinding","schemaBindingIsLoading","sourceEntityType","concreteType","undefined","t2","Symbol","for","onSuccess","_temp","onError","_temp2","mutate","mergeGrid","isPending","shouldPull","shouldPullBeforePush","buttonText","tooltipText","getSyncButtonLabels","isLoadingPrerequisiteData","t3","t4","buildMergeGridVariables","t5","t6","e","message","result","variables","bb14","type","onSynchronizeSuccess","syncType","onMergeTableSuccess","sourceEntity","isPullSupported","isSourceEntityUpdated","sourceEntityVersionNumber","versionNumber","isSchemaBindingUpdated","gridJsonSchema$Id","jsonSchemaVersionInfo","$id","table","gridSessionId","sessionId","errorMessages","length","map","msg","index","title","results","updateResult","failureMessages","getEntityUpdateResultsErrorMessages","join","rowsUpdatedStr","rowsProcessed","toLocaleString","updateResults","filter","failureCode","r","entityId","failureMessage"],"sources":["../../../src/components/DataGrid/SyncGridWithSourceButton.tsx"],"sourcesContent":["import GridMenuButton from '@/components/DataGrid/components/GridMenuButton/GridMenuButton'\nimport useMergeGridWithSource, {\n MergeGridWithSource,\n} from '@/components/DataGrid/useMergeGridWithSource'\nimport { displayToast } from '@/components/index'\nimport { useGetEntity } from '@/synapse-queries'\nimport { useGetSchemaBinding } from '@/synapse-queries/jsonschema/useEntityBoundSchema'\nimport { convertToEntityType } from '@/utils/functions/EntityTypeUtils'\nimport { CloudDownloadTwoTone, CloudSyncTwoTone } from '@mui/icons-material'\nimport { Skeleton, Tooltip } from '@mui/material'\nimport {\n Entity,\n EntityType,\n EntityUpdateResults,\n GridSession,\n instanceOfEntityUpdateResults,\n instanceOfRecordSet,\n instanceOfUploadToTableResult,\n JsonSchemaObjectBinding,\n SynchronizeGridResponse,\n TableUpdateTransactionResponse,\n} from '@sage-bionetworks/synapse-client'\nimport { SyncType } from '@sage-bionetworks/synapse-client/generated/models/SyncType'\n\nexport type SyncGridWithSourceButtonProps = {\n gridSession: GridSession\n}\n\nexport default function SyncGridWithSourceButton(\n props: SyncGridWithSourceButtonProps,\n) {\n const { gridSession } = props\n\n const { data: entity, isLoading: entityLoading } = useGetEntity(\n gridSession.sourceEntityId,\n )\n\n const { data: sourceEntitySchemaBinding, isLoading: schemaBindingIsLoading } =\n useGetSchemaBinding(gridSession.sourceEntityId ?? '', {\n enabled: !!gridSession.sourceEntityId,\n })\n\n const sourceEntityType = entity?.concreteType\n ? convertToEntityType(entity.concreteType)\n : undefined\n\n const { mutate: mergeGrid, isPending } = useMergeGridWithSource({\n onSuccess: (result, variables) => {\n switch (result.type) {\n case 'synchronize':\n onSynchronizeSuccess(result.data, variables.syncType)\n break\n case 'tableUpdateTransaction':\n onMergeTableSuccess(result.data)\n break\n default:\n result satisfies never\n }\n },\n onError: e => displayToast(e.message, 'danger'),\n })\n\n // At this time, only RecordSet sync supports PULL.\n // If the RecordSet source or JSON Schema has been updated since this grid was created,\n // we have the user PULL the latest changes before enabling a full PULL_PUSH, so they\n // have an opportunity to handle and fix unexpected merge outcomes.\n const shouldPull =\n entity !== undefined &&\n sourceEntitySchemaBinding !== undefined &&\n shouldPullBeforePush(gridSession, entity, sourceEntitySchemaBinding)\n\n const { buttonText, tooltipText } = getSyncButtonLabels(\n shouldPull,\n sourceEntityType,\n )\n\n const isLoadingPrerequisiteData = entityLoading || schemaBindingIsLoading\n\n if (isLoadingPrerequisiteData) {\n return <Skeleton width=\"100px\" />\n }\n\n return (\n <Tooltip title={tooltipText} describeChild>\n <GridMenuButton\n startIcon={shouldPull ? <CloudDownloadTwoTone /> : <CloudSyncTwoTone />}\n loading={isPending}\n onClick={() => {\n mergeGrid(\n buildMergeGridVariables(gridSession, sourceEntityType, shouldPull),\n )\n }}\n variant=\"contained\"\n >\n {buttonText}\n </GridMenuButton>\n </Tooltip>\n )\n}\n\n/**\n * If the source data or JSON Schema has been updated since this grid was created, we have\n * the user PULL the latest changes before enabling a full PULL_PUSH, so they have an\n * opportunity to handle unexpected merge outcomes.\n *\n * This only applies to source types that support the PULL SyncType.\n *\n * @param gridSession The grid session to check.\n * @param sourceEntity The source entity to check.\n * @param sourceEntitySchemaBinding The source entity's schema binding to check.\n * @returns True if the user should PULL before PULL_PUSH, false otherwise.\n */\nexport function shouldPullBeforePush(\n gridSession: GridSession,\n sourceEntity: Entity | null,\n sourceEntitySchemaBinding: JsonSchemaObjectBinding | null,\n): boolean {\n // Currently, only RecordSet supports PULL\n const isPullSupported =\n sourceEntity != null && instanceOfRecordSet(sourceEntity)\n if (!isPullSupported) {\n return false\n }\n\n // Guide the user to PULL first if the source was updated since the grid was\n // created/synced, or if the JSON Schema binding has updated.\n const isSourceEntityUpdated =\n gridSession.sourceEntityVersionNumber != null &&\n sourceEntity.versionNumber != null &&\n gridSession.sourceEntityVersionNumber < sourceEntity.versionNumber\n\n const isSchemaBindingUpdated =\n sourceEntitySchemaBinding != null &&\n gridSession.gridJsonSchema$Id !==\n sourceEntitySchemaBinding.jsonSchemaVersionInfo?.$id\n\n return isSourceEntityUpdated || isSchemaBindingUpdated\n}\n\n/**\n * Determines the button label and tooltip copy for the sync button based on whether the\n * user should PULL before PULL_PUSH, and the source entity's type.\n */\nexport function getSyncButtonLabels(\n shouldPull: boolean,\n sourceEntityType: EntityType | undefined,\n): { buttonText: string; tooltipText: string } {\n if (shouldPull) {\n return {\n buttonText: 'Import latest changes',\n tooltipText:\n 'Imports any recent changes into this Curator session. Your changes will not yet be applied.',\n }\n }\n if (sourceEntityType === EntityType.table) {\n return {\n buttonText: 'Apply changes',\n tooltipText:\n 'Applies any changes made in this Curator session to the source',\n }\n }\n return {\n buttonText: 'Sync changes',\n tooltipText:\n 'Applies any changes made in this Curator session, and imports any recent changes into this Curator session.',\n }\n}\n\n/**\n * Builds the variables passed to the merge grid mutation for the given grid session,\n * source entity type, and whether the user should PULL before PULL_PUSH.\n */\nexport function buildMergeGridVariables(\n gridSession: GridSession,\n sourceEntityType: EntityType | undefined,\n shouldPull: boolean,\n): MergeGridWithSource {\n return {\n gridSessionId: gridSession.sessionId!,\n sourceEntityId: gridSession.sourceEntityId!,\n sourceEntityType,\n syncType: shouldPull ? 'PULL' : 'PULL_PUSH',\n }\n}\n\nexport function onSynchronizeSuccess(\n result: SynchronizeGridResponse,\n syncType?: SyncType,\n) {\n if (result.errorMessages == null || result.errorMessages.length === 0) {\n if (syncType === 'PULL') {\n displayToast('Successfully imported latest changes.', 'success')\n } else {\n displayToast('Successfully synchronized changes.', 'success')\n }\n } else {\n displayToast(\n <ul>\n {result.errorMessages.map((msg, index) => (\n <li key={index}>{msg}</li>\n ))}\n </ul>,\n 'warning',\n { title: 'Some changes could not be applied' },\n )\n }\n}\n\nfunction onMergeTableSuccess(result: TableUpdateTransactionResponse) {\n if (result.results?.length) {\n // There should only be one result since the CSV upload is done in one step\n const updateResult = result.results[0]\n if (instanceOfEntityUpdateResults(updateResult)) {\n // This is an update to the contents of a View\n const failureMessages =\n getEntityUpdateResultsErrorMessages(updateResult).join('\\n')\n\n if (failureMessages) {\n displayToast(\n `Some changes could not be applied:\\n${failureMessages}`,\n 'danger',\n )\n } else {\n displayToast('Changes applied successfully', 'success')\n }\n } else if (instanceOfUploadToTableResult(updateResult)) {\n // This is an update to a TableEntity\n const rowsUpdatedStr = updateResult.rowsProcessed?.toLocaleString()\n displayToast(`Successfully updated ${rowsUpdatedStr} rows.`, 'success')\n }\n }\n}\n\nfunction getEntityUpdateResultsErrorMessages(\n results: EntityUpdateResults,\n): string[] {\n return (\n results.updateResults\n ?.filter(e => !!e.failureCode)\n .map(\n r => `${r.entityId}: ${r.failureMessage} (code: ${r.failureCode})`,\n ) ?? []\n )\n}\n"],"mappings":";;;;;;;;;;;;;;AA4BA,SAAewB,EAAAC,GAAA;CAAA,IAAAC,IAAAC,EAAA,EAAA,GAGb,EAAAJ,mBAAwBE,GAExB,EAAAG,MAAAC,GAAAC,WAAAC,MAAmD3B,EACjDmB,EAAWS,cACb,GAIaC,IAAA,CAAC,CAACV,EAAWS,gBAAeE;CAAA,AAAAR,EAAA,OAAAO,IACtCC,IAAAR,EAAA,MAFqDQ,IAAA,EAAAC,SAC3CF,EACX,GAACP,EAAA,KAAAO,GAAAP,EAAA,KAAAQ;CAHH,IAAA,EAAAN,MAAAQ,GAAAN,WAAAO,MACEhC,EAAoBkB,EAAWS,kBAAX,IAAkCE,CAErD,GAEHI,IAAyBT,GAAMU,eAC3BjC,EAAoBuB,EAAMU,YAClB,IAFaC,KAAAA,GAEZC;CAAA,AAAAf,EAAA,OAAAgB,OAAAC,IAAA,2BAAA,KAEmDF,IAAA;EAAAG,WACnDC;EAWVC,SACQC;CACX,GAACrB,EAAA,KAAAe,KAAAA,IAAAf,EAAA;CAdD,IAAA,EAAAsB,QAAAC,GAAAC,iBAAyCjD,EAAuBwC,CAc/D,GAMDU,IACEtB,MAAWW,KAAAA,KACXJ,MAA8BI,KAAAA,KAC9BY,EAAqB7B,GAAaM,GAAQO,CAAyB,GAErE,EAAAiB,eAAAC,mBAAoCC,EAClCJ,GACAb,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CAC1B,EACC,CAAA,GACJ,WACA,EAAEC,OAAO,oCAAoC,CAC/C;AAEJ;AAEA,SAASlB,EAAoBN,GAAwC;CACnE,IAAIA,EAAOyB,SAASL,QAAQ;EAE1B,IAAMM,IAAe1B,EAAOyB,QAAQ;EACpC,IAAI1E,EAA8B2E,CAAY,GAAG;GAE/C,IAAMC,IACJC,EAAoCF,CAAY,EAAEG,KAAK,IAAI;GAE7D,AAAIF,IACFxF,EACE,uCAAuCwF,KACvC,QACF,IAEAxF,EAAa,gCAAgC,SAAS;EAE1D,OAAO,IAAIc,EAA8ByE,CAAY,GAAG;GAEtD,IAAMI,IAAiBJ,EAAaK,eAAeC,eAAe;GAClE7F,EAAa,wBAAwB2F,EAAc,SAAU,SAAS;EACxE;CACF;AACF;AAEA,SAASF,EACPH,GACU;CACV,OACEA,EAAQQ,eACJC,QAAOpC,MAAK,CAAC,CAACA,EAAEqC,WAAW,EAC5Bd,KACCe,MAAK,GAAGA,EAAEC,SAAQ,IAAKD,EAAEE,eAAc,UAAWF,EAAED,YAAW,EACjE,KAAK,CAAA;AAEX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextMenu.d.ts","sourceRoot":"","sources":["../../../../src/components/DataGrid/components/contextMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,aAAa,EACd,MAAM,wCAAwC,CAAA;
|
|
1
|
+
{"version":3,"file":"contextMenu.d.ts","sourceRoot":"","sources":["../../../../src/components/DataGrid/components/contextMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,aAAa,EACd,MAAM,wCAAwC,CAAA;AAoD/C,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,cAAc,CACvD,OAAO,aAAa,CACrB,CAAC,kBAAkB,CAA4C,CAAA;AAEhE,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,cAAc,CACtD,OAAO,aAAa,CACrB,CAAC,sBAAsB,CAAoD,CAAA;AAE5E,eAAO,MAAM,0BAA0B,EAAE,KAAK,CAAC,cAAc,CAC3D,OAAO,aAAa,CACrB,CAAC,sBAAsB,CAEvB,CAAA"}
|
|
@@ -6,28 +6,28 @@ var a = [
|
|
|
6
6
|
"COPY",
|
|
7
7
|
"PASTE",
|
|
8
8
|
"CUT"
|
|
9
|
-
], o = r(), s =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}, c =
|
|
9
|
+
], o = r(), s = {
|
|
10
|
+
COPY: "Copy",
|
|
11
|
+
PASTE: "Paste",
|
|
12
|
+
CUT: "Cut",
|
|
13
|
+
INSERT_ROW_BELLOW: "Insert row below",
|
|
14
|
+
DELETE_ROW: "Delete row",
|
|
15
|
+
DUPLICATE_ROW: "Duplicate row",
|
|
16
|
+
DELETE_ROWS: "Delete rows",
|
|
17
|
+
DUPLICATE_ROWS: "Duplicate rows"
|
|
18
|
+
}, c = (n) => /* @__PURE__ */ t(e, { children: s[n.type] }), l = i(c), u = i(c), d = (e) => {
|
|
19
19
|
let r = n(5), i;
|
|
20
|
-
r[0] === e.items ? i = r[1] : (i = e.items.filter(
|
|
20
|
+
r[0] === e.items ? i = r[1] : (i = e.items.filter(h), r[0] = e.items, r[1] = i);
|
|
21
21
|
let a = i, o;
|
|
22
|
-
return r[2] !== a || r[3] !== e ? (o = /* @__PURE__ */ t(
|
|
22
|
+
return r[2] !== a || r[3] !== e ? (o = /* @__PURE__ */ t(l, {
|
|
23
23
|
...e,
|
|
24
24
|
items: a
|
|
25
25
|
}), r[2] = a, r[3] = e, r[4] = o) : o = r[4], o;
|
|
26
|
-
},
|
|
27
|
-
function
|
|
26
|
+
}, f = (e) => /* @__PURE__ */ t(o, { ...e }), p = (e) => /* @__PURE__ */ t(d, { ...e }), m = (e) => /* @__PURE__ */ t(u, { ...e });
|
|
27
|
+
function h(e) {
|
|
28
28
|
return a.includes(e.type);
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
|
-
export {
|
|
31
|
+
export { f as renderAddRowsComponent, m as renderRecordSetContextMenu, p as renderViewContextMenu };
|
|
32
32
|
|
|
33
33
|
//# sourceMappingURL=contextMenu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextMenu.js","names":["createAddRowsComponent","createContextMenuComponent","ContextMenuItem","DataSheetGrid","VIEW_ALLOWED_MENU_ITEMS","AddRowsComponent","renderContextMenuItem","item","type","
|
|
1
|
+
{"version":3,"file":"contextMenu.js","names":["createAddRowsComponent","createContextMenuComponent","ContextMenuItem","DataSheetGrid","VIEW_ALLOWED_MENU_ITEMS","AddRowsComponent","CONTEXT_MENU_ITEM_LABELS","Record","COPY","PASTE","CUT","INSERT_ROW_BELLOW","DELETE_ROW","DUPLICATE_ROW","DELETE_ROWS","DUPLICATE_ROWS","renderContextMenuItem","item","type","BaseViewContextMenuComponent","RecordSetContextMenuComponent","ViewContextMenuComponent","React","FC","ComponentProps","props","$","_c","t0","items","filter","_temp","filteredItems","t1","renderAddRowsComponent","renderViewContextMenu","renderRecordSetContextMenu","includes"],"sources":["../../../../src/components/DataGrid/components/contextMenu.tsx"],"sourcesContent":["import {\n createAddRowsComponent,\n createContextMenuComponent,\n ContextMenuItem,\n DataSheetGrid,\n} from '@sage-bionetworks/react-datasheet-grid'\n\n// Define which context menu items are allowed for tables (a subset)\nconst VIEW_ALLOWED_MENU_ITEMS: ContextMenuItem['type'][] = [\n 'COPY',\n 'PASTE',\n 'CUT',\n]\n\n// Create components outside of render to avoid recreating on every render\nconst AddRowsComponent = createAddRowsComponent()\n\n// Keyed by the full item type union, so adding a new item type upstream is a\n// compile error here rather than a menu entry that silently renders nothing.\nconst CONTEXT_MENU_ITEM_LABELS: Record<ContextMenuItem['type'], string> = {\n COPY: 'Copy',\n PASTE: 'Paste',\n CUT: 'Cut',\n INSERT_ROW_BELLOW: 'Insert row below',\n DELETE_ROW: 'Delete row',\n DUPLICATE_ROW: 'Duplicate row',\n DELETE_ROWS: 'Delete rows',\n DUPLICATE_ROWS: 'Duplicate rows',\n}\n\n// Shared render function for context menu items\nconst renderContextMenuItem = (item: ContextMenuItem) => (\n <>{CONTEXT_MENU_ITEM_LABELS[item.type]}</>\n)\n\n// Create base context menus (copy/cut/paste for recordSet, default for views)\nconst BaseViewContextMenuComponent = createContextMenuComponent(\n renderContextMenuItem,\n)\n\nconst RecordSetContextMenuComponent = createContextMenuComponent(\n renderContextMenuItem,\n)\n\n// Create a wrapper component that filters items for views\nconst ViewContextMenuComponent: React.FC<\n React.ComponentProps<typeof BaseViewContextMenuComponent>\n> = props => {\n // Filter the items to only include allowed ones for views\n const filteredItems = props.items.filter(item =>\n VIEW_ALLOWED_MENU_ITEMS.includes(item.type),\n )\n\n return <BaseViewContextMenuComponent {...props} items={filteredItems} />\n}\n\n// Create stable render functions outside the component\nexport const renderAddRowsComponent: React.ComponentProps<\n typeof DataSheetGrid\n>['addRowsComponent'] = props => <AddRowsComponent {...props} />\n\nexport const renderViewContextMenu: React.ComponentProps<\n typeof DataSheetGrid\n>['contextMenuComponent'] = props => <ViewContextMenuComponent {...props} />\n\nexport const renderRecordSetContextMenu: React.ComponentProps<\n typeof DataSheetGrid\n>['contextMenuComponent'] = props => (\n <RecordSetContextMenuComponent {...props} />\n)\n"],"mappings":";;;;AAQA,IAAMI,IAAqD;CACzD;CACA;CACA;AAAK,GAIDC,IAAmBL,EAAuB,GAI1CM,IAAoE;CACxEE,MAAM;CACNC,OAAO;CACPC,KAAK;CACLC,mBAAmB;CACnBC,YAAY;CACZC,eAAe;CACfC,aAAa;CACbC,gBAAgB;AAClB,GAGMC,KAAyBC,MAC7B,kBAAA,GAAA,EAAA,UAAGX,EAAyBW,EAAKC,MAAM,CAAA,GAInCC,IAA+BlB,EACnCe,CACF,GAEMI,IAAgCnB,EACpCe,CACF,GAGMK,KAEFI,MAAA;CAAA,IAAAC,IAAAC,EAAA,CAAA,GAAAC;CAAA,AAAAF,EAAA,OAAAD,EAAAI,QAIDD,IAAAF,EAAA,MAFqBE,IAAAH,EAAKI,MAAMC,OAAQC,CAEzC,GAACL,EAAA,KAAAD,EAAAI,OAAAH,EAAA,KAAAE;CAFD,IAAAI,IAAsBJ,GAErBK;CAEuE,OAFvEP,EAAA,OAAAM,KAAAN,EAAA,OAAAD,KAEMQ,IAAA,kBAAC,GAAD;EAA6B,GAAKR;EAAcO,OAAAA;CAAa,CAAA,GAAIN,EAAA,KAAAM,GAAAN,EAAA,KAAAD,GAAAC,EAAA,KAAAO,KAAAA,IAAAP,EAAA,IAAjEO;AAAiE,GAI7DC,KAEWT,MAAS,kBAAC,GAAD,EAAkB,GAAIA,EAAM,CAAA,GAEhDU,KAEeV,MAAS,kBAAC,GAAD,EAA0B,GAAIA,EAAM,CAAA,GAE5DW,KAEeX,MAC1B,kBAAC,GAAD,EAA+B,GAAIA,EAAM,CAAA;AArBvC,SAAAM,EAAAd,GAAA;CAAA,OAGAb,EAAuBiC,SAAUpB,EAAIC,IAAK;AAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EntityType,
|
|
1
|
+
import { EntityType, SynchronizeGridResponse, SyncType, TableUpdateTransactionResponse } from '@sage-bionetworks/synapse-client';
|
|
2
2
|
import { UseMutationOptions } from '@tanstack/react-query';
|
|
3
3
|
import { SynapseClientError } from '@sage-bionetworks/synapse-client';
|
|
4
4
|
export type MergeGridWithSource = {
|
|
@@ -14,10 +14,6 @@ export type MergeGridWithSource = {
|
|
|
14
14
|
export type MergeGridResult = {
|
|
15
15
|
type: 'synchronize';
|
|
16
16
|
data: SynchronizeGridResponse;
|
|
17
|
-
} | {
|
|
18
|
-
/** @deprecated */
|
|
19
|
-
type: 'recordset_overwrite';
|
|
20
|
-
data: GridRecordSetExportResponse;
|
|
21
17
|
} | {
|
|
22
18
|
type: 'tableUpdateTransaction';
|
|
23
19
|
data: TableUpdateTransactionResponse;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMergeGridWithSource.d.ts","sourceRoot":"","sources":["../../../src/components/DataGrid/useMergeGridWithSource.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,
|
|
1
|
+
{"version":3,"file":"useMergeGridWithSource.d.ts","sourceRoot":"","sources":["../../../src/components/DataGrid/useMergeGridWithSource.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,uBAAuB,EACvB,QAAQ,EACR,8BAA8B,EAC/B,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAe,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAGrE,MAAM,MAAM,mBAAmB,GAAG;IAChC,kEAAkE;IAClE,aAAa,EAAE,MAAM,CAAA;IACrB,0FAA0F;IAC1F,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,8EAA8E;IAC9E,gBAAgB,CAAC,EAAE,UAAU,CAAA;IAC7B,yGAAyG;IACzG,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,IAAI,EAAE,uBAAuB,CAAA;CAAE,GACtD;IACE,IAAI,EAAE,wBAAwB,CAAA;IAC9B,IAAI,EAAE,8BAA8B,CAAA;CACrC,CAAA;AAEL;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,OAAO,CAAC,EAAE,IAAI,CACZ,kBAAkB,CAChB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,CACpB,EACD,YAAY,CACb,wHA8BF"}
|
|
@@ -1,41 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import i from "./useMergeGridWithRecordSet.js";
|
|
7
|
-
import { EntityType as a } from "@sage-bionetworks/synapse-client";
|
|
8
|
-
import { useMutation as o } from "@tanstack/react-query";
|
|
9
|
-
import { c as s } from "react/compiler-runtime";
|
|
1
|
+
import { useSynchronizeGridSession as e } from "../../synapse-queries/grid/useGridSession.js";
|
|
2
|
+
import t from "./useMergeGridWithTable.js";
|
|
3
|
+
import { EntityType as n } from "@sage-bionetworks/synapse-client";
|
|
4
|
+
import { useMutation as r } from "@tanstack/react-query";
|
|
5
|
+
import { c as i } from "react/compiler-runtime";
|
|
10
6
|
//#region src/components/DataGrid/useMergeGridWithSource.ts
|
|
11
|
-
function
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
let { gridSessionId: t, sourceEntityId:
|
|
15
|
-
return o ||
|
|
7
|
+
function a(a) {
|
|
8
|
+
let o = i(6), s = e(), c = t(), l;
|
|
9
|
+
o[0] !== c || o[1] !== s ? (l = async (e) => {
|
|
10
|
+
let { gridSessionId: t, sourceEntityId: r, sourceEntityType: i, syncType: a } = e, o = i === n.entityview, l = i === n.recordset;
|
|
11
|
+
return o || l ? {
|
|
16
12
|
type: "synchronize",
|
|
17
|
-
data: await
|
|
13
|
+
data: await s.mutateAsync({
|
|
18
14
|
gridSessionId: t,
|
|
19
|
-
syncType:
|
|
15
|
+
syncType: a
|
|
20
16
|
})
|
|
21
|
-
} : s ? {
|
|
22
|
-
type: "recordset_overwrite",
|
|
23
|
-
data: await f.mutateAsync({ gridSessionId: t })
|
|
24
17
|
} : {
|
|
25
18
|
type: "tableUpdateTransaction",
|
|
26
|
-
data: await
|
|
19
|
+
data: await c.mutateAsync({
|
|
27
20
|
gridSessionId: t,
|
|
28
|
-
sourceEntityId:
|
|
21
|
+
sourceEntityId: r
|
|
29
22
|
})
|
|
30
23
|
};
|
|
31
|
-
},
|
|
32
|
-
let
|
|
33
|
-
return
|
|
34
|
-
...
|
|
35
|
-
mutationFn:
|
|
36
|
-
},
|
|
24
|
+
}, o[0] = c, o[1] = s, o[2] = l) : l = o[2];
|
|
25
|
+
let u;
|
|
26
|
+
return o[3] !== a || o[4] !== l ? (u = {
|
|
27
|
+
...a,
|
|
28
|
+
mutationFn: l
|
|
29
|
+
}, o[3] = a, o[4] = l, o[5] = u) : u = o[5], r(u);
|
|
37
30
|
}
|
|
38
31
|
//#endregion
|
|
39
|
-
export {
|
|
32
|
+
export { a as default };
|
|
40
33
|
|
|
41
34
|
//# sourceMappingURL=useMergeGridWithSource.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMergeGridWithSource.js","names":["useMergeGridWithTable","EntityType","
|
|
1
|
+
{"version":3,"file":"useMergeGridWithSource.js","names":["useMergeGridWithTable","EntityType","SynchronizeGridResponse","SyncType","TableUpdateTransactionResponse","useMutation","UseMutationOptions","SynapseClientError","useSynchronizeGridSession","MergeGridWithSource","gridSessionId","sourceEntityId","sourceEntityType","syncType","MergeGridResult","type","data","useMergeGridWithSource","options","$","_c","syncGridWithSource","mergeGridWithTable","t0","variables","isEntityView","entityview","isRecordSet","recordset","mutateAsync","data_0","t1","mutationFn"],"sources":["../../../src/components/DataGrid/useMergeGridWithSource.ts"],"sourcesContent":["import useMergeGridWithTable from './useMergeGridWithTable'\nimport {\n EntityType,\n SynchronizeGridResponse,\n SyncType,\n TableUpdateTransactionResponse,\n} from '@sage-bionetworks/synapse-client'\nimport { useMutation, UseMutationOptions } from '@tanstack/react-query'\nimport { SynapseClientError } from '@sage-bionetworks/synapse-client'\nimport { useSynchronizeGridSession } from '@/synapse-queries/grid/useGridSession'\n\nexport type MergeGridWithSource = {\n /** The ID of the grid session to merge with the source entity. */\n gridSessionId: string\n /** The ID of the source entity to merge with. This is only used for client-side logic. */\n sourceEntityId?: string\n /** The type of the source entity. This is only used for client-side logic. */\n sourceEntityType?: EntityType\n /** The type of synchronization to perform. Only valid for types supported by the Synchronize service. */\n syncType?: SyncType\n}\n\nexport type MergeGridResult =\n | { type: 'synchronize'; data: SynchronizeGridResponse }\n | {\n type: 'tableUpdateTransaction'\n data: TableUpdateTransactionResponse\n }\n\n/**\n * Single entrypoint to handle merging grid edits with source Synapse data.\n * Calls the appropriate mutation based on entity type:\n * - EntityView/RecordSet -> useSynchronizeGridSession\n * - TableEntity -> useMergeGridWithTable\n *\n * Returns a query mutation that handles synchronization.\n */\nexport default function useMergeGridWithSource(\n options?: Omit<\n UseMutationOptions<\n MergeGridResult,\n SynapseClientError,\n MergeGridWithSource\n >,\n 'mutationFn'\n >,\n) {\n // SynchronizeGridSession is the best option, but not all types are supported.\n // As support for other types is added, the other hooks should be replaced.\n const syncGridWithSource = useSynchronizeGridSession()\n const mergeGridWithTable = useMergeGridWithTable()\n\n return useMutation<MergeGridResult, SynapseClientError, MergeGridWithSource>({\n ...options,\n mutationFn: async variables => {\n const { gridSessionId, sourceEntityId, sourceEntityType, syncType } =\n variables\n const isEntityView = sourceEntityType === EntityType.entityview\n const isRecordSet = sourceEntityType === EntityType.recordset\n\n if (isEntityView || isRecordSet) {\n const data = await syncGridWithSource.mutateAsync({\n gridSessionId,\n syncType,\n })\n return { type: 'synchronize', data }\n } else {\n const data = await mergeGridWithTable.mutateAsync({\n gridSessionId,\n sourceEntityId: sourceEntityId!,\n })\n return { type: 'tableUpdateTransaction', data }\n }\n },\n })\n}\n"],"mappings":";;;;;;AAqCA,SAAeiB,EAAAC,GAAA;CAAA,IAAAC,IAAAC,EAAA,CAAA,GAYbC,IAA2Bb,EAA0B,GACrDc,IAA2BtB,EAAsB,GAACuB;CAAA,AAAAJ,EAAA,OAAAG,KAAAH,EAAA,OAAAE,KAIpCE,IAAA,OAAAC,MAAA;EACV,IAAA,EAAAd,kBAAAC,mBAAAC,qBAAAC,gBACEW,GACFC,IAAqBb,MAAqBX,EAAUyB,YACpDC,IAAoBf,MAAqBX,EAAU2B;EAY/C,OAVAH,KAAAE,IAKK;GAAAZ,MAAQ;GAAaC,MAAAA,MAJTK,EAAkBQ,YAAa;IAAAnB;IAAAG;GAGlD,CAAC;EACkC,IAM5B;GAAAE,MAAQ;GAAwBC,MAAEA,MAJtBM,EAAkBO,YAAa;IAAAnB;IAAAC;GAGlD,CAAC;EAC6C;CAC/C,GACFQ,EAAA,KAAAG,GAAAH,EAAA,KAAAE,GAAAF,EAAA,KAAAI,KAAAA,IAAAJ,EAAA;CAAA,IAAAY;CACF,OADEZ,EAAA,OAAAD,KAAAC,EAAA,OAAAI,KArB0EQ,IAAA;EAAA,GACxEb;EAAOc,YACET;CAoBd,GAACJ,EAAA,KAAAD,GAAAC,EAAA,KAAAI,GAAAJ,EAAA,KAAAY,KAAAA,IAAAZ,EAAA,IAtBMd,EAAsE0B,CAsB5E;AAAC"}
|