From b7e0ddd55831574d9e9991a319f814569af69a6a Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 20 Dec 2023 12:15:50 -0500 Subject: [PATCH] Page object permissions summary... --- client/src/api/datasetCollections.ts | 2 +- client/src/api/histories.ts | 3 + client/src/api/workflows.ts | 4 + client/src/components/Markdown/parse.ts | 45 +++ .../PageEditor/ObjectPermissions.vue | 267 ++++++++++++++++++ .../PageEditor/ObjectPermissionsModal.vue | 15 + .../PageEditor/PageEditorMarkdown.vue | 22 +- .../PageEditor/PermissionObjectType.vue | 31 ++ .../PageEditor/SharingIndicator.vue | 60 ++++ .../webapps/galaxy/api/dataset_collections.py | 11 +- .../galaxy/services/dataset_collections.py | 6 +- 11 files changed, 459 insertions(+), 7 deletions(-) create mode 100644 client/src/api/workflows.ts create mode 100644 client/src/components/PageEditor/ObjectPermissions.vue create mode 100644 client/src/components/PageEditor/ObjectPermissionsModal.vue create mode 100644 client/src/components/PageEditor/PermissionObjectType.vue create mode 100644 client/src/components/PageEditor/SharingIndicator.vue diff --git a/client/src/api/datasetCollections.ts b/client/src/api/datasetCollections.ts index cb09d46c66b5..47b17ea2baa3 100644 --- a/client/src/api/datasetCollections.ts +++ b/client/src/api/datasetCollections.ts @@ -11,7 +11,7 @@ const getCollectionDetails = fetcher.path("/api/dataset_collections/{id}").metho */ export async function fetchCollectionDetails(params: { id: string }): Promise { const { data } = await getCollectionDetails({ id: params.id }); - return data; + return data as HDCADetailed; } const getCollectionContents = fetcher diff --git a/client/src/api/histories.ts b/client/src/api/histories.ts index 65ad7e2d6b1d..9d3788a9505d 100644 --- a/client/src/api/histories.ts +++ b/client/src/api/histories.ts @@ -4,3 +4,6 @@ export const historiesFetcher = fetcher.path("/api/histories").method("get").cre export const archivedHistoriesFetcher = fetcher.path("/api/histories/archived").method("get").create(); export const undeleteHistory = fetcher.path("/api/histories/deleted/{history_id}/undelete").method("post").create(); export const purgeHistory = fetcher.path("/api/histories/{history_id}").method("delete").create(); + +export const sharing = fetcher.path("/api/histories/{history_id}/sharing").method("get").create(); +export const enableLink = fetcher.path("/api/histories/{history_id}/enable_link_access").method("put").create(); diff --git a/client/src/api/workflows.ts b/client/src/api/workflows.ts new file mode 100644 index 000000000000..ae5a054a6584 --- /dev/null +++ b/client/src/api/workflows.ts @@ -0,0 +1,4 @@ +import { fetcher } from "@/api/schema"; + +export const sharing = fetcher.path("/api/workflows/{id}/sharing").method("get").create(); +export const enableLink = fetcher.path("/api/workflows/{id}/enable_link_access").method("put").create(); diff --git a/client/src/components/Markdown/parse.ts b/client/src/components/Markdown/parse.ts index 900bbd3135db..3eb11ae54f89 100644 --- a/client/src/components/Markdown/parse.ts +++ b/client/src/components/Markdown/parse.ts @@ -77,3 +77,48 @@ export function getArgs(content: string) { content: content, }; } + +class ReferencedObjects { + jobs: Set = new Set(); + historyDatasets: Set = new Set(); + historyDatasetCollections: Set = new Set(); + workflows: Set = new Set(); + invocations: Set = new Set(); +} + +export function referencedObjects(markdown: string) { + const { sections } = splitMarkdown(markdown); + const objects = new ReferencedObjects(); + for (const section of sections) { + if (!("args" in section)) { + continue; + } + const args = section.args; + if (!args) { + continue; + } + if ("job_id" in args) { + addToSetIfHasValue(args.job_id, objects.jobs); + } + if ("history_dataset_id" in args) { + addToSetIfHasValue(args.history_dataset_id, objects.historyDatasets); + } + if ("history_dataset_collection_id" in args) { + addToSetIfHasValue(args.history_dataset_collection_id, objects.historyDatasetCollections); + } + if ("invocation_id" in args) { + addToSetIfHasValue(args.invocation_id, objects.invocations); + } + if ("workflow_id" in args) { + addToSetIfHasValue(args.workflow_id, objects.workflows); + } + // TODO: implicit collect job ids + } + return objects; +} + +function addToSetIfHasValue(value: string, toSet: Set): void { + if (value) { + toSet.add(value); + } +} diff --git a/client/src/components/PageEditor/ObjectPermissions.vue b/client/src/components/PageEditor/ObjectPermissions.vue new file mode 100644 index 000000000000..9e8aa15464ea --- /dev/null +++ b/client/src/components/PageEditor/ObjectPermissions.vue @@ -0,0 +1,267 @@ + + + diff --git a/client/src/components/PageEditor/ObjectPermissionsModal.vue b/client/src/components/PageEditor/ObjectPermissionsModal.vue new file mode 100644 index 000000000000..cb250f1884e6 --- /dev/null +++ b/client/src/components/PageEditor/ObjectPermissionsModal.vue @@ -0,0 +1,15 @@ + + + diff --git a/client/src/components/PageEditor/PageEditorMarkdown.vue b/client/src/components/PageEditor/PageEditorMarkdown.vue index 7ef80fe89225..e422a3c8855d 100644 --- a/client/src/components/PageEditor/PageEditorMarkdown.vue +++ b/client/src/components/PageEditor/PageEditorMarkdown.vue @@ -1,6 +1,20 @@