merge master
authorPawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>
Fri, 3 Aug 2018 07:22:05 +0000 (09:22 +0200)
committerPawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>
Fri, 3 Aug 2018 07:22:05 +0000 (09:22 +0200)
Feature #13905

Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>

1  2 
src/store/navigation/navigation-action.ts
src/views-components/create-project-dialog/create-project-dialog.tsx
src/views-components/dialog-create/dialog-collection-create.tsx
src/views-components/dialog-update/dialog-collection-update.tsx
src/views/workbench/workbench.tsx
yarn.lock

index 68d7fc5239528cb3bbcbb1a0464172fcfd713757,ffb0f7acf6f5fc3e69b1c0295936f6ee8c4eacc5..1ab212f936aec8ee5f593b6741c736ccaf3e1089
@@@ -6,14 -6,12 +6,14 @@@ import { Dispatch } from "redux"
  import { projectActions, getProjectList } from "../project/project-action";
  import { push } from "react-router-redux";
  import { TreeItemStatus } from "../../components/tree/tree";
 -import { findTreeItem } from "../project/project-reducer";
 +import { findTreeItem, getTreePath } from "../project/project-reducer";
- import { dataExplorerActions } from "../data-explorer/data-explorer-action";
- import { PROJECT_PANEL_ID } from "../../views/project-panel/project-panel";
  import { RootState } from "../store";
  import { Resource, ResourceKind } from "../../models/resource";
+ import { projectPanelActions } from "../project-panel/project-panel-action";
  import { getCollectionUrl } from "../../models/collection";
 -import { getProjectUrl } from "../../models/project";
 +import { getProjectUrl, ProjectResource } from "../../models/project";
- import { projectService } from "../../services/services";
++import { ServiceRepository } from "../../services/services";
++import { ProjectService } from "../../services/project-service/project-service";
  
  export const getResourceUrl = <T extends Resource>(resource: T): string => {
      switch (resource.kind) {
@@@ -69,14 -59,3 +69,14 @@@ export const setProjectItem = (itemId: 
          }
      };
  
-     export const loadProjectAncestors = async (uuid: string): Promise<Array<ProjectResource>> => {
 +    const USER_UUID_REGEX = /.*tpzed.*/;
 +
-             const currentProject = await projectService.get(uuid);
++    export const loadProjectAncestors = async (uuid: string, services?: any): Promise<Array<ProjectResource>> => {
 +        if (USER_UUID_REGEX.test(uuid)) {
 +            return [];
 +        } else {
++            const currentProject = await services.projectService.get(uuid);
 +            const ancestors = await loadProjectAncestors(currentProject.ownerUuid);
 +            return [...ancestors, currentProject];
 +        }
 +    };
index cbb80fff1281a6806424aa8469fdad1b396a2018,1a521890d71be9ac684cb57335dee9d935e29526..aa0dc7bc89a49ea3584806556d268435a05e737d
@@@ -22,10 -21,10 +21,10 @@@ const addProject = (data: { name: strin
          const { ownerUuid } = getState().projects.creator;
          return dispatch<any>(createProject(data)).then(() => {
              dispatch(snackbarActions.OPEN_SNACKBAR({
 -                message: "Created a new project",
 +                message: "Project has been successfully created.",
                  hideDuration: 2000
              }));
-             dispatch(dataExplorerActions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID }));
+             dispatch(projectPanelActions.REQUEST_ITEMS());
              dispatch<any>(getProjectList(ownerUuid));
          });
      };
index 08f47028c1c19a85df20898c88d2d2f221f647df,3e3b74aa92747d9adf5053d543097a1110ee3ace..874ce138c76e456ff798e3d63edb88a4d3aa79e2
@@@ -12,9 -12,9 +12,9 @@@ import DialogContent from '@material-ui
  import DialogTitle from '@material-ui/core/DialogTitle';
  import { Button, StyleRulesCallback, WithStyles, withStyles, CircularProgress } from '@material-ui/core';
  
 -import { COLLECTION_NAME_VALIDATION, COLLECTION_DESCRIPTION_VALIDATION } from '../../validators/create-project/create-project-validator';
 +import { COLLECTION_NAME_VALIDATION, COLLECTION_DESCRIPTION_VALIDATION } from '../../validators/create-collection/create-collection-validator';
  
- type CssRules = "button" | "lastButton" | "formContainer" | "textField" | "dialog" | "dialogTitle" | "createProgress" | "dialogActions";
+ type CssRules = "button" | "lastButton" | "formContainer" | "textField" | "createProgress" | "dialogActions";
  
  const styles: StyleRulesCallback<CssRules> = theme => ({
      button: {
index 0000000000000000000000000000000000000000,80a82b27fd97bb27a65dd954603e1cb7c2a965d8..08eee418bdc1f2bf016c0e575e0d751b3d96137c
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,131 +1,131 @@@
 -import { COLLECTION_NAME_VALIDATION, COLLECTION_DESCRIPTION_VALIDATION } from '../../validators/create-project/create-project-validator';
+ // Copyright (C) The Arvados Authors. All rights reserved.
+ //
+ // SPDX-License-Identifier: AGPL-3.0
+ import * as React from 'react';
+ import { reduxForm, Field } from 'redux-form';
+ import { compose } from 'redux';
+ import { ArvadosTheme } from '../../common/custom-theme';
+ import { Dialog, DialogActions, DialogContent, DialogTitle, TextField, StyleRulesCallback, withStyles, WithStyles, Button, CircularProgress } from '../../../node_modules/@material-ui/core';
++import { COLLECTION_NAME_VALIDATION, COLLECTION_DESCRIPTION_VALIDATION } from '../../validators/create-collection/create-collection-validator';
+ import { COLLECTION_FORM_NAME } from '../../store/collections/updator/collection-updator-action';
+ type CssRules = 'content' | 'actions' | 'textField' | 'buttonWrapper' | 'saveButton' | 'circularProgress';
+ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+     content: {
+         display: 'flex',
+         flexDirection: 'column'
+     },
+     actions: {
+         margin: 0,
+         padding: `${theme.spacing.unit}px ${theme.spacing.unit * 3 - theme.spacing.unit / 2}px 
+                 ${theme.spacing.unit * 3}px ${theme.spacing.unit * 3}px`
+     },
+     textField: {
+         marginBottom: theme.spacing.unit * 3
+     },
+     buttonWrapper: {
+         position: 'relative'
+     },
+     saveButton: {
+         boxShadow: 'none'
+     },
+     circularProgress: {
+         position: 'absolute',
+         top: 0,
+         bottom: 0,
+         left: 0,
+         right: 0,
+         margin: 'auto'
+     }
+ });
+ interface DialogCollectionDataProps {
+     open: boolean;
+     handleSubmit: any;
+     submitting: boolean;
+     invalid: boolean;
+     pristine: boolean;
+ }
+ interface DialogCollectionAction {
+     handleClose: () => void;
+     onSubmit: (data: { name: string, description: string }) => void;
+ }
+ type DialogCollectionProps = DialogCollectionDataProps & DialogCollectionAction & WithStyles<CssRules>;
+ interface TextFieldProps {
+     label: string;
+     floatinglabeltext: string;
+     className?: string;
+     input?: string;
+     meta?: any;
+ }
+ export const DialogCollectionUpdate = compose(
+     reduxForm({ form: COLLECTION_FORM_NAME }),
+     withStyles(styles))(
+         class DialogCollectionUpdate extends React.Component<DialogCollectionProps> {
+             render() {
+                 const { classes, open, handleClose, handleSubmit, onSubmit, submitting, invalid, pristine } = this.props;
+                 return (
+                     <Dialog open={open}
+                         onClose={handleClose}
+                         fullWidth={true}
+                         maxWidth='sm'
+                         disableBackdropClick={true}
+                         disableEscapeKeyDown={true}>
+                         <form onSubmit={handleSubmit((data: any) => onSubmit(data))}>
+                             <DialogTitle>Edit Collection</DialogTitle>
+                             <DialogContent className={classes.content}>
+                                 <Field name="name"
+                                     disabled={submitting}
+                                     component={this.renderTextField}
+                                     floatinglabeltext="Collection Name"
+                                     validate={COLLECTION_NAME_VALIDATION}
+                                     className={classes.textField}
+                                     label="Collection Name" />
+                                 <Field name="description"
+                                     disabled={submitting}
+                                     component={this.renderTextField}
+                                     floatinglabeltext="Description - optional"
+                                     validate={COLLECTION_DESCRIPTION_VALIDATION}
+                                     className={classes.textField}
+                                     label="Description - optional" />
+                             </DialogContent>
+                             <DialogActions className={classes.actions}>
+                                 <Button onClick={handleClose} color="primary"
+                                     disabled={submitting}>CANCEL</Button>
+                                 <div className={classes.buttonWrapper}>
+                                     <Button type="submit" className={classes.saveButton}
+                                         color="primary"
+                                         disabled={invalid || submitting || pristine}
+                                         variant="contained">
+                                         SAVE
+                                     </Button>
+                                     {submitting && <CircularProgress size={20} className={classes.circularProgress} />}
+                                 </div>
+                             </DialogActions>
+                         </form>
+                     </Dialog>
+                 );
+             }
+             renderTextField = ({ input, label, meta: { touched, error }, ...custom }: TextFieldProps) => (
+                 <TextField
+                     helperText={touched && error}
+                     label={label}
+                     className={this.props.classes.textField}
+                     error={touched && !!error}
+                     autoComplete='off'
+                     {...input}
+                     {...custom}
+                 />
+             )
+         }
+     );
index 1695201b4d2923e9892d0d208d7055500f8bffd7,dcce725b8cbbb213c08ed1f70ca902438d0d87a4..bd8c28e82c8c434a1f259c107d882e4a2af189c1
@@@ -89,9 -91,12 +91,13 @@@ interface WorkbenchDataProps 
      user?: User;
      currentToken?: string;
      sidePanelItems: SidePanelItem[];
 +    router?: any;
  }
  
+ interface WorkbenchServiceProps {
+     authService: AuthService;
+ }
  interface WorkbenchActionProps {
  }
  
diff --cc yarn.lock
index 1eed5d2fda1e5adb4dff764d193c58d4e664a708,1eed5d2fda1e5adb4dff764d193c58d4e664a708..968562f7d160ce3a154ec11cb965bafdecb26f0f
+++ b/yarn.lock
    version "10.5.2"
    resolved "https://registry.yarnpkg.com/@types/node/-/node-10.5.2.tgz#f19f05314d5421fe37e74153254201a7bf00a707"
  
++"@types/react-copy-to-clipboard@4.2.5":
++  version "4.2.5"
++  resolved "https://registry.yarnpkg.com/@types/react-copy-to-clipboard/-/react-copy-to-clipboard-4.2.5.tgz#bda288b4256288676019b75ca86f1714bbd206d4"
++  dependencies:
++    "@types/react" "*"
++
  "@types/react-dom@16.0.6":
    version "16.0.6"
    resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.0.6.tgz#f1a65a4e7be8ed5d123f8b3b9eacc913e35a1a3c"
@@@ -1817,6 -1817,6 +1823,12 @@@ copy-descriptor@^0.1.0
    version "0.1.1"
    resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"
  
++copy-to-clipboard@^3:
++  version "3.0.8"
++  resolved "https://registry.yarnpkg.com/copy-to-clipboard/-/copy-to-clipboard-3.0.8.tgz#f4e82f4a8830dce4666b7eb8ded0c9bcc313aba9"
++  dependencies:
++    toggle-selection "^1.0.3"
++
  core-js@^1.0.0:
    version "1.2.7"
    resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
@@@ -6098,6 -6098,6 +6110,13 @@@ rc@^1.0.1, rc@^1.1.6, rc@^1.2.7
      minimist "^1.2.0"
      strip-json-comments "~2.0.1"
  
++react-copy-to-clipboard@5.0.1:
++  version "5.0.1"
++  resolved "https://registry.yarnpkg.com/react-copy-to-clipboard/-/react-copy-to-clipboard-5.0.1.tgz#8eae107bb400be73132ed3b6a7b4fb156090208e"
++  dependencies:
++    copy-to-clipboard "^3"
++    prop-types "^15.5.8"
++
  react-dev-utils@^5.0.1:
    version "5.0.1"
    resolved "https://registry.yarnpkg.com/react-dev-utils/-/react-dev-utils-5.0.1.tgz#1f396e161fe44b595db1b186a40067289bf06613"
@@@ -7406,6 -7406,6 +7425,10 @@@ to-regex@^3.0.1, to-regex@^3.0.2
      regex-not "^1.0.2"
      safe-regex "^1.1.0"
  
++toggle-selection@^1.0.3:
++  version "1.0.6"
++  resolved "https://registry.yarnpkg.com/toggle-selection/-/toggle-selection-1.0.6.tgz#6e45b1263f2017fa0acc7d89d78b15b8bf77da32"
++
  toposort@^1.0.0:
    version "1.0.7"
    resolved "https://registry.yarnpkg.com/toposort/-/toposort-1.0.7.tgz#2e68442d9f64ec720b8cc89e6443ac6caa950029"