synapse-react-client 4.0.17 → 4.0.19
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/README.md +5 -3
- package/dist/SWC.index.d.ts +2 -0
- package/dist/SWC.index.d.ts.map +1 -1
- package/dist/SWC.index.js +3 -1
- package/dist/SWC.index.js.map +1 -1
- package/dist/assets/homepage/BlinkingLiveIcon.d.ts +1 -1
- package/dist/components/AccessRequirementAclEditor/AccessRequirementAclEditor.d.ts.map +1 -1
- package/dist/components/AccessRequirementAclEditor/AccessRequirementAclEditor.js.map +1 -1
- package/dist/components/AccessRequirementList/AccessRequirementList.js.map +1 -1
- package/dist/components/AccessRequirementList/RequirementItem/CertificationRequirement.js.map +1 -1
- package/dist/components/AccessRequirementList/RequirementItem/SelfSignAccessRequirementItem.js.map +1 -1
- package/dist/components/AccessRequirementList/RequirementItem/UnmanagedACTAccessRequirementItem.js.map +1 -1
- package/dist/components/AccessRequirementList/RequirementItem/ValidationRequirement.js.map +1 -1
- package/dist/components/AccessTokenPage/CreateAccessTokenModal.d.ts.map +1 -1
- package/dist/components/AccessTokenPage/CreateAccessTokenModal.js +56 -54
- package/dist/components/AccessTokenPage/CreateAccessTokenModal.js.map +1 -1
- package/dist/components/Authentication/PasswordField.d.ts +1 -1
- package/dist/components/Authentication/PasswordField.d.ts.map +1 -1
- package/dist/components/Authentication/PasswordField.js.map +1 -1
- package/dist/components/Authentication/TwoFactorEnrollmentForm.d.ts.map +1 -1
- package/dist/components/Authentication/TwoFactorEnrollmentForm.js +1 -2
- package/dist/components/Authentication/TwoFactorEnrollmentForm.js.map +1 -1
- package/dist/components/Authentication/UsernamePasswordForm.d.ts.map +1 -1
- package/dist/components/Authentication/UsernamePasswordForm.js +32 -29
- package/dist/components/Authentication/UsernamePasswordForm.js.map +1 -1
- package/dist/components/CardContainer/CardLink.d.ts +2 -2
- package/dist/components/CardContainer/CardLink.d.ts.map +1 -1
- package/dist/components/CardDeck/CardDeckCardProps.d.ts.map +1 -1
- package/dist/components/ChallengeSubmission/SubmissionDirectoryList.js.map +1 -1
- package/dist/components/ChallengeTeamWizard/CreateChallengeTeam.d.ts.map +1 -1
- package/dist/components/ChallengeTeamWizard/CreateChallengeTeam.js +106 -103
- package/dist/components/ChallengeTeamWizard/CreateChallengeTeam.js.map +1 -1
- package/dist/components/ChallengeTeamWizard/MembershipRequestForm.d.ts.map +1 -1
- package/dist/components/ChallengeTeamWizard/MembershipRequestForm.js.map +1 -1
- package/dist/components/ChallengeTeamWizard/useCreateAndRegisterChallengeTeam.d.ts.map +1 -1
- package/dist/components/ChallengeTeamWizard/useCreateAndRegisterChallengeTeam.js.map +1 -1
- package/dist/components/CreateProjectModal/CreateProjectModal.d.ts.map +1 -1
- package/dist/components/CreateProjectModal/CreateProjectModal.js +4 -4
- package/dist/components/CreateProjectModal/CreateProjectModal.js.map +1 -1
- package/dist/components/CreateTableViewWizard/TableNameForm.js +6 -6
- package/dist/components/CreateTableViewWizard/TableNameForm.js.map +1 -1
- package/dist/components/CrispChat/CrispChat.js +4 -4
- package/dist/components/CrispChat/CrispChat.js.map +1 -1
- package/dist/components/DataExplorer/DataExplorer.css +1 -0
- package/dist/components/DataExplorer/DataExplorer.d.ts +13 -0
- package/dist/components/DataExplorer/DataExplorer.d.ts.map +1 -0
- package/dist/components/DataExplorer/DataExplorer.js +119 -0
- package/dist/components/DataExplorer/DataExplorer.js.map +1 -0
- package/dist/components/DataExplorer/DataExplorer.module.js +22 -0
- package/dist/components/DataExplorer/DataExplorer.module.js.map +1 -0
- package/dist/components/DataExplorer/DataExplorer.module.scss +156 -0
- package/dist/components/DataGrid/columns/AutocompleteColumn.d.ts.map +1 -1
- package/dist/components/DataGrid/columns/AutocompleteColumn.js +106 -102
- package/dist/components/DataGrid/columns/AutocompleteColumn.js.map +1 -1
- package/dist/components/DataGrid/columns/AutocompleteMultipleEnumColumn.d.ts.map +1 -1
- package/dist/components/DataGrid/columns/AutocompleteMultipleEnumColumn.js +97 -89
- package/dist/components/DataGrid/columns/AutocompleteMultipleEnumColumn.js.map +1 -1
- package/dist/components/DataGrid/columns/useGridAutocompleteState.d.ts +19 -8
- package/dist/components/DataGrid/columns/useGridAutocompleteState.d.ts.map +1 -1
- package/dist/components/DataGrid/columns/useGridAutocompleteState.js +64 -43
- package/dist/components/DataGrid/columns/useGridAutocompleteState.js.map +1 -1
- package/dist/components/DataGrid/components/UploadCsvToGridDialog.d.ts.map +1 -1
- package/dist/components/DataGrid/components/UploadCsvToGridDialog.js +9 -9
- package/dist/components/DataGrid/components/UploadCsvToGridDialog.js.map +1 -1
- package/dist/components/DataGrid/hooks/useGetSchemaForGrid.d.ts.map +1 -1
- package/dist/components/DataGrid/hooks/useGetSchemaForGrid.js +8 -1
- package/dist/components/DataGrid/hooks/useGetSchemaForGrid.js.map +1 -1
- package/dist/components/DataGrid/utils/json-rx/JsonRxResponseComplete.js.map +1 -1
- package/dist/components/DownloadCart/RequestDownloadCard.js +14 -14
- package/dist/components/DownloadCart/RequestDownloadCard.js.map +1 -1
- package/dist/components/EntityAclEditor/EntityAclEditor.d.ts.map +1 -1
- package/dist/components/EntityAclEditor/EntityAclEditor.js.map +1 -1
- package/dist/components/EntityBadgeIcons/EntityBadgeIcons.d.ts.map +1 -1
- package/dist/components/EntityBadgeIcons/EntityBadgeIcons.js.map +1 -1
- package/dist/components/EntityCitation/EntityCitationUtils.js.map +1 -1
- package/dist/components/EntityDownloadConfirmation/EntityDownloadConfirmation.js.map +1 -1
- package/dist/components/EntityFinder/EntityFinder.js.map +1 -1
- package/dist/components/EntityFinder/EntityIdTextField.d.ts +17 -0
- package/dist/components/EntityFinder/EntityIdTextField.d.ts.map +1 -0
- package/dist/components/EntityFinder/EntityIdTextField.js +35 -0
- package/dist/components/EntityFinder/EntityIdTextField.js.map +1 -0
- package/dist/components/Evaluation/round_limits/EvaluationRoundLimitOptions.d.ts.map +1 -1
- package/dist/components/Evaluation/round_limits/EvaluationRoundLimitOptions.js +22 -16
- package/dist/components/Evaluation/round_limits/EvaluationRoundLimitOptions.js.map +1 -1
- package/dist/components/FeaturedDataTabs/FacetPlotsCardGrid.js.map +1 -1
- package/dist/components/Forum/ForumThreadEditor.js.map +1 -1
- package/dist/components/FullWidthAlert/FullWidthAlert.d.ts.map +1 -1
- package/dist/components/FullWidthAlert/FullWidthAlert.js.map +1 -1
- package/dist/components/GenericCard/PortalDOI/PortalDOIUtils.d.ts.map +1 -1
- package/dist/components/GenericCard/PortalDOI/PortalDOIUtils.js.map +1 -1
- package/dist/components/Markdown/widget/MarkdownSynapsePlot.js.map +1 -1
- package/dist/components/OAuthClientAclEditor/OAuthClientAclEditor.d.ts.map +1 -1
- package/dist/components/OAuthClientAclEditor/OAuthClientAclEditor.js.map +1 -1
- package/dist/components/PortalAclEditor/PortalAclEditor.d.ts.map +1 -1
- package/dist/components/PortalAclEditor/PortalAclEditor.js.map +1 -1
- package/dist/components/PortalHomePageHeader/PortalHomePageHeader.d.ts +1 -1
- package/dist/components/PortalHomePageHeader/PortalHomePageHeader.d.ts.map +1 -1
- package/dist/components/PortalHomePageHeader/PortalHomePageHeader.js +1 -1
- package/dist/components/PortalHomePageHeader/PortalHomePageHeader.js.map +1 -1
- package/dist/components/PortalList/CreatePortalModal.d.ts.map +1 -1
- package/dist/components/PortalList/CreatePortalModal.js +34 -33
- package/dist/components/PortalList/CreatePortalModal.js.map +1 -1
- package/dist/components/QueryVisualizationWrapper/QueryVisualizationWrapper.d.ts.map +1 -1
- package/dist/components/QueryVisualizationWrapper/QueryVisualizationWrapper.js +67 -65
- package/dist/components/QueryVisualizationWrapper/QueryVisualizationWrapper.js.map +1 -1
- package/dist/components/QueryWrapperPlotNav/QueryWrapperPlotNav.d.ts +1 -1
- package/dist/components/QueryWrapperPlotNav/QueryWrapperPlotNav.d.ts.map +1 -1
- package/dist/components/QueryWrapperPlotNav/QueryWrapperPlotNav.js +1 -0
- package/dist/components/QueryWrapperPlotNav/QueryWrapperPlotNav.js.map +1 -1
- package/dist/components/QueryWrapperPlotNav/RowSetView.d.ts.map +1 -1
- package/dist/components/QueryWrapperPlotNav/RowSetView.js.map +1 -1
- package/dist/components/Resources/Resources.Desktop.js.map +1 -1
- package/dist/components/SearchQueryWrapper/SearchQueryUseQueryOptions.js.map +1 -1
- package/dist/components/SearchQueryWrapperPlotNav/SearchQueryWrapperPlotNav.d.ts +1 -1
- package/dist/components/SearchQueryWrapperPlotNav/SearchQueryWrapperPlotNav.d.ts.map +1 -1
- package/dist/components/SearchQueryWrapperPlotNav/SearchQueryWrapperPlotNav.js +1 -0
- package/dist/components/SearchQueryWrapperPlotNav/SearchQueryWrapperPlotNav.js.map +1 -1
- package/dist/components/SetAccessRequirementCommonFields/SetAccessRequirementCommonFields.d.ts.map +1 -1
- package/dist/components/SetAccessRequirementCommonFields/SetAccessRequirementCommonFields.js.map +1 -1
- package/dist/components/SetBasicAccessRequirementFields/SetBasicAccessRequirementFields.d.ts.map +1 -1
- package/dist/components/SetBasicAccessRequirementFields/SetBasicAccessRequirementFields.js.map +1 -1
- package/dist/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.d.ts.map +1 -1
- package/dist/components/SetManagedAccessRequirementFields/SetManagedAccessRequirementFields.js.map +1 -1
- package/dist/components/StandaloneQueryWrapper/StandaloneQueryWrapper.d.ts +1 -1
- package/dist/components/StandaloneQueryWrapper/StandaloneQueryWrapper.d.ts.map +1 -1
- package/dist/components/StandaloneQueryWrapper/StandaloneQueryWrapper.js.map +1 -1
- package/dist/components/SynapseChat/SynapseChatInteraction.js.map +1 -1
- package/dist/components/SynapsePortalBanners/SynapsePortalBanners.d.ts.map +1 -1
- package/dist/components/SynapsePortalBanners/SynapsePortalBanners.js +1 -1
- package/dist/components/SynapsePortalBanners/SynapsePortalBanners.js.map +1 -1
- package/dist/components/SynapseTable/SearchV2.js.map +1 -1
- package/dist/components/SynapseTable/SynapseTable.js.map +1 -1
- package/dist/components/SynapseTable/SynapseTableUtils.d.ts.map +1 -1
- package/dist/components/SynapseTable/SynapseTableUtils.js.map +1 -1
- package/dist/components/SynapseTable/datasets/DatasetItemsEditor.js.map +1 -1
- package/dist/components/TableColumnSchemaEditor/ColumnModelForm.js +9 -9
- package/dist/components/TableColumnSchemaEditor/ColumnModelForm.js.map +1 -1
- package/dist/components/TableColumnSchemaEditor/ColumnModelFormFields/MultiValueField.js +4 -4
- package/dist/components/TableColumnSchemaEditor/TableColumnSchemaForm.d.ts.map +1 -1
- package/dist/components/TableColumnSchemaEditor/TableColumnSchemaForm.js +25 -25
- package/dist/components/TableColumnSchemaEditor/TableColumnSchemaForm.js.map +1 -1
- package/dist/components/TanStackTable/TanStackTableUtils.js.map +1 -1
- package/dist/components/TextField/TextField.css +1 -1
- package/dist/components/TextField/TextField.d.ts +14 -3
- package/dist/components/TextField/TextField.d.ts.map +1 -1
- package/dist/components/TextField/TextField.js +41 -43
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/TextField/TextField.module.js +3 -4
- package/dist/components/TextField/TextField.module.js.map +1 -1
- package/dist/components/TextField/TextField.module.scss +18 -10
- package/dist/components/TimelinePlot/TimelinePlotSpeciesSelector.d.ts.map +1 -1
- package/dist/components/TimelinePlot/TimelinePlotSpeciesSelector.js +20 -16
- package/dist/components/TimelinePlot/TimelinePlotSpeciesSelector.js.map +1 -1
- package/dist/components/UserCardList/UserCardList.d.ts.map +1 -1
- package/dist/components/UserCardList/UserCardList.js.map +1 -1
- package/dist/components/UserCardList/UserCardListGroups/UserCardListGroups.Desktop.js.map +1 -1
- package/dist/components/UserOrTeamBadge/useUserOrTeam.js.map +1 -1
- package/dist/components/UserSearchBox/UserSearchBox.d.ts.map +1 -1
- package/dist/components/UserSearchBox/UserSearchBox.js.map +1 -1
- package/dist/components/WikiMarkdownEditorButton/WikiMarkdownEditorButton.js.map +1 -1
- package/dist/components/dataaccess/SubmissionPage/SubmissionPage.js.map +1 -1
- package/dist/components/doi/CreateOrUpdateDoiModal.js +13 -13
- package/dist/components/doi/CreateOrUpdateDoiModal.js.map +1 -1
- package/dist/components/entity/page/title_bar/TitleBarProperties.js +23 -23
- package/dist/components/entity/page/title_bar/TitleBarProperties.js.map +1 -1
- package/dist/components/entity/page/title_bar/useGetMentions.js.map +1 -1
- package/dist/components/index.js +17 -17
- package/dist/components/styled/StyledFormControl.d.ts +15 -0
- package/dist/components/styled/StyledFormControl.d.ts.map +1 -1
- package/dist/components/styled/StyledFormControl.js +1 -0
- package/dist/components/styled/StyledFormControl.js.map +1 -1
- package/dist/components/styled/index.js +3 -3
- package/dist/components/table/CsvPreview/CreateTableFromCsvDialog.d.ts +18 -0
- package/dist/components/table/CsvPreview/CreateTableFromCsvDialog.d.ts.map +1 -0
- package/dist/components/table/CsvPreview/CreateTableFromCsvDialog.js +116 -0
- package/dist/components/table/CsvPreview/CreateTableFromCsvDialog.js.map +1 -0
- package/dist/components/table/CsvPreview/CsvPreviewDialog.d.ts +5 -5
- package/dist/components/table/CsvPreview/CsvPreviewDialog.d.ts.map +1 -1
- package/dist/components/table/CsvPreview/CsvPreviewDialog.js +27 -76
- package/dist/components/table/CsvPreview/CsvPreviewDialog.js.map +1 -1
- package/dist/components/table/CsvPreview/CsvPreviewWithOptions.d.ts +19 -0
- package/dist/components/table/CsvPreview/CsvPreviewWithOptions.d.ts.map +1 -0
- package/dist/components/table/CsvPreview/CsvPreviewWithOptions.js +41 -0
- package/dist/components/table/CsvPreview/CsvPreviewWithOptions.js.map +1 -0
- package/dist/components/table/CsvPreview/CsvUploadPreviewContent.d.ts +12 -0
- package/dist/components/table/CsvPreview/CsvUploadPreviewContent.d.ts.map +1 -0
- package/dist/components/table/CsvPreview/CsvUploadPreviewContent.js +25 -0
- package/dist/components/table/CsvPreview/CsvUploadPreviewContent.js.map +1 -0
- package/dist/components/table/CsvPreview/UpdateTableWithCsvDialog.d.ts +18 -0
- package/dist/components/table/CsvPreview/UpdateTableWithCsvDialog.d.ts.map +1 -0
- package/dist/components/table/CsvPreview/UpdateTableWithCsvDialog.js +55 -0
- package/dist/components/table/CsvPreview/UpdateTableWithCsvDialog.js.map +1 -0
- package/dist/components/table/CsvPreview/useCreateTableFromCsv.d.ts +19 -0
- package/dist/components/table/CsvPreview/useCreateTableFromCsv.d.ts.map +1 -0
- package/dist/components/table/CsvPreview/useCreateTableFromCsv.js +35 -0
- package/dist/components/table/CsvPreview/useCreateTableFromCsv.js.map +1 -0
- package/dist/components/table/CsvPreview/useCsvUploadPreview.d.ts +22 -0
- package/dist/components/table/CsvPreview/useCsvUploadPreview.d.ts.map +1 -0
- package/dist/components/table/CsvPreview/useCsvUploadPreview.js +32 -0
- package/dist/components/table/CsvPreview/useCsvUploadPreview.js.map +1 -0
- package/dist/components/table/CsvPreview/useUploadCsvToExistingTable.d.ts +14 -0
- package/dist/components/table/CsvPreview/useUploadCsvToExistingTable.d.ts.map +1 -0
- package/dist/components/table/CsvPreview/useUploadCsvToExistingTable.js +23 -0
- package/dist/components/table/CsvPreview/useUploadCsvToExistingTable.js.map +1 -0
- package/dist/components/utils/ConditionalWrapper.d.ts.map +1 -1
- package/dist/components/utils/ConditionalWrapper.js.map +1 -1
- package/dist/components/widgets/ElementWithTooltip.js.map +1 -1
- package/dist/components/widgets/facet-nav/FacetNavPanel.d.ts.map +1 -1
- package/dist/components/widgets/facet-nav/FacetNavPanel.js +69 -62
- package/dist/components/widgets/facet-nav/FacetNavPanel.js.map +1 -1
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilter.d.ts +1 -0
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilter.d.ts.map +1 -1
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilter.js +27 -26
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilter.js.map +1 -1
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilterDropdown.d.ts +1 -0
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilterDropdown.d.ts.map +1 -1
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilterDropdown.js +2 -1
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilterDropdown.js.map +1 -1
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilterUI.d.ts +1 -0
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilterUI.d.ts.map +1 -1
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilterUI.js +44 -43
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilterUI.js.map +1 -1
- package/dist/features/entity/metadata-task/components/CreateOrUpdateCurationTaskDialog.d.ts +13 -0
- package/dist/features/entity/metadata-task/components/CreateOrUpdateCurationTaskDialog.d.ts.map +1 -0
- package/dist/features/entity/metadata-task/components/CreateOrUpdateCurationTaskDialog.js +398 -0
- package/dist/features/entity/metadata-task/components/CreateOrUpdateCurationTaskDialog.js.map +1 -0
- package/dist/features/entity/metadata-task/components/MetadataTaskTableActionCell.d.ts.map +1 -1
- package/dist/features/entity/metadata-task/components/MetadataTaskTableActionCell.js +49 -19
- package/dist/features/entity/metadata-task/components/MetadataTaskTableActionCell.js.map +1 -1
- package/dist/features/entity/metadata-task/components/MetadataTasksPage.d.ts.map +1 -1
- package/dist/features/entity/metadata-task/components/MetadataTasksPage.js +49 -25
- package/dist/features/entity/metadata-task/components/MetadataTasksPage.js.map +1 -1
- package/dist/features/entity/metadata-task/hooks/useGridSessionForCurationTask.d.ts +0 -1
- package/dist/features/entity/metadata-task/hooks/useGridSessionForCurationTask.d.ts.map +1 -1
- package/dist/features/entity/metadata-task/hooks/useGridSessionForCurationTask.js +20 -22
- package/dist/features/entity/metadata-task/hooks/useGridSessionForCurationTask.js.map +1 -1
- package/dist/features/entity/metadata-task/hooks/useOpenCuratorButton.d.ts.map +1 -1
- package/dist/features/entity/metadata-task/hooks/useOpenCuratorButton.js +25 -27
- package/dist/features/entity/metadata-task/hooks/useOpenCuratorButton.js.map +1 -1
- package/dist/features/entity/metadata-task/utils/constants.d.ts +29 -0
- package/dist/features/entity/metadata-task/utils/constants.d.ts.map +1 -1
- package/dist/features/entity/metadata-task/utils/constants.js +2 -2
- package/dist/features/entity/metadata-task/utils/constants.js.map +1 -1
- package/dist/index.js +17 -17
- package/dist/mockServiceWorker.js +6 -8
- package/dist/mocks/curation/mockCurationTask.d.ts +2 -2
- package/dist/mocks/curation/mockCurationTask.d.ts.map +1 -1
- package/dist/mocks/curation/mockCurationTask.js +9 -5
- package/dist/mocks/curation/mockCurationTask.js.map +1 -1
- package/dist/mocks/msw/handlers/featureFlagHandlers.d.ts +1 -1
- package/dist/mocks/msw/handlers/featureFlagHandlers.d.ts.map +1 -1
- package/dist/mocks/msw/handlers/featureFlagHandlers.js +1 -1
- package/dist/mocks/msw/handlers/featureFlagHandlers.js.map +1 -1
- package/dist/style/components/_cards.scss +0 -3
- package/dist/style/components/_data-grid-extra.scss +2 -2
- package/dist/style/components/_login.scss +6 -2
- package/dist/style/main.css +1 -1
- package/dist/synapse-client/SynapseClient.d.ts +2 -1
- package/dist/synapse-client/SynapseClient.d.ts.map +1 -1
- package/dist/synapse-client/SynapseClient.js.map +1 -1
- package/dist/synapse-queries/QueryFilterUtils.js.map +1 -1
- package/dist/synapse-queries/curation/task/useCurationTask.d.ts +1 -0
- package/dist/synapse-queries/curation/task/useCurationTask.d.ts.map +1 -1
- package/dist/synapse-queries/curation/task/useCurationTask.js +16 -6
- package/dist/synapse-queries/curation/task/useCurationTask.js.map +1 -1
- package/dist/synapse-queries/dataaccess/useAccessRequirements.d.ts.map +1 -1
- package/dist/synapse-queries/dataaccess/useAccessRequirements.js.map +1 -1
- package/dist/synapse-queries/entity/useGetQueryResultBundle.js.map +1 -1
- package/dist/synapse-queries/featureflags/useGetFeatureFlag.d.ts +1 -1
- package/dist/synapse-queries/featureflags/useGetFeatureFlag.d.ts.map +1 -1
- package/dist/synapse-queries/featureflags/useGetFeatureFlag.js.map +1 -1
- package/dist/synapse-queries/file/useFiles.d.ts.map +1 -1
- package/dist/synapse-queries/file/useFiles.js.map +1 -1
- package/dist/synapse-queries/termsOfService/useTermsOfService.d.ts.map +1 -1
- package/dist/synapse-queries/termsOfService/useTermsOfService.js.map +1 -1
- package/dist/synapse-queries/user/useGetUserChallenges.d.ts.map +1 -1
- package/dist/synapse-queries/user/useGetUserChallenges.js.map +1 -1
- package/dist/testutils/ReactQueryMockUtils.js.map +1 -1
- package/dist/theme/palette/Palettes.d.ts +2 -2
- package/dist/theme/palette/Palettes.d.ts.map +1 -1
- package/dist/theme/palette/Palettes.js +2 -2
- package/dist/theme/palette/Palettes.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/ThemeTypes.d.ts +5 -6
- package/dist/utils/AppUtils/session/SynapseSessionManager.d.ts.map +1 -1
- package/dist/utils/AppUtils/session/SynapseSessionManager.js.map +1 -1
- package/dist/utils/featureflag/FeatureFlags.d.ts +13 -0
- package/dist/utils/featureflag/FeatureFlags.d.ts.map +1 -0
- package/dist/utils/featureflag/FeatureFlags.js +8 -0
- package/dist/utils/featureflag/FeatureFlags.js.map +1 -0
- package/dist/utils/functions/SanitizeHtmlUtils.js.map +1 -1
- package/dist/utils/functions/queryUtils.js.map +1 -1
- package/dist/utils/hooks/useGetInfoFromIds.d.ts.map +1 -1
- package/dist/utils/hooks/useGetInfoFromIds.js.map +1 -1
- package/dist/utils/slots/SlotUtils.d.ts.map +1 -1
- package/dist/utils/slots/SlotUtils.js.map +1 -1
- package/package.json +5 -6
|
@@ -2,49 +2,70 @@ import { useEffect as e, useLayoutEffect as t, useRef as n, useState as r } from
|
|
|
2
2
|
import { c as i } from "react/compiler-runtime";
|
|
3
3
|
//#region src/components/DataGrid/columns/useGridAutocompleteState.ts
|
|
4
4
|
function a(a) {
|
|
5
|
-
let o = i(
|
|
6
|
-
o[0] === s ?
|
|
7
|
-
|
|
8
|
-
}, o[0] = s, o[1] =
|
|
9
|
-
let
|
|
10
|
-
o[2] ===
|
|
11
|
-
|
|
12
|
-
}, o[2] =
|
|
13
|
-
let
|
|
14
|
-
o[4] ===
|
|
15
|
-
|
|
16
|
-
}, o[4] =
|
|
17
|
-
let
|
|
18
|
-
o[6] ===
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
let S;
|
|
22
|
-
o[
|
|
23
|
-
|
|
24
|
-
}, o[
|
|
25
|
-
let
|
|
26
|
-
o[10] ===
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}, o[
|
|
37
|
-
let
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
5
|
+
let o = i(22), { active: s, focus: c, stopEditing: l, onDeactivate: u } = a, d = n(null), [f, p] = r(!1), m = n(!1), h = n(s), g;
|
|
6
|
+
o[0] === s ? g = o[1] : (g = () => {
|
|
7
|
+
h.current = s;
|
|
8
|
+
}, o[0] = s, o[1] = g), t(g);
|
|
9
|
+
let _ = n(u), v;
|
|
10
|
+
o[2] === u ? v = o[3] : (v = () => {
|
|
11
|
+
_.current = u;
|
|
12
|
+
}, o[2] = u, o[3] = v), t(v);
|
|
13
|
+
let y = n(l), b;
|
|
14
|
+
o[4] === l ? b = o[5] : (b = () => {
|
|
15
|
+
y.current = l;
|
|
16
|
+
}, o[4] = l, o[5] = b), t(b);
|
|
17
|
+
let x = n(!1), S;
|
|
18
|
+
o[6] === Symbol.for("react.memo_cache_sentinel") ? (S = () => {
|
|
19
|
+
x.current = !0;
|
|
20
|
+
}, o[6] = S) : S = o[6];
|
|
21
|
+
let C = S, w, T;
|
|
22
|
+
o[7] === c ? (w = o[8], T = o[9]) : (w = () => {
|
|
23
|
+
c ? (d.current?.focus(), x.current || p(!0)) : m.current || (x.current = !1, p(!1), d.current?.blur());
|
|
24
|
+
}, T = [c], o[7] = c, o[8] = w, o[9] = T), e(w, T);
|
|
25
|
+
let E, D;
|
|
26
|
+
o[10] === c ? (E = o[11], D = o[12]) : (E = () => {
|
|
27
|
+
if (c) return;
|
|
28
|
+
let e = d.current;
|
|
29
|
+
if (!e) return;
|
|
30
|
+
let t = () => {
|
|
31
|
+
e.blur();
|
|
32
|
+
};
|
|
33
|
+
return e.addEventListener("focus", t), () => {
|
|
34
|
+
e.removeEventListener("focus", t);
|
|
35
|
+
};
|
|
36
|
+
}, D = [c], o[10] = c, o[11] = E, o[12] = D), e(E, D);
|
|
37
|
+
let O, k;
|
|
38
|
+
o[13] === s ? (O = o[14], k = o[15]) : (k = () => {
|
|
39
|
+
!s && !m.current && (x.current = !1, p(!1), d.current?.blur(), _.current?.());
|
|
40
|
+
}, O = [s], o[13] = s, o[14] = O, o[15] = k), e(k, O);
|
|
41
|
+
let A;
|
|
42
|
+
o[16] === Symbol.for("react.memo_cache_sentinel") ? (A = (e) => {
|
|
43
|
+
e.preventDefault(), e.target.closest("[role=\"option\"]") && (m.current = !0);
|
|
44
|
+
}, o[16] = A) : A = o[16];
|
|
45
|
+
let j = A, M;
|
|
46
|
+
o[17] === Symbol.for("react.memo_cache_sentinel") ? (M = () => {
|
|
47
|
+
m.current = !1;
|
|
48
|
+
}, o[17] = M) : M = o[17];
|
|
49
|
+
let N = M, P;
|
|
50
|
+
o[18] === Symbol.for("react.memo_cache_sentinel") ? (P = () => {
|
|
51
|
+
x.current = !1, p(!0);
|
|
52
|
+
}, o[18] = P) : P = o[18];
|
|
53
|
+
let F = P, I;
|
|
54
|
+
o[19] === Symbol.for("react.memo_cache_sentinel") ? (I = () => {
|
|
55
|
+
m.current = !1, p(!1), y.current?.({ nextRow: !1 });
|
|
56
|
+
}, o[19] = I) : I = o[19];
|
|
57
|
+
let L = I, R;
|
|
58
|
+
return o[20] === f ? R = o[21] : (R = {
|
|
59
|
+
menuIsOpen: f,
|
|
60
|
+
setMenuIsOpen: p,
|
|
61
|
+
inputRef: d,
|
|
62
|
+
activeRef: h,
|
|
63
|
+
handleListboxMouseDown: j,
|
|
64
|
+
notifyOptionCommitted: N,
|
|
65
|
+
handleMenuOpen: F,
|
|
66
|
+
handleClose: L,
|
|
67
|
+
handlePopupIndicatorMouseDown: C
|
|
68
|
+
}, o[20] = f, o[21] = R), R;
|
|
48
69
|
}
|
|
49
70
|
//#endregion
|
|
50
71
|
export { a as useGridAutocompleteState };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGridAutocompleteState.js","names":["useCallback","useEffect","useLayoutEffect","useRef","useState","UseGridAutocompleteStateProps","active","stopEditing","opts","nextRow","onDeactivate","UseGridAutocompleteStateReturn","menuIsOpen","setMenuIsOpen","open","inputRef","React","RefObject","HTMLInputElement","activeRef","handleListboxMouseDown","event","MouseEvent","notifyOptionCommitted","handleMenuOpen","handleClose","useGridAutocompleteState","t0","$","_c","optionMouseDownRef","t1","current","onDeactivateRef","t2","stopEditingRef","t3","t4","t5","focus","blur","t6","Symbol","for","preventDefault","target","Element","closest","t7","t8","t9","t10"],"sources":["../../../../src/components/DataGrid/columns/useGridAutocompleteState.ts"],"sourcesContent":["import {\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react'\n\nexport type UseGridAutocompleteStateProps = {\n active: boolean\n /**\n * `stopEditing` from react-datasheet-grid's CellProps. The hook ref-stabilizes\n * this internally, so callers can pass it directly without memoizing.\n */\n stopEditing?: (opts?: { nextRow: boolean }) => void\n /**\n * Called when the cell transitions from active to inactive and there is no\n * pending option click in progress (i.e. the portal-click guard is not set).\n * Store any free-text commit logic here. The callback is ref-stabilized inside\n * the hook, so it may freely capture local state without becoming a stale closure.\n */\n onDeactivate?: () => void\n}\n\nexport type UseGridAutocompleteStateReturn = {\n menuIsOpen: boolean\n setMenuIsOpen: (open: boolean) => void\n /** Ref to attach to the focusable input element for programmatic focus/blur. */\n inputRef: React.RefObject<HTMLInputElement | null>\n /**\n * Always reflects the current `active` value. Safe to read inside event\n * handler closures (e.g. onChange) without a stale capture.\n */\n activeRef: React.RefObject<boolean>\n /** Pass to `slotProps.listbox.onMouseDown` on the MUI Autocomplete. */\n handleListboxMouseDown: (event: React.MouseEvent) => void\n /**\n * Call at the top of every `onChange` handler to signal that a pending\n * option click has been committed. Clears the portal-click guard so that\n * subsequent active→false transitions can proceed normally.\n */\n notifyOptionCommitted: () => void\n /** Pass to the Autocomplete `onOpen` prop. */\n handleMenuOpen: () => void\n /**\n * Pass to the Autocomplete `onClose` prop. Clears the portal-click guard and\n * closes the menu, then stops editing without advancing to the next row.\n */\n handleClose: () => void\n}\n\n/**\n * Manages the shared focus/blur/menu state needed by grid autocomplete cell\n * components that are built on top of react-datasheet-grid.\n *\n * Both AutocompleteColumn and AutocompleteMultipleEnumColumn use the same\n * three-part pattern:\n * 1. When `active` becomes true → focus the input.\n * 2. When `active` becomes false with no pending option click → blur + close menu.\n * 3. The dropdown renders in a portal outside the grid cell. react-datasheet-grid\n * sees the mousedown as an outside click and fires active=false before onClick\n * → onChange. The `optionMouseDownRef` guard defers step 2 until the click\n * completes and onChange resets the ref.\n */\nexport function useGridAutocompleteState({\n active,\n stopEditing,\n onDeactivate,\n}: UseGridAutocompleteStateProps): UseGridAutocompleteStateReturn {\n const inputRef = useRef<HTMLInputElement>(null)\n const [menuIsOpen, setMenuIsOpen] = useState(false)\n const optionMouseDownRef = useRef(false)\n\n // Always reflects the latest `active` value — safe to read in closures.\n const activeRef = useRef(active)\n useLayoutEffect(() => {\n activeRef.current = active\n })\n\n // Ref-stabilize callbacks so effects/handlers never need them in deps arrays,\n // yet always call the latest versions (avoiding stale closures).\n const onDeactivateRef = useRef(onDeactivate)\n useLayoutEffect(() => {\n onDeactivateRef.current = onDeactivate\n })\n const stopEditingRef = useRef(stopEditing)\n useLayoutEffect(() => {\n stopEditingRef.current = stopEditing\n })\n\n useEffect(() => {\n if (active) {\n inputRef.current?.focus()\n } else if (!optionMouseDownRef.current) {\n // Only close when there is no pending option click; if there is one,\n // onChange will reset optionMouseDownRef and handle cleanup itself.\n setMenuIsOpen(false)\n inputRef.current?.blur()\n onDeactivateRef.current?.()\n }\n // Intentionally only re-runs when `active` changes.\n }, [active])\n\n const handleListboxMouseDown = useCallback((event: React.MouseEvent) => {\n // Prevent the input from blurring when clicking inside the listbox. MUI's\n // internal listbox onMouseDown does the same, but our slotProps replaces it,\n // so we must call preventDefault() here to preserve that behavior.\n event.preventDefault()\n // Only signal a pending option click when the mousedown actually targets an\n // option element. Clicks on scrollbars or listbox padding would otherwise\n // leave the guard stuck true (onChange never fires for non-selections),\n // causing later active→false transitions to skip blur/onDeactivate cleanup.\n if ((event.target as Element).closest('[role=\"option\"]')) {\n optionMouseDownRef.current = true\n }\n }, [])\n\n const notifyOptionCommitted = useCallback(() => {\n optionMouseDownRef.current = false\n }, [])\n\n const handleMenuOpen = useCallback(() => {\n setMenuIsOpen(true)\n }, [])\n\n const handleClose = useCallback(() => {\n // Clear the guard in case a mousedown on an option was abandoned before\n // onChange could fire (e.g. drag-off).\n optionMouseDownRef.current = false\n setMenuIsOpen(false)\n stopEditingRef.current?.({ nextRow: false })\n }, [])\n\n return {\n menuIsOpen,\n setMenuIsOpen,\n inputRef,\n activeRef,\n handleListboxMouseDown,\n notifyOptionCommitted,\n handleMenuOpen,\n handleClose,\n }\n}\n"],"mappings":";;;AAgEA,SAAO0B,EAAAC,GAAA;CAAA,IAAAC,IAAAC,EAAA,GAAA,EAAkC,EAAAvB,WAAAC,gBAAAG,oBAAAiB,GAKvCZ,IAAiBZ,EAAyB,KAAK,EAC/C,CAAAS,GAAAC,KAAoCT,EAAS,GAAM,EACnD0B,IAA2B3B,EAAO,GAAM,EAGxCgB,IAAkBhB,EAAOG,EAAO,EAAAyB;AAChC7B,CADgC0B,EAAA,OAAAtB,IAG/ByB,IAAAH,EAAA,MAFeG,UAAA;AACdZ,IAASa,UAAW1B;IACrBsB,EAAA,KAAAtB,GAAAsB,EAAA,KAAAG,IAFD7B,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AAA,IAE6BM,UAAA;AACjCpC,IAAc,GAAK;IACpBe,EAAA,MAAAqB,KAAAA,IAAArB,EAAA;CAFD,IAAAJ,IAAuByB,GAEjBC;AAAA,CAAAtB,EAAA,QAAAc,OAAAC,IAAA,4BAAA,IAE0BO,UAAA;AAK9Bf,EAFAL,EAAkBE,UAAW,IAC7BnB,EAAc,GAAM,EACpBsB,EAAcH,UAAW,EAAAvB,SAAW,IAAO,CAAC;IAC7CmB,EAAA,MAAAsB,KAAAA,IAAAtB,EAAA;CAND,IAAAH,IAAoByB,GAMdC;AAWL,QAXKvB,EAAA,QAAAhB,IAWLuC,IAAAvB,EAAA,OATMuB,IAAA;EAAAvC;EAAAC;EAAAE;EAAAI;EAAAC;EAAAG;EAAAC;EAAAC;EASN,EAAAG,EAAA,MAAAhB,GAAAgB,EAAA,MAAAuB,IATMA"}
|
|
1
|
+
{"version":3,"file":"useGridAutocompleteState.js","names":["useCallback","useEffect","useLayoutEffect","useRef","useState","UseGridAutocompleteStateProps","active","focus","stopEditing","opts","nextRow","onDeactivate","UseGridAutocompleteStateReturn","menuIsOpen","setMenuIsOpen","open","inputRef","React","RefObject","HTMLInputElement","activeRef","handleListboxMouseDown","event","MouseEvent","notifyOptionCommitted","handleMenuOpen","handleClose","handlePopupIndicatorMouseDown","useGridAutocompleteState","t0","$","_c","optionMouseDownRef","t1","current","onDeactivateRef","t2","stopEditingRef","t3","popupClickInProgressRef","t4","Symbol","for","t5","t6","blur","t7","t8","input","handleFocus","addEventListener","removeEventListener","t10","t9","t11","preventDefault","target","Element","closest","t12","t13","t14","t15"],"sources":["../../../../src/components/DataGrid/columns/useGridAutocompleteState.ts"],"sourcesContent":["import {\n useCallback,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n} from 'react'\n\nexport type UseGridAutocompleteStateProps = {\n active: boolean\n focus: boolean\n /**\n * `stopEditing` from react-datasheet-grid's CellProps. The hook ref-stabilizes\n * this internally, so callers can pass it directly without memoizing.\n */\n stopEditing?: (opts?: { nextRow: boolean }) => void\n /**\n * Called when the cell transitions from active to inactive and there is no\n * pending option click in progress (i.e. the portal-click guard is not set).\n * Store any free-text commit logic here. The callback is ref-stabilized inside\n * the hook, so it may freely capture local state without becoming a stale closure.\n */\n onDeactivate?: () => void\n}\n\nexport type UseGridAutocompleteStateReturn = {\n menuIsOpen: boolean\n setMenuIsOpen: (open: boolean) => void\n /** Ref to attach to the focusable input element for programmatic focus/blur. */\n inputRef: React.RefObject<HTMLInputElement | null>\n /**\n * Always reflects the current `active` value. Safe to read inside event\n * handler closures (e.g. onChange) without a stale capture.\n */\n activeRef: React.RefObject<boolean>\n /** Pass to `slotProps.listbox.onMouseDown` on the MUI Autocomplete. */\n handleListboxMouseDown: (event: React.MouseEvent) => void\n /**\n * Call at the top of every `onChange` handler to signal that a pending\n * option click has been committed. Clears the portal-click guard so that\n * subsequent active→false transitions can proceed normally.\n */\n notifyOptionCommitted: () => void\n /** Pass to the Autocomplete `onOpen` prop. */\n handleMenuOpen: () => void\n /**\n * Pass to the Autocomplete `onClose` prop. Clears the portal-click guard and\n * closes the menu, then stops editing without advancing to the next row.\n */\n handleClose: () => void\n /** Pass to `slotProps.popupIndicator.onMouseDown` on the MUI Autocomplete. */\n handlePopupIndicatorMouseDown: () => void\n}\n\n/**\n * Manages the shared focus/blur/menu state needed by grid autocomplete cell\n * components that are built on top of react-datasheet-grid.\n *\n * Grid cell state is two-tiered: `active` is set on first click (cell is\n * selected, but not editing), `focus` is set on second click (cell is in edit\n * mode). This hook keeps browser focus and dropdown visibility tied to `focus`\n * so the active-but-not-focused state doesn't show a caret or open the menu —\n * Backspace/Delete and type-to-edit then fall through to the grid's defaults.\n *\n * 1. When `focus` becomes true → focus the input + open the menu.\n * 2. When `focus` becomes false → blur + close the menu.\n * 3. When `active` becomes false with no pending option click → run\n * `onDeactivate` to commit any uncommitted free-text. This is separate\n * from focus because Escape clears `focus` but keeps `active`, and we\n * should not commit on Escape.\n * 4. The dropdown renders in a portal outside the grid cell. react-datasheet-grid\n * sees the mousedown as an outside click and fires active=false before onClick\n * → onChange. The `optionMouseDownRef` guard defers steps 2 and 3 until the\n * click completes and onChange resets the ref.\n */\nexport function useGridAutocompleteState({\n active,\n focus,\n stopEditing,\n onDeactivate,\n}: UseGridAutocompleteStateProps): UseGridAutocompleteStateReturn {\n const inputRef = useRef<HTMLInputElement>(null)\n const [menuIsOpen, setMenuIsOpen] = useState(false)\n const optionMouseDownRef = useRef(false)\n\n // Always reflects the latest `active` value — safe to read in closures.\n const activeRef = useRef(active)\n useLayoutEffect(() => {\n activeRef.current = active\n })\n\n // Ref-stabilize callbacks so effects/handlers never need them in deps arrays,\n // yet always call the latest versions (avoiding stale closures).\n const onDeactivateRef = useRef(onDeactivate)\n useLayoutEffect(() => {\n onDeactivateRef.current = onDeactivate\n })\n const stopEditingRef = useRef(stopEditing)\n useLayoutEffect(() => {\n stopEditingRef.current = stopEditing\n })\n\n // Tracks an in-flight popup-indicator click so the focus effect skips its\n // auto-open. Without this, the indicator click both (a) promotes the cell to\n // grid focus (our effect would open the menu) and (b) toggles via MUI's\n // own onClick (which would then close because we just opened it) — flicker.\n // Letting MUI handle the open via its onOpen avoids the dueling state.\n // Cleared by handleMenuOpen (successful click) or by the focus/active effects\n // when focus drops (abandoned press).\n const popupClickInProgressRef = useRef(false)\n const handlePopupIndicatorMouseDown = useCallback(() => {\n popupClickInProgressRef.current = true\n }, [])\n\n useEffect(() => {\n if (focus) {\n inputRef.current?.focus()\n if (!popupClickInProgressRef.current) {\n setMenuIsOpen(true)\n }\n } else if (!optionMouseDownRef.current) {\n // Only close when there is no pending option click; if there is one,\n // onChange will reset optionMouseDownRef and handle cleanup itself.\n popupClickInProgressRef.current = false\n setMenuIsOpen(false)\n inputRef.current?.blur()\n }\n }, [focus])\n\n // Defense in depth for the caret: when grid focus is false, MUI may still\n // route browser focus to the <input> (e.g. multi-mode chip-area clicks,\n // popup indicator clicks). Intercept any focus that lands on the input\n // while we're not in edit mode and blur it, so no caret blinks after the\n // last chip or inside the input.\n useEffect(() => {\n if (focus) return\n const input = inputRef.current\n if (!input) return\n const handleFocus = () => {\n input.blur()\n }\n input.addEventListener('focus', handleFocus)\n return () => {\n input.removeEventListener('focus', handleFocus)\n }\n }, [focus])\n\n useEffect(() => {\n if (!active && !optionMouseDownRef.current) {\n // Menus can be opened with grid focus=false (e.g. clicking the popup\n // indicator on a freshly-activated cell), so the focus effect alone is\n // not enough — close on deactivation too. Otherwise a deactivated cell\n // can leave a stale menu open that re-anchors and \"moves\" as the user\n // scrolls the grid, or stack up alongside the next cell's menu.\n popupClickInProgressRef.current = false\n setMenuIsOpen(false)\n inputRef.current?.blur()\n onDeactivateRef.current?.()\n }\n }, [active])\n\n const handleListboxMouseDown = useCallback((event: React.MouseEvent) => {\n // Prevent the input from blurring when clicking inside the listbox. MUI's\n // internal listbox onMouseDown does the same, but our slotProps replaces it,\n // so we must call preventDefault() here to preserve that behavior.\n event.preventDefault()\n // Only signal a pending option click when the mousedown actually targets an\n // option element. Clicks on scrollbars or listbox padding would otherwise\n // leave the guard stuck true (onChange never fires for non-selections),\n // causing later active→false transitions to skip blur/onDeactivate cleanup.\n if ((event.target as Element).closest('[role=\"option\"]')) {\n optionMouseDownRef.current = true\n }\n }, [])\n\n const notifyOptionCommitted = useCallback(() => {\n optionMouseDownRef.current = false\n }, [])\n\n const handleMenuOpen = useCallback(() => {\n popupClickInProgressRef.current = false\n setMenuIsOpen(true)\n }, [])\n\n const handleClose = useCallback(() => {\n // Clear the guard in case a mousedown on an option was abandoned before\n // onChange could fire (e.g. drag-off).\n optionMouseDownRef.current = false\n setMenuIsOpen(false)\n stopEditingRef.current?.({ nextRow: false })\n }, [])\n\n return {\n menuIsOpen,\n setMenuIsOpen,\n inputRef,\n activeRef,\n handleListboxMouseDown,\n notifyOptionCommitted,\n handleMenuOpen,\n handleClose,\n handlePopupIndicatorMouseDown,\n }\n}\n"],"mappings":";;;AA2EA,SAAO4B,EAAAC,GAAA;CAAA,IAA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AAC,IAAA,4BAAA,IAEoCiB,UAAA;AACxC3B,IAAkBE,UAAW;IAC9BJ,EAAA,MAAA6B,KAAAA,IAAA7B,EAAA;CAFD,IAAAN,IAA8BmC,GAExBC;AAAA,CAAA9B,EAAA,QAAAW,OAAAC,IAAA,4BAAA,IAE6BkB,UAAA;AAEjC9C,EADAyB,EAAuBL,UAAW,IAClCpB,EAAc,GAAK;IACpBgB,EAAA,MAAA8B,KAAAA,IAAA9B,EAAA;CAHD,IAAAL,IAAuBmC,GAGjBC;AAAA,CAAA/B,EAAA,QAAAW,OAAAC,IAAA,4BAAA,IAE0BmB,UAAA;AAK9BxB,EAFAL,EAAkBE,UAAW,IAC7BpB,EAAc,GAAM,EACpBuB,EAAcH,UAAW,EAAAxB,SAAW,IAAO,CAAC;IAC7CoB,EAAA,MAAA+B,KAAAA,IAAA/B,EAAA;CAND,IAAAJ,IAAoBmC,GAMdC;AAYL,QAZKhC,EAAA,QAAAjB,IAYLiD,IAAAhC,EAAA,OAVMgC,IAAA;EAAAjD;EAAAC;EAAAE;EAAAI;EAAAC;EAAAG;EAAAC;EAAAC;EAAAC;EAUN,EAAAG,EAAA,MAAAjB,GAAAiB,EAAA,MAAAgC,IAVMA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadCsvToGridDialog.d.ts","sourceRoot":"","sources":["../../../../src/components/DataGrid/components/UploadCsvToGridDialog.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAGxE,KAAK,0BAA0B,GAAG;IAChC,aAAa,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,UAAU,EAAE,MAAM,IAAI,CAAA;CACvB,CAAA;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,YAAgB,EAChB,YAAgB,GACjB,EAAE,qBAAqB,GAAG,MAAM,CAchC;AAED,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC3C,KAAK,EAAE,0BAA0B,
|
|
1
|
+
{"version":3,"file":"UploadCsvToGridDialog.d.ts","sourceRoot":"","sources":["../../../../src/components/DataGrid/components/UploadCsvToGridDialog.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAGxE,KAAK,0BAA0B,GAAG;IAChC,aAAa,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,UAAU,EAAE,MAAM,IAAI,CAAA;CACvB,CAAA;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,YAAgB,EAChB,YAAgB,GACjB,EAAE,qBAAqB,GAAG,MAAM,CAchC;AAED,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAC3C,KAAK,EAAE,0BAA0B,2CAoClC"}
|
|
@@ -11,12 +11,12 @@ function o({ createdCount: e = 0, updatedCount: t = 0 }) {
|
|
|
11
11
|
return e > 0 && (n += `created ${e.toLocaleString()} rows`), e > 0 && t > 0 ? n += " and " : t == 0 && (n += "."), t > 0 && (n += `updated ${t.toLocaleString()} rows.`), a(n);
|
|
12
12
|
}
|
|
13
13
|
function s(a) {
|
|
14
|
-
let s = i(
|
|
14
|
+
let s = i(12), { gridSessionId: c, open: l, onClose: u, onComplete: d } = a, f;
|
|
15
15
|
s[0] === d ? f = s[1] : (f = { onSuccess: (t) => {
|
|
16
16
|
e(o(t), "success", { title: "Data imported successfully" }), d();
|
|
17
17
|
} }, s[0] = d, s[1] = f);
|
|
18
|
-
let { mutate: p, isPending: m, error: h } = t(f), g;
|
|
19
|
-
s[2] !== c || s[3] !== p ? (
|
|
18
|
+
let { mutate: p, isPending: m, error: h } = t(f), g = String(l), _;
|
|
19
|
+
s[2] !== c || s[3] !== p ? (_ = (e, t, n) => {
|
|
20
20
|
p({
|
|
21
21
|
concreteType: "org.sagebionetworks.repo.model.grid.GridCsvImportRequest",
|
|
22
22
|
sessionId: c,
|
|
@@ -24,15 +24,15 @@ function s(a) {
|
|
|
24
24
|
csvDescriptor: n,
|
|
25
25
|
schema: t
|
|
26
26
|
});
|
|
27
|
-
}, s[2] = c, s[3] = p, s[4] =
|
|
28
|
-
let
|
|
29
|
-
return s[5] !== m || s[6] !== u || s[7] !== l || s[8] !== g || s[9] !== _ ? (
|
|
27
|
+
}, s[2] = c, s[3] = p, s[4] = _) : _ = s[4];
|
|
28
|
+
let v = h?.message, y;
|
|
29
|
+
return s[5] !== m || s[6] !== u || s[7] !== l || s[8] !== g || s[9] !== _ || s[10] !== v ? (y = /* @__PURE__ */ r(n, {
|
|
30
30
|
open: l,
|
|
31
31
|
onClose: u,
|
|
32
|
-
onConfirm:
|
|
33
|
-
errorMessage:
|
|
32
|
+
onConfirm: _,
|
|
33
|
+
errorMessage: v,
|
|
34
34
|
confirmIsPending: m
|
|
35
|
-
}), s[5] = m, s[6] = u, s[7] = l, s[8] = g, s[9] = _, s[10] = v) :
|
|
35
|
+
}, g), s[5] = m, s[6] = u, s[7] = l, s[8] = g, s[9] = _, s[10] = v, s[11] = y) : y = s[11], y;
|
|
36
36
|
}
|
|
37
37
|
//#endregion
|
|
38
38
|
export { s as default, o as getUpdateMessage };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadCsvToGridDialog.js","names":["displayToast","CsvPreviewDialog","useImportCsvIntoGrid","GridCsvImportResponse","upperFirst","UploadCsvToGridDialogProps","gridSessionId","open","onClose","onComplete","getUpdateMessage","createdCount","updatedCount","message","toLocaleString","UploadCsvToGridDialog","props","$","_c","t0","onSuccess","result","title","mutate","importCsvIntoGrid","isPending","error","t1","fileHandleId","schema","csvDescriptor","concreteType","sessionId","
|
|
1
|
+
{"version":3,"file":"UploadCsvToGridDialog.js","names":["displayToast","CsvPreviewDialog","useImportCsvIntoGrid","GridCsvImportResponse","upperFirst","UploadCsvToGridDialogProps","gridSessionId","open","onClose","onComplete","getUpdateMessage","createdCount","updatedCount","message","toLocaleString","UploadCsvToGridDialog","props","$","_c","t0","onSuccess","result","title","mutate","importCsvIntoGrid","isPending","error","t1","String","t2","fileHandleId","schema","csvDescriptor","concreteType","sessionId","t3","t4"],"sources":["../../../../src/components/DataGrid/components/UploadCsvToGridDialog.tsx"],"sourcesContent":["import { displayToast } from '@/components/index'\nimport CsvPreviewDialog from '@/components/table/CsvPreview/CsvPreviewDialog'\nimport { useImportCsvIntoGrid } from '@/synapse-queries/grid/useImportCsvIntoGrid'\nimport { GridCsvImportResponse } from '@sage-bionetworks/synapse-client'\nimport upperFirst from 'lodash-es/upperFirst'\n\ntype UploadCsvToGridDialogProps = {\n gridSessionId: string\n open: boolean\n onClose: () => void\n onComplete: () => void\n}\n\nexport function getUpdateMessage({\n createdCount = 0,\n updatedCount = 0,\n}: GridCsvImportResponse): string {\n let message = ''\n if (createdCount > 0) {\n message += `created ${createdCount.toLocaleString()} rows`\n }\n if (createdCount > 0 && updatedCount > 0) {\n message += ' and '\n } else if (updatedCount == 0) {\n message += '.'\n }\n if (updatedCount > 0) {\n message += `updated ${updatedCount.toLocaleString()} rows.`\n }\n return upperFirst(message)\n}\n\nexport default function UploadCsvToGridDialog(\n props: UploadCsvToGridDialogProps,\n) {\n const { gridSessionId, open, onClose, onComplete } = props\n\n const {\n mutate: importCsvIntoGrid,\n isPending,\n error,\n } = useImportCsvIntoGrid({\n onSuccess: result => {\n displayToast(getUpdateMessage(result), 'success', {\n title: 'Data imported successfully',\n })\n onComplete()\n },\n })\n\n return (\n <CsvPreviewDialog\n key={String(open)}\n open={open}\n onClose={onClose}\n onConfirm={(fileHandleId, schema, csvDescriptor) => {\n importCsvIntoGrid({\n concreteType:\n 'org.sagebionetworks.repo.model.grid.GridCsvImportRequest',\n sessionId: gridSessionId,\n fileHandleId,\n csvDescriptor,\n schema,\n })\n }}\n errorMessage={error?.message}\n confirmIsPending={isPending}\n />\n )\n}\n"],"mappings":";;;;;;;;AAaA,SAAgBU,EAAiB,EAC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AAAR,EAAA,KAAAT,GAAAS,EAAA,KAAAV,GAAAU,EAAA,KAAAU,GAAAV,EAAA,KAAAY,GAAAZ,EAAA,MAAAkB,GAAAlB,EAAA,MAAAmB,KAAAA,IAAAnB,EAAA,KAhBFmB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetSchemaForGrid.d.ts","sourceRoot":"","sources":["../../../../src/components/DataGrid/hooks/useGetSchemaForGrid.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EAEZ,MAAM,kCAAkC,CAAA;AAUzC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"useGetSchemaForGrid.d.ts","sourceRoot":"","sources":["../../../../src/components/DataGrid/hooks/useGetSchemaForGrid.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EAEZ,MAAM,kCAAkC,CAAA;AAUzC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAiEzC;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,2BAmCtE"}
|
|
@@ -23,7 +23,14 @@ var { compareSchemaDefinitions: u, compareSchemaValues: d } = a(), { mergeArrayO
|
|
|
23
23
|
"path",
|
|
24
24
|
"type",
|
|
25
25
|
"currentVersion",
|
|
26
|
-
"benefactorId"
|
|
26
|
+
"benefactorId",
|
|
27
|
+
"dataFileHandleId",
|
|
28
|
+
"dataFileName",
|
|
29
|
+
"dataFileSizeBytes",
|
|
30
|
+
"dataFileMD5Hex",
|
|
31
|
+
"dataFileConcreteType",
|
|
32
|
+
"dataFileBucket",
|
|
33
|
+
"dataFileKey"
|
|
27
34
|
];
|
|
28
35
|
function h(e) {
|
|
29
36
|
if (!e.properties) return e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetSchemaForGrid.js","names":["useGetEntity","useGetSchema","GridSession","instanceOfEntityView","createComparator","createMerger","createShallowAllOfMerge","createDeduplicator","createIntersector","JSONSchema7","isObject","useMemo","compareSchemaDefinitions","compareSchemaValues","mergeArrayOfSchemaDefinitions","intersectJson","deduplicateJsonSchemaDef","shallowAllOfMerge","GRID_ENTITY_READONLY_PROPERTIES","addReadonlyToEntityProperties","jsonSchema","properties","updatedProperties","propertiesToMakeReadonly","forEach","prop","readOnly","useGetSchemaForGrid","session","$","_c","t0","gridJsonSchema$Id","t1","enabled","data","t2","sourceEntityId","t3","entityData","undefined","includeBaseEntitySchema","t4","select","entityJsonSchema","t5","t6","allOf"],"sources":["../../../../src/components/DataGrid/hooks/useGetSchemaForGrid.ts"],"sourcesContent":["import { useGetEntity, useGetSchema } from '@/synapse-queries/index'\nimport {\n GridSession,\n instanceOfEntityView,\n} from '@sage-bionetworks/synapse-client'\nimport {\n createComparator,\n createMerger,\n createShallowAllOfMerge,\n} from '@x0k/json-schema-merge'\nimport {\n createDeduplicator,\n createIntersector,\n} from '@x0k/json-schema-merge/lib/array'\nimport { JSONSchema7 } from 'json-schema'\nimport isObject from 'lodash-es/isObject'\nimport { useMemo } from 'react'\n\nconst { compareSchemaDefinitions, compareSchemaValues } = createComparator()\nconst { mergeArrayOfSchemaDefinitions } = createMerger({\n intersectJson: createIntersector(compareSchemaValues),\n deduplicateJsonSchemaDef: createDeduplicator(compareSchemaDefinitions),\n})\nconst shallowAllOfMerge = createShallowAllOfMerge(mergeArrayOfSchemaDefinitions)\n\nconst GRID_ENTITY_READONLY_PROPERTIES = [\n 'name',\n 'id',\n 'createdBy',\n 'createdOn',\n 'modifiedBy',\n 'modifiedOn',\n 'etag',\n 'concreteType',\n 'parentId',\n 'path',\n 'type',\n 'currentVersion',\n 'benefactorId',\n]\n\n/**\n * The Synapse JSON Schemas for entities do not indicate which properties should be readOnly.\n * Amend the schema to mark certain properties as readOnly so they cannot be edited in the grid.\n */\nfunction addReadonlyToEntityProperties(jsonSchema: JSONSchema7): JSONSchema7 {\n if (!jsonSchema.properties) {\n return jsonSchema\n }\n\n const updatedProperties = { ...jsonSchema.properties }\n\n // List of properties to mark as read-only\n const propertiesToMakeReadonly = GRID_ENTITY_READONLY_PROPERTIES\n\n propertiesToMakeReadonly.forEach(prop => {\n if (updatedProperties[prop]) {\n updatedProperties[prop] = {\n ...(isObject(updatedProperties[prop]) ? updatedProperties[prop] : {}),\n readOnly: true,\n }\n } else {\n updatedProperties[prop] = { readOnly: true }\n }\n })\n\n return {\n ...jsonSchema,\n properties: updatedProperties,\n }\n}\n\n/**\n * Hook to get the JSON schema for a Data Grid, merging in the base Entity schema if the source entity is an EntityView.\n * @param session - The GridSession object.\n */\nexport default function useGetSchemaForGrid(session: GridSession | null) {\n const { data: jsonSchema } = useGetSchema(session?.gridJsonSchema$Id ?? '', {\n enabled: !!session?.gridJsonSchema$Id,\n })\n\n const { data: entityData } = useGetEntity(\n session?.sourceEntityId,\n undefined,\n {\n enabled: !!session?.sourceEntityId,\n },\n )\n\n let includeBaseEntitySchema = false\n if (entityData && instanceOfEntityView(entityData)) {\n includeBaseEntitySchema = true\n }\n\n const { data: entityJsonSchema } = useGetSchema(\n 'org.sagebionetworks-repo.model.Entity',\n {\n enabled: includeBaseEntitySchema,\n select: addReadonlyToEntityProperties,\n },\n )\n\n return useMemo(() => {\n if (jsonSchema && entityJsonSchema) {\n return shallowAllOfMerge({\n allOf: [entityJsonSchema, jsonSchema],\n }) as JSONSchema7\n } else {\n return jsonSchema\n }\n }, [jsonSchema, entityJsonSchema])\n}\n"],"mappings":";;;;;;;;;AAkBA,IAAM,EAAEY,6BAA0BC,2BAAwBT,GAAkB,EACtE,EAAEU,qCAAkCT,EAAa;CACrDU,eAAeP,EAAkBK,EAAoB;CACrDG,0BAA0BT,EAAmBK,EAAwB;CACtE,CAAC,EACIK,IAAoBX,EAAwBQ,EAA8B,EAE1EI,IAAkC;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAMD,SAASC,EAA8BC,GAAsC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AAf,EAAA,OAAAT,KACzB0B,IAAA7B,EAAkB,EAAA8B,OAChB,CAACH,GAAkBxB,EAAU,EACrC,CAAC,EAAAS,EAAA,KAAAe,GAAAf,EAAA,KAAAT,GAAAS,EAAA,KAAAiB,KAAAA,IAAAjB,EAAA,IAFFgB,IAAOC;OAIPD,KAAOzB;AACR,QAPIyB"}
|
|
1
|
+
{"version":3,"file":"useGetSchemaForGrid.js","names":["useGetEntity","useGetSchema","GridSession","instanceOfEntityView","createComparator","createMerger","createShallowAllOfMerge","createDeduplicator","createIntersector","JSONSchema7","isObject","useMemo","compareSchemaDefinitions","compareSchemaValues","mergeArrayOfSchemaDefinitions","intersectJson","deduplicateJsonSchemaDef","shallowAllOfMerge","GRID_ENTITY_READONLY_PROPERTIES","addReadonlyToEntityProperties","jsonSchema","properties","updatedProperties","propertiesToMakeReadonly","forEach","prop","readOnly","useGetSchemaForGrid","session","$","_c","t0","gridJsonSchema$Id","t1","enabled","data","t2","sourceEntityId","t3","entityData","undefined","includeBaseEntitySchema","t4","select","entityJsonSchema","t5","t6","allOf"],"sources":["../../../../src/components/DataGrid/hooks/useGetSchemaForGrid.ts"],"sourcesContent":["import { useGetEntity, useGetSchema } from '@/synapse-queries/index'\nimport {\n GridSession,\n instanceOfEntityView,\n} from '@sage-bionetworks/synapse-client'\nimport {\n createComparator,\n createMerger,\n createShallowAllOfMerge,\n} from '@x0k/json-schema-merge'\nimport {\n createDeduplicator,\n createIntersector,\n} from '@x0k/json-schema-merge/lib/array'\nimport { JSONSchema7 } from 'json-schema'\nimport isObject from 'lodash-es/isObject'\nimport { useMemo } from 'react'\n\nconst { compareSchemaDefinitions, compareSchemaValues } = createComparator()\nconst { mergeArrayOfSchemaDefinitions } = createMerger({\n intersectJson: createIntersector(compareSchemaValues),\n deduplicateJsonSchemaDef: createDeduplicator(compareSchemaDefinitions),\n})\nconst shallowAllOfMerge = createShallowAllOfMerge(mergeArrayOfSchemaDefinitions)\n\nconst GRID_ENTITY_READONLY_PROPERTIES = [\n 'name',\n 'id',\n 'createdBy',\n 'createdOn',\n 'modifiedBy',\n 'modifiedOn',\n 'etag',\n 'concreteType',\n 'parentId',\n 'path',\n 'type',\n 'currentVersion',\n 'benefactorId',\n 'dataFileHandleId',\n 'dataFileName',\n 'dataFileSizeBytes',\n 'dataFileMD5Hex',\n 'dataFileConcreteType',\n 'dataFileBucket',\n 'dataFileKey',\n]\n\n/**\n * The Synapse JSON Schemas for entities do not indicate which properties should be readOnly.\n * Amend the schema to mark certain properties as readOnly so they cannot be edited in the grid.\n */\nfunction addReadonlyToEntityProperties(jsonSchema: JSONSchema7): JSONSchema7 {\n if (!jsonSchema.properties) {\n return jsonSchema\n }\n\n const updatedProperties = { ...jsonSchema.properties }\n\n // List of properties to mark as read-only\n const propertiesToMakeReadonly = GRID_ENTITY_READONLY_PROPERTIES\n\n propertiesToMakeReadonly.forEach(prop => {\n if (updatedProperties[prop]) {\n updatedProperties[prop] = {\n ...(isObject(updatedProperties[prop]) ? updatedProperties[prop] : {}),\n readOnly: true,\n }\n } else {\n updatedProperties[prop] = { readOnly: true }\n }\n })\n\n return {\n ...jsonSchema,\n properties: updatedProperties,\n }\n}\n\n/**\n * Hook to get the JSON schema for a Data Grid, merging in the base Entity schema if the source entity is an EntityView.\n * @param session - The GridSession object.\n */\nexport default function useGetSchemaForGrid(session: GridSession | null) {\n const { data: jsonSchema } = useGetSchema(session?.gridJsonSchema$Id ?? '', {\n enabled: !!session?.gridJsonSchema$Id,\n })\n\n const { data: entityData } = useGetEntity(\n session?.sourceEntityId,\n undefined,\n {\n enabled: !!session?.sourceEntityId,\n },\n )\n\n let includeBaseEntitySchema = false\n if (entityData && instanceOfEntityView(entityData)) {\n includeBaseEntitySchema = true\n }\n\n const { data: entityJsonSchema } = useGetSchema(\n 'org.sagebionetworks-repo.model.Entity',\n {\n enabled: includeBaseEntitySchema,\n select: addReadonlyToEntityProperties,\n },\n )\n\n return useMemo(() => {\n if (jsonSchema && entityJsonSchema) {\n return shallowAllOfMerge({\n allOf: [entityJsonSchema, jsonSchema],\n }) as JSONSchema7\n } else {\n return jsonSchema\n }\n }, [jsonSchema, entityJsonSchema])\n}\n"],"mappings":";;;;;;;;;AAkBA,IAAM,EAAEY,6BAA0BC,2BAAwBT,GAAkB,EACtE,EAAEU,qCAAkCT,EAAa;CACrDU,eAAeP,EAAkBK,EAAoB;CACrDG,0BAA0BT,EAAmBK,EAAwB;CACtE,CAAC,EACIK,IAAoBX,EAAwBQ,EAA8B,EAE1EI,IAAkC;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAMD,SAASC,EAA8BC,GAAsC;AAC3E,KAAI,CAACA,EAAWC,WACd,QAAOD;CAGT,IAAME,IAAoB,EAAE,GAAGF,EAAWC,YAAY;AAgBtD,QAXAE,EAAyBC,SAAQC,MAAQ;AACvC,EAAIH,EAAkBG,KACpBH,EAAkBG,KAAQ;GACxB,GAAIf,EAASY,EAAkBG,GAAM,GAAGH,EAAkBG,KAAQ,EAAE;GACpEC,UAAU;GACX,GAEDJ,EAAkBG,KAAQ,EAAEC,UAAU,IAAM;GAE9C,EAEK;EACL,GAAGN;EACHC,YAAYC;EACb;;AAOH,SAAeK,EAAAC,GAAA;CAAA,IAAAC,IAAAC,EAAA,EAAA,EAEFC,IAAA,CAAC,CAACH,GAAOI,mBAAmBC;AAAA,CAAAJ,EAAA,OAAAE,IACtCE,IAAAJ,EAAA,MAF2EI,IAAA,EAAAC,SACjEH,GACV,EAAAF,EAAA,KAAAE,GAAAF,EAAA,KAAAI;CAFD,IAAA,EAAAE,MAAAf,MAA6BnB,EAAa2B,GAAOI,qBAAP,IAAkCC,EAE1E,EAMWG,IAAA,CAAC,CAACR,GAAOS,gBAAgBC;AAAA,CAAAT,EAAA,OAAAO,IACnCE,IAAAT,EAAA,MAFDS,IAAA,EAAAJ,SACWE,GACV,EAAAP,EAAA,KAAAO,GAAAP,EAAA,KAAAS;CALH,IAAA,EAAAH,MAAAI,MAA6BvC,EAC3B4B,GAAOS,gBACPG,KAAAA,GACAF,EAGD,EAEDG,IAA8B;AAC9B,CAAIF,KAAcpC,EAAqBoC,EAAW,KAChDE,IAA0BA;CAC3B,IAAAC;AAAA,CAAAb,EAAA,OAAAY,IAOEC,IAAAb,EAAA,MAHDa,IAAA;EAAAR,SACWO;EAAuBE,QACxBxB;EACT,EAAAU,EAAA,KAAAY,GAAAZ,EAAA,KAAAa;CALH,IAAA,EAAAP,MAAAS,MAAmC3C,EACjC,yCACAyC,EAID,EAAAG;AAGC,KAAIzB,KAAAwB,GAA8B;EAAA,IAAAE;AAChCD,EADgChB,EAAA,OAAAe,KAAAf,EAAA,OAAAT,KACzB0B,IAAA7B,EAAkB,EAAA8B,OAChB,CAACH,GAAkBxB,EAAU,EACrC,CAAC,EAAAS,EAAA,KAAAe,GAAAf,EAAA,KAAAT,GAAAS,EAAA,KAAAiB,KAAAA,IAAAjB,EAAA,IAFFgB,IAAOC;OAIPD,KAAOzB;AACR,QAPIyB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonRxResponseComplete.js","names":["JsonRxMessage","RESPONSE_COMPLETE_TYPE_CODE","JsonRxResponseComplete","subscriptionId","payload","TPayload","getSubscriptionId","getPayload","constructor","getJson","Array","json","typeCode","undefined","push"],"sources":["../../../../../src/components/DataGrid/utils/json-rx/JsonRxResponseComplete.ts"],"sourcesContent":["import JsonRxMessage from './JsonRxMessage'\n\nexport const RESPONSE_COMPLETE_TYPE_CODE = 5\n\nexport default class JsonRxResponseComplete<\n TPayload = unknown,\n> extends JsonRxMessage {\n private subscriptionId: number\n private payload?: TPayload\n\n public getSubscriptionId(): number {\n return this.subscriptionId\n }\n\n public getPayload(): TPayload | undefined {\n return this.payload
|
|
1
|
+
{"version":3,"file":"JsonRxResponseComplete.js","names":["JsonRxMessage","RESPONSE_COMPLETE_TYPE_CODE","JsonRxResponseComplete","subscriptionId","payload","TPayload","getSubscriptionId","getPayload","constructor","getJson","Array","json","typeCode","undefined","push"],"sources":["../../../../../src/components/DataGrid/utils/json-rx/JsonRxResponseComplete.ts"],"sourcesContent":["import JsonRxMessage from './JsonRxMessage'\n\nexport const RESPONSE_COMPLETE_TYPE_CODE = 5\n\nexport default class JsonRxResponseComplete<\n TPayload = unknown,\n> extends JsonRxMessage {\n private subscriptionId: number\n private payload?: TPayload\n\n public getSubscriptionId(): number {\n return this.subscriptionId\n }\n\n public getPayload(): TPayload | undefined {\n return this.payload\n }\n constructor(subscriptionId: number, payload?: TPayload) {\n super(RESPONSE_COMPLETE_TYPE_CODE)\n this.subscriptionId = subscriptionId\n this.payload = payload\n }\n\n public getJson(): Array<unknown> {\n const json: Array<unknown> = [this.typeCode, this.subscriptionId]\n if (this.payload !== undefined) {\n json.push(this.payload)\n }\n return json\n }\n}\n"],"mappings":";;AAEA,IAAaC,IAA8B,GAEtBC,IAArB,cAEUF,EAAc;CACtB;CACA;CAEA,oBAAmC;AACjC,SAAO,KAAKG;;CAGd,aAA0C;AACxC,SAAO,KAAKC;;CAEdI,YAAYL,GAAwBC,GAAoB;AAGtD,EAFA,MAAA,EAAkC,EAClC,KAAKD,iBAAiBA,GACtB,KAAKC,UAAUA;;CAGjB,UAAiC;EAC/B,IAAMO,IAAuB,CAAC,KAAKC,UAAU,KAAKT,eAAe;AAIjE,SAHI,KAAKC,YAAYS,KAAAA,KACnBF,EAAKG,KAAK,KAAKV,QAAQ,EAElBO"}
|
|
@@ -3,34 +3,34 @@ import t from "../../synapse-queries/entity/useEntityBundle.js";
|
|
|
3
3
|
import { useGetFeatureFlag as n } from "../../synapse-queries/featureflags/useGetFeatureFlag.js";
|
|
4
4
|
import "../../synapse-queries/index.js";
|
|
5
5
|
import { ActionRequiredCard as r } from "./ActionRequiredCard/ActionRequiredCard.js";
|
|
6
|
-
import i from "
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
6
|
+
import { FeatureFlagEnum as i } from "../../utils/featureflag/FeatureFlags.js";
|
|
7
|
+
import a from "../EntityAclEditor/EntityAclEditorModal.js";
|
|
8
|
+
import { useState as o } from "react";
|
|
9
|
+
import { Alert as s, Button as c, Typography as l } from "@mui/material";
|
|
10
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
11
11
|
//#region src/components/DownloadCart/RequestDownloadCard.tsx
|
|
12
12
|
var p = ((e) => window.open(`https://www.synapse.org/Synapse:${e}`, "_blank")), m = "Download Permission Required";
|
|
13
13
|
function h(h) {
|
|
14
14
|
let { entityId: g, count: _, onViewSharingSettingsClicked: v = p } = h, { data: y, isLoading: b, isError: x, error: S } = t(g, void 0, {
|
|
15
15
|
includeEntity: !0,
|
|
16
16
|
includePermissions: !0
|
|
17
|
-
}), [C, w] =
|
|
18
|
-
return x ? /* @__PURE__ */
|
|
17
|
+
}), [C, w] = o(!1), T = !!y?.permissions.canDownload, E = n(i.REACT_ENTITY_ACL_EDITOR);
|
|
18
|
+
return x ? /* @__PURE__ */ d(s, {
|
|
19
19
|
severity: "error",
|
|
20
20
|
children: S.reason
|
|
21
|
-
}) : /* @__PURE__ */
|
|
21
|
+
}) : /* @__PURE__ */ d(r, {
|
|
22
22
|
isLoading: b,
|
|
23
23
|
title: m,
|
|
24
|
-
description: /* @__PURE__ */
|
|
24
|
+
description: /* @__PURE__ */ f(u, { children: [
|
|
25
25
|
"You must be granted the download permission on",
|
|
26
26
|
" ",
|
|
27
|
-
/* @__PURE__ */
|
|
27
|
+
/* @__PURE__ */ d("strong", { children: y?.entity.name }),
|
|
28
28
|
" in order to download this set of files."
|
|
29
29
|
] }),
|
|
30
30
|
iconType: e,
|
|
31
31
|
count: _,
|
|
32
|
-
actionNode: /* @__PURE__ */
|
|
33
|
-
/* @__PURE__ */
|
|
32
|
+
actionNode: /* @__PURE__ */ f(u, { children: [
|
|
33
|
+
/* @__PURE__ */ d(l, {
|
|
34
34
|
variant: "smallText1",
|
|
35
35
|
sx: {
|
|
36
36
|
mb: 1,
|
|
@@ -38,12 +38,12 @@ function h(h) {
|
|
|
38
38
|
},
|
|
39
39
|
children: "Contact an administrator to request download permission"
|
|
40
40
|
}),
|
|
41
|
-
/* @__PURE__ */
|
|
41
|
+
/* @__PURE__ */ d(a, {
|
|
42
42
|
entityId: g,
|
|
43
43
|
open: C,
|
|
44
44
|
onClose: () => w(!1)
|
|
45
45
|
}),
|
|
46
|
-
/* @__PURE__ */
|
|
46
|
+
/* @__PURE__ */ d(c, {
|
|
47
47
|
variant: "outlined",
|
|
48
48
|
onClick: () => {
|
|
49
49
|
E ? w(!0) : v(g);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestDownloadCard.js","names":[],"sources":["../../../src/components/DownloadCart/RequestDownloadCard.tsx"],"sourcesContent":["import { useGetEntityBundle, useGetFeatureFlag } from '@/synapse-queries'\nimport { DOWNLOAD_PERMISSION_REQUIRED } from '@/utils/SynapseConstants'\nimport { Alert, Button, Typography } from '@mui/material'\nimport { FeatureFlagEnum } from '
|
|
1
|
+
{"version":3,"file":"RequestDownloadCard.js","names":[],"sources":["../../../src/components/DownloadCart/RequestDownloadCard.tsx"],"sourcesContent":["import { useGetEntityBundle, useGetFeatureFlag } from '@/synapse-queries'\nimport { DOWNLOAD_PERMISSION_REQUIRED } from '@/utils/SynapseConstants'\nimport { Alert, Button, Typography } from '@mui/material'\nimport { FeatureFlagEnum } from '@/utils/featureflag/FeatureFlags'\nimport { useState } from 'react'\nimport EntityAclEditorModal from '../EntityAclEditor/EntityAclEditorModal'\nimport { ActionRequiredCard } from './ActionRequiredCard/ActionRequiredCard'\n\nexport type RequestDownloadCardProps = {\n entityId: string\n count?: number\n /** Invoked when a user clicks \"View Sharing Settings\" for a set of files that require the Download permission*/\n onViewSharingSettingsClicked?: (benefactorId: string) => void\n}\n\nconst DEFAULT_ON_VIEW_SHARING_SETTINGS_CLICKED = (benefactorEntityId =>\n window.open(\n `https://www.synapse.org/Synapse:${benefactorEntityId}`,\n '_blank',\n )) satisfies RequestDownloadCardProps['onViewSharingSettingsClicked']\n\nexport const REQUEST_DOWNLOAD_TITLE = 'Download Permission Required'\nexport function RequestDownloadCard(props: RequestDownloadCardProps) {\n const {\n entityId,\n count,\n onViewSharingSettingsClicked = DEFAULT_ON_VIEW_SHARING_SETTINGS_CLICKED,\n } = props\n const {\n data: entityBundle,\n isLoading,\n isError,\n error,\n } = useGetEntityBundle(entityId, undefined, {\n includeEntity: true,\n includePermissions: true,\n })\n\n const [showSharingSettings, setShowSharingSettings] = useState(false)\n\n const hasDownloadPermission = Boolean(entityBundle?.permissions.canDownload)\n\n const useReactACLEditor = useGetFeatureFlag(\n FeatureFlagEnum.REACT_ENTITY_ACL_EDITOR,\n )\n\n if (isError) {\n return <Alert severity={'error'}>{error.reason}</Alert>\n }\n return (\n <ActionRequiredCard\n isLoading={isLoading}\n title={REQUEST_DOWNLOAD_TITLE}\n description={\n <>\n You must be granted the download permission on{' '}\n <strong>{entityBundle?.entity.name}</strong> in order to download this\n set of files.\n </>\n }\n iconType={DOWNLOAD_PERMISSION_REQUIRED}\n count={count}\n actionNode={\n <>\n <Typography variant=\"smallText1\" sx={{ mb: 1, color: 'grey.700' }}>\n Contact an administrator to request download permission\n </Typography>\n <EntityAclEditorModal\n entityId={entityId}\n open={showSharingSettings}\n onClose={() => setShowSharingSettings(false)}\n />\n <Button\n variant=\"outlined\"\n onClick={() => {\n if (useReactACLEditor) {\n setShowSharingSettings(true)\n } else {\n onViewSharingSettingsClicked(entityId)\n }\n }}\n disabled={hasDownloadPermission}\n >\n {hasDownloadPermission ? 'Complete' : 'View Sharing Settings'}\n </Button>\n </>\n }\n />\n )\n}\n"],"mappings":";;;;;;;;;;;AAeA,IAAM,MAA4C,MAChD,OAAO,KACL,mCAAmC,KACnC,SACD,GAEU,IAAyB;AACtC,SAAgB,EAAoB,GAAiC;CACnE,IAAM,EACJ,aACA,UACA,kCAA+B,MAC7B,GACE,EACJ,MAAM,GACN,cACA,YACA,aACE,EAAmB,GAAU,KAAA,GAAW;EAC1C,eAAe;EACf,oBAAoB;EACrB,CAAC,EAEI,CAAC,GAAqB,KAA0B,EAAS,GAAM,EAE/D,IAAwB,EAAQ,GAAc,YAAY,aAE1D,IAAoB,EACxB,EAAgB,wBACjB;AAKD,QAHI,IACK,kBAAC,GAAD;EAAO,UAAU;YAAU,EAAM;EAAe,CAAA,GAGvD,kBAAC,GAAD;EACa;EACX,OAAO;EACP,aACE,kBAAA,GAAA,EAAA,UAAA;GAAE;GAC+C;GAC/C,kBAAC,UAAD,EAAA,UAAS,GAAc,OAAO,MAAc,CAAA;;GAE3C,EAAA,CAAA;EAEL,UAAU;EACH;EACP,YACE,kBAAA,GAAA,EAAA,UAAA;GACE,kBAAC,GAAD;IAAY,SAAQ;IAAa,IAAI;KAAE,IAAI;KAAG,OAAO;KAAY;cAAE;IAEtD,CAAA;GACb,kBAAC,GAAD;IACY;IACV,MAAM;IACN,eAAe,EAAuB,GAAM;IAC5C,CAAA;GACF,kBAAC,GAAD;IACE,SAAQ;IACR,eAAe;AACb,KAAI,IACF,EAAuB,GAAK,GAE5B,EAA6B,EAAS;;IAG1C,UAAU;cAET,IAAwB,aAAa;IAC/B,CAAA;GACR,EAAA,CAAA;EAEL,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityAclEditor.d.ts","sourceRoot":"","sources":["../../../src/components/EntityAclEditor/EntityAclEditor.tsx"],"names":[],"mappings":"AAyDA,MAAM,MAAM,oBAAoB,GAAG;IACjC,oIAAoI;IACpI,QAAQ,EAAE,MAAM,CAAA;IAChB,iEAAiE;IACjE,eAAe,EAAE,CAAC,cAAc,EAAE,OAAO,KAAK,IAAI,CAAA;IAClD,kDAAkD;IAClD,eAAe,EAAE,MAAM,IAAI,CAAA;IAC3B;;6BAEyB;IACzB,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,IAAI,CAAA;CACjB,CAAA;
|
|
1
|
+
{"version":3,"file":"EntityAclEditor.d.ts","sourceRoot":"","sources":["../../../src/components/EntityAclEditor/EntityAclEditor.tsx"],"names":[],"mappings":"AAyDA,MAAM,MAAM,oBAAoB,GAAG;IACjC,oIAAoI;IACpI,QAAQ,EAAE,MAAM,CAAA;IAChB,iEAAiE;IACjE,eAAe,EAAE,CAAC,cAAc,EAAE,OAAO,KAAK,IAAI,CAAA;IAClD,kDAAkD;IAClD,eAAe,EAAE,MAAM,IAAI,CAAA;IAC3B;;6BAEyB;IACzB,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,IAAI,CAAA;CACjB,CAAA;AAgYD,QAAA,MAAM,2BAA2B,wHAahC,CAAA;AAED,eAAe,2BAA2B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityAclEditor.js","names":[],"sources":["../../../src/components/EntityAclEditor/EntityAclEditor.tsx"],"sourcesContent":["import {\n useCreateEntityACL,\n useDeleteEntityACL,\n useSuspenseGetCurrentUserProfile,\n useSuspenseGetEntityBenefactorACL,\n useSuspenseGetEntityBundle,\n useUpdateEntityACL,\n} from '@/synapse-queries'\nimport { useGetRealmPrincipals } from '@/synapse-queries/realm/useRealmPrincipals'\nimport { BackendDestinationEnum, getEndpoint } from '@/utils/functions'\nimport {\n consolidateResourceAccessList,\n isEntityPublic,\n resourceAccessListIsEqual,\n} from '@/utils/functions/AccessControlListUtils'\nimport { getPrincipalDisplayName } from '@/utils/functions/getPrincipalDisplayName'\nimport { entityTypeToFriendlyName } from '@/utils/functions/EntityTypeUtils'\nimport {\n getAccessTypeFromPermissionLevel,\n PermissionLevel,\n permissionLevelToLabel,\n} from '@/utils/PermissionLevelToAccessType'\nimport { SYNAPSE_DOCS_SHARING_SETTINGS_PERMISSIONS_CONDITIONS_FOR_USE_URL } from '@/utils/SynapseConstants'\nimport { Alert, Link, Stack } from '@mui/material'\nimport { EntityType } from '@sage-bionetworks/synapse-client'\nimport {\n ALL_ENTITY_BUNDLE_FIELDS,\n ResourceAccess,\n UserProfile,\n} from '@sage-bionetworks/synapse-types'\nimport {\n ForwardedRef,\n forwardRef,\n Suspense,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from 'react'\nimport { AclEditor, AclEditorProps } from '../AclEditor/AclEditor'\nimport { AclEditorSkeleton } from '../AclEditor/AclEditorSkeleton'\nimport useUpdateAcl from '../AclEditor/useUpdateAcl'\nimport { SynapseErrorBoundary } from '../error'\nimport FullWidthAlert from '../FullWidthAlert'\nimport { CreateOrDeleteLocalSharingSettingsButton } from './CreateOrDeleteLocalSharingSettingsButton'\nimport { InheritanceMessage } from './InheritanceMessage'\nimport OpenData from './OpenData'\nimport useNotifyNewACLUsers from './useNotifyNewACLUsers'\n\nconst availablePermissionLevels: PermissionLevel[] = [\n 'CAN_VIEW',\n 'CAN_DOWNLOAD',\n 'CAN_EDIT',\n 'CAN_EDIT_DELETE',\n 'CAN_ADMINISTER',\n]\n\nexport type EntityAclEditorProps = {\n /** The ID of the entity on which to view/edit the ACL. Note that the ACL may actually belong to an entity ancestor (benefactor). */\n entityId: string\n /** Invoked when the user can/cannot save the pending changes. */\n onCanSaveChange: (canSaveChanges: boolean) => void\n /** Invoked when changes are successfully made. */\n onUpdateSuccess: () => void\n /** Special case to show specific copy and allow changes to an inherited ACL immediately after a file is uploaded.\n * Note that if this is true, the entityId should be the ID of the folder or project that is the benefactor of the newly uploaded file(s)\n * @defaultValue false */\n isAfterUpload?: boolean\n}\n\nexport type EntityAclEditorHandle = {\n save: () => void\n}\n\nfunction getSubject(entityName: string) {\n return `${entityName} (shared on Synapse)`\n}\n\nfunction getBody(profile: UserProfile, entityId: string) {\n return `${getPrincipalDisplayName(\n {\n userName: profile.userName ?? '',\n firstName: profile.firstName,\n lastName: profile.lastName,\n },\n { showFullName: true, showUsername: false },\n )} has shared an item with you on Synapse:\\n${getEndpoint(\n BackendDestinationEnum.PORTAL_ENDPOINT,\n )}Synapse:${entityId}`\n}\n\nfunction getCanEditResourceAccess(\n canEdit: boolean,\n isInherited: boolean,\n ownProfile: UserProfile,\n publicGroupId: string | undefined,\n): AclEditorProps['canEdit'] {\n if (!canEdit || isInherited) {\n return false\n }\n return (resourceAccess: ResourceAccess): boolean => {\n // Users cannot change their own permissions\n const isSelf = ownProfile.ownerId === String(resourceAccess.principalId)\n // Users cannot change permission level for the public group, only add/remove it.\n // To give the public group DOWNLOAD access, ACT must mark it as anonymous access.\n const isPublicGroup =\n publicGroupId !== undefined &&\n String(resourceAccess.principalId) === publicGroupId\n if (isSelf || isPublicGroup) {\n return false\n }\n return true\n }\n}\n\nfunction getCanDeleteResourceAccess(\n canEdit: boolean,\n isInherited: boolean,\n ownProfile: UserProfile,\n): AclEditorProps['canRemoveEntry'] {\n if (!canEdit || isInherited) {\n return false\n }\n return (resourceAccess: ResourceAccess): boolean => {\n // Users cannot delete their own permissions\n const isSelf = ownProfile.ownerId === String(resourceAccess.principalId)\n if (isSelf) {\n return false\n }\n return canEdit\n }\n}\n\nfunction getDisplayedPermissionLevelOverride(\n isOpenData: boolean,\n publicGroupId: string | undefined,\n): AclEditorProps['displayedPermissionLevelOverride'] {\n return (resourceAccess: ResourceAccess) => {\n if (\n publicGroupId !== undefined &&\n String(resourceAccess.principalId) === publicGroupId\n ) {\n return isOpenData\n ? permissionLevelToLabel['CAN_DOWNLOAD']\n : permissionLevelToLabel['CAN_VIEW']\n }\n return undefined\n }\n}\n\nconst EntityAclEditor = forwardRef(function EntityAclEditor(\n props: EntityAclEditorProps,\n ref: ForwardedRef<EntityAclEditorHandle>,\n) {\n const {\n entityId,\n onCanSaveChange,\n onUpdateSuccess,\n isAfterUpload = false,\n } = props\n\n const { data: ownProfile } = useSuspenseGetCurrentUserProfile()\n const { data: realmPrincipals } = useGetRealmPrincipals()\n const { publicGroup: publicGroupId } = realmPrincipals || {}\n const { data: entityBundle } = useSuspenseGetEntityBundle(\n entityId,\n undefined,\n ALL_ENTITY_BUNDLE_FIELDS,\n { staleTime: Infinity },\n )\n const isProject = EntityType.project == entityBundle.entityType\n\n // The parent's benefactor ACL will be shown if the user removes the ACL on the current entity\n const { data: parentAcl } = useSuspenseGetEntityBenefactorACL(\n entityBundle.entity.parentId!,\n {\n staleTime: Infinity,\n },\n )\n\n const consolidatedOriginalResourceAccess = useMemo(\n () =>\n consolidateResourceAccessList(entityBundle.benefactorAcl.resourceAccess),\n [entityBundle.benefactorAcl.resourceAccess],\n )\n\n const parentResourceAccess = useMemo(\n () => parentAcl?.resourceAccess ?? [],\n [parentAcl],\n )\n const canEdit = entityBundle.permissions.canChangePermissions\n const isOpenData = entityBundle.permissions.isEntityOpenData\n const originalIsInherited = !(entityBundle.benefactorAcl.id == entityId)\n const [updatedIsInherited, setUpdatedIsInherited] =\n useState(originalIsInherited)\n const [notifyNewAdditions, setNotifyNewAdditions] = useState(false)\n const [error, setError] = useState<Error>()\n\n const {\n resourceAccessList: updatedResourceAccessList,\n setResourceAccessList,\n addResourceAccessItem,\n updateResourceAccessItem,\n removeResourceAccessItem,\n resetDirtyState,\n } = useUpdateAcl({\n initialResourceAccessList: consolidatedOriginalResourceAccess,\n })\n\n // If `consolidatedOriginalResourceAccess` changes, reset state\n useEffect(() => {\n if (consolidatedOriginalResourceAccess) {\n resetDirtyState()\n setResourceAccessList([...consolidatedOriginalResourceAccess])\n }\n }, [\n consolidatedOriginalResourceAccess,\n resetDirtyState,\n setResourceAccessList,\n ])\n\n // If `originalIsInherited` changes, reset state\n useEffect(() => {\n resetDirtyState()\n setUpdatedIsInherited(originalIsInherited)\n }, [originalIsInherited, resetDirtyState])\n\n // If the editor toggles the inherited state, reset the resource access list\n useEffect(() => {\n if (originalIsInherited == updatedIsInherited) {\n // The user reverted to the original state (regardless of inherited or not)\n setResourceAccessList(consolidatedOriginalResourceAccess)\n } else if (updatedIsInherited) {\n // The user toggled to inherited, update the resource access list to match the parent\n setResourceAccessList(parentResourceAccess)\n } else {\n // The user toggled to local, no need to update the list (the parent's list is already in the editor)\n }\n resetDirtyState()\n }, [\n originalIsInherited,\n consolidatedOriginalResourceAccess,\n parentResourceAccess,\n resetDirtyState,\n setResourceAccessList,\n updatedIsInherited,\n ])\n\n const isPublic = isEntityPublic(\n updatedResourceAccessList,\n realmPrincipals ?? {},\n )\n\n const {\n sendNotification,\n isLoading: isLoadingSendMessageToNewACLUsers,\n isPending: isPendingSendMessageToNewACLUsers,\n } = useNotifyNewACLUsers({\n subject: getSubject(entityBundle.entity.name || ''),\n body: getBody(ownProfile, entityId),\n initialResourceAccessList: consolidatedOriginalResourceAccess,\n newResourceAccessList: updatedResourceAccessList,\n })\n\n const mutationOptions = {\n onSuccess: () => {\n if (notifyNewAdditions) {\n sendNotification()\n }\n onUpdateSuccess()\n },\n onError: (e: Error) => {\n setError(e)\n },\n }\n\n const { mutate: createAcl, isPending: isPendingCreateAcl } =\n useCreateEntityACL(mutationOptions)\n const { mutate: updateAcl, isPending: isPendingUpdateAcl } =\n useUpdateEntityACL(mutationOptions)\n const { mutate: deleteAcl, isPending: isPendingDeleteAcl } =\n useDeleteEntityACL(mutationOptions)\n\n const isPending =\n isPendingCreateAcl ||\n isPendingUpdateAcl ||\n isPendingDeleteAcl ||\n isPendingSendMessageToNewACLUsers\n\n const hasAclChanged = useMemo(() => {\n return (\n originalIsInherited != updatedIsInherited ||\n !resourceAccessListIsEqual(\n consolidatedOriginalResourceAccess,\n updatedResourceAccessList,\n )\n )\n }, [\n consolidatedOriginalResourceAccess,\n originalIsInherited,\n updatedIsInherited,\n updatedResourceAccessList,\n ])\n\n const canSave =\n hasAclChanged || isLoadingSendMessageToNewACLUsers || isPending\n\n const showInheritedAclUpdateWarning = hasAclChanged && isAfterUpload\n\n useEffect(() => {\n onCanSaveChange(canSave)\n }, [onCanSaveChange, canSave])\n\n useImperativeHandle(\n ref,\n () => {\n return {\n save() {\n if (canSave) {\n // Check if the inheritance changed; if so, the ACL should be created/deleted\n if (originalIsInherited != updatedIsInherited) {\n if (updatedIsInherited) {\n deleteAcl(entityId)\n } else {\n createAcl({\n id: entityId,\n resourceAccess: updatedResourceAccessList,\n })\n }\n } else {\n // Inheritance did not change; update the ACL\n updateAcl({\n // ensure we get all fields from the original ACL, including the etag\n ...entityBundle.accessControlList!,\n resourceAccess: updatedResourceAccessList,\n })\n }\n } else {\n console.error('EntityAclEditor: save() called but canSave is false')\n }\n },\n }\n },\n [\n canSave,\n createAcl,\n deleteAcl,\n entityBundle,\n entityId,\n originalIsInherited,\n updateAcl,\n updatedIsInherited,\n updatedResourceAccessList,\n ],\n )\n\n return (\n <Stack\n sx={{\n gap: 2,\n }}\n >\n <OpenData\n isOpenData={isOpenData}\n isPublic={isPublic}\n currentUserCanUpdateSharingSettings={canEdit}\n />\n <InheritanceMessage\n isProject={isProject}\n isInherited={updatedIsInherited}\n benefactorId={updatedIsInherited ? parentAcl?.id : entityId}\n isAfterUpload={isAfterUpload}\n />\n {showInheritedAclUpdateWarning && (\n <FullWidthAlert\n isGlobal={false}\n variant={'warning'}\n title={`Edits will affect settings of entire ${entityTypeToFriendlyName(\n entityBundle?.entityType,\n ).toLowerCase()}.`}\n description={\n <>\n <p>\n Editing the settings here will impact the sharing settings for\n all files and folders within this{' '}\n {entityTypeToFriendlyName(\n entityBundle?.entityType,\n ).toLowerCase()}\n , not just the ones you've recently uploaded.\n </p>\n <p>\n View the instructions above for setting your{' '}\n <Link\n href={\n SYNAPSE_DOCS_SHARING_SETTINGS_PERMISSIONS_CONDITIONS_FOR_USE_URL\n }\n target={'_blank'}\n >\n Local Sharing Settings\n </Link>\n .\n </p>\n </>\n }\n />\n )}\n {/* Create / delete local sharing settings button */}\n {!isAfterUpload &&\n !isProject &&\n entityBundle.permissions.canEnableInheritance && (\n <CreateOrDeleteLocalSharingSettingsButton\n isInherited={updatedIsInherited}\n setIsInherited={setUpdatedIsInherited}\n />\n )}\n {error && <Alert severity=\"error\">{error.message}</Alert>}\n <AclEditor\n isInherited={updatedIsInherited}\n canEdit={getCanEditResourceAccess(\n canEdit,\n updatedIsInherited,\n ownProfile,\n publicGroupId,\n )}\n canRemoveEntry={getCanDeleteResourceAccess(\n canEdit,\n updatedIsInherited,\n ownProfile,\n )}\n resourceAccessList={updatedResourceAccessList}\n availablePermissionLevels={availablePermissionLevels}\n emptyText={/* This should never happen */ ''}\n displayedPermissionLevelOverride={getDisplayedPermissionLevelOverride(\n isOpenData,\n publicGroupId,\n )}\n onAddPrincipalToAcl={id => {\n if (publicGroupId !== undefined && String(id) === publicGroupId) {\n addResourceAccessItem(\n id,\n getAccessTypeFromPermissionLevel('CAN_VIEW'),\n )\n } else {\n addResourceAccessItem(\n id,\n getAccessTypeFromPermissionLevel('CAN_DOWNLOAD'),\n )\n }\n }}\n updateResourceAccessItem={updateResourceAccessItem}\n removeResourceAccessItem={removeResourceAccessItem}\n showNotifyCheckbox={true}\n notifyCheckboxValue={notifyNewAdditions}\n onNotifyCheckboxChange={setNotifyNewAdditions}\n showAddRemovePublicButton={true}\n />\n </Stack>\n )\n})\n\nconst EntityAclEditorWithSuspense = forwardRef(\n function EntityAclEditorWithSuspense(\n props: EntityAclEditorProps,\n ref: ForwardedRef<EntityAclEditorHandle>,\n ) {\n return (\n <SynapseErrorBoundary>\n <Suspense fallback={<AclEditorSkeleton />}>\n <EntityAclEditor {...props} ref={ref} />\n </Suspense>\n </SynapseErrorBoundary>\n )\n },\n)\n\nexport default EntityAclEditorWithSuspense\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,IAAM,KAA+C;CACnD;CACA;CACA;CACA;CACA;CACD;AAmBD,SAAS,EAAW,GAAoB;AACtC,QAAO,GAAG,EAAW;;AAGvB,SAAS,EAAQ,GAAsB,GAAkB;AACvD,QAAO,GAAG,EACR;EACE,UAAU,EAAQ,YAAY;EAC9B,WAAW,EAAQ;EACn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ACA,EAAiC,WAAW,CAC7C,GAED,EACE,GACA,EAAiC,eAAe,CACjD;;IAGqB;IACA;IAC1B,oBAAoB;IACpB,qBAAqB;IACrB,wBAAwB;IACxB,2BAA2B;IAC3B,CAAA;GACI;;EAEV,EAEI,IAA8B,EAClC,SACE,GACA,GACA;AACA,QACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;EAAU,UAAU,kBAAC,GAAD,EAAqB,CAAA;YACvC,kBAAC,GAAD;GAAiB,GAAI;GAAY;GAAO,CAAA;EAC/B,CAAA,EACU,CAAA;EAG5B"}
|
|
1
|
+
{"version":3,"file":"EntityAclEditor.js","names":[],"sources":["../../../src/components/EntityAclEditor/EntityAclEditor.tsx"],"sourcesContent":["import {\n useCreateEntityACL,\n useDeleteEntityACL,\n useSuspenseGetCurrentUserProfile,\n useSuspenseGetEntityBenefactorACL,\n useSuspenseGetEntityBundle,\n useUpdateEntityACL,\n} from '@/synapse-queries'\nimport { useGetRealmPrincipals } from '@/synapse-queries/realm/useRealmPrincipals'\nimport { BackendDestinationEnum, getEndpoint } from '@/utils/functions'\nimport {\n consolidateResourceAccessList,\n isEntityPublic,\n resourceAccessListIsEqual,\n} from '@/utils/functions/AccessControlListUtils'\nimport { getPrincipalDisplayName } from '@/utils/functions/getPrincipalDisplayName'\nimport { entityTypeToFriendlyName } from '@/utils/functions/EntityTypeUtils'\nimport {\n getAccessTypeFromPermissionLevel,\n PermissionLevel,\n permissionLevelToLabel,\n} from '@/utils/PermissionLevelToAccessType'\nimport { SYNAPSE_DOCS_SHARING_SETTINGS_PERMISSIONS_CONDITIONS_FOR_USE_URL } from '@/utils/SynapseConstants'\nimport { Alert, Link, Stack } from '@mui/material'\nimport { EntityType } from '@sage-bionetworks/synapse-client'\nimport {\n ALL_ENTITY_BUNDLE_FIELDS,\n ResourceAccess,\n UserProfile,\n} from '@sage-bionetworks/synapse-types'\nimport {\n ForwardedRef,\n forwardRef,\n Suspense,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from 'react'\nimport { AclEditor, AclEditorProps } from '../AclEditor/AclEditor'\nimport { AclEditorSkeleton } from '../AclEditor/AclEditorSkeleton'\nimport useUpdateAcl from '../AclEditor/useUpdateAcl'\nimport { SynapseErrorBoundary } from '../error'\nimport FullWidthAlert from '../FullWidthAlert'\nimport { CreateOrDeleteLocalSharingSettingsButton } from './CreateOrDeleteLocalSharingSettingsButton'\nimport { InheritanceMessage } from './InheritanceMessage'\nimport OpenData from './OpenData'\nimport useNotifyNewACLUsers from './useNotifyNewACLUsers'\n\nconst availablePermissionLevels: PermissionLevel[] = [\n 'CAN_VIEW',\n 'CAN_DOWNLOAD',\n 'CAN_EDIT',\n 'CAN_EDIT_DELETE',\n 'CAN_ADMINISTER',\n]\n\nexport type EntityAclEditorProps = {\n /** The ID of the entity on which to view/edit the ACL. Note that the ACL may actually belong to an entity ancestor (benefactor). */\n entityId: string\n /** Invoked when the user can/cannot save the pending changes. */\n onCanSaveChange: (canSaveChanges: boolean) => void\n /** Invoked when changes are successfully made. */\n onUpdateSuccess: () => void\n /** Special case to show specific copy and allow changes to an inherited ACL immediately after a file is uploaded.\n * Note that if this is true, the entityId should be the ID of the folder or project that is the benefactor of the newly uploaded file(s)\n * @defaultValue false */\n isAfterUpload?: boolean\n}\n\nexport type EntityAclEditorHandle = {\n save: () => void\n}\n\nfunction getSubject(entityName: string) {\n return `${entityName} (shared on Synapse)`\n}\n\nfunction getBody(profile: UserProfile, entityId: string) {\n return `${getPrincipalDisplayName(\n {\n userName: profile.userName ?? '',\n firstName: profile.firstName,\n lastName: profile.lastName,\n },\n { showFullName: true, showUsername: false },\n )} has shared an item with you on Synapse:\\n${getEndpoint(\n BackendDestinationEnum.PORTAL_ENDPOINT,\n )}Synapse:${entityId}`\n}\n\nfunction getCanEditResourceAccess(\n canEdit: boolean,\n isInherited: boolean,\n ownProfile: UserProfile,\n publicGroupId: string | undefined,\n): AclEditorProps['canEdit'] {\n if (!canEdit || isInherited) {\n return false\n }\n return (resourceAccess: ResourceAccess): boolean => {\n // Users cannot change their own permissions\n const isSelf = ownProfile.ownerId === String(resourceAccess.principalId)\n // Users cannot change permission level for the public group, only add/remove it.\n // To give the public group DOWNLOAD access, ACT must mark it as anonymous access.\n const isPublicGroup =\n publicGroupId !== undefined &&\n String(resourceAccess.principalId) === publicGroupId\n if (isSelf || isPublicGroup) {\n return false\n }\n return true\n }\n}\n\nfunction getCanDeleteResourceAccess(\n canEdit: boolean,\n isInherited: boolean,\n ownProfile: UserProfile,\n): AclEditorProps['canRemoveEntry'] {\n if (!canEdit || isInherited) {\n return false\n }\n return (resourceAccess: ResourceAccess): boolean => {\n // Users cannot delete their own permissions\n const isSelf = ownProfile.ownerId === String(resourceAccess.principalId)\n if (isSelf) {\n return false\n }\n return canEdit\n }\n}\n\nfunction getDisplayedPermissionLevelOverride(\n isOpenData: boolean,\n publicGroupId: string | undefined,\n): AclEditorProps['displayedPermissionLevelOverride'] {\n return (resourceAccess: ResourceAccess) => {\n if (\n publicGroupId !== undefined &&\n String(resourceAccess.principalId) === publicGroupId\n ) {\n return isOpenData\n ? permissionLevelToLabel['CAN_DOWNLOAD']\n : permissionLevelToLabel['CAN_VIEW']\n }\n return undefined\n }\n}\n\nconst EntityAclEditor = forwardRef(function EntityAclEditor(\n props: EntityAclEditorProps,\n ref: ForwardedRef<EntityAclEditorHandle>,\n) {\n const {\n entityId,\n onCanSaveChange,\n onUpdateSuccess,\n isAfterUpload = false,\n } = props\n\n const { data: ownProfile } = useSuspenseGetCurrentUserProfile()\n const { data: realmPrincipals } = useGetRealmPrincipals()\n const { publicGroup: publicGroupId } = realmPrincipals || {}\n const { data: entityBundle } = useSuspenseGetEntityBundle(\n entityId,\n undefined,\n ALL_ENTITY_BUNDLE_FIELDS,\n { staleTime: Infinity },\n )\n const isProject = EntityType.project == entityBundle.entityType\n\n // The parent's benefactor ACL will be shown if the user removes the ACL on the current entity\n const { data: parentAcl } = useSuspenseGetEntityBenefactorACL(\n entityBundle.entity.parentId!,\n {\n staleTime: Infinity,\n },\n )\n\n const consolidatedOriginalResourceAccess = useMemo(\n () =>\n consolidateResourceAccessList(entityBundle.benefactorAcl.resourceAccess),\n [entityBundle.benefactorAcl.resourceAccess],\n )\n\n const parentResourceAccess = useMemo(\n () => parentAcl?.resourceAccess ?? [],\n [parentAcl],\n )\n const canEdit = entityBundle.permissions.canChangePermissions\n const isOpenData = entityBundle.permissions.isEntityOpenData\n const originalIsInherited = !(entityBundle.benefactorAcl.id == entityId)\n const [updatedIsInherited, setUpdatedIsInherited] =\n useState(originalIsInherited)\n const [notifyNewAdditions, setNotifyNewAdditions] = useState(false)\n const [error, setError] = useState<Error>()\n\n const {\n resourceAccessList: updatedResourceAccessList,\n setResourceAccessList,\n addResourceAccessItem,\n updateResourceAccessItem,\n removeResourceAccessItem,\n resetDirtyState,\n } = useUpdateAcl({\n initialResourceAccessList: consolidatedOriginalResourceAccess,\n })\n\n // If `consolidatedOriginalResourceAccess` changes, reset state\n useEffect(() => {\n if (consolidatedOriginalResourceAccess) {\n resetDirtyState()\n setResourceAccessList([...consolidatedOriginalResourceAccess])\n }\n }, [\n consolidatedOriginalResourceAccess,\n resetDirtyState,\n setResourceAccessList,\n ])\n\n // If `originalIsInherited` changes, reset state\n useEffect(() => {\n resetDirtyState()\n setUpdatedIsInherited(originalIsInherited)\n }, [originalIsInherited, resetDirtyState])\n\n // If the editor toggles the inherited state, reset the resource access list\n useEffect(() => {\n if (originalIsInherited == updatedIsInherited) {\n // The user reverted to the original state (regardless of inherited or not)\n setResourceAccessList(consolidatedOriginalResourceAccess)\n } else if (updatedIsInherited) {\n // The user toggled to inherited, update the resource access list to match the parent\n setResourceAccessList(parentResourceAccess)\n } else {\n // The user toggled to local, no need to update the list (the parent's list is already in the editor)\n }\n resetDirtyState()\n }, [\n originalIsInherited,\n consolidatedOriginalResourceAccess,\n parentResourceAccess,\n resetDirtyState,\n setResourceAccessList,\n updatedIsInherited,\n ])\n\n const isPublic = isEntityPublic(\n updatedResourceAccessList,\n realmPrincipals ?? {},\n )\n\n const {\n sendNotification,\n isLoading: isLoadingSendMessageToNewACLUsers,\n isPending: isPendingSendMessageToNewACLUsers,\n } = useNotifyNewACLUsers({\n subject: getSubject(entityBundle.entity.name || ''),\n body: getBody(ownProfile, entityId),\n initialResourceAccessList: consolidatedOriginalResourceAccess,\n newResourceAccessList: updatedResourceAccessList,\n })\n\n const mutationOptions = {\n onSuccess: () => {\n if (notifyNewAdditions) {\n sendNotification()\n }\n onUpdateSuccess()\n },\n onError: (e: Error) => {\n setError(e)\n },\n }\n\n const { mutate: createAcl, isPending: isPendingCreateAcl } =\n useCreateEntityACL(mutationOptions)\n const { mutate: updateAcl, isPending: isPendingUpdateAcl } =\n useUpdateEntityACL(mutationOptions)\n const { mutate: deleteAcl, isPending: isPendingDeleteAcl } =\n useDeleteEntityACL(mutationOptions)\n\n const isPending =\n isPendingCreateAcl ||\n isPendingUpdateAcl ||\n isPendingDeleteAcl ||\n isPendingSendMessageToNewACLUsers\n\n const hasAclChanged = useMemo(() => {\n return (\n originalIsInherited != updatedIsInherited ||\n !resourceAccessListIsEqual(\n consolidatedOriginalResourceAccess,\n updatedResourceAccessList,\n )\n )\n }, [\n consolidatedOriginalResourceAccess,\n originalIsInherited,\n updatedIsInherited,\n updatedResourceAccessList,\n ])\n\n const canSave =\n hasAclChanged || isLoadingSendMessageToNewACLUsers || isPending\n\n const showInheritedAclUpdateWarning = hasAclChanged && isAfterUpload\n\n useEffect(() => {\n onCanSaveChange(canSave)\n }, [onCanSaveChange, canSave])\n\n useImperativeHandle(ref, () => {\n return {\n save() {\n if (canSave) {\n // Check if the inheritance changed; if so, the ACL should be created/deleted\n if (originalIsInherited != updatedIsInherited) {\n if (updatedIsInherited) {\n deleteAcl(entityId)\n } else {\n createAcl({\n id: entityId,\n resourceAccess: updatedResourceAccessList,\n })\n }\n } else {\n // Inheritance did not change; update the ACL\n updateAcl({\n // ensure we get all fields from the original ACL, including the etag\n ...entityBundle.accessControlList!,\n resourceAccess: updatedResourceAccessList,\n })\n }\n } else {\n console.error('EntityAclEditor: save() called but canSave is false')\n }\n },\n }\n }, [\n canSave,\n createAcl,\n deleteAcl,\n entityBundle,\n entityId,\n originalIsInherited,\n updateAcl,\n updatedIsInherited,\n updatedResourceAccessList,\n ])\n\n return (\n <Stack\n sx={{\n gap: 2,\n }}\n >\n <OpenData\n isOpenData={isOpenData}\n isPublic={isPublic}\n currentUserCanUpdateSharingSettings={canEdit}\n />\n <InheritanceMessage\n isProject={isProject}\n isInherited={updatedIsInherited}\n benefactorId={updatedIsInherited ? parentAcl?.id : entityId}\n isAfterUpload={isAfterUpload}\n />\n {showInheritedAclUpdateWarning && (\n <FullWidthAlert\n isGlobal={false}\n variant={'warning'}\n title={`Edits will affect settings of entire ${entityTypeToFriendlyName(\n entityBundle?.entityType,\n ).toLowerCase()}.`}\n description={\n <>\n <p>\n Editing the settings here will impact the sharing settings for\n all files and folders within this{' '}\n {entityTypeToFriendlyName(\n entityBundle?.entityType,\n ).toLowerCase()}\n , not just the ones you've recently uploaded.\n </p>\n <p>\n View the instructions above for setting your{' '}\n <Link\n href={\n SYNAPSE_DOCS_SHARING_SETTINGS_PERMISSIONS_CONDITIONS_FOR_USE_URL\n }\n target={'_blank'}\n >\n Local Sharing Settings\n </Link>\n .\n </p>\n </>\n }\n />\n )}\n {/* Create / delete local sharing settings button */}\n {!isAfterUpload &&\n !isProject &&\n entityBundle.permissions.canEnableInheritance && (\n <CreateOrDeleteLocalSharingSettingsButton\n isInherited={updatedIsInherited}\n setIsInherited={setUpdatedIsInherited}\n />\n )}\n {error && <Alert severity=\"error\">{error.message}</Alert>}\n <AclEditor\n isInherited={updatedIsInherited}\n canEdit={getCanEditResourceAccess(\n canEdit,\n updatedIsInherited,\n ownProfile,\n publicGroupId,\n )}\n canRemoveEntry={getCanDeleteResourceAccess(\n canEdit,\n updatedIsInherited,\n ownProfile,\n )}\n resourceAccessList={updatedResourceAccessList}\n availablePermissionLevels={availablePermissionLevels}\n emptyText={/* This should never happen */ ''}\n displayedPermissionLevelOverride={getDisplayedPermissionLevelOverride(\n isOpenData,\n publicGroupId,\n )}\n onAddPrincipalToAcl={id => {\n if (publicGroupId !== undefined && String(id) === publicGroupId) {\n addResourceAccessItem(\n id,\n getAccessTypeFromPermissionLevel('CAN_VIEW'),\n )\n } else {\n addResourceAccessItem(\n id,\n getAccessTypeFromPermissionLevel('CAN_DOWNLOAD'),\n )\n }\n }}\n updateResourceAccessItem={updateResourceAccessItem}\n removeResourceAccessItem={removeResourceAccessItem}\n showNotifyCheckbox={true}\n notifyCheckboxValue={notifyNewAdditions}\n onNotifyCheckboxChange={setNotifyNewAdditions}\n showAddRemovePublicButton={true}\n />\n </Stack>\n )\n})\n\nconst EntityAclEditorWithSuspense = forwardRef(\n function EntityAclEditorWithSuspense(\n props: EntityAclEditorProps,\n ref: ForwardedRef<EntityAclEditorHandle>,\n ) {\n return (\n <SynapseErrorBoundary>\n <Suspense fallback={<AclEditorSkeleton />}>\n <EntityAclEditor {...props} ref={ref} />\n </Suspense>\n </SynapseErrorBoundary>\n )\n },\n)\n\nexport default EntityAclEditorWithSuspense\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,IAAM,KAA+C;CACnD;CACA;CACA;CACA;CACA;CACD;AAmBD,SAAS,EAAW,GAAoB;AACtC,QAAO,GAAG,EAAW;;AAGvB,SAAS,EAAQ,GAAsB,GAAkB;AACvD,QAAO,GAAG,EACR;EACE,UAAU,EAAQ,YAAY;EAC9B,WAAW,EAAQ;EACnB,UAAU,EAAQ;EACnB,EACD;EAAE,cAAc;EAAM,cAAc;EAAO,CAC5C,CAAC,4CAA4C,EAC5C,EAAuB,gBACxB,CAAC,UAAU;;AAGd,SAAS,EACP,GACA,GACA,GACA,GAC2B;AAI3B,QAHI,CAAC,KAAW,IACP,MAED,MAA4C;EAElD,IAAM,IAAS,EAAW,YAAY,OAAO,EAAe,YAAY,EAGlE,IACJ,MAAkB,KA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AAqB,CAAA;YACvC,kBAAC,GAAD;GAAiB,GAAI;GAAY;GAAO,CAAA;EAC/B,CAAA,EACU,CAAA;EAG5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityBadgeIcons.d.ts","sourceRoot":"","sources":["../../../src/components/EntityBadgeIcons/EntityBadgeIcons.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAOlD,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"EntityBadgeIcons.d.ts","sourceRoot":"","sources":["../../../src/components/EntityBadgeIcons/EntityBadgeIcons.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAOlD,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EACL,MAAM,GACN,QAAQ,GACR,cAAc,GACd,SAAS,GACT,SAAS,GACT,QAAQ,GACR,OAAO,GACP,cAAc,CAAA;IAClB,cAAc,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,MAAM,CAAA;IACnD,qFAAqF;IACrF,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,oFAAoF;IACpF,2BAA2B,CAAC,EAAE,OAAO,CAAA;IACrC,+HAA+H;IAC/H,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,wDAAwD;IACxD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,0FAA0F;IAC1F,uBAAuB,CAAC,EAAE,OAAO,CAAA;IAEjC,UAAU,CAAC,EAAE,OAAO,CAAA;IAEpB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACxC,wFAAwF;IACxF,YAAY,EAAE,OAAO,CAAA;CACtB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAC3B,OAAO,qBAAqB,KAC3B,KAAK,CAAC,SAqSR,CAAA;AAED,eAAe,gBAAgB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityBadgeIcons.js","names":[],"sources":["../../../src/components/EntityBadgeIcons/EntityBadgeIcons.tsx"],"sourcesContent":["import {\n useDeleteEntity,\n useGetEntityBundle,\n useGetJson,\n useGetSchemaBinding,\n useGetValidationResults,\n} from '@/synapse-queries'\nimport { useGetRealmPrincipals } from '@/synapse-queries/realm/useRealmPrincipals'\nimport { isEntityPublic } from '@/utils/functions/AccessControlListUtils'\nimport {\n ChatBubbleTwoTone,\n CheckTwoTone,\n DescriptionTwoTone,\n LinkOffTwoTone,\n LocalOfferTwoTone,\n LockTwoTone,\n PublicTwoTone,\n} from '@mui/icons-material'\nimport { Tooltip } from '@mui/material'\nimport { EntityType } from '@sage-bionetworks/synapse-client'\nimport { ALL_ENTITY_BUNDLE_FIELDS } from '@sage-bionetworks/synapse-types'\nimport { isEmpty } from 'lodash-es'\nimport React, { useEffect, useState } from 'react'\nimport { useInView } from 'react-intersection-observer'\nimport { getDisplayedAnnotation } from '../entity/metadata/AnnotationsTable'\nimport { EntityModal } from '../entity/metadata/EntityModal'\nimport { HoverPopover } from '../styled/HoverPopover'\nimport WarningDialog from '../SynapseForm/WarningDialog'\n\nexport type EntityBadgeIconsProps = {\n entityId: string\n versionNumber?: number\n flexWrap?: // possible settings for flex-wrap\n | 'wrap'\n | 'nowrap'\n | '-moz-initial'\n | 'inherit'\n | 'initial'\n | 'revert'\n | 'unset'\n | 'wrap-reverse'\n justifyContent?: 'flex-start' | 'flex-end' | string\n /** Shows an icon indicating if the entity is 'public' or 'private'. Default true */\n showIsPublicPrivate?: boolean\n /** Shows an icon if the entity has sharing settings set on itself. Default true */\n showHasLocalSharingSettings?: boolean\n /** Shows an icon if the entity has annotations, or if it has a validation schema (in experimental mode only). Default true */\n showHasAnnotations?: boolean\n /** Shows an icon if the entity a wiki. Default true */\n showHasWiki?: boolean\n /** Shows an icon if the entity has been mentioned in discussion threads. Default true */\n showHasDiscussionThread?: boolean\n /* Shows an 'unlink' button if the entity is a link and the user has permission to delete it. Default true */\n showUnlink?: boolean\n /* Invoked after the entity is unlinked/deleted in case there is cleanup to do. Returns the entityId */\n onUnlink?: (entityId: string) => void\n onUnlinkError?: (error: unknown) => void\n /** Whether or not the badges (e.g. Annotations) can trigger opening a modal on click */\n canOpenModal: boolean\n}\n\n/**\n * Stateless component used to show icons that show an entity's status.\n * Adapted from https://github.com/Sage-Bionetworks/SynapseWebClient/blob/46b9b717636cda2421926d96365244bbb72a05b6/src/main/java/org/sagebionetworks/web/client/widget/entity/EntityBadge.java\n */\nexport const EntityBadgeIcons = (\n props: EntityBadgeIconsProps,\n): React.ReactNode => {\n const {\n entityId,\n versionNumber,\n flexWrap = 'nowrap',\n justifyContent = 'flex-start',\n showIsPublicPrivate = true,\n showHasLocalSharingSettings = true,\n showHasAnnotations = true,\n showHasWiki = true,\n showHasDiscussionThread = true,\n showUnlink = true,\n onUnlink = () => {\n /* noop */\n },\n onUnlinkError = () => {\n /* noop */\n },\n canOpenModal,\n } = props\n\n const { data } = useGetRealmPrincipals()\n const realmPrincipals = data || {}\n\n enum SchemaConformanceState {\n NO_SCHEMA = '', // or not in experimental mode\n VALID = 'Valid',\n INVALID = 'Invalid',\n ANNOTATIONS_MISSING = 'Missing',\n }\n\n const { ref, inView } = useInView()\n\n const { data: entityData } = useGetJson(entityId, versionNumber, true, {\n enabled: inView,\n })\n const annotations = entityData?.annotations\n const { data: bundle } = useGetEntityBundle(\n entityId,\n versionNumber,\n ALL_ENTITY_BUNDLE_FIELDS,\n {\n enabled: inView,\n },\n )\n const [showModal, setShowModal] = useState(false)\n const [showUnlinkConfirmModal, setShowUnlinkConfirmModal] = useState(false)\n const [schemaConformance, setSchemaConformance] = useState(\n SchemaConformanceState.NO_SCHEMA,\n )\n\n const { data: boundSchema } = useGetSchemaBinding(entityId, {\n enabled: inView,\n staleTime: 60 * 1000, // 60 seconds\n })\n\n const { data: schemaValidationResults } = useGetValidationResults(entityId, {\n enabled: inView && !!boundSchema,\n staleTime: 60 * 1000, // 60 seconds\n })\n\n const annotationsCount =\n annotations && !isEmpty(annotations) ? Object.keys(annotations).length : 0\n useEffect(() => {\n if (schemaValidationResults) {\n if (schemaValidationResults.isValid) {\n setSchemaConformance(SchemaConformanceState.VALID)\n } else if (annotationsCount) {\n // If annotations exist, then indicate that they are invalid\n setSchemaConformance(SchemaConformanceState.INVALID)\n } else {\n // If annotations are missing, it's still invalid, but should appear differently\n setSchemaConformance(SchemaConformanceState.ANNOTATIONS_MISSING)\n }\n }\n }, [\n schemaValidationResults,\n annotationsCount,\n annotations,\n SchemaConformanceState.VALID,\n SchemaConformanceState.INVALID,\n SchemaConformanceState.ANNOTATIONS_MISSING,\n ])\n\n const { mutate: unlinkEntity } = useDeleteEntity({\n onSuccess: (_, entityId) => {\n onUnlink(entityId)\n },\n onError: onUnlinkError,\n })\n\n /**\n * Convert the list of annotations to a string of <tr>...anno1</tr><tr>...anno2</tr>...\n * If there are no annotations, this is the empty string ('')\n */\n const annotationsTableRows = (\n <>\n {annotations\n ? Object.entries(annotations ?? []).map(([key, value]) => (\n <tr key={key}>\n <td>\n <b>{key}</b>\n </td>\n <td>\n {Array.isArray(value)\n ? value.map(getDisplayedAnnotation).join(', ')\n : getDisplayedAnnotation(value as string | number | boolean)}\n </td>\n </tr>\n ))\n : ''}\n </>\n )\n // We also show the schema name if there is one (and we're in experimental mode)\n const valiationSchemaTableRow = (\n <>\n {boundSchema ? (\n <tr>\n <td>\n <b>Validation Schema</b>\n </td>\n <td>{boundSchema.jsonSchemaVersionInfo.schemaName}</td>\n </tr>\n ) : (\n ''\n )}\n </>\n )\n const annotationsTitle = schemaValidationResults\n ? `${schemaConformance} Annotations`\n : ''\n const annotationsHtml = (\n <div className=\"EntityBadgeTooltip\">\n <table>\n <tbody>\n {annotationsTableRows ? annotationsTableRows : ''}\n {valiationSchemaTableRow}\n </tbody>\n </table>\n </div>\n )\n\n return (\n <div className=\"EntityBadge\" ref={ref} style={{ flexWrap, justifyContent }}>\n {bundle && (\n <>\n <div onClick={e => e.stopPropagation()}>\n <EntityModal\n entityId={entityId}\n show={showModal}\n showTabs={false}\n onClose={() => setShowModal(false)}\n initialTab={'ANNOTATIONS'}\n />\n </div>\n {showIsPublicPrivate &&\n bundle.benefactorAcl &&\n isEntityPublic(\n bundle.benefactorAcl.resourceAccess,\n realmPrincipals,\n ) ? (\n <Tooltip title=\"Public\" enterNextDelay={100} placement=\"right\">\n <PublicTwoTone\n aria-hidden={false}\n role=\"img\"\n className=\"EntityBadge__Badge\"\n data-testid={'is-public-icon'}\n />\n </Tooltip>\n ) : null}\n {showIsPublicPrivate &&\n bundle.benefactorAcl &&\n !isEntityPublic(\n bundle.benefactorAcl.resourceAccess,\n realmPrincipals,\n ) ? (\n <Tooltip title=\"Private\" enterNextDelay={100} placement=\"right\">\n <LockTwoTone\n aria-hidden={false}\n role=\"img\"\n className=\"EntityBadge__Badge\"\n data-testid={'is-private-icon'}\n />\n </Tooltip>\n ) : null}\n {showHasLocalSharingSettings &&\n bundle.benefactorAcl &&\n entityId === bundle.benefactorAcl.id ? (\n <Tooltip\n title=\"Sharing Settings have been set\"\n enterNextDelay={100}\n placement=\"right\"\n >\n <CheckTwoTone\n aria-hidden={false}\n role=\"img\"\n className=\"EntityBadge__Badge\"\n data-testid={'sharing-settings-icon'}\n />\n </Tooltip>\n ) : null}\n\n {showHasAnnotations &&\n !!(annotationsCount || schemaValidationResults) && (\n <HoverPopover\n title={annotationsTitle}\n popoverContent={annotationsHtml}\n placement=\"right\"\n maxWidth={500}\n actionButton={\n canOpenModal\n ? {\n content: 'Edit Annotations',\n onClick: () => setShowModal(true),\n closeOnClick: true,\n }\n : undefined\n }\n >\n <LocalOfferTwoTone\n aria-hidden={false}\n role={canOpenModal ? 'button' : 'img'}\n className={`EntityBadge__Badge ${schemaConformance}`}\n data-html={true}\n data-testid={'annotations-icon'}\n />\n </HoverPopover>\n )}\n {showHasWiki && bundle.rootWikiId && (\n <Tooltip title=\"Has a wiki\" enterNextDelay={100} placement=\"right\">\n <DescriptionTwoTone\n aria-hidden={false}\n role=\"img\"\n className=\"EntityBadge__Badge\"\n data-testid={'wiki-icon'}\n />\n </Tooltip>\n )}\n {showHasDiscussionThread &&\n !!bundle.threadCount &&\n !!(bundle.threadCount > 0) && (\n <Tooltip\n title=\"Has been mentioned in discussion\"\n enterNextDelay={100}\n placement=\"right\"\n >\n <ChatBubbleTwoTone\n aria-hidden={false}\n role=\"img\"\n className=\"EntityBadge__Badge\"\n data-testid={'discussion-icon'}\n />\n </Tooltip>\n )}\n {showUnlink &&\n bundle.entityType === EntityType.link &&\n bundle.permissions?.canDelete && (\n <>\n <WarningDialog\n open={showUnlinkConfirmModal}\n title=\"Confirm Unlink\"\n content={\n 'Are you sure you want to remove this link? The original object will not be changed.'\n }\n confirmButtonText=\"Unlink\"\n confirmButtonColor=\"error\"\n onConfirm={() => {\n unlinkEntity(entityId)\n setShowUnlinkConfirmModal(false)\n }}\n onCancel={() => {\n setShowUnlinkConfirmModal(false)\n }}\n />\n <Tooltip\n title=\"Remove this link\"\n enterNextDelay={100}\n placement=\"right\"\n >\n <LinkOffTwoTone\n aria-hidden={false}\n role=\"button\"\n onClick={() => setShowUnlinkConfirmModal(true)}\n className=\"EntityBadge__Badge Unlink\"\n data-testid={'unlink-icon'}\n />\n </Tooltip>\n </>\n )}\n </>\n )}\n </div>\n )\n}\n\nexport default EntityBadgeIcons\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiEA,IAAa,KACX,MACoB;CACpB,IAAM,EACJ,aACA,kBACA,cAAW,UACX,oBAAiB,cACjB,yBAAsB,IACtB,iCAA8B,IAC9B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ChB,WAAU;cAEV,kBAAC,IAAD;KACE,eAAa;KACb,MAAK;KACL,eAAe,EAA0B,GAAK;KAC9C,WAAU;KACV,eAAa;KACb,CAAA;IACM,CAAA,CACT,EAAA,CAAA;GAEN,EAAA,CAAA;EAED,CAAA"}
|
|
1
|
+
{"version":3,"file":"EntityBadgeIcons.js","names":[],"sources":["../../../src/components/EntityBadgeIcons/EntityBadgeIcons.tsx"],"sourcesContent":["import {\n useDeleteEntity,\n useGetEntityBundle,\n useGetJson,\n useGetSchemaBinding,\n useGetValidationResults,\n} from '@/synapse-queries'\nimport { useGetRealmPrincipals } from '@/synapse-queries/realm/useRealmPrincipals'\nimport { isEntityPublic } from '@/utils/functions/AccessControlListUtils'\nimport {\n ChatBubbleTwoTone,\n CheckTwoTone,\n DescriptionTwoTone,\n LinkOffTwoTone,\n LocalOfferTwoTone,\n LockTwoTone,\n PublicTwoTone,\n} from '@mui/icons-material'\nimport { Tooltip } from '@mui/material'\nimport { EntityType } from '@sage-bionetworks/synapse-client'\nimport { ALL_ENTITY_BUNDLE_FIELDS } from '@sage-bionetworks/synapse-types'\nimport { isEmpty } from 'lodash-es'\nimport React, { useEffect, useState } from 'react'\nimport { useInView } from 'react-intersection-observer'\nimport { getDisplayedAnnotation } from '../entity/metadata/AnnotationsTable'\nimport { EntityModal } from '../entity/metadata/EntityModal'\nimport { HoverPopover } from '../styled/HoverPopover'\nimport WarningDialog from '../SynapseForm/WarningDialog'\n\nexport type EntityBadgeIconsProps = {\n entityId: string\n versionNumber?: number\n flexWrap?: // possible settings for flex-wrap\n | 'wrap'\n | 'nowrap'\n | '-moz-initial'\n | 'inherit'\n | 'initial'\n | 'revert'\n | 'unset'\n | 'wrap-reverse'\n justifyContent?: 'flex-start' | 'flex-end' | string\n /** Shows an icon indicating if the entity is 'public' or 'private'. Default true */\n showIsPublicPrivate?: boolean\n /** Shows an icon if the entity has sharing settings set on itself. Default true */\n showHasLocalSharingSettings?: boolean\n /** Shows an icon if the entity has annotations, or if it has a validation schema (in experimental mode only). Default true */\n showHasAnnotations?: boolean\n /** Shows an icon if the entity a wiki. Default true */\n showHasWiki?: boolean\n /** Shows an icon if the entity has been mentioned in discussion threads. Default true */\n showHasDiscussionThread?: boolean\n /* Shows an 'unlink' button if the entity is a link and the user has permission to delete it. Default true */\n showUnlink?: boolean\n /* Invoked after the entity is unlinked/deleted in case there is cleanup to do. Returns the entityId */\n onUnlink?: (entityId: string) => void\n onUnlinkError?: (error: unknown) => void\n /** Whether or not the badges (e.g. Annotations) can trigger opening a modal on click */\n canOpenModal: boolean\n}\n\n/**\n * Stateless component used to show icons that show an entity's status.\n * Adapted from https://github.com/Sage-Bionetworks/SynapseWebClient/blob/46b9b717636cda2421926d96365244bbb72a05b6/src/main/java/org/sagebionetworks/web/client/widget/entity/EntityBadge.java\n */\nexport const EntityBadgeIcons = (\n props: EntityBadgeIconsProps,\n): React.ReactNode => {\n const {\n entityId,\n versionNumber,\n flexWrap = 'nowrap',\n justifyContent = 'flex-start',\n showIsPublicPrivate = true,\n showHasLocalSharingSettings = true,\n showHasAnnotations = true,\n showHasWiki = true,\n showHasDiscussionThread = true,\n showUnlink = true,\n onUnlink = () => {\n /* noop */\n },\n onUnlinkError = () => {\n /* noop */\n },\n canOpenModal,\n } = props\n\n const { data } = useGetRealmPrincipals()\n const realmPrincipals = data || {}\n\n enum SchemaConformanceState {\n NO_SCHEMA = '', // or not in experimental mode\n VALID = 'Valid',\n INVALID = 'Invalid',\n ANNOTATIONS_MISSING = 'Missing',\n }\n\n const { ref, inView } = useInView()\n\n const { data: entityData } = useGetJson(entityId, versionNumber, true, {\n enabled: inView,\n })\n const annotations = entityData?.annotations\n const { data: bundle } = useGetEntityBundle(\n entityId,\n versionNumber,\n ALL_ENTITY_BUNDLE_FIELDS,\n {\n enabled: inView,\n },\n )\n const [showModal, setShowModal] = useState(false)\n const [showUnlinkConfirmModal, setShowUnlinkConfirmModal] = useState(false)\n const [schemaConformance, setSchemaConformance] = useState(\n SchemaConformanceState.NO_SCHEMA,\n )\n\n const { data: boundSchema } = useGetSchemaBinding(entityId, {\n enabled: inView,\n staleTime: 60 * 1000, // 60 seconds\n })\n\n const { data: schemaValidationResults } = useGetValidationResults(entityId, {\n enabled: inView && !!boundSchema,\n staleTime: 60 * 1000, // 60 seconds\n })\n\n const annotationsCount =\n annotations && !isEmpty(annotations) ? Object.keys(annotations).length : 0\n useEffect(() => {\n if (schemaValidationResults) {\n if (schemaValidationResults.isValid) {\n setSchemaConformance(SchemaConformanceState.VALID)\n } else if (annotationsCount) {\n // If annotations exist, then indicate that they are invalid\n setSchemaConformance(SchemaConformanceState.INVALID)\n } else {\n // If annotations are missing, it's still invalid, but should appear differently\n setSchemaConformance(SchemaConformanceState.ANNOTATIONS_MISSING)\n }\n }\n }, [\n schemaValidationResults,\n annotationsCount,\n annotations,\n SchemaConformanceState.VALID,\n SchemaConformanceState.INVALID,\n SchemaConformanceState.ANNOTATIONS_MISSING,\n ])\n\n const { mutate: unlinkEntity } = useDeleteEntity({\n onSuccess: (_, entityId) => {\n onUnlink(entityId)\n },\n onError: onUnlinkError,\n })\n\n /**\n * Convert the list of annotations to a string of <tr>...anno1</tr><tr>...anno2</tr>...\n * If there are no annotations, this is the empty string ('')\n */\n const annotationsTableRows = (\n <>\n {annotations\n ? Object.entries(annotations ?? []).map(([key, value]) => (\n <tr key={key}>\n <td>\n <b>{key}</b>\n </td>\n <td>\n {Array.isArray(value)\n ? value.map(getDisplayedAnnotation).join(', ')\n : getDisplayedAnnotation(value as string | number | boolean)}\n </td>\n </tr>\n ))\n : ''}\n </>\n )\n // We also show the schema name if there is one (and we're in experimental mode)\n const valiationSchemaTableRow = (\n <>\n {boundSchema ? (\n <tr>\n <td>\n <b>Validation Schema</b>\n </td>\n <td>{boundSchema.jsonSchemaVersionInfo.schemaName}</td>\n </tr>\n ) : (\n ''\n )}\n </>\n )\n const annotationsTitle = schemaValidationResults\n ? `${schemaConformance} Annotations`\n : ''\n const annotationsHtml = (\n <div className=\"EntityBadgeTooltip\">\n <table>\n <tbody>\n {annotationsTableRows ? annotationsTableRows : ''}\n {valiationSchemaTableRow}\n </tbody>\n </table>\n </div>\n )\n\n return (\n <div className=\"EntityBadge\" ref={ref} style={{ flexWrap, justifyContent }}>\n {bundle && (\n <>\n <div onClick={e => e.stopPropagation()}>\n <EntityModal\n entityId={entityId}\n show={showModal}\n showTabs={false}\n onClose={() => setShowModal(false)}\n initialTab={'ANNOTATIONS'}\n />\n </div>\n {showIsPublicPrivate &&\n bundle.benefactorAcl &&\n isEntityPublic(\n bundle.benefactorAcl.resourceAccess,\n realmPrincipals,\n ) ? (\n <Tooltip title=\"Public\" enterNextDelay={100} placement=\"right\">\n <PublicTwoTone\n aria-hidden={false}\n role=\"img\"\n className=\"EntityBadge__Badge\"\n data-testid={'is-public-icon'}\n />\n </Tooltip>\n ) : null}\n {showIsPublicPrivate &&\n bundle.benefactorAcl &&\n !isEntityPublic(\n bundle.benefactorAcl.resourceAccess,\n realmPrincipals,\n ) ? (\n <Tooltip title=\"Private\" enterNextDelay={100} placement=\"right\">\n <LockTwoTone\n aria-hidden={false}\n role=\"img\"\n className=\"EntityBadge__Badge\"\n data-testid={'is-private-icon'}\n />\n </Tooltip>\n ) : null}\n {showHasLocalSharingSettings &&\n bundle.benefactorAcl &&\n entityId === bundle.benefactorAcl.id ? (\n <Tooltip\n title=\"Sharing Settings have been set\"\n enterNextDelay={100}\n placement=\"right\"\n >\n <CheckTwoTone\n aria-hidden={false}\n role=\"img\"\n className=\"EntityBadge__Badge\"\n data-testid={'sharing-settings-icon'}\n />\n </Tooltip>\n ) : null}\n\n {showHasAnnotations &&\n !!(annotationsCount || schemaValidationResults) && (\n <HoverPopover\n title={annotationsTitle}\n popoverContent={annotationsHtml}\n placement=\"right\"\n maxWidth={500}\n actionButton={\n canOpenModal\n ? {\n content: 'Edit Annotations',\n onClick: () => setShowModal(true),\n closeOnClick: true,\n }\n : undefined\n }\n >\n <LocalOfferTwoTone\n aria-hidden={false}\n role={canOpenModal ? 'button' : 'img'}\n className={`EntityBadge__Badge ${schemaConformance}`}\n data-html={true}\n data-testid={'annotations-icon'}\n />\n </HoverPopover>\n )}\n {showHasWiki && bundle.rootWikiId && (\n <Tooltip title=\"Has a wiki\" enterNextDelay={100} placement=\"right\">\n <DescriptionTwoTone\n aria-hidden={false}\n role=\"img\"\n className=\"EntityBadge__Badge\"\n data-testid={'wiki-icon'}\n />\n </Tooltip>\n )}\n {showHasDiscussionThread &&\n !!bundle.threadCount &&\n !!(bundle.threadCount > 0) && (\n <Tooltip\n title=\"Has been mentioned in discussion\"\n enterNextDelay={100}\n placement=\"right\"\n >\n <ChatBubbleTwoTone\n aria-hidden={false}\n role=\"img\"\n className=\"EntityBadge__Badge\"\n data-testid={'discussion-icon'}\n />\n </Tooltip>\n )}\n {showUnlink &&\n bundle.entityType === EntityType.link &&\n bundle.permissions?.canDelete && (\n <>\n <WarningDialog\n open={showUnlinkConfirmModal}\n title=\"Confirm Unlink\"\n content={\n 'Are you sure you want to remove this link? The original object will not be changed.'\n }\n confirmButtonText=\"Unlink\"\n confirmButtonColor=\"error\"\n onConfirm={() => {\n unlinkEntity(entityId)\n setShowUnlinkConfirmModal(false)\n }}\n onCancel={() => {\n setShowUnlinkConfirmModal(false)\n }}\n />\n <Tooltip\n title=\"Remove this link\"\n enterNextDelay={100}\n placement=\"right\"\n >\n <LinkOffTwoTone\n aria-hidden={false}\n role=\"button\"\n onClick={() => setShowUnlinkConfirmModal(true)}\n className=\"EntityBadge__Badge Unlink\"\n data-testid={'unlink-icon'}\n />\n </Tooltip>\n </>\n )}\n </>\n )}\n </div>\n )\n}\n\nexport default EntityBadgeIcons\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiEA,IAAa,KACX,MACoB;CACpB,IAAM,EACJ,aACA,kBACA,cAAW,UACX,oBAAiB,cACjB,yBAAsB,IACtB,iCAA8B,IAC9B,wBAAqB,IACrB,iBAAc,IACd,6BAA0B,IAC1B,gBAAa,IACb,o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