X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/9caac45e4e1c1bfe42876eaeb74b4c32df6904e3..63ffac0b419097265599243dd645c0447d1c24d6:/src/views-components/details-panel/project-details.tsx diff --git a/src/views-components/details-panel/project-details.tsx b/src/views-components/details-panel/project-details.tsx index 8f03cc5d..7db4df7b 100644 --- a/src/views-components/details-panel/project-details.tsx +++ b/src/views-components/details-panel/project-details.tsx @@ -4,6 +4,7 @@ import * as React from 'react'; import { connect } from 'react-redux'; +import { RootState } from '~/store/store'; import { openProjectPropertiesDialog } from '~/store/details-panel/details-panel-action'; import { ProjectIcon, RenameIcon } from '~/components/icon/icon'; import { ProjectResource } from '~/models/project'; @@ -15,6 +16,11 @@ import { DetailsAttribute } from "~/components/details-attribute/details-attribu import { RichTextEditorLink } from '~/components/rich-text-editor-link/rich-text-editor-link'; import { withStyles, StyleRulesCallback, Chip, WithStyles } from '@material-ui/core'; import { ArvadosTheme } from '~/common/custom-theme'; +import * as CopyToClipboard from 'react-copy-to-clipboard'; +import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions'; +import { getTagValueLabel, getTagKeyLabel, Vocabulary } from '~/models/vocabulary'; +import { getVocabulary } from "~/store/vocabulary/vocabulary-selectors"; +import { Dispatch } from 'redux'; export class ProjectDetails extends DetailsData { getIcon(className?: string) { @@ -42,19 +48,32 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ interface ProjectDetailsComponentDataProps { project: ProjectResource; + vocabulary: Vocabulary; } interface ProjectDetailsComponentActionProps { onClick: () => void; + onCopy: (message: string) => void; } -const mapDispatchToProps = ({ onClick: openProjectPropertiesDialog }); +const mapStateToProps = ({ properties }: RootState) => ({ + vocabulary: getVocabulary(properties), +}); + +const mapDispatchToProps = (dispatch: Dispatch) => ({ + onClick: () => dispatch(openProjectPropertiesDialog()), + onCopy: (message: string) => dispatch(snackbarActions.OPEN_SNACKBAR({ + message, + hideDuration: 2000, + kind: SnackbarKind.SUCCESS + })) +}); type ProjectDetailsComponentProps = ProjectDetailsComponentDataProps & ProjectDetailsComponentActionProps & WithStyles; -const ProjectDetailsComponent = connect(null, mapDispatchToProps)( +const ProjectDetailsComponent = connect(mapStateToProps, mapDispatchToProps)( withStyles(styles)( - ({ classes, project, onClick }: ProjectDetailsComponentProps) =>
+ ({ classes, project, onClick, vocabulary, onCopy }: ProjectDetailsComponentProps) =>
{/* Missing attr */} @@ -80,7 +99,12 @@ const ProjectDetailsComponent = connect(null, mapDispatchToProps)( { Object.keys(project.properties).map(k => { - return ; + const label = `${getTagKeyLabel(k, vocabulary)}: ${getTagValueLabel(k, project.properties[k], vocabulary)}`; + return ( + onCopy("Copied")}> + + + ); }) }