[ARVADOS-WORKBENCH2] updated: 1.1.4-699-g1700eb6
Git user
git at public.curoverse.com
Tue Aug 21 05:09:37 EDT 2018
Summary of changes:
.../move-collection-dialog.ts | 19 ++-------
.../move-project-dialog/move-project-dialog.ts | 18 ++------
.../move-to-dialog/move-to-dialog.ts} | 7 ++--
.../action-sets/collection-action-set.ts | 2 +-
.../action-sets/collection-resource-action-set.ts | 2 +-
.../context-menu/action-sets/project-action-set.ts | 2 +-
.../move-collection-dialog.ts | 42 +++----------------
.../move-project-dialog/move-project-dialog.ts | 48 +++-------------------
.../move-to-dialog/move-to-dialog.tsx | 11 +----
9 files changed, 27 insertions(+), 124 deletions(-)
copy src/{views-components => store}/move-collection-dialog/move-collection-dialog.ts (76%)
copy src/{views-components => store}/move-project-dialog/move-project-dialog.ts (81%)
copy src/{models/empty.ts => store/move-to-dialog/move-to-dialog.ts} (59%)
via 1700eb6123c054b185034c420d69ac41e2a749e6 (commit)
from e478b4da43dcf7c0625b145c906e39d77fb5941f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 1700eb6123c054b185034c420d69ac41e2a749e6
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Tue Aug 21 11:09:21 2018 +0200
Refactor code
Feature #13831
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/views-components/move-collection-dialog/move-collection-dialog.ts b/src/store/move-collection-dialog/move-collection-dialog.ts
similarity index 76%
copy from src/views-components/move-collection-dialog/move-collection-dialog.ts
copy to src/store/move-collection-dialog/move-collection-dialog.ts
index 7409151..375f2e2 100644
--- a/src/views-components/move-collection-dialog/move-collection-dialog.ts
+++ b/src/store/move-collection-dialog/move-collection-dialog.ts
@@ -2,16 +2,15 @@
//
// SPDX-License-Identifier: AGPL-3.0
-import { Dispatch, compose } from "redux";
-import { withDialog } from "~/store/dialog/with-dialog";
+import { Dispatch } from "redux";
import { dialogActions } from "~/store/dialog/dialog-actions";
-import { reduxForm, startSubmit, stopSubmit, initialize } from 'redux-form';
+import { startSubmit, stopSubmit, initialize } from 'redux-form';
import { ServiceRepository } from '~/services/services';
import { RootState } from '~/store/store';
import { getCommonResourceServiceError, CommonResourceServiceError } from "~/common/api/common-resource-service";
import { snackbarActions } from '~/store/snackbar/snackbar-actions';
-import { MoveToFormDialogData, MoveToFormDialog } from '../move-to-dialog/move-to-dialog';
-import { projectPanelActions } from '../../store/project-panel/project-panel-action';
+import { projectPanelActions } from '~/store/project-panel/project-panel-action';
+import { MoveToFormDialogData } from '../move-to-dialog/move-to-dialog';
export const MOVE_COLLECTION_DIALOG = 'moveCollectionDialog';
@@ -40,13 +39,3 @@ export const moveCollection = (resource: MoveToFormDialogData) =>
}
}
};
-
-export const MoveCollectionDialog = compose(
- withDialog(MOVE_COLLECTION_DIALOG),
- reduxForm<MoveToFormDialogData>({
- form: MOVE_COLLECTION_DIALOG,
- onSubmit: (data, dispatch) => {
- dispatch(moveCollection(data));
- }
- })
-)(MoveToFormDialog);
diff --git a/src/views-components/move-project-dialog/move-project-dialog.ts b/src/store/move-project-dialog/move-project-dialog.ts
similarity index 81%
copy from src/views-components/move-project-dialog/move-project-dialog.ts
copy to src/store/move-project-dialog/move-project-dialog.ts
index 4fce540..797707f 100644
--- a/src/views-components/move-project-dialog/move-project-dialog.ts
+++ b/src/store/move-project-dialog/move-project-dialog.ts
@@ -2,17 +2,16 @@
//
// SPDX-License-Identifier: AGPL-3.0
-import { Dispatch, compose } from "redux";
-import { withDialog } from "~/store/dialog/with-dialog";
+import { Dispatch } from "redux";
import { dialogActions } from "~/store/dialog/dialog-actions";
-import { reduxForm, startSubmit, stopSubmit, initialize } from 'redux-form';
+import { startSubmit, stopSubmit, initialize } from 'redux-form';
import { ServiceRepository } from '~/services/services';
import { RootState } from '~/store/store';
import { getCommonResourceServiceError, CommonResourceServiceError } from "~/common/api/common-resource-service";
import { snackbarActions } from '~/store/snackbar/snackbar-actions';
-import { MoveToFormDialogData, MoveToFormDialog } from '../move-to-dialog/move-to-dialog';
import { projectPanelActions } from '~/store/project-panel/project-panel-action';
import { getProjectList } from '~/store/project/project-action';
+import { MoveToFormDialogData } from '../move-to-dialog/move-to-dialog';
export const MOVE_PROJECT_DIALOG = 'moveProjectDialog';
@@ -45,14 +44,3 @@ export const moveProject = (resource: MoveToFormDialogData) =>
}
}
};
-
-export const MoveProjectDialog = compose(
- withDialog(MOVE_PROJECT_DIALOG),
- reduxForm<MoveToFormDialogData>({
- form: MOVE_PROJECT_DIALOG,
- onSubmit: (data, dispatch) => {
- dispatch(moveProject(data));
- }
- })
-)(MoveToFormDialog);
-
diff --git a/src/store/move-to-dialog/move-to-dialog.ts b/src/store/move-to-dialog/move-to-dialog.ts
new file mode 100644
index 0000000..6261a79
--- /dev/null
+++ b/src/store/move-to-dialog/move-to-dialog.ts
@@ -0,0 +1,9 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+export interface MoveToFormDialogData {
+ name: string;
+ uuid: string;
+ ownerUuid: string;
+}
\ No newline at end of file
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 d807fea..7b1c4d5 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
@@ -8,7 +8,7 @@ import { toggleFavorite } from "~/store/favorites/favorites-actions";
import { RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon, ProvenanceGraphIcon, AdvancedIcon, RemoveIcon } from "~/components/icon/icon";
import { openUpdater } from "~/store/collections/updater/collection-updater-action";
import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action";
-import { openMoveCollectionDialog } from '../../move-collection-dialog/move-collection-dialog';
+import { openMoveCollectionDialog } from '~/store/move-collection-dialog/move-collection-dialog';
export const collectionActionSet: ContextMenuActionSet = [[
{
diff --git a/src/views-components/context-menu/action-sets/collection-resource-action-set.ts b/src/views-components/context-menu/action-sets/collection-resource-action-set.ts
index b41176f..3866cc0 100644
--- a/src/views-components/context-menu/action-sets/collection-resource-action-set.ts
+++ b/src/views-components/context-menu/action-sets/collection-resource-action-set.ts
@@ -8,7 +8,7 @@ import { toggleFavorite } from "~/store/favorites/favorites-actions";
import { RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon, RemoveIcon } from "~/components/icon/icon";
import { openUpdater } from "~/store/collections/updater/collection-updater-action";
import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action";
-import { openMoveCollectionDialog } from '../../move-collection-dialog/move-collection-dialog';
+import { openMoveCollectionDialog } from '~/store/move-collection-dialog/move-collection-dialog';
export const collectionResourceActionSet: ContextMenuActionSet = [[
{
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 b8121c3..2f1f05e 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
@@ -11,7 +11,7 @@ import { ToggleFavoriteAction } from "../actions/favorite-action";
import { toggleFavorite } from "~/store/favorites/favorites-actions";
import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action";
import { PROJECT_CREATE_DIALOG } from "../../dialog-create/dialog-project-create";
-import { openMoveProjectDialog } from '../../move-project-dialog/move-project-dialog';
+import { openMoveProjectDialog } from '~/store/move-project-dialog/move-project-dialog';
export const projectActionSet: ContextMenuActionSet = [[
{
diff --git a/src/views-components/move-collection-dialog/move-collection-dialog.ts b/src/views-components/move-collection-dialog/move-collection-dialog.ts
index 7409151..783f0c7 100644
--- a/src/views-components/move-collection-dialog/move-collection-dialog.ts
+++ b/src/views-components/move-collection-dialog/move-collection-dialog.ts
@@ -2,44 +2,12 @@
//
// SPDX-License-Identifier: AGPL-3.0
-import { Dispatch, compose } from "redux";
+import { compose } from "redux";
import { withDialog } from "~/store/dialog/with-dialog";
-import { dialogActions } from "~/store/dialog/dialog-actions";
-import { reduxForm, startSubmit, stopSubmit, initialize } from 'redux-form';
-import { ServiceRepository } from '~/services/services';
-import { RootState } from '~/store/store';
-import { getCommonResourceServiceError, CommonResourceServiceError } from "~/common/api/common-resource-service";
-import { snackbarActions } from '~/store/snackbar/snackbar-actions';
-import { MoveToFormDialogData, MoveToFormDialog } from '../move-to-dialog/move-to-dialog';
-import { projectPanelActions } from '../../store/project-panel/project-panel-action';
-
-export const MOVE_COLLECTION_DIALOG = 'moveCollectionDialog';
-
-export const openMoveCollectionDialog = (resource: { name: string, uuid: string }) =>
- (dispatch: Dispatch) => {
- dispatch(initialize(MOVE_COLLECTION_DIALOG, resource));
- dispatch(dialogActions.OPEN_DIALOG({ id: MOVE_COLLECTION_DIALOG, data: {} }));
- };
-
-export const moveCollection = (resource: MoveToFormDialogData) =>
- async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- dispatch(startSubmit(MOVE_COLLECTION_DIALOG));
- try {
- const collection = await services.collectionService.get(resource.uuid);
- await services.collectionService.update(resource.uuid, { ...collection, ownerUuid: resource.ownerUuid });
- dispatch(projectPanelActions.REQUEST_ITEMS());
- dispatch(dialogActions.CLOSE_DIALOG({ id: MOVE_COLLECTION_DIALOG }));
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been moved', hideDuration: 2000 }));
- } catch (e) {
- const error = getCommonResourceServiceError(e);
- if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
- dispatch(stopSubmit(MOVE_COLLECTION_DIALOG, { ownerUuid: 'A collection with the same name already exists in the target project.' }));
- } else {
- dispatch(dialogActions.CLOSE_DIALOG({ id: MOVE_COLLECTION_DIALOG }));
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not move the collection.', hideDuration: 2000 }));
- }
- }
- };
+import { reduxForm } from 'redux-form';
+import { MoveToFormDialog } from '../move-to-dialog/move-to-dialog';
+import { MOVE_COLLECTION_DIALOG, moveCollection } from '~/store/move-collection-dialog/move-collection-dialog';
+import { MoveToFormDialogData } from '~/store/move-to-dialog/move-to-dialog';
export const MoveCollectionDialog = compose(
withDialog(MOVE_COLLECTION_DIALOG),
diff --git a/src/views-components/move-project-dialog/move-project-dialog.ts b/src/views-components/move-project-dialog/move-project-dialog.ts
index 4fce540..9ec6748 100644
--- a/src/views-components/move-project-dialog/move-project-dialog.ts
+++ b/src/views-components/move-project-dialog/move-project-dialog.ts
@@ -2,49 +2,13 @@
//
// SPDX-License-Identifier: AGPL-3.0
-import { Dispatch, compose } from "redux";
+import { compose } from "redux";
import { withDialog } from "~/store/dialog/with-dialog";
-import { dialogActions } from "~/store/dialog/dialog-actions";
-import { reduxForm, startSubmit, stopSubmit, initialize } from 'redux-form';
-import { ServiceRepository } from '~/services/services';
-import { RootState } from '~/store/store';
-import { getCommonResourceServiceError, CommonResourceServiceError } from "~/common/api/common-resource-service";
-import { snackbarActions } from '~/store/snackbar/snackbar-actions';
-import { MoveToFormDialogData, MoveToFormDialog } from '../move-to-dialog/move-to-dialog';
-import { projectPanelActions } from '~/store/project-panel/project-panel-action';
-import { getProjectList } from '~/store/project/project-action';
-
-export const MOVE_PROJECT_DIALOG = 'moveProjectDialog';
-
-export const openMoveProjectDialog = (resource: { name: string, uuid: string }) =>
- (dispatch: Dispatch) => {
- dispatch(initialize(MOVE_PROJECT_DIALOG, resource));
- dispatch(dialogActions.OPEN_DIALOG({ id: MOVE_PROJECT_DIALOG, data: {} }));
- };
-
-export const moveProject = (resource: MoveToFormDialogData) =>
- async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- dispatch(startSubmit(MOVE_PROJECT_DIALOG));
- try {
- const project = await services.projectService.get(resource.uuid);
- await services.projectService.update(resource.uuid, { ...project, ownerUuid: resource.ownerUuid });
- dispatch(projectPanelActions.REQUEST_ITEMS());
- dispatch<any>(getProjectList(project.ownerUuid));
- dispatch<any>(getProjectList(resource.ownerUuid));
- dispatch(dialogActions.CLOSE_DIALOG({ id: MOVE_PROJECT_DIALOG }));
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Project has been moved', hideDuration: 2000 }));
- } catch (e) {
- const error = getCommonResourceServiceError(e);
- if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
- dispatch(stopSubmit(MOVE_PROJECT_DIALOG, { ownerUuid: 'A project with the same name already exists in the target project.' }));
- } else if (error === CommonResourceServiceError.OWNERSHIP_CYCLE) {
- dispatch(stopSubmit(MOVE_PROJECT_DIALOG, { ownerUuid: 'Cannot move a project into itself.' }));
- } else {
- dispatch(dialogActions.CLOSE_DIALOG({ id: MOVE_PROJECT_DIALOG }));
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not move the project.', hideDuration: 2000 }));
- }
- }
- };
+import { reduxForm } from 'redux-form';
+import { MOVE_PROJECT_DIALOG } from '~/store/move-project-dialog/move-project-dialog';
+import { moveProject } from '~/store/move-project-dialog/move-project-dialog';
+import { MoveToFormDialogData } from '~/store/move-to-dialog/move-to-dialog';
+import { MoveToFormDialog } from '../move-to-dialog/move-to-dialog';
export const MoveProjectDialog = compose(
withDialog(MOVE_PROJECT_DIALOG),
diff --git a/src/views-components/move-to-dialog/move-to-dialog.tsx b/src/views-components/move-to-dialog/move-to-dialog.tsx
index 9b5d06a..4c27722 100644
--- a/src/views-components/move-to-dialog/move-to-dialog.tsx
+++ b/src/views-components/move-to-dialog/move-to-dialog.tsx
@@ -8,15 +8,8 @@ import { WithDialogProps } from '~/store/dialog/with-dialog';
import { FormDialog } from '~/components/form-dialog/form-dialog';
import { ProjectTreePicker } from '~/views-components/project-tree-picker/project-tree-picker';
import { Typography } from "@material-ui/core";
-import { ResourceKind } from '~/models/resource';
-import { MOVE_TO_VALIDATION } from '../../validators/validators';
-
-export interface MoveToFormDialogData {
- name: string;
- uuid: string;
- ownerUuid: string;
- kind: ResourceKind;
-}
+import { MOVE_TO_VALIDATION } from '~/validators/validators';
+import { MoveToFormDialogData } from '~/store/move-to-dialog/move-to-dialog';
export const MoveToFormDialog = (props: WithDialogProps<string> & InjectedFormProps<MoveToFormDialogData>) =>
<FormDialog
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list