From c1b5417d1036da83283b7c84ff7cae5c553ada27 Mon Sep 17 00:00:00 2001 From: Lisa Knox Date: Sun, 17 Sep 2023 17:07:07 -0400 Subject: [PATCH] 15768: fixed dialog not closing on single collection copy Arvados-DCO-1.1-Signed-off-by: Lisa Knox --- .../collections/collection-copy-actions.ts | 2 ++ .../open-in-new-tab.actions.ts | 6 ++--- src/store/workbench/workbench-actions.ts | 6 ++++- .../api-client-authorization-action-set.ts | 26 ++++++++++++------- .../action-sets/collection-action-set.ts | 21 +++++++-------- .../ms-collection-action-set.ts | 3 ++- 6 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/store/collections/collection-copy-actions.ts b/src/store/collections/collection-copy-actions.ts index d4e647f8..e454712a 100644 --- a/src/store/collections/collection-copy-actions.ts +++ b/src/store/collections/collection-copy-actions.ts @@ -19,6 +19,7 @@ export const COLLECTION_COPY_FORM_NAME = "collectionCopyFormName"; export const COLLECTION_MULTI_COPY_FORM_NAME = "collectionMultiCopyFormName"; export const openCollectionCopyDialog = (resource: { name: string; uuid: string; isSingle?: boolean }) => (dispatch: Dispatch) => { + console.log(resource); dispatch(resetPickerProjectTree()); dispatch(initProjectsTreePicker(COLLECTION_COPY_FORM_NAME)); const initialData: CopyFormDialogData = { name: `Copy of: ${resource.name}`, ownerUuid: "", uuid: resource.uuid, isSingle: resource.isSingle }; @@ -36,6 +37,7 @@ export const openMultiCollectionCopyDialog = (resource: { name: string; uuid: st export const copyCollection = (resource: CopyFormDialogData) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + console.log("COPYCOLL", resource); const formName = resource.isSingle ? COLLECTION_COPY_FORM_NAME : COLLECTION_MULTI_COPY_FORM_NAME; dispatch(startSubmit(formName)); let collection = getResource(resource.uuid)(getState().resources); diff --git a/src/store/open-in-new-tab/open-in-new-tab.actions.ts b/src/store/open-in-new-tab/open-in-new-tab.actions.ts index 6a1ec643..7c6c2bb3 100644 --- a/src/store/open-in-new-tab/open-in-new-tab.actions.ts +++ b/src/store/open-in-new-tab/open-in-new-tab.actions.ts @@ -23,11 +23,11 @@ export const copyToClipboardAction = (resources: Array) => (dispatch: Dispa let output = ""; - resources.forEach(resource => { + for (const resource of [...resources]) { let url = getNavUrl(resource.uuid, getState().auth, false); if (url[0] === "/") url = `${window.location.origin}${url}`; - output += output.length ? `, ${url}` : url; - }); + output += output.length ? `,${url}` : url; + } if (output.length) { const wasCopied = copy(output); diff --git a/src/store/workbench/workbench-actions.ts b/src/store/workbench/workbench-actions.ts index 3d580915..95db8c4f 100644 --- a/src/store/workbench/workbench-actions.ts +++ b/src/store/workbench/workbench-actions.ts @@ -444,7 +444,11 @@ export const copyCollection = (data: CopyFormDialogData) => async (dispatch: Dis const newName = data.isSingle ? data.name : `Copy of: ${copyToProject.name}`; try { const collection = await dispatch( - collectionCopyActions.copyCollection({ ...copyToProject, name: newName, isSingle: data.isSingle }) + collectionCopyActions.copyCollection({ + ...copyToProject, + name: newName, + isSingle: collectionsToCopy.length === 1 ? true : data.isSingle, + }) ); if (copyToProject && collection) { await dispatch(reloadProjectMatchingUuid([copyToProject.uuid])); diff --git a/src/views-components/context-menu/action-sets/api-client-authorization-action-set.ts b/src/views-components/context-menu/action-sets/api-client-authorization-action-set.ts index 001bae4f..0d3bebb1 100644 --- a/src/views-components/context-menu/action-sets/api-client-authorization-action-set.ts +++ b/src/views-components/context-menu/action-sets/api-client-authorization-action-set.ts @@ -5,32 +5,38 @@ import { openApiClientAuthorizationAttributesDialog, openApiClientAuthorizationRemoveDialog, -} from 'store/api-client-authorizations/api-client-authorizations-actions'; -import { openAdvancedTabDialog } from 'store/advanced-tab/advanced-tab'; -import { ContextMenuActionSet } from 'views-components/context-menu/context-menu-action-set'; -import { AdvancedIcon, RemoveIcon, AttributesIcon } from 'components/icon/icon'; +} from "store/api-client-authorizations/api-client-authorizations-actions"; +import { openAdvancedTabDialog } from "store/advanced-tab/advanced-tab"; +import { ContextMenuActionSet } from "views-components/context-menu/context-menu-action-set"; +import { AdvancedIcon, RemoveIcon, AttributesIcon } from "components/icon/icon"; export const apiClientAuthorizationActionSet: ContextMenuActionSet = [ [ { - name: 'Attributes', + name: "Attributes", icon: AttributesIcon, execute: (dispatch, resources) => { - resources.forEach(({ uuid }) => dispatch(openApiClientAuthorizationAttributesDialog(uuid))); + for (const resource of [...resources]) { + dispatch(openApiClientAuthorizationAttributesDialog(resource.uuid)); + } }, }, { - name: 'API Details', + name: "API Details", icon: AdvancedIcon, execute: (dispatch, resources) => { - resources.forEach(({ uuid }) => dispatch(openAdvancedTabDialog(uuid))); + for (const resource of [...resources]) { + dispatch(openAdvancedTabDialog(resource.uuid)); + } }, }, { - name: 'Remove', + name: "Remove", icon: RemoveIcon, execute: (dispatch, resources) => { - resources.forEach(({ uuid }) => dispatch(openApiClientAuthorizationRemoveDialog(uuid))); + for (const resource of [...resources]) { + dispatch(openApiClientAuthorizationRemoveDialog(resource.uuid)); + } }, }, ], diff --git a/src/views-components/context-menu/action-sets/collection-action-set.ts b/src/views-components/context-menu/action-sets/collection-action-set.ts index 86c850f0..e7a34ec3 100644 --- a/src/views-components/context-menu/action-sets/collection-action-set.ts +++ b/src/views-components/context-menu/action-sets/collection-action-set.ts @@ -38,14 +38,13 @@ const toggleFavoriteAction: ContextMenuAction = { component: ToggleFavoriteAction, name: "ToggleFavoriteAction", execute: (dispatch, resources) => { - resources.forEach(resource => + for (const resource of [...resources]) { dispatch(toggleFavorite(resource)).then(() => { dispatch(favoritePanelActions.REQUEST_ITEMS()); - }) - ); + }); + } }, }; - const commonActionSet: ContextMenuActionSet = [ [ { @@ -81,7 +80,7 @@ const commonActionSet: ContextMenuActionSet = [ icon: AdvancedIcon, name: "API Details", execute: (dispatch, resources) => { - resources.forEach(resource => dispatch(openAdvancedTabDialog(resource.uuid))); + dispatch(openAdvancedTabDialog(resources[0].uuid)); }, }, ], @@ -95,7 +94,7 @@ export const readOnlyCollectionActionSet: ContextMenuActionSet = [ icon: FolderSharedIcon, name: "Open with 3rd party client", execute: (dispatch, resources) => { - resources.forEach(resource => dispatch(openWebDavS3InfoDialog(resource.uuid))); + dispatch(openWebDavS3InfoDialog(resources[0].uuid)); }, }, ], @@ -108,14 +107,14 @@ export const collectionActionSet: ContextMenuActionSet = [ icon: RenameIcon, name: "Edit collection", execute: (dispatch, resources) => { - resources.forEach(resource => dispatch(openCollectionUpdateDialog(resource))); + dispatch(openCollectionUpdateDialog(resources[0])); }, }, { icon: ShareIcon, name: "Share", execute: (dispatch, resources) => { - resources.forEach(({ uuid }) => dispatch(openSharingDialog(uuid))); + dispatch(openSharingDialog(resources[0].uuid)); }, }, { @@ -142,11 +141,11 @@ export const collectionAdminActionSet: ContextMenuActionSet = [ component: TogglePublicFavoriteAction, name: "TogglePublicFavoriteAction", execute: (dispatch, resources) => { - resources.forEach(resource => + for (const resource of resources) { dispatch(togglePublicFavorite(resource)).then(() => { dispatch(publicFavoritePanelActions.REQUEST_ITEMS()); - }) - ); + }); + } }, }, ], diff --git a/src/views-components/multiselect-toolbar/ms-collection-action-set.ts b/src/views-components/multiselect-toolbar/ms-collection-action-set.ts index f6d7e712..77215470 100644 --- a/src/views-components/multiselect-toolbar/ms-collection-action-set.ts +++ b/src/views-components/multiselect-toolbar/ms-collection-action-set.ts @@ -15,7 +15,8 @@ export const msCollectionActionSet: ContextMenuActionSet = [ { icon: CopyIcon, name: "Make a copy", - execute: (dispatch, resources) => { + execute: (dispatch, [...resources]) => { + console.log(resources); if (resources[0].isSingle || resources.length === 1) dispatch(openCollectionCopyDialog(resources[0])); else dispatch(openMultiCollectionCopyDialog(resources[0])); }, -- 2.30.2