From 876f422044cb7235edbb19dbfa2a516e5dc86f5a Mon Sep 17 00:00:00 2001 From: Pawel Kowalczyk Date: Mon, 1 Oct 2018 13:27:11 +0200 Subject: [PATCH] modal-for-file-selection Feature #14231 Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk --- .../collection-panel-files-actions.ts | 4 +-- .../file-selection/file-selection-actions.ts | 15 ++++++++++ .../action-sets/project-action-set.ts | 3 +- .../dialog-file-selection.tsx | 29 +++++++++++++++++++ .../dialog-forms/file-selection-dialog.ts | 21 ++++++++++++++ .../dialog-move/dialog-move-to.tsx | 4 +-- .../workflow-tree-picker.tsx | 18 +++++++----- src/views/login-panel/login-panel.tsx | 2 +- src/views/workbench/workbench.tsx | 2 ++ 9 files changed, 84 insertions(+), 14 deletions(-) create mode 100644 src/store/file-selection/file-selection-actions.ts create mode 100644 src/views-components/dialog-file-selection/dialog-file-selection.tsx create mode 100644 src/views-components/dialog-forms/file-selection-dialog.ts diff --git a/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts b/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts index f214fd2f7b..0460c97797 100644 --- a/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts +++ b/src/store/collection-panel/collection-panel-files/collection-panel-files-actions.ts @@ -11,10 +11,8 @@ import { snackbarActions } from "../../snackbar/snackbar-actions"; import { dialogActions } from '../../dialog/dialog-actions'; import { getNodeValue } from "~/models/tree"; import { filterCollectionFilesBySelection } from './collection-panel-files-state'; -import { startSubmit, initialize, stopSubmit, reset } from 'redux-form'; -import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service"; +import { startSubmit, stopSubmit, reset } from 'redux-form'; import { getDialog } from "~/store/dialog/dialog-reducer"; -import { resetPickerProjectTree } from '~/store/project-tree-picker/project-tree-picker-actions'; export const collectionPanelFilesAction = unionize({ SET_COLLECTION_FILES: ofType(), diff --git a/src/store/file-selection/file-selection-actions.ts b/src/store/file-selection/file-selection-actions.ts new file mode 100644 index 0000000000..cfdc27be0f --- /dev/null +++ b/src/store/file-selection/file-selection-actions.ts @@ -0,0 +1,15 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import { Dispatch } from "redux"; +import { dialogActions } from "~/store/dialog/dialog-actions"; +import { resetPickerProjectTree } from '~/store/project-tree-picker/project-tree-picker-actions'; + +export const FILE_SELECTION = 'fileSelection'; + +export const openFileSelectionDialog = () => + (dispatch: Dispatch) => { + dispatch(resetPickerProjectTree()); + dispatch(dialogActions.OPEN_DIALOG({ id: FILE_SELECTION, data: {} })); + }; \ No newline at end of file diff --git a/src/views-components/context-menu/action-sets/project-action-set.ts b/src/views-components/context-menu/action-sets/project-action-set.ts index e5a1915472..36b8eef0ca 100644 --- a/src/views-components/context-menu/action-sets/project-action-set.ts +++ b/src/views-components/context-menu/action-sets/project-action-set.ts @@ -12,6 +12,7 @@ import { openProjectCreateDialog } from '~/store/projects/project-create-actions import { openProjectUpdateDialog } from '~/store/projects/project-update-actions'; import { ToggleTrashAction } from "~/views-components/context-menu/actions/trash-action"; import { toggleProjectTrashed } from "~/store/trash/trash-actions"; +import { openFileSelectionDialog } from '../../../store/file-selection/file-selection-actions'; export const projectActionSet: ContextMenuActionSet = [[ { @@ -45,7 +46,7 @@ export const projectActionSet: ContextMenuActionSet = [[ { icon: MoveToIcon, name: "Move to", - execute: (dispatch, resource) => dispatch(openMoveProjectDialog(resource)) + execute: (dispatch, resource) => dispatch(openFileSelectionDialog()) }, { icon: CopyIcon, diff --git a/src/views-components/dialog-file-selection/dialog-file-selection.tsx b/src/views-components/dialog-file-selection/dialog-file-selection.tsx new file mode 100644 index 0000000000..6521e2be41 --- /dev/null +++ b/src/views-components/dialog-file-selection/dialog-file-selection.tsx @@ -0,0 +1,29 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import * as React from 'react'; +import { InjectedFormProps, Field } from 'redux-form'; +import { WithDialogProps } from '~/store/dialog/with-dialog'; +import { CollectionCreateFormDialogData } from '~/store/collections/collection-create-actions'; +import { FormDialog } from '~/components/form-dialog/form-dialog'; +import { require } from '~/validators/require'; +import { WorkflowTreePickerField } from '~/views-components/workflow-tree-picker/workflow-tree-picker'; + +type FileSelectionProps = WithDialogProps<{}> & InjectedFormProps; + +export const DialogFileSelection = (props: FileSelectionProps) => + ; + +const FileSelectionFields = () => + ; + +const FILES_FIELD_VALIDATION = [require]; \ No newline at end of file diff --git a/src/views-components/dialog-forms/file-selection-dialog.ts b/src/views-components/dialog-forms/file-selection-dialog.ts new file mode 100644 index 0000000000..7c883cbf91 --- /dev/null +++ b/src/views-components/dialog-forms/file-selection-dialog.ts @@ -0,0 +1,21 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import { compose } from "redux"; +import { reduxForm } from 'redux-form'; +import { withDialog } from "~/store/dialog/with-dialog"; +import { FILE_SELECTION } from '~/store/file-selection/file-selection-actions'; +import { DialogFileSelection } from '~/views-components/dialog-file-selection/dialog-file-selection'; +import { dialogActions } from '~/store/dialog/dialog-actions'; + +export const FileSelectionDialog = compose( + withDialog(FILE_SELECTION), + reduxForm({ + form: FILE_SELECTION, + onSubmit: (data, dispatch) => { + dispatch(dialogActions.CLOSE_DIALOG({ id: FILE_SELECTION })); + return data; + } + }) +)(DialogFileSelection); \ No newline at end of file diff --git a/src/views-components/dialog-move/dialog-move-to.tsx b/src/views-components/dialog-move/dialog-move-to.tsx index 6b0ac88100..425b9e462a 100644 --- a/src/views-components/dialog-move/dialog-move-to.tsx +++ b/src/views-components/dialog-move/dialog-move-to.tsx @@ -6,7 +6,7 @@ import * as React from "react"; import { InjectedFormProps, Field } from 'redux-form'; import { WithDialogProps } from '~/store/dialog/with-dialog'; import { FormDialog } from '~/components/form-dialog/form-dialog'; -import { WorkflowTreePickerField } from '~/views-components/workflow-tree-picker/workflow-tree-picker'; +import { ProjectTreePickerField } from '~/views-components/project-tree-picker/project-tree-picker'; import { MOVE_TO_VALIDATION } from '~/validators/validators'; import { MoveToFormDialogData } from '~/store/move-to-dialog/move-to-dialog'; @@ -21,6 +21,6 @@ export const DialogMoveTo = (props: WithDialogProps & InjectedFormProps< const MoveToDialogFields = () => ; diff --git a/src/views-components/workflow-tree-picker/workflow-tree-picker.tsx b/src/views-components/workflow-tree-picker/workflow-tree-picker.tsx index f9db4eaaca..3f971720f5 100644 --- a/src/views-components/workflow-tree-picker/workflow-tree-picker.tsx +++ b/src/views-components/workflow-tree-picker/workflow-tree-picker.tsx @@ -17,8 +17,9 @@ import { RootState } from "~/store/store"; import { ServiceRepository } from "~/services/services"; import { FilterBuilder } from "~/services/api/filter-builder"; import { WrappedFieldProps } from 'redux-form'; -import { ResourceKind } from '~/models/resource'; +import { ResourceKind, extractUuidKind } from '~/models/resource'; import { GroupContentsResource } from '~/services/groups-service/groups-service'; +import { loadCollectionFiles } from '~/store/collection-panel/collection-panel-files/collection-panel-files-actions'; type WorkflowTreePickerProps = Pick; @@ -55,7 +56,7 @@ const getNotSelectedTreePickerKind = (pickerId: string) => { return [TreePickerId.PROJECTS, TreePickerId.FAVORITES, TreePickerId.SHARED_WITH_ME].filter(nodeId => nodeId !== pickerId); }; -export enum TreePickerId { +enum TreePickerId { PROJECTS = 'Projects', SHARED_WITH_ME = 'Shared with me', FAVORITES = 'Favorites' @@ -75,6 +76,8 @@ export const WorkflowTreePicker = connect(undefined, mapDispatchToProps)((props: export const loadProjectTreePicker = (nodeId: string) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + console.log(nodeId); + console.log(extractUuidKind(nodeId)); dispatch(workflowTreePickerActions.LOAD_TREE_PICKER_NODE({ nodeId, pickerId: TreePickerId.PROJECTS })); const ownerUuid = nodeId.length === 0 ? services.authService.getUuid() || '' : nodeId; @@ -84,9 +87,11 @@ export const loadProjectTreePicker = (nodeId: string) => .addEqual('ownerUuid', ownerUuid) .getFilters(); - const { items } = await services.groupsService.contents(ownerUuid, { filters }); + const { items } = (extractUuidKind(nodeId) === ResourceKind.COLLECTION) + ? dispatch(loadCollectionFiles(nodeId)) + : await services.groupsService.contents(ownerUuid, { filters }); - dispatch(receiveTreePickerData(nodeId, items, TreePickerId.PROJECTS)); + await dispatch(receiveTreePickerData(nodeId, items, TreePickerId.PROJECTS)); }; export const loadFavoriteTreePicker = (nodeId: string) => @@ -111,7 +116,6 @@ export const loadFavoriteTreePicker = (nodeId: string) => }; const getProjectPickerIcon = (item: TreeItem) => { - console.log(item); switch (item.data.name) { case TreePickerId.FAVORITES: return FavoriteIcon; @@ -129,7 +133,7 @@ const getResourceIcon = (item: TreeItem) => { case ResourceKind.COLLECTION: return CollectionIcon; case ResourceKind.PROJECT: - return ProjectsIcon; + return ProjectIcon; default: return ProjectIcon; } @@ -143,7 +147,7 @@ const renderTreeItem = (item: TreeItem) => hasMargin={true} />; -export const receiveTreePickerData = (nodeId: string, items: GroupContentsResource[], pickerId: string) => +export const receiveTreePickerData = (nodeId: string, items: GroupContentsResource[] = [], pickerId: string) => (dispatch: Dispatch) => { dispatch(workflowTreePickerActions.LOAD_TREE_PICKER_NODE_SUCCESS({ nodeId, diff --git a/src/views/login-panel/login-panel.tsx b/src/views/login-panel/login-panel.tsx index 2928a94ef0..6a9210acad 100644 --- a/src/views/login-panel/login-panel.tsx +++ b/src/views/login-panel/login-panel.tsx @@ -55,7 +55,7 @@ export const LoginPanel = withStyles(styles)(connect()( - Welcome to the Arvados Wrokbench + Welcome to the Arvados Workbench The "Log in" button below will show you a Google sign-in page. diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx index 47e2254150..ec806d5f5b 100644 --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@ -41,6 +41,7 @@ import { SharedWithMePanel } from '~/views/shared-with-me-panel/shared-with-me-p import { RunProcessPanel } from '~/views/run-process-panel/run-process-panel'; import SplitterLayout from 'react-splitter-layout'; import { WorkflowPanel } from '~/views/workflow-panel/workflow-panel'; +import { FileSelectionDialog } from '~/views-components/dialog-forms/file-selection-dialog'; type CssRules = 'root' | 'container' | 'splitter' | 'asidePanel' | 'contentWrapper' | 'content'; @@ -114,6 +115,7 @@ export const WorkbenchPanel = + -- 2.30.2