synapse-react-client 4.0.12 → 4.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SWC.index.js +1 -1
- package/dist/components/ChallengeRegisterButton/ChallengeRegisterButton.d.ts.map +1 -1
- package/dist/components/ChallengeRegisterButton/ChallengeRegisterButton.js +76 -45
- package/dist/components/ChallengeRegisterButton/ChallengeRegisterButton.js.map +1 -1
- package/dist/components/ChallengeRequirementsModal/ChallengeRequirementsModal.d.ts.map +1 -1
- package/dist/components/ChallengeRequirementsModal/ChallengeRequirementsModal.js +2 -2
- package/dist/components/ChallengeRequirementsModal/ChallengeRequirementsModal.js.map +1 -1
- package/dist/components/ChallengeTeamWizard/ChallengeTeamWizard.d.ts.map +1 -1
- package/dist/components/ChallengeTeamWizard/ChallengeTeamWizard.js +2 -2
- package/dist/components/ChallengeTeamWizard/ChallengeTeamWizard.js.map +1 -1
- package/dist/components/DataGrid/utils/DataGridUtils.js +1 -1
- package/dist/components/DataGrid/utils/DataGridUtils.js.map +1 -1
- package/dist/components/DraggableDialog/DraggableDialog.js +21 -21
- package/dist/components/DraggableDialog/DraggableDialog.js.map +1 -1
- package/dist/components/EntityDownloadButton/EntityDownloadButton.d.ts +6 -0
- package/dist/components/EntityDownloadButton/EntityDownloadButton.d.ts.map +1 -1
- package/dist/components/EntityDownloadButton/EntityDownloadButton.js +6 -1
- package/dist/components/EntityDownloadButton/EntityDownloadButton.js.map +1 -1
- package/dist/components/FullTextSearch/FullTextSearch.d.ts.map +1 -1
- package/dist/components/FullTextSearch/FullTextSearch.js +28 -20
- package/dist/components/FullTextSearch/FullTextSearch.js.map +1 -1
- package/dist/components/FullTextSearch/FullTextSearchUtils.d.ts.map +1 -1
- package/dist/components/FullTextSearch/FullTextSearchUtils.js +7 -2
- package/dist/components/FullTextSearch/FullTextSearchUtils.js.map +1 -1
- package/dist/components/GenericCard/BioregistryRules.d.ts.map +1 -1
- package/dist/components/GenericCard/BioregistryRules.js +9 -1
- package/dist/components/GenericCard/BioregistryRules.js.map +1 -1
- package/dist/components/Goals/Goals.Desktop.d.ts +3 -1
- package/dist/components/Goals/Goals.Desktop.d.ts.map +1 -1
- package/dist/components/Goals/Goals.Desktop.js +2 -3
- package/dist/components/Goals/Goals.Desktop.js.map +1 -1
- package/dist/components/Goals/Goals.d.ts +1 -0
- package/dist/components/Goals/Goals.d.ts.map +1 -1
- package/dist/components/Goals/Goals.js +33 -27
- package/dist/components/Goals/Goals.js.map +1 -1
- package/dist/components/Markdown/widget/MarkdownTableOfContents.d.ts.map +1 -1
- package/dist/components/Markdown/widget/MarkdownTableOfContents.js +15 -11
- package/dist/components/Markdown/widget/MarkdownTableOfContents.js.map +1 -1
- package/dist/components/QueryWrapper/useOnQueryDataChange.d.ts.map +1 -1
- package/dist/components/QueryWrapper/useOnQueryDataChange.js +19 -17
- package/dist/components/QueryWrapper/useOnQueryDataChange.js.map +1 -1
- package/dist/components/SearchQueryWrapper/SearchQueryUseQueryOptions.d.ts.map +1 -1
- package/dist/components/SearchQueryWrapper/SearchQueryUseQueryOptions.js +2 -2
- package/dist/components/SearchQueryWrapper/SearchQueryUseQueryOptions.js.map +1 -1
- package/dist/components/SearchQueryWrapper/SearchQueryWrapper.d.ts.map +1 -1
- package/dist/components/SearchQueryWrapper/SearchQueryWrapper.js +30 -30
- package/dist/components/SearchQueryWrapper/SearchQueryWrapper.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 +4 -2
- package/dist/components/SearchQueryWrapperPlotNav/SearchQueryWrapperPlotNav.js.map +1 -1
- package/dist/components/SynapseHomepageV2/WordPressNews.d.ts.map +1 -1
- package/dist/components/SynapseHomepageV2/WordPressNews.js +13 -36
- package/dist/components/SynapseHomepageV2/WordPressNews.js.map +1 -1
- package/dist/components/SynapseSearchPageResults/SearchPagePortalBanners.d.ts.map +1 -1
- package/dist/components/SynapseSearchPageResults/SearchPagePortalBanners.js +1 -1
- package/dist/components/SynapseSearchPageResults/SearchPagePortalBanners.js.map +1 -1
- package/dist/components/SynapseSearchPageResults/SynapseSearchPageRouter.d.ts.map +1 -1
- package/dist/components/SynapseSearchPageResults/SynapseSearchPageRouter.js +14 -12
- package/dist/components/SynapseSearchPageResults/SynapseSearchPageRouter.js.map +1 -1
- package/dist/components/SynapseTable/SearchV2.d.ts +11 -0
- package/dist/components/SynapseTable/SearchV2.d.ts.map +1 -1
- package/dist/components/SynapseTable/SearchV2.js.map +1 -1
- package/dist/components/WordPress/WordPressLatestPostChip.css +1 -0
- package/dist/components/WordPress/WordPressLatestPostChip.d.ts +5 -0
- package/dist/components/WordPress/WordPressLatestPostChip.d.ts.map +1 -0
- package/dist/components/WordPress/WordPressLatestPostChip.js +29 -0
- package/dist/components/WordPress/WordPressLatestPostChip.js.map +1 -0
- package/dist/components/WordPress/WordPressLatestPostChip.module.js +9 -0
- package/dist/components/WordPress/WordPressLatestPostChip.module.js.map +1 -0
- package/dist/components/WordPress/WordPressLatestPostChip.module.scss +33 -0
- package/dist/components/WordPress/useWordPressCategories.d.ts +3 -0
- package/dist/components/WordPress/useWordPressCategories.d.ts.map +1 -0
- package/dist/components/WordPress/useWordPressCategories.js +19 -0
- package/dist/components/WordPress/useWordPressCategories.js.map +1 -0
- package/dist/components/WordPress/useWordPressPosts.d.ts +3 -0
- package/dist/components/WordPress/useWordPressPosts.d.ts.map +1 -0
- package/dist/components/WordPress/useWordPressPosts.js +23 -0
- package/dist/components/WordPress/useWordPressPosts.js.map +1 -0
- package/dist/features/curator/dashboard/components/CurationTaskCard.js +1 -1
- package/dist/features/curator/dashboard/components/CurationTaskCard.js.map +1 -1
- package/dist/features/entity/metadata-task/components/MetadataTaskTableActionCell.d.ts.map +1 -1
- package/dist/features/entity/metadata-task/components/MetadataTaskTableActionCell.js +6 -6
- package/dist/features/entity/metadata-task/components/MetadataTaskTableActionCell.js.map +1 -1
- package/dist/features/entity/metadata-task/hooks/useGridSessionForCurationTask.d.ts.map +1 -1
- package/dist/features/entity/metadata-task/hooks/useGridSessionForCurationTask.js +24 -20
- package/dist/features/entity/metadata-task/hooks/useGridSessionForCurationTask.js.map +1 -1
- package/dist/features/entity/metadata-task/hooks/useOpenCuratorButton.d.ts +2 -2
- package/dist/features/entity/metadata-task/hooks/useOpenCuratorButton.d.ts.map +1 -1
- package/dist/features/entity/metadata-task/hooks/useOpenCuratorButton.js +30 -21
- package/dist/features/entity/metadata-task/hooks/useOpenCuratorButton.js.map +1 -1
- package/dist/features/entity/metadata-task/utils/constants.d.ts +1 -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/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/hooks/useShowDesktop.d.ts.map +1 -1
- package/dist/utils/hooks/useShowDesktop.js +4 -9
- package/dist/utils/hooks/useShowDesktop.js.map +1 -1
- package/package.json +3 -3
package/dist/SWC.index.js
CHANGED
|
@@ -109,7 +109,7 @@ var x = { BackendDestinationEnum: r }, S = {
|
|
|
109
109
|
sendSearchResultsReturnedEvent: y,
|
|
110
110
|
sendSearchResultReturnedEvent: v,
|
|
111
111
|
sendSearchResultClickedEvent: _
|
|
112
|
-
}, T = "4.0.
|
|
112
|
+
}, T = "4.0.15";
|
|
113
113
|
//#endregion
|
|
114
114
|
export { w as Analytics, a as HttpClient, d as Palettes, o as SynapseClient, C as SynapseComponents, n as SynapseConstants, S as SynapseContext, x as SynapseEnums, m as SynapseQueries, T as SynapseReactClientVersion, p as SynapseSessionManager, i as xssOptions };
|
|
115
115
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChallengeRegisterButton.d.ts","sourceRoot":"","sources":["../../../src/components/ChallengeRegisterButton/ChallengeRegisterButton.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,kBAAkB,EAAqB,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"ChallengeRegisterButton.d.ts","sourceRoot":"","sources":["../../../src/components/ChallengeRegisterButton/ChallengeRegisterButton.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,kBAAkB,EAAqB,MAAM,SAAS,CAAA;AAO/D,MAAM,WAAW,4BAA4B;IAC3C,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAA;IAC7C,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;IACxB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAA;CAC1B;AAED,QAAA,MAAM,uBAAuB,GAAI,oDAK9B,4BAA4B,KAAG,KAAK,CAAC,SAiIvC,CAAA;AAED,eAAe,uBAAuB,CAAA"}
|
|
@@ -10,60 +10,91 @@ import { useEffect as o } from "react";
|
|
|
10
10
|
import { Box as s } from "@mui/material";
|
|
11
11
|
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
12
12
|
import u from "@mui/icons-material/ExitToApp";
|
|
13
|
+
import d from "@mui/icons-material/PendingActions";
|
|
13
14
|
//#region src/components/ChallengeRegisterButton/ChallengeRegisterButton.tsx
|
|
14
|
-
var
|
|
15
|
-
let { isAuthenticated:
|
|
15
|
+
var f = ({ projectId: f, onError: p, onJoinClick: m, onLeaveClick: h }) => {
|
|
16
|
+
let { isAuthenticated: g } = e(), { data: _ } = r({ enabled: g }), { data: v, isLoading: y, error: b } = t(f, { enabled: g }), { data: x, isLoading: S, error: C } = i(v?.participantTeamId, _?.ownerId, { enabled: !!v && !!_ }), w = !!x, { data: T, error: E, isLoading: D } = n(v?.id, 20, 0, { enabled: !!v && g }), O = T && T.results.length > 0, k = w && O, A = w && !O, j = b || C || E;
|
|
16
17
|
return o(() => {
|
|
17
|
-
|
|
18
|
-
}, [
|
|
18
|
+
j && p && p(j);
|
|
19
|
+
}, [j, p]), y || S || D ? /* @__PURE__ */ c(a, {
|
|
19
20
|
showSpinner: !0,
|
|
20
21
|
children: "Loading..."
|
|
21
|
-
}) : /* @__PURE__ */ l(s, { children: [
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
backgroundColor: "#109488",
|
|
28
|
-
fontSize: "1.12em",
|
|
29
|
-
textTransform: "none",
|
|
30
|
-
padding: "4px 18px",
|
|
31
|
-
fontWeight: 400,
|
|
32
|
-
":hover": {
|
|
22
|
+
}) : /* @__PURE__ */ l(s, { children: [
|
|
23
|
+
!k && !A && /* @__PURE__ */ c(a, {
|
|
24
|
+
disableElevation: !0,
|
|
25
|
+
variant: "contained",
|
|
26
|
+
onClick: () => g && m ? m() : void 0,
|
|
27
|
+
sx: {
|
|
33
28
|
color: "white",
|
|
34
|
-
backgroundColor: "#109488"
|
|
29
|
+
backgroundColor: "#109488",
|
|
30
|
+
fontSize: "1.12em",
|
|
31
|
+
textTransform: "none",
|
|
32
|
+
padding: "4px 18px",
|
|
33
|
+
fontWeight: 400,
|
|
34
|
+
":hover": {
|
|
35
|
+
color: "white",
|
|
36
|
+
backgroundColor: "#109488"
|
|
37
|
+
},
|
|
38
|
+
":active": {
|
|
39
|
+
color: "white",
|
|
40
|
+
backgroundColor: "#109488"
|
|
41
|
+
},
|
|
42
|
+
":visited": {
|
|
43
|
+
color: "white",
|
|
44
|
+
backgroundColor: "#109488"
|
|
45
|
+
}
|
|
35
46
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
children: "Register for this Challenge"
|
|
48
|
+
}),
|
|
49
|
+
A && /* @__PURE__ */ c(a, {
|
|
50
|
+
disableElevation: !0,
|
|
51
|
+
variant: "contained",
|
|
52
|
+
endIcon: /* @__PURE__ */ c(d, {}),
|
|
53
|
+
onClick: () => g && m ? m() : void 0,
|
|
54
|
+
sx: {
|
|
55
|
+
color: "#4A2E1B",
|
|
56
|
+
backgroundColor: "#FFD486",
|
|
57
|
+
fontSize: "1.12em",
|
|
58
|
+
textTransform: "none",
|
|
59
|
+
padding: "4px 18px",
|
|
60
|
+
fontWeight: 400,
|
|
61
|
+
":hover": {
|
|
62
|
+
color: "#4A2E1B",
|
|
63
|
+
backgroundColor: "#FFD486"
|
|
64
|
+
},
|
|
65
|
+
":active": {
|
|
66
|
+
color: "#4A2E1B",
|
|
67
|
+
backgroundColor: "#FFD486"
|
|
68
|
+
},
|
|
69
|
+
":visited": {
|
|
70
|
+
color: "#4A2E1B",
|
|
71
|
+
backgroundColor: "#FFD486"
|
|
72
|
+
}
|
|
39
73
|
},
|
|
40
|
-
|
|
74
|
+
children: "Complete Registration"
|
|
75
|
+
}),
|
|
76
|
+
k && /* @__PURE__ */ c(a, {
|
|
77
|
+
disableElevation: !0,
|
|
78
|
+
variant: "outlined",
|
|
79
|
+
endIcon: /* @__PURE__ */ c(u, {}),
|
|
80
|
+
onClick: () => h ? h() : void 0,
|
|
81
|
+
sx: {
|
|
82
|
+
borderColor: "white",
|
|
41
83
|
color: "white",
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
fontSize: "1.12em",
|
|
55
|
-
textTransform: "none",
|
|
56
|
-
padding: "4px 18px",
|
|
57
|
-
fontWeight: 400,
|
|
58
|
-
":hover": {
|
|
59
|
-
color: "#172430",
|
|
60
|
-
borderColor: "#172430"
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
children: "Leave Challenge"
|
|
64
|
-
})] });
|
|
84
|
+
fontSize: "1.12em",
|
|
85
|
+
textTransform: "none",
|
|
86
|
+
padding: "4px 18px",
|
|
87
|
+
fontWeight: 400,
|
|
88
|
+
":hover": {
|
|
89
|
+
color: "#172430",
|
|
90
|
+
borderColor: "#172430"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
children: "Leave Challenge"
|
|
94
|
+
})
|
|
95
|
+
] });
|
|
65
96
|
};
|
|
66
97
|
//#endregion
|
|
67
|
-
export {
|
|
98
|
+
export { f as default };
|
|
68
99
|
|
|
69
100
|
//# sourceMappingURL=ChallengeRegisterButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChallengeRegisterButton.js","names":[],"sources":["../../../src/components/ChallengeRegisterButton/ChallengeRegisterButton.tsx"],"sourcesContent":["import {\n useGetCurrentUserProfile,\n useGetEntityChallenge,\n useGetIsUserMemberOfTeam,\n useGetUserSubmissionTeams,\n} from '@/synapse-queries'\nimport React from 'react'\nimport { SynapseClientError, useSynapseContext } from '@/utils'\nimport ExitToAppIcon from '@mui/icons-material/ExitToApp'\nimport { Box } from '@mui/material'\nimport { useEffect } from 'react'\nimport SpinnerButton from '../SpinnerButton/SpinnerButton'\n\nexport interface ChallengeRegisterButtonProps {\n projectId: string\n onError?: (error: SynapseClientError) => void\n onJoinClick?: () => void\n onLeaveClick?: () => void\n}\n\nconst ChallengeRegisterButton = ({\n projectId,\n onError,\n onJoinClick,\n onLeaveClick,\n}: ChallengeRegisterButtonProps): React.ReactNode => {\n const { isAuthenticated } = useSynapseContext()\n const { data: userProfile } = useGetCurrentUserProfile({\n enabled: isAuthenticated,\n })\n\n const {\n data: challenge,\n isLoading: isLoadingChallenge,\n error: getChallengeError,\n } = useGetEntityChallenge(projectId, {\n enabled: isAuthenticated,\n })\n\n // Verify that user is a member of the participant team\n const {\n data: teamMembership,\n isLoading: isLoadingTeamMembership,\n error: getTeamMembershipError,\n } = useGetIsUserMemberOfTeam(\n challenge?.participantTeamId!,\n userProfile?.ownerId!,\n {\n enabled: !!challenge && !!userProfile,\n },\n )\n\n const isRegistered = Boolean(teamMembership)\n\n const {\n data: userSubmissionTeams,\n error: getSubmissionTeamsError,\n isLoading: isLoadingSubmissionTeams,\n } = useGetUserSubmissionTeams(challenge?.id!, 20, 0, {\n enabled: !!challenge && isAuthenticated,\n })\n\n const hasSubmissionTeam =\n userSubmissionTeams && userSubmissionTeams.results.length > 0\n const isMemberOfBothParticipantAndSubmissionTeams =\n isRegistered && hasSubmissionTeam\n\n const error =\n getChallengeError || getTeamMembershipError || getSubmissionTeamsError\n\n useEffect(() => {\n if (error && onError) onError(error)\n }, [error, onError])\n\n const isLoading =\n isLoadingChallenge || isLoadingTeamMembership || isLoadingSubmissionTeams\n\n if (isLoading) {\n return <SpinnerButton showSpinner>Loading...</SpinnerButton>\n }\n\n return (\n <Box>\n {!isMemberOfBothParticipantAndSubmissionTeams && (\n <SpinnerButton\n disableElevation={true}\n variant=\"contained\"\n onClick={() =>\n isAuthenticated && onJoinClick ? onJoinClick() : undefined\n }\n sx={{\n color: '
|
|
1
|
+
{"version":3,"file":"ChallengeRegisterButton.js","names":[],"sources":["../../../src/components/ChallengeRegisterButton/ChallengeRegisterButton.tsx"],"sourcesContent":["import {\n useGetCurrentUserProfile,\n useGetEntityChallenge,\n useGetIsUserMemberOfTeam,\n useGetUserSubmissionTeams,\n} from '@/synapse-queries'\nimport React from 'react'\nimport { SynapseClientError, useSynapseContext } from '@/utils'\nimport ExitToAppIcon from '@mui/icons-material/ExitToApp'\nimport PendingActionsIcon from '@mui/icons-material/PendingActions'\nimport { Box } from '@mui/material'\nimport { useEffect } from 'react'\nimport SpinnerButton from '../SpinnerButton/SpinnerButton'\n\nexport interface ChallengeRegisterButtonProps {\n projectId: string\n onError?: (error: SynapseClientError) => void\n onJoinClick?: () => void\n onLeaveClick?: () => void\n}\n\nconst ChallengeRegisterButton = ({\n projectId,\n onError,\n onJoinClick,\n onLeaveClick,\n}: ChallengeRegisterButtonProps): React.ReactNode => {\n const { isAuthenticated } = useSynapseContext()\n const { data: userProfile } = useGetCurrentUserProfile({\n enabled: isAuthenticated,\n })\n\n const {\n data: challenge,\n isLoading: isLoadingChallenge,\n error: getChallengeError,\n } = useGetEntityChallenge(projectId, {\n enabled: isAuthenticated,\n })\n\n // Verify that user is a member of the participant team\n const {\n data: teamMembership,\n isLoading: isLoadingTeamMembership,\n error: getTeamMembershipError,\n } = useGetIsUserMemberOfTeam(\n challenge?.participantTeamId!,\n userProfile?.ownerId!,\n {\n enabled: !!challenge && !!userProfile,\n },\n )\n\n const isRegistered = Boolean(teamMembership)\n\n const {\n data: userSubmissionTeams,\n error: getSubmissionTeamsError,\n isLoading: isLoadingSubmissionTeams,\n } = useGetUserSubmissionTeams(challenge?.id!, 20, 0, {\n enabled: !!challenge && isAuthenticated,\n })\n\n const hasSubmissionTeam =\n userSubmissionTeams && userSubmissionTeams.results.length > 0\n const isMemberOfBothParticipantAndSubmissionTeams =\n isRegistered && hasSubmissionTeam\n const isMemberOfParticipantTeamOnly = isRegistered && !hasSubmissionTeam\n\n const error =\n getChallengeError || getTeamMembershipError || getSubmissionTeamsError\n\n useEffect(() => {\n if (error && onError) onError(error)\n }, [error, onError])\n\n const isLoading =\n isLoadingChallenge || isLoadingTeamMembership || isLoadingSubmissionTeams\n\n if (isLoading) {\n return <SpinnerButton showSpinner>Loading...</SpinnerButton>\n }\n\n return (\n <Box>\n {!isMemberOfBothParticipantAndSubmissionTeams &&\n !isMemberOfParticipantTeamOnly && (\n <SpinnerButton\n disableElevation={true}\n variant=\"contained\"\n onClick={() =>\n isAuthenticated && onJoinClick ? onJoinClick() : undefined\n }\n sx={{\n color: 'white',\n backgroundColor: '#109488',\n fontSize: '1.12em',\n textTransform: 'none',\n padding: '4px 18px',\n fontWeight: 400,\n ':hover': { color: 'white', backgroundColor: '#109488' },\n ':active': { color: 'white', backgroundColor: '#109488' },\n ':visited': { color: 'white', backgroundColor: '#109488' },\n }}\n >\n Register for this Challenge\n </SpinnerButton>\n )}\n {isMemberOfParticipantTeamOnly && (\n <SpinnerButton\n disableElevation={true}\n variant=\"contained\"\n endIcon={<PendingActionsIcon />}\n onClick={() =>\n isAuthenticated && onJoinClick ? onJoinClick() : undefined\n }\n sx={{\n color: '#4A2E1B',\n backgroundColor: '#FFD486',\n fontSize: '1.12em',\n textTransform: 'none',\n padding: '4px 18px',\n fontWeight: 400,\n ':hover': { color: '#4A2E1B', backgroundColor: '#FFD486' },\n ':active': { color: '#4A2E1B', backgroundColor: '#FFD486' },\n ':visited': { color: '#4A2E1B', backgroundColor: '#FFD486' },\n }}\n >\n Complete Registration\n </SpinnerButton>\n )}\n {isMemberOfBothParticipantAndSubmissionTeams && (\n <SpinnerButton\n disableElevation={true}\n variant=\"outlined\"\n endIcon={<ExitToAppIcon />}\n onClick={() => (onLeaveClick ? onLeaveClick() : undefined)}\n sx={{\n borderColor: 'white',\n color: 'white',\n fontSize: '1.12em',\n textTransform: 'none',\n padding: '4px 18px',\n fontWeight: 400,\n ':hover': {\n color: '#172430',\n borderColor: '#172430',\n },\n }}\n >\n Leave Challenge\n </SpinnerButton>\n )}\n </Box>\n )\n}\n\nexport default ChallengeRegisterButton\n"],"mappings":";;;;;;;;;;;;;;AAqBA,IAAM,KAA2B,EAC/B,cACA,YACA,gBACA,sBACmD;CACnD,IAAM,EAAE,uBAAoB,GAAmB,EACzC,EAAE,MAAM,MAAgB,EAAyB,EACrD,SAAS,GACV,CAAC,EAEI,EACJ,MAAM,GACN,WAAW,GACX,OAAO,MACL,EAAsB,GAAW,EACnC,SAAS,GACV,CAAC,EAGI,EACJ,MAAM,GACN,WAAW,GACX,OAAO,MACL,EACF,GAAW,mBACX,GAAa,SACb,EACE,SAAS,CAAC,CAAC,KAAa,CAAC,CAAC,GAC3B,CACF,EAEK,IAAe,EAAQ,GAEvB,EACJ,MAAM,GACN,OAAO,GACP,WAAW,MACT,EAA0B,GAAW,IAAK,IAAI,GAAG,EACnD,SAAS,CAAC,CAAC,KAAa,GACzB,CAAC,EAEI,IACJ,KAAuB,EAAoB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,aAAa;KACd;IACF;aACF;GAEe,CAAA;EAEd,EAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChallengeRequirementsModal.d.ts","sourceRoot":"","sources":["../../../src/components/ChallengeRequirementsModal/ChallengeRequirementsModal.tsx"],"names":[],"mappings":"AAmBA,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,OAAO,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,kBAAkB,EAAE,MAAM,IAAI,CAAA;CAC/B,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAChD,KAAK,EAAE,+BAA+B,
|
|
1
|
+
{"version":3,"file":"ChallengeRequirementsModal.d.ts","sourceRoot":"","sources":["../../../src/components/ChallengeRequirementsModal/ChallengeRequirementsModal.tsx"],"names":[],"mappings":"AAmBA,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,OAAO,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,kBAAkB,EAAE,MAAM,IAAI,CAAA;CAC/B,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAChD,KAAK,EAAE,+BAA+B,2CA4HvC"}
|
|
@@ -33,9 +33,9 @@ function y(y) {
|
|
|
33
33
|
P,
|
|
34
34
|
B,
|
|
35
35
|
L
|
|
36
|
-
].filter((e) => !!e), G =
|
|
36
|
+
].filter((e) => !!e), G = "Next Step";
|
|
37
37
|
return I && (G = "Registering..."), d(W) ? !j || !b ? /* @__PURE__ */ g(h, {}) : /* @__PURE__ */ g(l, {
|
|
38
|
-
dialogTitle: "Challenge Terms and Conditions",
|
|
38
|
+
dialogTitle: "Challenge Registration (Step 1 of 2): Terms and Conditions",
|
|
39
39
|
subjectId: j,
|
|
40
40
|
subjectType: v.TEAM,
|
|
41
41
|
teamId: D?.participantTeamId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChallengeRequirementsModal.js","names":[],"sources":["../../../src/components/ChallengeRequirementsModal/ChallengeRequirementsModal.tsx"],"sourcesContent":["import {\n useGetAccessRequirementsForTeam,\n useGetAccessRequirementStatuses,\n useGetCurrentUserProfile,\n useGetEntity,\n useGetEntityChallenge,\n} from '@/synapse-queries'\nimport {\n useAddMemberToTeam,\n useGetMembershipStatus,\n} from '@/synapse-queries/team/useTeamMembers'\nimport { SynapseClientError, useSynapseContext } from '@/utils'\nimport { Alert, Button, Typography } from '@mui/material'\nimport { RestrictableObjectType } from '@sage-bionetworks/synapse-types'\nimport { isEmpty } from 'lodash-es'\nimport { useCallback } from 'react'\nimport AccessRequirementList from '../AccessRequirementList/AccessRequirementList'\nimport { SynapseSpinner } from '../LoadingScreen/LoadingScreen'\n\nexport type ChallengeRequirementsModalProps = {\n open: boolean\n projectId: string\n onCancel: () => void\n onRegisterComplete: () => void\n}\n\n/**\n * The challenge requirements modal will\n * 1. Display the access requirements that must be accepted to join a participant team. The component will guide the user through meeting the requirements.\n * 2. If the user has accepted the requirements, the user can click 'Register' to join the team\n * If the user has not accepted the requirements, the user cannot register for the challenge.\n */\nexport default function ChallengeRequirementsModal(\n props: ChallengeRequirementsModalProps,\n) {\n const { open, projectId, onRegisterComplete, onCancel } = props\n const { data: project, error: getEntityError } = useGetEntity(projectId)\n\n const { isAuthenticated } = useSynapseContext()\n\n const { data: challenge, error: getChallengeError } =\n useGetEntityChallenge(projectId)\n const { data: userProfile, error: getProfileError } =\n useGetCurrentUserProfile({\n enabled: isAuthenticated,\n })\n\n const participantTeamId = challenge?.participantTeamId\n const userId = userProfile?.ownerId\n\n const { data: teamMembershipStatus, error: getMembershipStatusError } =\n useGetMembershipStatus(participantTeamId!, userId!, {\n enabled: Boolean(participantTeamId && userId),\n })\n\n const {\n mutateAsync: addTeamMember,\n isPending: registrationIsPending,\n error: registrationError,\n } = useAddMemberToTeam()\n\n const {\n data: fetchedRequirementsForTeam,\n isSuccess: hasFetchedRequirements,\n error: getAccessRequirementsError,\n } = useGetAccessRequirementsForTeam(challenge?.participantTeamId!, {\n enabled: Boolean(challenge?.participantTeamId),\n })\n\n const requirementStatusesQueryResults = useGetAccessRequirementStatuses(\n fetchedRequirementsForTeam?.map(ar => String(ar.id)) ?? [],\n )\n\n const meetsAllRequirements =\n hasFetchedRequirements &&\n requirementStatusesQueryResults.every(queryResult => {\n return queryResult.status === 'success' && queryResult.data.isApproved\n })\n\n const registerForChallenge = useCallback(async () => {\n if (participantTeamId && userId && !teamMembershipStatus?.isMember) {\n await addTeamMember({\n teamId: participantTeamId,\n userId,\n })\n }\n onRegisterComplete()\n }, [\n addTeamMember,\n onRegisterComplete,\n participantTeamId,\n teamMembershipStatus?.isMember,\n userId,\n ])\n\n const errors = [\n getEntityError,\n getChallengeError,\n getProfileError,\n getMembershipStatusError,\n getAccessRequirementsError,\n registrationError,\n ].filter((e): e is SynapseClientError => Boolean(e))\n\n // It's possible that the user joined the team, but requirements on the team changed since they became a member\n // They do not need to re-join the team, but they should still be prompted to accept the requirements\n let registerButtonText =
|
|
1
|
+
{"version":3,"file":"ChallengeRequirementsModal.js","names":[],"sources":["../../../src/components/ChallengeRequirementsModal/ChallengeRequirementsModal.tsx"],"sourcesContent":["import {\n useGetAccessRequirementsForTeam,\n useGetAccessRequirementStatuses,\n useGetCurrentUserProfile,\n useGetEntity,\n useGetEntityChallenge,\n} from '@/synapse-queries'\nimport {\n useAddMemberToTeam,\n useGetMembershipStatus,\n} from '@/synapse-queries/team/useTeamMembers'\nimport { SynapseClientError, useSynapseContext } from '@/utils'\nimport { Alert, Button, Typography } from '@mui/material'\nimport { RestrictableObjectType } from '@sage-bionetworks/synapse-types'\nimport { isEmpty } from 'lodash-es'\nimport { useCallback } from 'react'\nimport AccessRequirementList from '../AccessRequirementList/AccessRequirementList'\nimport { SynapseSpinner } from '../LoadingScreen/LoadingScreen'\n\nexport type ChallengeRequirementsModalProps = {\n open: boolean\n projectId: string\n onCancel: () => void\n onRegisterComplete: () => void\n}\n\n/**\n * The challenge requirements modal will\n * 1. Display the access requirements that must be accepted to join a participant team. The component will guide the user through meeting the requirements.\n * 2. If the user has accepted the requirements, the user can click 'Register' to join the team\n * If the user has not accepted the requirements, the user cannot register for the challenge.\n */\nexport default function ChallengeRequirementsModal(\n props: ChallengeRequirementsModalProps,\n) {\n const { open, projectId, onRegisterComplete, onCancel } = props\n const { data: project, error: getEntityError } = useGetEntity(projectId)\n\n const { isAuthenticated } = useSynapseContext()\n\n const { data: challenge, error: getChallengeError } =\n useGetEntityChallenge(projectId)\n const { data: userProfile, error: getProfileError } =\n useGetCurrentUserProfile({\n enabled: isAuthenticated,\n })\n\n const participantTeamId = challenge?.participantTeamId\n const userId = userProfile?.ownerId\n\n const { data: teamMembershipStatus, error: getMembershipStatusError } =\n useGetMembershipStatus(participantTeamId!, userId!, {\n enabled: Boolean(participantTeamId && userId),\n })\n\n const {\n mutateAsync: addTeamMember,\n isPending: registrationIsPending,\n error: registrationError,\n } = useAddMemberToTeam()\n\n const {\n data: fetchedRequirementsForTeam,\n isSuccess: hasFetchedRequirements,\n error: getAccessRequirementsError,\n } = useGetAccessRequirementsForTeam(challenge?.participantTeamId!, {\n enabled: Boolean(challenge?.participantTeamId),\n })\n\n const requirementStatusesQueryResults = useGetAccessRequirementStatuses(\n fetchedRequirementsForTeam?.map(ar => String(ar.id)) ?? [],\n )\n\n const meetsAllRequirements =\n hasFetchedRequirements &&\n requirementStatusesQueryResults.every(queryResult => {\n return queryResult.status === 'success' && queryResult.data.isApproved\n })\n\n const registerForChallenge = useCallback(async () => {\n if (participantTeamId && userId && !teamMembershipStatus?.isMember) {\n await addTeamMember({\n teamId: participantTeamId,\n userId,\n })\n }\n onRegisterComplete()\n }, [\n addTeamMember,\n onRegisterComplete,\n participantTeamId,\n teamMembershipStatus?.isMember,\n userId,\n ])\n\n const errors = [\n getEntityError,\n getChallengeError,\n getProfileError,\n getMembershipStatusError,\n getAccessRequirementsError,\n registrationError,\n ].filter((e): e is SynapseClientError => Boolean(e))\n\n // It's possible that the user joined the team, but requirements on the team changed since they became a member\n // They do not need to re-join the team, but they should still be prompted to accept the requirements\n let registerButtonText = 'Next Step'\n if (registrationIsPending) {\n registerButtonText = 'Registering...'\n }\n\n if (!isEmpty(errors)) {\n return (\n <Alert severity=\"error\">\n {errors.map((e, index) => (\n <Typography variant={'body1'} key={index}>\n {e.reason}\n </Typography>\n ))}\n </Alert>\n )\n }\n\n if (!participantTeamId || !open) {\n return <></>\n }\n\n return (\n <AccessRequirementList\n dialogTitle={`Challenge Registration (Step 1 of 2): Terms and Conditions`}\n subjectId={participantTeamId}\n subjectType={RestrictableObjectType.TEAM}\n teamId={challenge?.participantTeamId}\n renderAsModal={true}\n requestObjectName={project?.name}\n onHide={() => {\n onCancel()\n }}\n customDialogActions={\n <>\n <Button variant={'outlined'} onClick={onCancel}>\n Cancel\n </Button>\n <Button\n variant={'contained'}\n onClick={() => {\n registerForChallenge()\n }}\n startIcon={registrationIsPending ? <SynapseSpinner /> : undefined}\n disabled={!meetsAllRequirements || registrationIsPending}\n >\n {registerButtonText}\n </Button>\n </>\n }\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,SAAwB,EACtB,GACA;CACA,IAAM,EAAE,SAAM,cAAW,uBAAoB,gBAAa,GACpD,EAAE,MAAM,GAAS,OAAO,MAAmB,EAAa,EAAU,EAElE,EAAE,uBAAoB,GAAmB,EAEzC,EAAE,MAAM,GAAW,OAAO,MAC9B,EAAsB,EAAU,EAC5B,EAAE,MAAM,GAAa,OAAO,MAChC,EAAyB,EACvB,SAAS,GACV,CAAC,EAEE,IAAoB,GAAW,mBAC/B,IAAS,GAAa,SAEtB,EAAE,MAAM,GAAsB,OAAO,MACzC,EAAuB,GAAoB,GAAS,EAClD,SAAS,GAAQ,KAAqB,IACvC,CAAC,EAEE,EACJ,aAAa,GACb,WA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1 @@
|
|
|
1
|
-
{"version":3,"file":"ChallengeTeamWizard.d.ts","sourceRoot":"","sources":["../../../src/components/ChallengeTeamWizard/ChallengeTeamWizard.tsx"],"names":[],"mappings":"AAuDA,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB,CAAA;AAED;;;;GAIG;AACH,iBAAS,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"ChallengeTeamWizard.d.ts","sourceRoot":"","sources":["../../../src/components/ChallengeTeamWizard/ChallengeTeamWizard.tsx"],"names":[],"mappings":"AAuDA,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB,CAAA;AAED;;;;GAIG;AACH,iBAAS,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,2CA8W3D;AAED,eAAe,mBAAmB,CAAA"}
|
|
@@ -23,7 +23,7 @@ var C = /* @__PURE__ */ function(e) {
|
|
|
23
23
|
}(C || {});
|
|
24
24
|
function w(e) {
|
|
25
25
|
switch (e) {
|
|
26
|
-
case C.SELECT_YOUR_CHALLENGE_TEAM: return "Select Your
|
|
26
|
+
case C.SELECT_YOUR_CHALLENGE_TEAM: return "Select Your Submission Team";
|
|
27
27
|
case C.ACCEPT_INVITATION: return "Invitation to Join Team";
|
|
28
28
|
case C.JOIN_REQUEST_FORM: return "Request Team Membership";
|
|
29
29
|
case C.JOIN_REQUEST_SENT: return "Request Sent";
|
|
@@ -181,7 +181,7 @@ function T(T) {
|
|
|
181
181
|
onCancel: le,
|
|
182
182
|
open: D,
|
|
183
183
|
actions: de,
|
|
184
|
-
title: w(A)
|
|
184
|
+
title: `Challenge Registration (Step 2 of 2): ${w(A)}`,
|
|
185
185
|
content: /* @__PURE__ */ x(t, { children: /* @__PURE__ */ x(g, {
|
|
186
186
|
sx: {
|
|
187
187
|
display: "flex",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChallengeTeamWizard.js","names":[],"sources":["../../../src/components/ChallengeTeamWizard/ChallengeTeamWizard.tsx"],"sourcesContent":["import {\n useAddMemberToTeam,\n useGetCurrentUserProfile,\n useGetEntityChallenge,\n useGetMembershipStatus,\n useGetUserSubmissionTeams,\n} from '@/synapse-queries'\nimport { useSynapseContext } from '@/utils'\nimport { Alert, Box, Button, Tooltip, Typography } from '@mui/material'\nimport { noop } from 'lodash-es'\nimport { useCallback, useMemo, useRef, useState } from 'react'\nimport { DialogBase } from '../DialogBase'\nimport { SignInPrompt, SynapseErrorBoundary } from '../error/ErrorBanner'\nimport { SynapseSpinner } from '../LoadingScreen/LoadingScreen'\nimport {\n CreateChallengeTeam,\n CreateChallengeTeamHandle,\n} from './CreateChallengeTeam'\nimport {\n MembershipRequestForm,\n MembershipRequestFormHandle,\n} from './MembershipRequestForm'\nimport {\n AcceptMembershipInvitationButton,\n OpenMembershipInvitation,\n} from './OpenMembershipInvitation'\nimport { RegistrationSuccessful } from './RegistrationSuccessful'\nimport { SelectChallengeTeam } from './SelectChallengeTeam'\n\nenum ChallengeTeamWizardStep {\n SELECT_YOUR_CHALLENGE_TEAM = 'SELECT_YOUR_CHALLENGE_TEAM',\n ACCEPT_INVITATION = 'ACCEPT_INVITATION',\n JOIN_REQUEST_FORM = 'JOIN_REQUEST_FORM',\n JOIN_REQUEST_SENT = 'JOIN_REQUEST_SENT',\n CREATE_NEW_TEAM = 'CREATE_NEW_TEAM',\n REGISTRATION_SUCCESSFUL = 'REGISTRATION_SUCCESSFUL',\n}\n\nfunction getStepDialogTitle(step: ChallengeTeamWizardStep) {\n switch (step) {\n case ChallengeTeamWizardStep.SELECT_YOUR_CHALLENGE_TEAM:\n return 'Select Your Challenge Team'\n case ChallengeTeamWizardStep.ACCEPT_INVITATION:\n return 'Invitation to Join Team'\n case ChallengeTeamWizardStep.JOIN_REQUEST_FORM:\n return 'Request Team Membership'\n case ChallengeTeamWizardStep.JOIN_REQUEST_SENT:\n return 'Request Sent'\n case ChallengeTeamWizardStep.CREATE_NEW_TEAM:\n return 'Create Team'\n case ChallengeTeamWizardStep.REGISTRATION_SUCCESSFUL:\n return 'Registration Successful!'\n }\n}\n\nexport type ChallengeTeamWizardProps = {\n projectId: string\n isShowingModal?: boolean\n onClose: () => void\n}\n\n/**\n * The ChallengeTeamWizard is used to guide a user through the process of joining or creating a team for a challenge.\n *\n * A required precondition is that the user is NOT on any registered submission team for the challenge.\n */\nfunction ChallengeTeamWizard(props: ChallengeTeamWizardProps) {\n const { projectId, isShowingModal = false, onClose } = props\n const { isAuthenticated } = useSynapseContext()\n\n const [step, setStep] = useState<ChallengeTeamWizardStep>(\n ChallengeTeamWizardStep.SELECT_YOUR_CHALLENGE_TEAM,\n )\n const [selectedTeamId, setSelectedTeamId] = useState<string | undefined>()\n\n // Tracks if the form to create a new team is valid, so the wizard can control the `disabled` status of the confirm button\n const [canCreateNewTeam, setCanCreateNewTeam] = useState(false)\n // true if the user has created a new team to register for the challenge\n const [hasCreatedNewTeam, setHasCreatedNewTeam] = useState<boolean>(false)\n\n const membershipRequestFormRef = useRef<MembershipRequestFormHandle>(null)\n const createTeamRef = useRef<CreateChallengeTeamHandle>(null)\n\n const { data: userProfile, isLoading: isLoadingUserProfile } =\n useGetCurrentUserProfile({\n enabled: isAuthenticated,\n })\n\n // Retrieve the challenge associated with the projectId passed through props\n const { data: challenge, isLoading: isLoadingChallenge } =\n useGetEntityChallenge(projectId)\n\n const {\n mutateAsync: addTeamMember,\n isPending: addMemberToTeamIsPending,\n error: addUserToTeamError,\n } = useAddMemberToTeam()\n\n // Determine whether the given user belongs to any submission teams\n const { data: userSubmissionTeams, error: userSubmissionTeamError } =\n useGetUserSubmissionTeams(challenge?.id!, 1, 0, {\n enabled: Boolean(isAuthenticated && challenge),\n })\n\n const isMemberOfSubmissionTeam =\n userSubmissionTeams && userSubmissionTeams.results.length > 0\n\n const {\n data: selectedTeamMembershipStatus,\n isLoading: selectedTeamMembershipStatusIsLoading,\n error: selectedTeamMembershipStatusError,\n } = useGetMembershipStatus(selectedTeamId!, String(userProfile?.ownerId), {\n enabled: isAuthenticated && !!selectedTeamId && !!userProfile,\n })\n\n const addUserToTeam = useCallback(async () => {\n if (!selectedTeamId || !userProfile) return\n await addTeamMember({\n teamId: selectedTeamId,\n userId: userProfile.ownerId,\n })\n setStep(ChallengeTeamWizardStep.REGISTRATION_SUCCESSFUL)\n }, [addTeamMember, setStep, selectedTeamId, userProfile])\n\n const hide = useCallback(() => {\n setHasCreatedNewTeam(false)\n setSelectedTeamId(undefined)\n onClose()\n }, [onClose])\n\n const isLoading = isLoadingUserProfile || isLoadingChallenge\n\n const backButton = useMemo(() => {\n switch (step) {\n case ChallengeTeamWizardStep.SELECT_YOUR_CHALLENGE_TEAM:\n case ChallengeTeamWizardStep.JOIN_REQUEST_SENT:\n case ChallengeTeamWizardStep.REGISTRATION_SUCCESSFUL:\n // Cannot go back from these steps\n return <></>\n case ChallengeTeamWizardStep.ACCEPT_INVITATION:\n case ChallengeTeamWizardStep.JOIN_REQUEST_FORM:\n case ChallengeTeamWizardStep.CREATE_NEW_TEAM:\n default:\n // All the other steps go back to team selection\n return (\n <Button\n variant={'outlined'}\n onClick={() => {\n setStep(ChallengeTeamWizardStep.SELECT_YOUR_CHALLENGE_TEAM)\n setSelectedTeamId(undefined)\n }}\n >\n Back\n </Button>\n )\n }\n }, [step])\n\n const closeButton = useMemo(() => {\n return (\n <Button\n variant={'contained'}\n onClick={() => {\n onClose()\n }}\n >\n Close\n </Button>\n )\n }, [onClose])\n\n // Determine modal content based on step.id\n const { actions = <></>, content = <></> } = useMemo(() => {\n if (!isAuthenticated) {\n return {\n content: (\n <Alert severity={'error'}>\n <SignInPrompt />\n </Alert>\n ),\n }\n }\n\n if (isMemberOfSubmissionTeam) {\n return {\n content: (\n <Alert severity={'error'}>\n <Typography>\n You are already a member of a registered submission team for this\n Challenge.\n </Typography>\n </Alert>\n ),\n }\n }\n\n switch (step) {\n case ChallengeTeamWizardStep.SELECT_YOUR_CHALLENGE_TEAM: {\n let buttonText = 'Join Team'\n let disableJoiningSelectedTeam = false\n let buttonOnClickBehavior: () => void = noop\n let buttonTooltip = ''\n if (\n selectedTeamMembershipStatus &&\n selectedTeamMembershipStatus.hasOpenInvitation\n ) {\n // The user has been invited to join the selected team\n buttonText = 'View Invitation to Join Team'\n buttonOnClickBehavior = () => {\n setStep(ChallengeTeamWizardStep.ACCEPT_INVITATION)\n }\n } else if (\n selectedTeamMembershipStatus &&\n selectedTeamMembershipStatus.hasOpenRequest\n ) {\n // User already has an open request to join the selected team, disable button to avoid request spamming\n buttonText = 'Join Request Pending'\n disableJoiningSelectedTeam = true\n buttonTooltip =\n 'You have already submitted a request to join this team.'\n } else if (\n selectedTeamMembershipStatus &&\n selectedTeamMembershipStatus.membershipApprovalRequired\n ) {\n // The user has to send a request to join the selected team\n buttonText = 'Request to Join Team'\n buttonOnClickBehavior = () => {\n setStep(ChallengeTeamWizardStep.JOIN_REQUEST_FORM)\n }\n } else if (\n selectedTeamMembershipStatus &&\n selectedTeamMembershipStatus.canJoin\n ) {\n // The user can freely join the selected team\n buttonText = 'Join Team'\n buttonOnClickBehavior = () => {\n void addUserToTeam()\n }\n }\n return {\n content: challenge && !isMemberOfSubmissionTeam && (\n <SelectChallengeTeam\n challengeId={challenge.id}\n onCreateTeam={() =>\n setStep(ChallengeTeamWizardStep.CREATE_NEW_TEAM)\n }\n selectedTeamId={selectedTeamId}\n onSelectTeam={teamId => setSelectedTeamId(teamId)}\n />\n ),\n actions: (\n <>\n {backButton}\n <Tooltip title={buttonTooltip}>\n {/* Wrap button in span to show tooltip when button is disabled */}\n <span>\n <Button\n onClick={buttonOnClickBehavior}\n startIcon={\n addMemberToTeamIsPending ? <SynapseSpinner /> : undefined\n }\n disabled={\n !selectedTeamId ||\n selectedTeamMembershipStatusIsLoading ||\n addMemberToTeamIsPending ||\n disableJoiningSelectedTeam\n }\n variant={'contained'}\n >\n {buttonText}\n </Button>\n </span>\n </Tooltip>\n </>\n ),\n }\n }\n case ChallengeTeamWizardStep.ACCEPT_INVITATION:\n return {\n content: <OpenMembershipInvitation teamId={selectedTeamId!} />,\n actions: (\n <>\n {backButton}\n <AcceptMembershipInvitationButton\n teamId={selectedTeamId!}\n onSuccess={() => {\n setStep(ChallengeTeamWizardStep.REGISTRATION_SUCCESSFUL)\n }}\n />\n </>\n ),\n }\n case ChallengeTeamWizardStep.JOIN_REQUEST_FORM:\n return {\n content: (\n <MembershipRequestForm\n ref={membershipRequestFormRef}\n teamId={selectedTeamId!}\n onRequestSubmitted={() => {\n setStep(ChallengeTeamWizardStep.JOIN_REQUEST_SENT)\n }}\n />\n ),\n actions: (\n <>\n {backButton}\n <Button\n variant={'contained'}\n onClick={() => {\n membershipRequestFormRef?.current?.submit()\n }}\n >\n Send Request\n </Button>\n </>\n ),\n }\n\n case ChallengeTeamWizardStep.JOIN_REQUEST_SENT:\n return {\n content: (\n <Typography variant=\"body1\" sx={{ lineHeight: '20px' }}>\n Team Manager(s) have received your request. Check your Synapse\n email address for status of your request.\n </Typography>\n ),\n actions: (\n <>\n {backButton}\n {closeButton}\n </>\n ),\n }\n case ChallengeTeamWizardStep.REGISTRATION_SUCCESSFUL:\n return {\n content: (\n <RegistrationSuccessful\n createdNewTeam={hasCreatedNewTeam}\n teamId={selectedTeamId}\n />\n ),\n actions: (\n <>\n {backButton}\n {closeButton}\n </>\n ),\n }\n case ChallengeTeamWizardStep.CREATE_NEW_TEAM: {\n return {\n content: (\n <CreateChallengeTeam\n ref={createTeamRef}\n challengeId={challenge?.id!}\n onCanSubmitChange={canSubmit => setCanCreateNewTeam(canSubmit)}\n onFinished={teamId => {\n setHasCreatedNewTeam(true)\n setSelectedTeamId(teamId)\n setStep(ChallengeTeamWizardStep.REGISTRATION_SUCCESSFUL)\n }}\n />\n ),\n actions: (\n <>\n {backButton}\n <Button\n variant={'contained'}\n disabled={!canCreateNewTeam}\n onClick={() => {\n createTeamRef?.current?.submit()\n }}\n >\n Create Team\n </Button>\n </>\n ),\n }\n }\n }\n }, [\n isAuthenticated,\n isMemberOfSubmissionTeam,\n step,\n selectedTeamId,\n backButton,\n closeButton,\n hasCreatedNewTeam,\n selectedTeamMembershipStatus,\n challenge,\n addMemberToTeamIsPending,\n selectedTeamMembershipStatusIsLoading,\n addUserToTeam,\n canCreateNewTeam,\n ])\n\n const errorMessage =\n addUserToTeamError?.message ||\n selectedTeamMembershipStatusError?.message ||\n userSubmissionTeamError?.message\n\n return (\n <DialogBase\n onCancel={hide}\n open={isShowingModal}\n actions={actions}\n title={getStepDialogTitle(step)}\n content={\n <SynapseErrorBoundary>\n <Box\n sx={{\n display: 'flex',\n flexDirection: 'column',\n gap: 1,\n }}\n >\n {isLoading ? (\n <SynapseSpinner size={40} />\n ) : (\n <>\n {content}\n {errorMessage && (\n <Alert severity={'error'}>{errorMessage}</Alert>\n )}\n </>\n )}\n </Box>\n </SynapseErrorBoundary>\n }\n />\n )\n}\n\nexport default ChallengeTeamWizard\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6BA,IAAK,IAAL,yBAAA,GAAA;QACE,EAAA,6BAA6B,8BAC7B,EAAA,oBAAoB,qBACpB,EAAA,oBAAoB,qBACpB,EAAA,oBAAoB,qBACpB,EAAA,kBAAkB,mBAClB,EAAA,0BAA0B;EANvB,KAAA,EAAA,CAOJ;AAED,SAAS,EAAmB,GAA+B;AACzD,SAAQ,GAAR;EACE,KAAK,EAAwB,2BAC3B,QAAO;EACT,KAAK,EAAwB,kBAC3B,QAAO;EACT,KAAK,EAAwB,kBAC3B,QAAO;EACT,KAAK,EAAwB,kBAC3B,QAAO;EACT,KAAK,EAAwB,gBAC3B,QAAO;EACT,KAAK,EAAwB,wBAC3B,QAAO;;;AAeb,SAAS,EAAoB,GAAiC;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MAFA,EAAqB,GAAK,EAC1B,EAAkB,EAAO,EACzB,EAAQ,EAAwB,wBAAwB;;KAE1D,CAAA;IAEJ,SACE,kBAAA,GAAA,EAAA,UAAA,CACG,GACD,kBAAC,GAAD;KACE,SAAS;KACT,UAAU,CAAC;KACX,eAAe;AACb,SAAe,SAAS,QAAQ;;eAEnC;KAEQ,CAAA,CACR,EAAA,CAAA;IAEN;;IAGJ;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,EAEI,IACJ,GAAoB,WACpB,IAAmC,WACnC,IAAyB;AAE3B,QACE,kBAAC,GAAD;EACE,UAAU;EACV,MAAM;EACG;EACT,OAAO,EAAmB,EAAK;EAC/B,SACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;GACE,IAAI;IACF,SAAS;IACT,eAAe;IACf,KAAK;IACN;aAEA,KACC,kBAAC,GAAD,EAAgB,MAAM,IAAM,CAAA,GAE5B,kBAAA,GAAA,EAAA,UAAA,CACG,IACA,KACC,kBAAC,GAAD;IAAO,UAAU;cAAU;IAAqB,CAAA,CAEjD,EAAA,CAAA;GAED,CAAA,EACe,CAAA;EAEzB,CAAA"}
|
|
1
|
+
{"version":3,"file":"ChallengeTeamWizard.js","names":[],"sources":["../../../src/components/ChallengeTeamWizard/ChallengeTeamWizard.tsx"],"sourcesContent":["import {\n useAddMemberToTeam,\n useGetCurrentUserProfile,\n useGetEntityChallenge,\n useGetMembershipStatus,\n useGetUserSubmissionTeams,\n} from '@/synapse-queries'\nimport { useSynapseContext } from '@/utils'\nimport { Alert, Box, Button, Tooltip, Typography } from '@mui/material'\nimport { noop } from 'lodash-es'\nimport { useCallback, useMemo, useRef, useState } from 'react'\nimport { DialogBase } from '../DialogBase'\nimport { SignInPrompt, SynapseErrorBoundary } from '../error/ErrorBanner'\nimport { SynapseSpinner } from '../LoadingScreen/LoadingScreen'\nimport {\n CreateChallengeTeam,\n CreateChallengeTeamHandle,\n} from './CreateChallengeTeam'\nimport {\n MembershipRequestForm,\n MembershipRequestFormHandle,\n} from './MembershipRequestForm'\nimport {\n AcceptMembershipInvitationButton,\n OpenMembershipInvitation,\n} from './OpenMembershipInvitation'\nimport { RegistrationSuccessful } from './RegistrationSuccessful'\nimport { SelectChallengeTeam } from './SelectChallengeTeam'\n\nenum ChallengeTeamWizardStep {\n SELECT_YOUR_CHALLENGE_TEAM = 'SELECT_YOUR_CHALLENGE_TEAM',\n ACCEPT_INVITATION = 'ACCEPT_INVITATION',\n JOIN_REQUEST_FORM = 'JOIN_REQUEST_FORM',\n JOIN_REQUEST_SENT = 'JOIN_REQUEST_SENT',\n CREATE_NEW_TEAM = 'CREATE_NEW_TEAM',\n REGISTRATION_SUCCESSFUL = 'REGISTRATION_SUCCESSFUL',\n}\n\nfunction getStepDialogTitle(step: ChallengeTeamWizardStep) {\n switch (step) {\n case ChallengeTeamWizardStep.SELECT_YOUR_CHALLENGE_TEAM:\n return 'Select Your Submission Team'\n case ChallengeTeamWizardStep.ACCEPT_INVITATION:\n return 'Invitation to Join Team'\n case ChallengeTeamWizardStep.JOIN_REQUEST_FORM:\n return 'Request Team Membership'\n case ChallengeTeamWizardStep.JOIN_REQUEST_SENT:\n return 'Request Sent'\n case ChallengeTeamWizardStep.CREATE_NEW_TEAM:\n return 'Create Team'\n case ChallengeTeamWizardStep.REGISTRATION_SUCCESSFUL:\n return 'Registration Successful!'\n }\n}\n\nexport type ChallengeTeamWizardProps = {\n projectId: string\n isShowingModal?: boolean\n onClose: () => void\n}\n\n/**\n * The ChallengeTeamWizard is used to guide a user through the process of joining or creating a team for a challenge.\n *\n * A required precondition is that the user is NOT on any registered submission team for the challenge.\n */\nfunction ChallengeTeamWizard(props: ChallengeTeamWizardProps) {\n const { projectId, isShowingModal = false, onClose } = props\n const { isAuthenticated } = useSynapseContext()\n\n const [step, setStep] = useState<ChallengeTeamWizardStep>(\n ChallengeTeamWizardStep.SELECT_YOUR_CHALLENGE_TEAM,\n )\n const [selectedTeamId, setSelectedTeamId] = useState<string | undefined>()\n\n // Tracks if the form to create a new team is valid, so the wizard can control the `disabled` status of the confirm button\n const [canCreateNewTeam, setCanCreateNewTeam] = useState(false)\n // true if the user has created a new team to register for the challenge\n const [hasCreatedNewTeam, setHasCreatedNewTeam] = useState<boolean>(false)\n\n const membershipRequestFormRef = useRef<MembershipRequestFormHandle>(null)\n const createTeamRef = useRef<CreateChallengeTeamHandle>(null)\n\n const { data: userProfile, isLoading: isLoadingUserProfile } =\n useGetCurrentUserProfile({\n enabled: isAuthenticated,\n })\n\n // Retrieve the challenge associated with the projectId passed through props\n const { data: challenge, isLoading: isLoadingChallenge } =\n useGetEntityChallenge(projectId)\n\n const {\n mutateAsync: addTeamMember,\n isPending: addMemberToTeamIsPending,\n error: addUserToTeamError,\n } = useAddMemberToTeam()\n\n // Determine whether the given user belongs to any submission teams\n const { data: userSubmissionTeams, error: userSubmissionTeamError } =\n useGetUserSubmissionTeams(challenge?.id!, 1, 0, {\n enabled: Boolean(isAuthenticated && challenge),\n })\n\n const isMemberOfSubmissionTeam =\n userSubmissionTeams && userSubmissionTeams.results.length > 0\n\n const {\n data: selectedTeamMembershipStatus,\n isLoading: selectedTeamMembershipStatusIsLoading,\n error: selectedTeamMembershipStatusError,\n } = useGetMembershipStatus(selectedTeamId!, String(userProfile?.ownerId), {\n enabled: isAuthenticated && !!selectedTeamId && !!userProfile,\n })\n\n const addUserToTeam = useCallback(async () => {\n if (!selectedTeamId || !userProfile) return\n await addTeamMember({\n teamId: selectedTeamId,\n userId: userProfile.ownerId,\n })\n setStep(ChallengeTeamWizardStep.REGISTRATION_SUCCESSFUL)\n }, [addTeamMember, setStep, selectedTeamId, userProfile])\n\n const hide = useCallback(() => {\n setHasCreatedNewTeam(false)\n setSelectedTeamId(undefined)\n onClose()\n }, [onClose])\n\n const isLoading = isLoadingUserProfile || isLoadingChallenge\n\n const backButton = useMemo(() => {\n switch (step) {\n case ChallengeTeamWizardStep.SELECT_YOUR_CHALLENGE_TEAM:\n case ChallengeTeamWizardStep.JOIN_REQUEST_SENT:\n case ChallengeTeamWizardStep.REGISTRATION_SUCCESSFUL:\n // Cannot go back from these steps\n return <></>\n case ChallengeTeamWizardStep.ACCEPT_INVITATION:\n case ChallengeTeamWizardStep.JOIN_REQUEST_FORM:\n case ChallengeTeamWizardStep.CREATE_NEW_TEAM:\n default:\n // All the other steps go back to team selection\n return (\n <Button\n variant={'outlined'}\n onClick={() => {\n setStep(ChallengeTeamWizardStep.SELECT_YOUR_CHALLENGE_TEAM)\n setSelectedTeamId(undefined)\n }}\n >\n Back\n </Button>\n )\n }\n }, [step])\n\n const closeButton = useMemo(() => {\n return (\n <Button\n variant={'contained'}\n onClick={() => {\n onClose()\n }}\n >\n Close\n </Button>\n )\n }, [onClose])\n\n // Determine modal content based on step.id\n const { actions = <></>, content = <></> } = useMemo(() => {\n if (!isAuthenticated) {\n return {\n content: (\n <Alert severity={'error'}>\n <SignInPrompt />\n </Alert>\n ),\n }\n }\n\n if (isMemberOfSubmissionTeam) {\n return {\n content: (\n <Alert severity={'error'}>\n <Typography>\n You are already a member of a registered submission team for this\n Challenge.\n </Typography>\n </Alert>\n ),\n }\n }\n\n switch (step) {\n case ChallengeTeamWizardStep.SELECT_YOUR_CHALLENGE_TEAM: {\n let buttonText = 'Join Team'\n let disableJoiningSelectedTeam = false\n let buttonOnClickBehavior: () => void = noop\n let buttonTooltip = ''\n if (\n selectedTeamMembershipStatus &&\n selectedTeamMembershipStatus.hasOpenInvitation\n ) {\n // The user has been invited to join the selected team\n buttonText = 'View Invitation to Join Team'\n buttonOnClickBehavior = () => {\n setStep(ChallengeTeamWizardStep.ACCEPT_INVITATION)\n }\n } else if (\n selectedTeamMembershipStatus &&\n selectedTeamMembershipStatus.hasOpenRequest\n ) {\n // User already has an open request to join the selected team, disable button to avoid request spamming\n buttonText = 'Join Request Pending'\n disableJoiningSelectedTeam = true\n buttonTooltip =\n 'You have already submitted a request to join this team.'\n } else if (\n selectedTeamMembershipStatus &&\n selectedTeamMembershipStatus.membershipApprovalRequired\n ) {\n // The user has to send a request to join the selected team\n buttonText = 'Request to Join Team'\n buttonOnClickBehavior = () => {\n setStep(ChallengeTeamWizardStep.JOIN_REQUEST_FORM)\n }\n } else if (\n selectedTeamMembershipStatus &&\n selectedTeamMembershipStatus.canJoin\n ) {\n // The user can freely join the selected team\n buttonText = 'Join Team'\n buttonOnClickBehavior = () => {\n void addUserToTeam()\n }\n }\n return {\n content: challenge && !isMemberOfSubmissionTeam && (\n <SelectChallengeTeam\n challengeId={challenge.id}\n onCreateTeam={() =>\n setStep(ChallengeTeamWizardStep.CREATE_NEW_TEAM)\n }\n selectedTeamId={selectedTeamId}\n onSelectTeam={teamId => setSelectedTeamId(teamId)}\n />\n ),\n actions: (\n <>\n {backButton}\n <Tooltip title={buttonTooltip}>\n {/* Wrap button in span to show tooltip when button is disabled */}\n <span>\n <Button\n onClick={buttonOnClickBehavior}\n startIcon={\n addMemberToTeamIsPending ? <SynapseSpinner /> : undefined\n }\n disabled={\n !selectedTeamId ||\n selectedTeamMembershipStatusIsLoading ||\n addMemberToTeamIsPending ||\n disableJoiningSelectedTeam\n }\n variant={'contained'}\n >\n {buttonText}\n </Button>\n </span>\n </Tooltip>\n </>\n ),\n }\n }\n case ChallengeTeamWizardStep.ACCEPT_INVITATION:\n return {\n content: <OpenMembershipInvitation teamId={selectedTeamId!} />,\n actions: (\n <>\n {backButton}\n <AcceptMembershipInvitationButton\n teamId={selectedTeamId!}\n onSuccess={() => {\n setStep(ChallengeTeamWizardStep.REGISTRATION_SUCCESSFUL)\n }}\n />\n </>\n ),\n }\n case ChallengeTeamWizardStep.JOIN_REQUEST_FORM:\n return {\n content: (\n <MembershipRequestForm\n ref={membershipRequestFormRef}\n teamId={selectedTeamId!}\n onRequestSubmitted={() => {\n setStep(ChallengeTeamWizardStep.JOIN_REQUEST_SENT)\n }}\n />\n ),\n actions: (\n <>\n {backButton}\n <Button\n variant={'contained'}\n onClick={() => {\n membershipRequestFormRef?.current?.submit()\n }}\n >\n Send Request\n </Button>\n </>\n ),\n }\n\n case ChallengeTeamWizardStep.JOIN_REQUEST_SENT:\n return {\n content: (\n <Typography variant=\"body1\" sx={{ lineHeight: '20px' }}>\n Team Manager(s) have received your request. Check your Synapse\n email address for status of your request.\n </Typography>\n ),\n actions: (\n <>\n {backButton}\n {closeButton}\n </>\n ),\n }\n case ChallengeTeamWizardStep.REGISTRATION_SUCCESSFUL:\n return {\n content: (\n <RegistrationSuccessful\n createdNewTeam={hasCreatedNewTeam}\n teamId={selectedTeamId}\n />\n ),\n actions: (\n <>\n {backButton}\n {closeButton}\n </>\n ),\n }\n case ChallengeTeamWizardStep.CREATE_NEW_TEAM: {\n return {\n content: (\n <CreateChallengeTeam\n ref={createTeamRef}\n challengeId={challenge?.id!}\n onCanSubmitChange={canSubmit => setCanCreateNewTeam(canSubmit)}\n onFinished={teamId => {\n setHasCreatedNewTeam(true)\n setSelectedTeamId(teamId)\n setStep(ChallengeTeamWizardStep.REGISTRATION_SUCCESSFUL)\n }}\n />\n ),\n actions: (\n <>\n {backButton}\n <Button\n variant={'contained'}\n disabled={!canCreateNewTeam}\n onClick={() => {\n createTeamRef?.current?.submit()\n }}\n >\n Create Team\n </Button>\n </>\n ),\n }\n }\n }\n }, [\n isAuthenticated,\n isMemberOfSubmissionTeam,\n step,\n selectedTeamId,\n backButton,\n closeButton,\n hasCreatedNewTeam,\n selectedTeamMembershipStatus,\n challenge,\n addMemberToTeamIsPending,\n selectedTeamMembershipStatusIsLoading,\n addUserToTeam,\n canCreateNewTeam,\n ])\n\n const errorMessage =\n addUserToTeamError?.message ||\n selectedTeamMembershipStatusError?.message ||\n userSubmissionTeamError?.message\n\n return (\n <DialogBase\n onCancel={hide}\n open={isShowingModal}\n actions={actions}\n title={`Challenge Registration (Step 2 of 2): ${getStepDialogTitle(\n step,\n )}`}\n content={\n <SynapseErrorBoundary>\n <Box\n sx={{\n display: 'flex',\n flexDirection: 'column',\n gap: 1,\n }}\n >\n {isLoading ? (\n <SynapseSpinner size={40} />\n ) : (\n <>\n {content}\n {errorMessage && (\n <Alert severity={'error'}>{errorMessage}</Alert>\n )}\n </>\n )}\n </Box>\n </SynapseErrorBoundary>\n }\n />\n )\n}\n\nexport default ChallengeTeamWizard\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6BA,IAAK,IAAL,yBAAA,GAAA;QACE,EAAA,6BAA6B,8BAC7B,EAAA,oBAAoB,qBACpB,EAAA,oBAAoB,qBACpB,EAAA,oBAAoB,qBACpB,EAAA,kBAAkB,mBAClB,EAAA,0BAA0B;EANvB,KAAA,EAAA,CAOJ;AAED,SAAS,EAAmB,GAA+B;AACzD,SAAQ,GAAR;EACE,KAAK,EAAwB,2BAC3B,QAAO;EACT,KAAK,EAAwB,kBAC3B,QAAO;EACT,KAAK,EAAwB,kBAC3B,QAAO;EACT,KAAK,EAAwB,kBAC3B,QAAO;EACT,KAAK,EAAwB,gBAC3B,QAAO;EACT,KAAK,EAAwB,wBAC3B,QAAO;;;AAeb,SAAS,EAAoB,GAAiC;CAC5D,IAAM,EAAE,cAAW,oBAAiB,IAAO,eAAY,GACjD,EAAE,uBAAoB,GAAmB,EAEzC,CAAC,GAAM,KAAW,EACtB,EAAwB,2BACzB,EACK,CAAC,GAAgB,KAAqB,GAA8B,EAGpE,CAAC,GAAkB,MAAuB,EAAS,GAAM,EAEzD,CAAC,GAAmB,KAAwB,EAAkB,GAAM,EAEpE,IAA2B,EAAoC,KAAK,EACpE,IAAgB,EAAkC,KAAK,EAEvD,EAAE,MAAM,GAAa,WAAW,MACpC,EAAyB,EACvB,SAAS,GACV,CAAC,EAGE,EAAE,MAAM,GAAW,WAAW,MAClC,EAAsB,EAAU,EAE5B,EACJ,aAAa,GACb,WAAW,GACX,OAAO,MACL,GAAoB,EAGlB,EAAE,MAAM,GAAqB,OAAO,OACxC,GAA0B,GAAW,IAAK,GAAG,GAAG,EAC9C,SAAS,GAAQ,KAAmB,IACrC,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A,KACC,kBAAC,GAAD,EAAgB,MAAM,IAAM,CAAA,GAE5B,kBAAA,GAAA,EAAA,UAAA,CACG,IACA,KACC,kBAAC,GAAD;IAAO,UAAU;cAAU;IAAqB,CAAA,CAEjD,EAAA,CAAA;GAED,CAAA,EACe,CAAA;EAEzB,CAAA"}
|
|
@@ -24,7 +24,7 @@ function r(e, t) {
|
|
|
24
24
|
if (r.length !== i.length) return !1;
|
|
25
25
|
for (let n of r) {
|
|
26
26
|
let r = e[n], i = t[n], a = (e) => e == null || e === "";
|
|
27
|
-
if (!(a(r) && a(i)) &&
|
|
27
|
+
if (!(a(r) && a(i)) && !Object.is(r, i)) return !1;
|
|
28
28
|
}
|
|
29
29
|
return !0;
|
|
30
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataGridUtils.js","names":["SYNAPSE_ENTITY_ID_REGEX","DataGridRow","Operation","QueryInput","GRID_ROW_REACT_KEY_PROPERTY","parseQueryInput","input","trimmedInput","trim","type","toUpperCase","startsWith","test","rowsAreIdentical","a","b","isDataKey","key","aKeys","Object","keys","filter","bKeys","length","aVal","bVal","isNullish","v","undefined","
|
|
1
|
+
{"version":3,"file":"DataGridUtils.js","names":["SYNAPSE_ENTITY_ID_REGEX","DataGridRow","Operation","QueryInput","GRID_ROW_REACT_KEY_PROPERTY","parseQueryInput","input","trimmedInput","trim","type","toUpperCase","startsWith","test","rowsAreIdentical","a","b","isDataKey","key","aKeys","Object","keys","filter","bKeys","length","aVal","bVal","isNullish","v","undefined","is","removeNoOpOperations","newValue","rowValues","operations","isNoop","operation","oldVal","slice","fromRowIndex","toRowIndex","newVal","comparisonResults","map","oldItem","idx","every","Boolean","op"],"sources":["../../../../src/components/DataGrid/utils/DataGridUtils.ts"],"sourcesContent":["import { SYNAPSE_ENTITY_ID_REGEX } from '@/utils/functions/RegularExpressions'\nimport { DataGridRow, Operation, QueryInput } from '../DataGridTypes'\n\n// We embed a value into the in row data passed to react-datasheet-grid for use as a render optimization\nexport const GRID_ROW_REACT_KEY_PROPERTY = '__rowKey'\n\n// Query Input can either be an empty string, a SQL query, or a session ID\nexport const parseQueryInput = (input: string): QueryInput => {\n const trimmedInput = input.trim()\n if (!trimmedInput) {\n return { type: 'empty', input: '' }\n } else if (trimmedInput.toUpperCase().startsWith('SELECT')) {\n return { type: 'sql', input: trimmedInput }\n } else if (SYNAPSE_ENTITY_ID_REGEX.test(trimmedInput)) {\n return { type: 'recordSetId', input: trimmedInput }\n } else if (/^[A-Za-z]\\w*=+$/.test(trimmedInput)) {\n return { type: 'sessionId', input: trimmedInput }\n }\n return { type: 'unknown', input: trimmedInput }\n}\n\nexport function rowsAreIdentical(a: DataGridRow, b: DataGridRow): boolean {\n const isDataKey = (key: string) => !key.startsWith('__')\n const aKeys = Object.keys(a).filter(isDataKey)\n const bKeys = Object.keys(b).filter(isDataKey)\n if (aKeys.length !== bKeys.length) return false\n for (const key of aKeys) {\n const aVal = a[key] as string | number | boolean | null | undefined\n const bVal = b[key] as string | number | boolean | null | undefined\n // Treat null, undefined, and empty string as equivalent\n const isNullish = (v: unknown) => v === null || v === undefined || v === ''\n if (isNullish(aVal) && isNullish(bVal)) continue\n if (!Object.is(aVal, bVal)) return false\n }\n return true\n}\n\n/**\n * Remove no-op operations created by react-datasheet-grid that would result in invalid or undesired changes to the json-joy CRDT model\n * @param newValue\n * @param rowValues\n * @param operations\n */\nexport function removeNoOpOperations(\n newValue: DataGridRow[],\n rowValues: DataGridRow[],\n operations: Operation[],\n) {\n function isNoop(operation: Operation): boolean {\n if (operation.type === 'UPDATE') {\n const oldVal = rowValues.slice(\n operation.fromRowIndex,\n operation.toRowIndex,\n )\n const newVal = newValue.slice(\n operation.fromRowIndex,\n operation.toRowIndex,\n )\n\n const comparisonResults = oldVal.map((oldItem, idx) =>\n rowsAreIdentical(oldItem, newVal[idx]),\n )\n return comparisonResults.every(Boolean)\n }\n return false\n }\n\n return operations.filter(op => !isNoop(op))\n}\n"],"mappings":";;AAIA,I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AAOa,EAAG,CAAC"}
|
|
@@ -7,10 +7,10 @@ import g from "@mui/icons-material/Close";
|
|
|
7
7
|
import _ from "react-draggable";
|
|
8
8
|
//#region src/components/DraggableDialog/DraggableDialog.tsx
|
|
9
9
|
function v({ open: v = !1, onClose: y, title: b, children: x }) {
|
|
10
|
-
let S =
|
|
10
|
+
let S = p(), C = f(S.breakpoints.down("sm")), w = r(null), [T, E] = i(), [D, O] = i({
|
|
11
11
|
x: 100,
|
|
12
12
|
y: 100
|
|
13
|
-
}), { width:
|
|
13
|
+
}), { width: k, height: A, handleResizeStart: j } = e({
|
|
14
14
|
initialWidth: 600,
|
|
15
15
|
initialHeight: 500,
|
|
16
16
|
minWidth: 300,
|
|
@@ -21,26 +21,26 @@ function v({ open: v = !1, onClose: y, title: b, children: x }) {
|
|
|
21
21
|
if (n(() => {
|
|
22
22
|
function e() {
|
|
23
23
|
let e = {
|
|
24
|
-
left: -(
|
|
24
|
+
left: -(k - 100),
|
|
25
25
|
top: 0,
|
|
26
26
|
right: window.innerWidth - 100,
|
|
27
27
|
bottom: window.innerHeight - 100
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
E(e), O((t) => ({
|
|
30
30
|
x: Math.max(e.left, Math.min(t.x, e.right)),
|
|
31
31
|
y: Math.max(e.top, Math.min(t.y, e.bottom))
|
|
32
32
|
}));
|
|
33
33
|
}
|
|
34
34
|
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
35
|
-
}, [
|
|
36
|
-
let
|
|
35
|
+
}, [k, A]), !v) return null;
|
|
36
|
+
let M = /* @__PURE__ */ h(l, {
|
|
37
37
|
elevation: 5,
|
|
38
38
|
sx: {
|
|
39
39
|
display: "flex",
|
|
40
40
|
flexDirection: "column",
|
|
41
|
-
height:
|
|
42
|
-
width:
|
|
43
|
-
...
|
|
41
|
+
height: C ? "95vh" : `${A}px`,
|
|
42
|
+
width: C ? "95vw" : `${k}px`,
|
|
43
|
+
...C && { position: "fixed" }
|
|
44
44
|
},
|
|
45
45
|
children: [
|
|
46
46
|
/* @__PURE__ */ h(u, {
|
|
@@ -78,28 +78,28 @@ function v({ open: v = !1, onClose: y, title: b, children: x }) {
|
|
|
78
78
|
return /* @__PURE__ */ m(a, {
|
|
79
79
|
sx: {
|
|
80
80
|
position: "fixed",
|
|
81
|
-
zIndex:
|
|
81
|
+
zIndex: S.zIndex.modal,
|
|
82
82
|
top: 0,
|
|
83
83
|
left: 0,
|
|
84
|
-
pointerEvents:
|
|
84
|
+
pointerEvents: C ? "auto" : "none"
|
|
85
85
|
},
|
|
86
|
-
children:
|
|
87
|
-
position:
|
|
88
|
-
onDrag: (e, t) =>
|
|
86
|
+
children: C ? M : /* @__PURE__ */ m(_, {
|
|
87
|
+
position: D,
|
|
88
|
+
onDrag: (e, t) => O({
|
|
89
89
|
x: t.x,
|
|
90
90
|
y: t.y
|
|
91
91
|
}),
|
|
92
|
-
nodeRef:
|
|
93
|
-
bounds:
|
|
92
|
+
nodeRef: w,
|
|
93
|
+
bounds: T,
|
|
94
94
|
handle: ".drag-handle",
|
|
95
95
|
children: /* @__PURE__ */ m(a, {
|
|
96
|
-
ref:
|
|
96
|
+
ref: w,
|
|
97
97
|
sx: { pointerEvents: "auto" },
|
|
98
98
|
children: /* @__PURE__ */ m(t, {
|
|
99
|
-
width:
|
|
100
|
-
height:
|
|
101
|
-
onResizeStart:
|
|
102
|
-
children:
|
|
99
|
+
width: k,
|
|
100
|
+
height: A,
|
|
101
|
+
onResizeStart: j,
|
|
102
|
+
children: M
|
|
103
103
|
})
|
|
104
104
|
})
|
|
105
105
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DraggableDialog.js","names":[],"sources":["../../../src/components/DraggableDialog/DraggableDialog.tsx"],"sourcesContent":["import Draggable, { DraggableBounds } from 'react-draggable'\nimport {\n Box,\n IconButton,\n Paper,\n Stack,\n Typography,\n Divider,\n useMediaQuery,\n useTheme,\n DialogContent,\n} from '@mui/material'\nimport CloseIcon from '@mui/icons-material/Close'\nimport { useRef, ReactNode, useEffect, useState } from 'react'\nimport { useResizable } from '../ResizableContainer/hooks/useResizable'\nimport { ResizableContainer } from '../ResizableContainer/ResizableContainer'\n\ntype DraggableDialogProps = {\n open?: boolean\n onClose?: () => void\n children: ReactNode\n title?: ReactNode\n}\n\nexport default function DraggableDialog({\n open = false,\n onClose,\n title,\n children,\n}: DraggableDialogProps) {\n const theme = useTheme()\n const isMobile = useMediaQuery(theme.breakpoints.down('sm'))\n const draggableRef = useRef<HTMLDivElement>(null)\n const [bounds, setBounds] = useState<DraggableBounds>()\n const [position, setPosition] = useState({ x: 100, y: 100 })\n const { width, height, handleResizeStart } = useResizable({\n initialWidth: 600,\n initialHeight: 500,\n minWidth: 300,\n minHeight: 200,\n maxWidth: 1200,\n maxHeight: 800,\n })\n\n useEffect(() => {\n // Calculate draggable bounds to keep dialog within viewport with margin\n function updateBounds() {\n const margin = 100\n const dialogWidth = width\n\n const newBounds = {\n left: -(dialogWidth - margin),\n top: 0,\n right: window.innerWidth - margin,\n bottom: window.innerHeight - margin,\n }\n\n setBounds(newBounds)\n\n // Clamp dialog position to new bounds to keep it visible after window resize\n setPosition(prevPosition => ({\n x: Math.max(newBounds.left, Math.min(prevPosition.x, newBounds.right)),\n y: Math.max(newBounds.top, Math.min(prevPosition.y, newBounds.bottom)),\n }))\n }\n updateBounds()\n window.addEventListener('resize', updateBounds)\n return () => window.removeEventListener('resize', updateBounds)\n }, [width, height])\n\n if (!open) {\n return null\n }\n\n const paperContent = (\n <Paper\n elevation={5}\n sx={{\n display: 'flex',\n flexDirection: 'column',\n height: isMobile ? '95vh' : `${height}px`,\n width: isMobile ? '95vw' : `${width}px`,\n ...(isMobile && {\n position: 'fixed',\n }),\n }}\n >\n <Stack\n direction=\"row\"\n alignItems=\"center\"\n gap=\"5px\"\n className=\"drag-handle\"\n sx={{\n padding: '20px',\n cursor: 'move',\n }}\n >\n <Typography variant=\"headline1\">{title}</Typography>\n <Box sx={{ flexGrow: 1 }} />\n <IconButton onClick={onClose}>\n <CloseIcon />\n </IconButton>\n </Stack>\n <Divider sx={{ mx: 2 }} />\n <DialogContent\n sx={{\n height: '100%',\n maxWidth: '100%',\n padding: '16px',\n }}\n >\n {children}\n </DialogContent>\n </Paper>\n )\n\n return (\n <Box\n sx={{\n position: 'fixed',\n zIndex:
|
|
1
|
+
{"version":3,"file":"DraggableDialog.js","names":[],"sources":["../../../src/components/DraggableDialog/DraggableDialog.tsx"],"sourcesContent":["import Draggable, { DraggableBounds } from 'react-draggable'\nimport {\n Box,\n IconButton,\n Paper,\n Stack,\n Typography,\n Divider,\n useMediaQuery,\n useTheme,\n DialogContent,\n} from '@mui/material'\nimport CloseIcon from '@mui/icons-material/Close'\nimport { useRef, ReactNode, useEffect, useState } from 'react'\nimport { useResizable } from '../ResizableContainer/hooks/useResizable'\nimport { ResizableContainer } from '../ResizableContainer/ResizableContainer'\n\ntype DraggableDialogProps = {\n open?: boolean\n onClose?: () => void\n children: ReactNode\n title?: ReactNode\n}\n\nexport default function DraggableDialog({\n open = false,\n onClose,\n title,\n children,\n}: DraggableDialogProps) {\n const theme = useTheme()\n const isMobile = useMediaQuery(theme.breakpoints.down('sm'))\n const draggableRef = useRef<HTMLDivElement>(null)\n const [bounds, setBounds] = useState<DraggableBounds>()\n const [position, setPosition] = useState({ x: 100, y: 100 })\n const { width, height, handleResizeStart } = useResizable({\n initialWidth: 600,\n initialHeight: 500,\n minWidth: 300,\n minHeight: 200,\n maxWidth: 1200,\n maxHeight: 800,\n })\n\n useEffect(() => {\n // Calculate draggable bounds to keep dialog within viewport with margin\n function updateBounds() {\n const margin = 100\n const dialogWidth = width\n\n const newBounds = {\n left: -(dialogWidth - margin),\n top: 0,\n right: window.innerWidth - margin,\n bottom: window.innerHeight - margin,\n }\n\n setBounds(newBounds)\n\n // Clamp dialog position to new bounds to keep it visible after window resize\n setPosition(prevPosition => ({\n x: Math.max(newBounds.left, Math.min(prevPosition.x, newBounds.right)),\n y: Math.max(newBounds.top, Math.min(prevPosition.y, newBounds.bottom)),\n }))\n }\n updateBounds()\n window.addEventListener('resize', updateBounds)\n return () => window.removeEventListener('resize', updateBounds)\n }, [width, height])\n\n if (!open) {\n return null\n }\n\n const paperContent = (\n <Paper\n elevation={5}\n sx={{\n display: 'flex',\n flexDirection: 'column',\n height: isMobile ? '95vh' : `${height}px`,\n width: isMobile ? '95vw' : `${width}px`,\n ...(isMobile && {\n position: 'fixed',\n }),\n }}\n >\n <Stack\n direction=\"row\"\n alignItems=\"center\"\n gap=\"5px\"\n className=\"drag-handle\"\n sx={{\n padding: '20px',\n cursor: 'move',\n }}\n >\n <Typography variant=\"headline1\">{title}</Typography>\n <Box sx={{ flexGrow: 1 }} />\n <IconButton onClick={onClose}>\n <CloseIcon />\n </IconButton>\n </Stack>\n <Divider sx={{ mx: 2 }} />\n <DialogContent\n sx={{\n height: '100%',\n maxWidth: '100%',\n padding: '16px',\n }}\n >\n {children}\n </DialogContent>\n </Paper>\n )\n\n return (\n <Box\n sx={{\n position: 'fixed',\n zIndex: theme.zIndex.modal,\n top: 0,\n left: 0,\n pointerEvents: isMobile ? 'auto' : 'none',\n }}\n >\n {isMobile ? (\n paperContent\n ) : (\n <Draggable\n position={position}\n onDrag={(e, data) => setPosition({ x: data.x, y: data.y })}\n nodeRef={draggableRef}\n bounds={bounds}\n handle=\".drag-handle\"\n >\n <Box ref={draggableRef} sx={{ pointerEvents: 'auto' }}>\n <ResizableContainer\n width={width}\n height={height}\n onResizeStart={handleResizeStart}\n >\n {paperContent}\n </ResizableContainer>\n </Box>\n </Draggable>\n )}\n </Box>\n )\n}\n"],"mappings":";;;;;;;;AAwBA,SAAwB,EAAgB,EACtC,UAAO,IACP,YACA,UACA,eACuB;CACvB,IAAM,IAAQ,GAAU,EAClB,IAAW,EAAc,EAAM,YAAY,KAAK,KAAK,CAAC,EACtD,IAAe,EAAuB,KAAK,EAC3C,CAAC,GAAQ,KAAa,GAA2B,EACjD,CAAC,GA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,kBAAC,GAAD;IACE,IAAI;KACF,QAAQ;KACR,UAAU;KACV,SAAS;KACV;IAEA;IACa,CAAA;GACV;;AAGV,QACE,kBAAC,GAAD;EACE,IAAI;GACF,UAAU;GACV,QAAQ,EAAM,OAAO;GACrB,KAAK;GACL,MAAM;GACN,eAAe,IAAW,SAAS;GACpC;YAEA,IACC,IAEA,kBAAC,GAAD;GACY;GACV,SAAS,GAAG,MAAS,EAAY;IAAE,GAAG,EAAK;IAAG,GAAG,EAAK;IAAG,CAAC;GAC1D,SAAS;GACD;GACR,QAAO;aAEP,kBAAC,GAAD;IAAK,KAAK;IAAc,IAAI,EAAE,eAAe,QAAQ;cACnD,kBAAC,GAAD;KACS;KACC;KACR,eAAe;eAEd;KACkB,CAAA;IACjB,CAAA;GACI,CAAA;EAEV,CAAA"}
|
|
@@ -2,6 +2,12 @@ import { EntityType } from '@sage-bionetworks/synapse-client';
|
|
|
2
2
|
import { RefObject } from 'react';
|
|
3
3
|
export declare const PYTHON_CLIENT_IMPORT_AND_LOGIN = "import synapseclient\nsyn = synapseclient.Synapse()\nsyn.login(authToken=\"YOUR_TOKEN_HERE\")";
|
|
4
4
|
export declare const R_CLIENT_IMPORT_AND_LOGIN = "library(synapser)\nsynLogin(authToken=\"YOUR_TOKEN_HERE\")";
|
|
5
|
+
type ProgrammaticAccessCode = {
|
|
6
|
+
cliCode: string | undefined;
|
|
7
|
+
rCode: string | undefined;
|
|
8
|
+
pythonCode: string | undefined;
|
|
9
|
+
};
|
|
10
|
+
export declare function getProgrammaticAccessCode(type: EntityType, entityId: string, version: number | undefined): ProgrammaticAccessCode;
|
|
5
11
|
declare enum DownloadAction {
|
|
6
12
|
downloadFile = 0,
|
|
7
13
|
addToCart = 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityDownloadButton.d.ts","sourceRoot":"","sources":["../../../src/components/EntityDownloadButton/EntityDownloadButton.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAK7D,OAAO,EAAE,SAAS,EAAY,MAAM,OAAO,CAAA;AAkB3C,eAAO,MAAM,8BAA8B,kGAEJ,CAAA;AAGvC,eAAO,MAAM,yBAAyB,+DACA,CAAA;
|
|
1
|
+
{"version":3,"file":"EntityDownloadButton.d.ts","sourceRoot":"","sources":["../../../src/components/EntityDownloadButton/EntityDownloadButton.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAK7D,OAAO,EAAE,SAAS,EAAY,MAAM,OAAO,CAAA;AAkB3C,eAAO,MAAM,8BAA8B,kGAEJ,CAAA;AAGvC,eAAO,MAAM,yBAAyB,+DACA,CAAA;AAEtC,KAAK,sBAAsB,GAAG;IAC5B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;CAC/B,CAAA;AAGD,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,sBAAsB,CAkDxB;AAED,aAAK,cAAc;IACjB,YAAY,IAAA;IACZ,SAAS,IAAA;IACT,kBAAkB,IAAA;IAClB,wBAAwB,IAAA;IACxB,WAAW,IAAA;CACZ;AA6FD,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE,UAAU,GACf,cAAc,EAAE,EAAE,CAoCpB;AA2ED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAC1C,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,UAAU,CAAA;IACtB,6BAA6B,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IAC7D,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,2CAgLA"}
|
|
@@ -59,6 +59,11 @@ read.table(query$filepath, sep=",")`,
|
|
|
59
59
|
query = syn.tableQuery("SELECT * FROM ${r}")
|
|
60
60
|
query.asDataFrame()`
|
|
61
61
|
};
|
|
62
|
+
case C.searchindex: return {
|
|
63
|
+
cliCode: void 0,
|
|
64
|
+
rCode: void 0,
|
|
65
|
+
pythonCode: void 0
|
|
66
|
+
};
|
|
62
67
|
default: throw Error(`Unhandled EntityType: ${e}`);
|
|
63
68
|
}
|
|
64
69
|
}
|
|
@@ -207,6 +212,6 @@ function F(n) {
|
|
|
207
212
|
] });
|
|
208
213
|
}
|
|
209
214
|
//#endregion
|
|
210
|
-
export { F as EntityDownloadButton, E as PYTHON_CLIENT_IMPORT_AND_LOGIN, D as R_CLIENT_IMPORT_AND_LOGIN, M as getDownloadActionsForEntityType };
|
|
215
|
+
export { F as EntityDownloadButton, E as PYTHON_CLIENT_IMPORT_AND_LOGIN, D as R_CLIENT_IMPORT_AND_LOGIN, M as getDownloadActionsForEntityType, O as getProgrammaticAccessCode };
|
|
211
216
|
|
|
212
217
|
//# sourceMappingURL=EntityDownloadButton.js.map
|