From: Michal Klobukowski Date: Thu, 25 Oct 2018 20:26:03 +0000 (+0200) Subject: Create sharing dialog root X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/2a1d30b31a3d93d94ea0651dc7c8944d83a11e9e Create sharing dialog root Feature #14365 Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski --- diff --git a/src/components/dialog-actions/dialog-actions.tsx b/src/components/dialog-actions/dialog-actions.tsx new file mode 100644 index 0000000000..6987a1068c --- /dev/null +++ b/src/components/dialog-actions/dialog-actions.tsx @@ -0,0 +1,18 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import { DialogActions as MuiDialogActions } from '@material-ui/core/'; +import { StyleRulesCallback, withStyles } from '@material-ui/core'; + +const styles: StyleRulesCallback<'root'> = theme => { + const margin = theme.spacing.unit * 3; + return { + root: { + marginRight: margin, + marginBottom: margin, + marginLeft: margin, + }, + }; +}; +export const DialogActions = withStyles(styles)(MuiDialogActions); diff --git a/src/store/sharing-dialog/sharing-dialog-actions.ts b/src/store/sharing-dialog/sharing-dialog-actions.ts new file mode 100644 index 0000000000..efd5329512 --- /dev/null +++ b/src/store/sharing-dialog/sharing-dialog-actions.ts @@ -0,0 +1,16 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import { dialogActions } from "~/store/dialog/dialog-actions"; +import { withDialog } from "~/store/dialog/with-dialog"; + +export const SHARING_DIALOG_NAME = 'SHARING_DIALOG_NAME'; + +export const openSharingDialog = (resourceUuid: string) => + dialogActions.OPEN_DIALOG({ id: SHARING_DIALOG_NAME, data: resourceUuid }); + +export const closeSharingDialog = () => + dialogActions.CLOSE_DIALOG({ id: SHARING_DIALOG_NAME }); + +export const connectSharingDialog = withDialog(SHARING_DIALOG_NAME); 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 cff30fb166..80b5effeef 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 @@ -13,6 +13,7 @@ import { openCollectionCopyDialog } from "~/store/collections/collection-copy-ac import { ToggleTrashAction } from "~/views-components/context-menu/actions/trash-action"; import { toggleCollectionTrashed } from "~/store/trash/trash-actions"; import { detailsPanelActions } from '~/store/details-panel/details-panel-action'; +import { openSharingDialog } from '../../../store/sharing-dialog/sharing-dialog-actions'; export const collectionActionSet: ContextMenuActionSet = [[ { @@ -25,8 +26,8 @@ export const collectionActionSet: ContextMenuActionSet = [[ { icon: ShareIcon, name: "Share", - execute: (dispatch, resource) => { - // add code + execute: (dispatch, { uuid }) => { + dispatch(openSharingDialog(uuid)); } }, { diff --git a/src/views-components/sharing-dialog/sharing-dialog-component.tsx b/src/views-components/sharing-dialog/sharing-dialog-component.tsx new file mode 100644 index 0000000000..a303cbfb77 --- /dev/null +++ b/src/views-components/sharing-dialog/sharing-dialog-component.tsx @@ -0,0 +1,59 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import * as React from 'react'; +import { Dialog, DialogTitle, Button, Grid, DialogContent } from '@material-ui/core'; +import { DialogActions } from '~/components/dialog-actions/dialog-actions'; + + +export interface SharingDialogDataProps { + open: boolean; + saveEnabled: boolean; + children: React.ReactNode; +} +export interface SharingDialogActionProps { + onClose: () => void; + onSave: () => void; + onAdvanced: () => void; +} +export default (props: SharingDialogDataProps & SharingDialogActionProps) => { + const { children, open, saveEnabled, onAdvanced, onClose, onSave } = props; + return + + Sharing settings + + + {children} + + + + + + + + + + + + + + + + ; +}; diff --git a/src/views-components/sharing-dialog/sharing-dialog.tsx b/src/views-components/sharing-dialog/sharing-dialog.tsx new file mode 100644 index 0000000000..e83885ade1 --- /dev/null +++ b/src/views-components/sharing-dialog/sharing-dialog.tsx @@ -0,0 +1,30 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import { compose, Dispatch } from 'redux'; +import { connect } from 'react-redux'; + +import { connectSharingDialog } from '~/store/sharing-dialog/sharing-dialog-actions'; +import { WithDialogProps } from '~/store/dialog/with-dialog'; +import { RootState } from '~/store/store'; + +import SharingDialogComponent, { SharingDialogDataProps, SharingDialogActionProps } from './sharing-dialog-component'; + +const mapStateToProps = (_: RootState, props: WithDialogProps): SharingDialogDataProps => ({ + ...props, + saveEnabled: false, + children: null, +}); + +const mapDispatchToProps = (_: Dispatch, props: WithDialogProps): SharingDialogActionProps => ({ + ...props, + onClose: props.closeDialog, + onSave: () => { console.log('save'); }, + onAdvanced: () => { console.log('advanced'); }, +}); + +export const SharingDialog = compose( + connectSharingDialog, + connect(mapStateToProps, mapDispatchToProps) +)(SharingDialogComponent); diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx index 788c96ae6b..2e8bc19215 100644 --- a/src/views/workbench/workbench.tsx +++ b/src/views/workbench/workbench.tsx @@ -48,6 +48,7 @@ import { FavoritesTreePicker } from '../../views-components/projects-tree-picker import { ProjectsTreePicker } from '~/views-components/projects-tree-picker/projects-tree-picker'; import { Chips } from '~/components/chips/chips'; import { ChipsInput } from '../../components/chips-input/chips-input'; +import { SharingDialog } from '~/views-components/sharing-dialog/sharing-dialog'; type CssRules = 'root' | 'container' | 'splitter' | 'asidePanel' | 'contentWrapper' | 'content'; @@ -130,6 +131,7 @@ export const WorkbenchPanel = +