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
|
@@ -2,22 +2,23 @@ import { useSynapseContext as e } from "../../../../utils/context/SynapseContext
|
|
|
2
2
|
import "../../../../utils/index.js";
|
|
3
3
|
import { getGridSessionQuery as t, useCreateGridSession as n, useDeleteGridSession as r } from "../../../../synapse-queries/grid/useGridSession.js";
|
|
4
4
|
import { useUpdateCurationTaskStatus as i } from "../../../../synapse-queries/curation/task/useCurationTask.js";
|
|
5
|
-
import a from "../utils/
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import { OPEN_CURATOR_LINK_TASK_CONFLICT_ERROR_MESSAGE as a } from "../utils/constants.js";
|
|
6
|
+
import o from "../utils/taskHasAssignee.js";
|
|
7
|
+
import { getCreateGridRequestForMetadataTask as s } from "../utils/getCreateGridRequestForMetadataTask.js";
|
|
8
|
+
import { SynapseClientError as c } from "@sage-bionetworks/synapse-client";
|
|
9
|
+
import { useMutation as l, useQueryClient as u } from "@tanstack/react-query";
|
|
9
10
|
//#region src/features/entity/metadata-task/hooks/useGridSessionForCurationTask.ts
|
|
10
|
-
function
|
|
11
|
-
let { mutateAsync:
|
|
12
|
-
return
|
|
11
|
+
function d() {
|
|
12
|
+
let { mutateAsync: d } = n(), { mutateAsync: f } = i(), { mutateAsync: p } = r(), m = e(), h = u();
|
|
13
|
+
return l({ mutationFn: async (e) => {
|
|
13
14
|
let { task: n, status: r } = e;
|
|
14
15
|
if (!n || !r) throw Error("CurationTaskBundle is missing task or status");
|
|
15
|
-
let i =
|
|
16
|
-
if (
|
|
17
|
-
let e = await
|
|
18
|
-
...t(
|
|
19
|
-
...
|
|
20
|
-
queryClient:
|
|
16
|
+
let i = o(n), l = r?.executionDetails?.activeSessionId;
|
|
17
|
+
if (l) try {
|
|
18
|
+
let e = await h.fetchQuery({
|
|
19
|
+
...t(l, {
|
|
20
|
+
...m,
|
|
21
|
+
queryClient: h
|
|
21
22
|
}),
|
|
22
23
|
staleTime: 0
|
|
23
24
|
});
|
|
@@ -26,29 +27,32 @@ function u() {
|
|
|
26
27
|
gridSessionOwnerMatchesTaskAssignee: i && e.ownerPrincipalId == n.assigneePrincipalId
|
|
27
28
|
};
|
|
28
29
|
} catch (e) {
|
|
29
|
-
if (!(e instanceof
|
|
30
|
+
if (!(e instanceof c && e.status === 404)) throw e;
|
|
30
31
|
}
|
|
31
32
|
if (n.taskProperties == null) throw Error("CurationTask is missing taskProperties");
|
|
32
|
-
let
|
|
33
|
+
let u = (await d({
|
|
34
|
+
...s(n),
|
|
35
|
+
authorizationMode: "SOURCE_BENEFACTOR"
|
|
36
|
+
})).gridSession;
|
|
33
37
|
try {
|
|
34
|
-
await
|
|
38
|
+
await f({
|
|
35
39
|
...r,
|
|
36
40
|
executionDetails: {
|
|
37
41
|
...r.executionDetails,
|
|
38
|
-
activeSessionId:
|
|
42
|
+
activeSessionId: u.sessionId,
|
|
39
43
|
concreteType: "org.sagebionetworks.repo.model.curation.execution.GridExecutionDetails"
|
|
40
44
|
}
|
|
41
45
|
});
|
|
42
46
|
} catch (e) {
|
|
43
|
-
throw e instanceof
|
|
47
|
+
throw e instanceof c && e.status === 412 ? (await p(u.sessionId), Error(a)) : e;
|
|
44
48
|
}
|
|
45
49
|
return {
|
|
46
|
-
gridSession:
|
|
50
|
+
gridSession: u,
|
|
47
51
|
gridSessionOwnerMatchesTaskAssignee: i
|
|
48
52
|
};
|
|
49
53
|
} });
|
|
50
54
|
}
|
|
51
55
|
//#endregion
|
|
52
|
-
export {
|
|
56
|
+
export { d as default };
|
|
53
57
|
|
|
54
58
|
//# sourceMappingURL=useGridSessionForCurationTask.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGridSessionForCurationTask.js","names":[],"sources":["../../../../../src/features/entity/metadata-task/hooks/useGridSessionForCurationTask.ts"],"sourcesContent":["import { useUpdateCurationTaskStatus } from '@/synapse-queries/curation/task/useCurationTask'\nimport {\n getGridSessionQuery,\n useCreateGridSession,\n useDeleteGridSession,\n} from '@/synapse-queries/grid/useGridSession'\nimport { useSynapseContext } from '@/utils'\nimport {\n GridSession,\n SynapseClientError,\n TaskBundle,\n} from '@sage-bionetworks/synapse-client'\nimport { useMutation, useQueryClient } from '@tanstack/react-query'\nimport { getCreateGridRequestForMetadataTask } from '../utils/getCreateGridRequestForMetadataTask'\nimport taskHasAssignee from '../utils/taskHasAssignee'\n\nexport type UseGridSessionForCurationTaskResult = {\n gridSession: GridSession\n gridSessionOwnerMatchesTaskAssignee: boolean\n}\n\n/**\n * A hook to get or create a GridSession for a given CurationTask. If an appropriate GridSession exists, it will be returned.\n * If not, a new GridSession will be created based on the CurationTask's properties.\n *\n * @returns A mutation object with a function to get or create a GridSession for a CurationTask. The response will also indicate\n * if the GridSession owner matches the task assignee (if there is one).\n * @throws SynapseClientError with status 403 if the user does not have permission to access an existing GridSession\n */\nexport default function useGridSessionForCurationTask() {\n const { mutateAsync: createGridSession } = useCreateGridSession()\n const { mutateAsync: updateCurationTaskStatus } =\n useUpdateCurationTaskStatus()\n const { mutateAsync: deleteGridSession } = useDeleteGridSession()\n\n const synapseContext = useSynapseContext()\n const queryClient = useQueryClient()\n\n return useMutation<\n UseGridSessionForCurationTaskResult,\n SynapseClientError,\n TaskBundle\n >({\n mutationFn: async curationTaskBundle => {\n const { task, status } = curationTaskBundle\n if (!task || !status) {\n throw new Error('CurationTaskBundle is missing task or status')\n }\n\n const hasAssignee = taskHasAssignee(task)\n\n const gridSessionId = status?.executionDetails?.activeSessionId\n if (gridSessionId) {\n try {\n // Verify the session is still active before returning it\n const gridSession = await queryClient.fetchQuery({\n ...getGridSessionQuery(gridSessionId, {\n ...synapseContext,\n queryClient,\n }),\n staleTime: 0,\n })\n\n const assigneeMatchesGridSessionOwner =\n hasAssignee &&\n gridSession.ownerPrincipalId == task.assigneePrincipalId\n\n return {\n gridSession,\n gridSessionOwnerMatchesTaskAssignee:\n assigneeMatchesGridSessionOwner,\n }\n } catch (e) {\n if (e instanceof SynapseClientError && e.status === 404) {\n // Session not found, will create a new one\n } else {\n throw e\n }\n }\n }\n // Create a session and link it to the task\n const taskProperties = task.taskProperties\n if (taskProperties == null) {\n throw new Error('CurationTask is missing taskProperties')\n }\n\n const createGridRequest = getCreateGridRequestForMetadataTask(task)\n const createGridResponse = await createGridSession(createGridRequest)\n const gridSession = createGridResponse.gridSession!\n\n // Associate the new session with the task\n try {\n await updateCurationTaskStatus({\n ...status,\n executionDetails: {\n ...status.executionDetails,\n activeSessionId: gridSession.sessionId!,\n concreteType:\n 'org.sagebionetworks.repo.model.curation.execution.GridExecutionDetails',\n },\n })\n } catch (e) {\n if (e instanceof SynapseClientError && e.status === 412) {\n // etag mismatch -- possible race condition.\n // Delete the session we just created to avoid orphaned sessions, and throw an error to notify the user that they may need to refresh and try again.\n await deleteGridSession(gridSession.sessionId!)\n throw new Error(
|
|
1
|
+
{"version":3,"file":"useGridSessionForCurationTask.js","names":[],"sources":["../../../../../src/features/entity/metadata-task/hooks/useGridSessionForCurationTask.ts"],"sourcesContent":["import { useUpdateCurationTaskStatus } from '@/synapse-queries/curation/task/useCurationTask'\nimport {\n getGridSessionQuery,\n useCreateGridSession,\n useDeleteGridSession,\n} from '@/synapse-queries/grid/useGridSession'\nimport { useSynapseContext } from '@/utils'\nimport {\n CreateGridRequest,\n GridSession,\n SynapseClientError,\n TaskBundle,\n} from '@sage-bionetworks/synapse-client'\nimport { useMutation, useQueryClient } from '@tanstack/react-query'\nimport { OPEN_CURATOR_LINK_TASK_CONFLICT_ERROR_MESSAGE } from '../utils/constants'\nimport { getCreateGridRequestForMetadataTask } from '../utils/getCreateGridRequestForMetadataTask'\nimport taskHasAssignee from '../utils/taskHasAssignee'\n\nexport type UseGridSessionForCurationTaskResult = {\n gridSession: GridSession\n gridSessionOwnerMatchesTaskAssignee: boolean\n}\n\n/**\n * A hook to get or create a GridSession for a given CurationTask. If an appropriate GridSession exists, it will be returned.\n * If not, a new GridSession will be created based on the CurationTask's properties.\n *\n * @returns A mutation object with a function to get or create a GridSession for a CurationTask. The response will also indicate\n * if the GridSession owner matches the task assignee (if there is one).\n * @throws SynapseClientError with status 403 if the user does not have permission to access an existing GridSession\n */\nexport default function useGridSessionForCurationTask() {\n const { mutateAsync: createGridSession } = useCreateGridSession()\n const { mutateAsync: updateCurationTaskStatus } =\n useUpdateCurationTaskStatus()\n const { mutateAsync: deleteGridSession } = useDeleteGridSession()\n\n const synapseContext = useSynapseContext()\n const queryClient = useQueryClient()\n\n return useMutation<\n UseGridSessionForCurationTaskResult,\n SynapseClientError,\n TaskBundle\n >({\n mutationFn: async curationTaskBundle => {\n const { task, status } = curationTaskBundle\n if (!task || !status) {\n throw new Error('CurationTaskBundle is missing task or status')\n }\n\n const hasAssignee = taskHasAssignee(task)\n\n const gridSessionId = status?.executionDetails?.activeSessionId\n if (gridSessionId) {\n try {\n // Verify the session is still active before returning it\n const gridSession = await queryClient.fetchQuery({\n ...getGridSessionQuery(gridSessionId, {\n ...synapseContext,\n queryClient,\n }),\n staleTime: 0,\n })\n\n const assigneeMatchesGridSessionOwner =\n hasAssignee &&\n gridSession.ownerPrincipalId == task.assigneePrincipalId\n\n return {\n gridSession,\n gridSessionOwnerMatchesTaskAssignee:\n assigneeMatchesGridSessionOwner,\n }\n } catch (e) {\n if (e instanceof SynapseClientError && e.status === 404) {\n // Session not found, will create a new one\n } else {\n throw e\n }\n }\n }\n // Create a session and link it to the task\n const taskProperties = task.taskProperties\n if (taskProperties == null) {\n throw new Error('CurationTask is missing taskProperties')\n }\n\n const createGridRequest: CreateGridRequest = {\n ...getCreateGridRequestForMetadataTask(task),\n authorizationMode: 'SOURCE_BENEFACTOR',\n }\n const createGridResponse = await createGridSession(createGridRequest)\n const gridSession = createGridResponse.gridSession!\n\n // Associate the new session with the task\n try {\n await updateCurationTaskStatus({\n ...status,\n executionDetails: {\n ...status.executionDetails,\n activeSessionId: gridSession.sessionId!,\n concreteType:\n 'org.sagebionetworks.repo.model.curation.execution.GridExecutionDetails',\n },\n })\n } catch (e) {\n if (e instanceof SynapseClientError && e.status === 412) {\n // etag mismatch -- possible race condition.\n // Delete the session we just created to avoid orphaned sessions, and throw an error to notify the user that they may need to refresh and try again.\n await deleteGridSession(gridSession.sessionId!)\n throw new Error(OPEN_CURATOR_LINK_TASK_CONFLICT_ERROR_MESSAGE)\n } else {\n // Rethrow any other error\n throw e\n }\n }\n\n // Since we just created the session, the user must have access, and the owner must match the assignee (if there is one).\n return {\n gridSession,\n gridSessionOwnerMatchesTaskAssignee: hasAssignee,\n }\n },\n })\n}\n"],"mappings":";;;;;;;;;;AA+BA,SAAwB,IAAgC;CACtD,IAAM,EAAE,aAAa,MAAsB,GAAsB,EAC3D,EAAE,aAAa,MACnB,GAA6B,EACzB,EAAE,aAAa,MAAsB,GAAsB,EAE3D,IAAiB,GAAmB,EACpC,IAAc,GAAgB;AAEpC,QAAO,EAIL,EACA,YAAY,OAAM,MAAsB;EACtC,IAAM,EAAE,SAAM,cAAW;AACzB,MAAI,CAAC,KAAQ,CAAC,EACZ,OAAU,MAAM,+CAA+C;EAGjE,IAAM,IAAc,EAAgB,EAAK,EAEnC,IAAgB,GAAQ,kBAAkB;AAChD,MAAI,EACF,KAAI;GAEF,IAAM,IAAc,MAAM,EAAY,WAAW;IAC/C,GAAG,EAAoB,GAAe;KACpC,GAAG;KACH;KACD,CAAC;IACF,WAAW;IACZ,CAAC;AAMF,UAAO;IACL;IACA,qCALA,KACA,EAAY,oBAAoB,EAAK;IAMtC;WACM,GAAG;AACV,OAAI,eAAa,KAAsB,EAAE,WAAW,KAGlD,OAAM;;AAMZ,MADuB,EAAK,kBACN,KACpB,OAAU,MAAM,yCAAyC;EAQ3D,IAAM,KAAc,MADa,EAAkB;GAHjD,GAAG,EAAoC,EAAK;GAC5C,mBAAmB;GAE8B,CAAkB,EAC9B;AAGvC,MAAI;AACF,SAAM,EAAyB;IAC7B,GAAG;IACH,kBAAkB;KAChB,GAAG,EAAO;KACV,iBAAiB,EAAY;KAC7B,cACE;KACH;IACF,CAAC;WACK,GAAG;AAQR,SAPE,aAAa,KAAsB,EAAE,WAAW,OAGlD,MAAM,EAAkB,EAAY,UAAW,EACrC,MAAM,EAA8C,IAGxD;;AAKV,SAAO;GACL;GACA,qCAAqC;GACtC;IAEJ,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TaskBundle } from '@sage-bionetworks/synapse-client';
|
|
2
2
|
type UseOpenCuratorFromTaskButtonReturn = {
|
|
3
3
|
isLoading: boolean;
|
|
4
4
|
isPending: boolean;
|
|
5
5
|
hasPermission?: boolean;
|
|
6
6
|
onClick: () => void;
|
|
7
7
|
};
|
|
8
|
-
export default function useOpenCuratorFromTaskButton(
|
|
8
|
+
export default function useOpenCuratorFromTaskButton(taskBundle: TaskBundle): UseOpenCuratorFromTaskButtonReturn;
|
|
9
9
|
export {};
|
|
10
10
|
//# sourceMappingURL=useOpenCuratorButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOpenCuratorButton.d.ts","sourceRoot":"","sources":["../../../../../src/features/entity/metadata-task/hooks/useOpenCuratorButton.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useOpenCuratorButton.d.ts","sourceRoot":"","sources":["../../../../../src/features/entity/metadata-task/hooks/useOpenCuratorButton.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,UAAU,EACX,MAAM,kCAAkC,CAAA;AAYzC,KAAK,kCAAkC,GAAG;IACxC,SAAS,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB,CAAA;AAOD,MAAM,CAAC,OAAO,UAAU,4BAA4B,CAClD,UAAU,EAAE,UAAU,GACrB,kCAAkC,CAwEpC"}
|
|
@@ -1,37 +1,46 @@
|
|
|
1
1
|
import { displayToast as e } from "../../../../components/ToastMessage/ToastMessage.js";
|
|
2
2
|
import { useGetEntityPermissions as t } from "../../../../synapse-queries/entity/useEntity.js";
|
|
3
|
+
import { useGetFeatureFlag as n } from "../../../../synapse-queries/featureflags/useGetFeatureFlag.js";
|
|
3
4
|
import "../../../../synapse-queries/index.js";
|
|
4
5
|
import "../../../../components/index.js";
|
|
5
|
-
import { getLinkToGridSession as
|
|
6
|
-
import { OPEN_CURATOR_ERROR_TITLE as
|
|
7
|
-
import { getGridSourceIdForTask as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
6
|
+
import { getLinkToGridSession as r } from "../../../../utils/functions/getSynapseWebClientLink.js";
|
|
7
|
+
import { OPEN_CURATOR_ERROR_TITLE as i, OPEN_CURATOR_UNAUTHORIZED_ERROR_MESSAGE as a } from "../utils/constants.js";
|
|
8
|
+
import { getGridSourceIdForTask as o } from "../utils/getGridSourceIdForTask.js";
|
|
9
|
+
import s from "./useGridSessionForCurationTask.js";
|
|
10
|
+
import c from "./useGridSessionForCurationTask_legacy.js";
|
|
11
|
+
import { useCallback as l } from "react";
|
|
12
|
+
import { FeatureFlagEnum as u } from "@sage-bionetworks/synapse-types";
|
|
13
|
+
import { SynapseClientError as d } from "@sage-bionetworks/synapse-client";
|
|
11
14
|
//#region src/features/entity/metadata-task/hooks/useOpenCuratorButton.ts
|
|
12
|
-
function
|
|
13
|
-
let
|
|
14
|
-
window.open(
|
|
15
|
+
function f(e, t) {
|
|
16
|
+
let n = r(e, t);
|
|
17
|
+
window.open(n, "_blank", "noopener");
|
|
15
18
|
}
|
|
16
|
-
function
|
|
17
|
-
let { mutateAsync:
|
|
19
|
+
function p(r) {
|
|
20
|
+
let p = r.task, m = n(u.CURATOR_LINK_TASK_TO_GRID_SESSION), { mutateAsync: h, isPending: g } = c(), { mutateAsync: _, isPending: v } = s(), { data: y, isLoading: b } = t(o(p)), x = y?.canView, S = l(async () => {
|
|
18
21
|
let t;
|
|
19
22
|
try {
|
|
20
|
-
t = await
|
|
23
|
+
t = m ? (await _(r)).gridSession : await h({ curationTask: p }), f(t.sessionId, p.taskId);
|
|
21
24
|
} catch (t) {
|
|
22
|
-
t instanceof
|
|
25
|
+
t instanceof d && t.status === 403 ? (console.error(t), e(a, "danger", { title: i })) : (console.error("Error opening Curator for curation task", t), e(t instanceof Error ? t.message : String(t), "danger", { title: i }));
|
|
23
26
|
}
|
|
24
|
-
}, [
|
|
27
|
+
}, [
|
|
28
|
+
p,
|
|
29
|
+
r,
|
|
30
|
+
m,
|
|
31
|
+
h,
|
|
32
|
+
_
|
|
33
|
+
]), C = l(() => {
|
|
34
|
+
S();
|
|
35
|
+
}, [S]);
|
|
25
36
|
return {
|
|
26
|
-
hasPermission:
|
|
27
|
-
isLoading:
|
|
28
|
-
isPending:
|
|
29
|
-
onClick:
|
|
30
|
-
h();
|
|
31
|
-
}, [h])
|
|
37
|
+
hasPermission: x,
|
|
38
|
+
isLoading: b,
|
|
39
|
+
isPending: m ? v : g,
|
|
40
|
+
onClick: C
|
|
32
41
|
};
|
|
33
42
|
}
|
|
34
43
|
//#endregion
|
|
35
|
-
export {
|
|
44
|
+
export { p as default };
|
|
36
45
|
|
|
37
46
|
//# sourceMappingURL=useOpenCuratorButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOpenCuratorButton.js","names":[],"sources":["../../../../../src/features/entity/metadata-task/hooks/useOpenCuratorButton.ts"],"sourcesContent":["import { displayToast } from '@/components'\nimport { useGetEntityPermissions } from '@/synapse-queries'\nimport {\n
|
|
1
|
+
{"version":3,"file":"useOpenCuratorButton.js","names":[],"sources":["../../../../../src/features/entity/metadata-task/hooks/useOpenCuratorButton.ts"],"sourcesContent":["import { displayToast } from '@/components'\nimport { useGetEntityPermissions } from '@/synapse-queries'\nimport { useGetFeatureFlag } from '@/synapse-queries/featureflags/useGetFeatureFlag'\nimport {\n GridSession,\n SynapseClientError,\n TaskBundle,\n} from '@sage-bionetworks/synapse-client'\nimport { FeatureFlagEnum } from '@sage-bionetworks/synapse-types'\nimport { useCallback } from 'react'\nimport {\n OPEN_CURATOR_ERROR_TITLE,\n OPEN_CURATOR_UNAUTHORIZED_ERROR_MESSAGE,\n} from '../utils/constants'\nimport { getGridSourceIdForTask } from '../utils/getGridSourceIdForTask'\nimport useGridSessionForCurationTask from './useGridSessionForCurationTask'\nimport useGridSessionForCurationTask_legacy from './useGridSessionForCurationTask_legacy'\nimport { getLinkToGridSession } from '@/utils/functions/getSynapseWebClientLink'\n\ntype UseOpenCuratorFromTaskButtonReturn = {\n isLoading: boolean\n isPending: boolean\n hasPermission?: boolean\n onClick: () => void\n}\n\nfunction openGridSessionInNewWindow(gridSessionId: string, taskId: number) {\n const gridUrl = getLinkToGridSession(gridSessionId, taskId)\n window.open(gridUrl, '_blank', 'noopener')\n}\n\nexport default function useOpenCuratorFromTaskButton(\n taskBundle: TaskBundle,\n): UseOpenCuratorFromTaskButtonReturn {\n const curationTask = taskBundle.task!\n\n const isTaskLinkedSessionFlagEnabled = useGetFeatureFlag(\n FeatureFlagEnum.CURATOR_LINK_TASK_TO_GRID_SESSION,\n )\n\n const {\n mutateAsync: getOrCreateLegacyGridSessionForUnassignedTask,\n isPending: legacyOpenGridIsPending,\n } = useGridSessionForCurationTask_legacy()\n\n const {\n mutateAsync: getOrCreateTaskLinkedGridSession,\n isPending: taskLinkedOpenGridIsPending,\n } = useGridSessionForCurationTask()\n\n const gridSourceEntityId = getGridSourceIdForTask(curationTask)\n const {\n data: sourceEntityPermissions,\n isLoading: isLoadingEntityPermissions,\n } = useGetEntityPermissions(gridSourceEntityId)\n\n const hasPermission = sourceEntityPermissions?.canView\n\n const openNewOrExistingCuratorSession = useCallback(async () => {\n let gridSession: GridSession\n try {\n if (isTaskLinkedSessionFlagEnabled) {\n const result = await getOrCreateTaskLinkedGridSession(taskBundle)\n gridSession = result.gridSession\n } else {\n gridSession = await getOrCreateLegacyGridSessionForUnassignedTask({\n curationTask,\n })\n }\n openGridSessionInNewWindow(gridSession.sessionId!, curationTask.taskId!)\n } catch (error) {\n if (error instanceof SynapseClientError && error.status === 403) {\n console.error(error)\n displayToast(OPEN_CURATOR_UNAUTHORIZED_ERROR_MESSAGE, 'danger', {\n title: OPEN_CURATOR_ERROR_TITLE,\n })\n } else {\n console.error('Error opening Curator for curation task', error)\n const errorMessage =\n error instanceof Error ? error.message : String(error)\n displayToast(errorMessage, 'danger', {\n title: OPEN_CURATOR_ERROR_TITLE,\n })\n }\n }\n }, [\n curationTask,\n taskBundle,\n isTaskLinkedSessionFlagEnabled,\n getOrCreateLegacyGridSessionForUnassignedTask,\n getOrCreateTaskLinkedGridSession,\n ])\n\n const handleClickOpenCurator = useCallback(() => {\n void openNewOrExistingCuratorSession()\n }, [openNewOrExistingCuratorSession])\n\n return {\n hasPermission,\n isLoading: isLoadingEntityPermissions,\n isPending: isTaskLinkedSessionFlagEnabled\n ? taskLinkedOpenGridIsPending\n : legacyOpenGridIsPending,\n onClick: handleClickOpenCurator,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA0BA,SAAS,EAA2B,GAAuB,GAAgB;CACzE,IAAM,IAAU,EAAqB,GAAe,EAAO;AAC3D,QAAO,KAAK,GAAS,UAAU,WAAW;;AAG5C,SAAwB,EACtB,GACoC;CACpC,IAAM,IAAe,EAAW,MAE1B,IAAiC,EACrC,EAAgB,kCACjB,EAEK,EACJ,aAAa,GACb,WAAW,MACT,GAAsC,EAEpC,EACJ,aAAa,GACb,WAAW,MACT,GAA+B,EAG7B,EACJ,MAAM,GACN,WAAW,MACT,EAJuB,EAAuB,EAItB,CAAmB,EAEzC,IAAgB,GAAyB,SAEzC,IAAkC,EAAY,YAAY;EAC9D,IAAI;AACJ,MAAI;AASF,GARA,AAIE,IAJE,KAEY,MADO,EAAiC,EAAW,EAC5C,cAEP,MAAM,EAA8C,EAChE,iBACD,CAAC,EAEJ,EAA2B,EAAY,WAAY,EAAa,OAAQ;WACjE,GAAO;AACd,GAAI,aAAiB,KAAsB,EAAM,WAAW,OAC1D,QAAQ,MAAM,EAAM,EACpB,EAAa,GAAyC,UAAU,EAC9D,OAAO,GACR,CAAC,KAEF,QAAQ,MAAM,2CAA2C,EAAM,EAG/D,EADE,aAAiB,QAAQ,EAAM,UAAU,OAAO,EAAM,EAC7B,UAAU,EACnC,OAAO,GACR,CAAC;;IAGL;EACD;EACA;EACA;EACA;EACA;EACD,CAAC,EAEI,IAAyB,QAAkB;AAC1C,KAAiC;IACrC,CAAC,EAAgC,CAAC;AAErC,QAAO;EACL;EACA,WAAW;EACX,WAAW,IACP,IACA;EACJ,SAAS;EACV"}
|
|
@@ -2,4 +2,5 @@ export declare const OPEN_CURATOR_ERROR_TITLE = "An error occurred while trying
|
|
|
2
2
|
export declare const OPEN_CURATOR_UNAUTHORIZED_ERROR_MESSAGE = "You don't have permission to view the existing Curator session for this task. It was likely created by another data contributor. A data manager should create a new task and assign it to you or your team.";
|
|
3
3
|
export declare const OPEN_CURATOR_TOOLTIP_TITLE = "Open Curator to edit metadata";
|
|
4
4
|
export declare const OPEN_CURATOR_NO_PERMISSION_ON_SOURCE_ERROR_MESSAGE = "You do not have permission to view the Working Copy";
|
|
5
|
+
export declare const OPEN_CURATOR_LINK_TASK_CONFLICT_ERROR_MESSAGE = "Failed to link Grid session to Curation Task. The task was updated since it was last retrieved. Please refresh and try again.";
|
|
5
6
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/features/entity/metadata-task/utils/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,mDACa,CAAA;AAClD,eAAO,MAAM,uCAAuC,gNAC2J,CAAA;AAE/M,eAAO,MAAM,0BAA0B,kCAAkC,CAAA;AACzE,eAAO,MAAM,kDAAkD,wDACR,CAAA"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/features/entity/metadata-task/utils/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,mDACa,CAAA;AAClD,eAAO,MAAM,uCAAuC,gNAC2J,CAAA;AAE/M,eAAO,MAAM,0BAA0B,kCAAkC,CAAA;AACzE,eAAO,MAAM,kDAAkD,wDACR,CAAA;AACvD,eAAO,MAAM,6CAA6C,kIACuE,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/features/entity/metadata-task/utils/constants.ts
|
|
2
|
-
var e = "An error occurred while trying to open Curator", t = "You don't have permission to view the existing Curator session for this task. It was likely created by another data contributor. A data manager should create a new task and assign it to you or your team.", n = "Open Curator to edit metadata", r = "You do not have permission to view the Working Copy";
|
|
2
|
+
var e = "An error occurred while trying to open Curator", t = "You don't have permission to view the existing Curator session for this task. It was likely created by another data contributor. A data manager should create a new task and assign it to you or your team.", n = "Open Curator to edit metadata", r = "You do not have permission to view the Working Copy", i = "Failed to link Grid session to Curation Task. The task was updated since it was last retrieved. Please refresh and try again.";
|
|
3
3
|
//#endregion
|
|
4
|
-
export { e as OPEN_CURATOR_ERROR_TITLE, r as OPEN_CURATOR_NO_PERMISSION_ON_SOURCE_ERROR_MESSAGE, n as OPEN_CURATOR_TOOLTIP_TITLE, t as OPEN_CURATOR_UNAUTHORIZED_ERROR_MESSAGE };
|
|
4
|
+
export { e as OPEN_CURATOR_ERROR_TITLE, i as OPEN_CURATOR_LINK_TASK_CONFLICT_ERROR_MESSAGE, r as OPEN_CURATOR_NO_PERMISSION_ON_SOURCE_ERROR_MESSAGE, n as OPEN_CURATOR_TOOLTIP_TITLE, t as OPEN_CURATOR_UNAUTHORIZED_ERROR_MESSAGE };
|
|
5
5
|
|
|
6
6
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../../../../../src/features/entity/metadata-task/utils/constants.ts"],"sourcesContent":["export const OPEN_CURATOR_ERROR_TITLE =\n 'An error occurred while trying to open Curator'\nexport const OPEN_CURATOR_UNAUTHORIZED_ERROR_MESSAGE =\n \"You don't have permission to view the existing Curator session for this task. It was likely created by another data contributor. A data manager should create a new task and assign it to you or your team.\"\n\nexport const OPEN_CURATOR_TOOLTIP_TITLE = 'Open Curator to edit metadata'\nexport const OPEN_CURATOR_NO_PERMISSION_ON_SOURCE_ERROR_MESSAGE =\n 'You do not have permission to view the Working Copy'\n"],"mappings":";AAAA,IAAa,IACX,kDACW,IACX,+MAEW,IAA6B,iCAC7B,IACX"}
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../../../../src/features/entity/metadata-task/utils/constants.ts"],"sourcesContent":["export const OPEN_CURATOR_ERROR_TITLE =\n 'An error occurred while trying to open Curator'\nexport const OPEN_CURATOR_UNAUTHORIZED_ERROR_MESSAGE =\n \"You don't have permission to view the existing Curator session for this task. It was likely created by another data contributor. A data manager should create a new task and assign it to you or your team.\"\n\nexport const OPEN_CURATOR_TOOLTIP_TITLE = 'Open Curator to edit metadata'\nexport const OPEN_CURATOR_NO_PERMISSION_ON_SOURCE_ERROR_MESSAGE =\n 'You do not have permission to view the Working Copy'\nexport const OPEN_CURATOR_LINK_TASK_CONFLICT_ERROR_MESSAGE =\n 'Failed to link Grid session to Curation Task. The task was updated since it was last retrieved. Please refresh and try again.'\n"],"mappings":";AAAA,IAAa,IACX,kDACW,IACX,+MAEW,IAA6B,iCAC7B,IACX,uDACW,IACX"}
|