From f05ff87a5a04b0a6c45c2cba0b492c561de2e651 Mon Sep 17 00:00:00 2001 From: Janicki Artur Date: Wed, 26 Sep 2018 15:47:50 +0200 Subject: [PATCH] improve dialog and fix richTextEditorLink Feature #14120 Arvados-DCO-1.1-Signed-off-by: Janicki Artur --- .../rich-text-editor-link.tsx | 24 ++++++++++++------- .../rich-text-editor-dialog-actions.tsx | 2 +- .../details-panel/project-details.tsx | 11 +++++---- .../rich-text-editor-dialog.tsx | 9 +++---- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/components/rich-text-editor-link/rich-text-editor-link.tsx b/src/components/rich-text-editor-link/rich-text-editor-link.tsx index ca942d7832..2d6a5b4fda 100644 --- a/src/components/rich-text-editor-link/rich-text-editor-link.tsx +++ b/src/components/rich-text-editor-link/rich-text-editor-link.tsx @@ -3,7 +3,8 @@ // SPDX-License-Identifier: AGPL-3.0 import * as React from 'react'; -import { DispatchProp } from 'react-redux'; +import { Dispatch } from 'redux'; +import { connect } from 'react-redux'; import { withStyles, StyleRulesCallback, WithStyles, Typography } from '@material-ui/core'; import { ArvadosTheme } from '~/common/custom-theme'; import { openRichTextEditorDialog } from '~/store/rich-text-editor-dialog/rich-text-editor-dialog-actions'; @@ -23,13 +24,20 @@ interface RichTextEditorLinkData { content: string; } -type RichTextEditorLinkProps = RichTextEditorLinkData & WithStyles; +interface RichTextEditorLinkActions { + onClick: (title: string, content: string) => void; +} + +type RichTextEditorLinkProps = RichTextEditorLinkData & RichTextEditorLinkActions & WithStyles; + +const mapDispatchToProps = (dispatch: Dispatch) => ({ + onClick: (title: string, content: string) => dispatch(openRichTextEditorDialog(title, content)) +}); -export const RichTextEditorLink = withStyles(styles)( - ({ classes, title, content, label }: RichTextEditorLinkProps) => - dispatch(openRichTextEditorDialog(title, content))} - > +export const RichTextEditorLink = connect(undefined, mapDispatchToProps)( + withStyles(styles)(({ classes, title, content, label, onClick }: RichTextEditorLinkProps) => + onClick(title, content) }> {label} -); \ No newline at end of file + )); \ No newline at end of file diff --git a/src/store/rich-text-editor-dialog/rich-text-editor-dialog-actions.tsx b/src/store/rich-text-editor-dialog/rich-text-editor-dialog-actions.tsx index 39f3d840a9..d8bb6fd1c2 100644 --- a/src/store/rich-text-editor-dialog/rich-text-editor-dialog-actions.tsx +++ b/src/store/rich-text-editor-dialog/rich-text-editor-dialog-actions.tsx @@ -7,6 +7,6 @@ import { dialogActions } from "~/store/dialog/dialog-actions"; export const RICH_TEXT_EDITOR_DIALOG_NAME = 'richTextEditorDialogName'; export const openRichTextEditorDialog = (title: string, text: string) => - (dispatch: Dispatch) => { + async (dispatch: Dispatch) => { dispatch(dialogActions.OPEN_DIALOG({ id: RICH_TEXT_EDITOR_DIALOG_NAME, data: { title, text } })); }; \ No newline at end of file diff --git a/src/views-components/details-panel/project-details.tsx b/src/views-components/details-panel/project-details.tsx index 0e8835affd..331952f259 100644 --- a/src/views-components/details-panel/project-details.tsx +++ b/src/views-components/details-panel/project-details.tsx @@ -29,10 +29,13 @@ export class ProjectDetails extends DetailsData { {/* Missing attr */} - + {this.item.description ? + + : '---' + } ; } diff --git a/src/views-components/rich-text-editor-dialog/rich-text-editor-dialog.tsx b/src/views-components/rich-text-editor-dialog/rich-text-editor-dialog.tsx index 4ac572f767..a997355410 100644 --- a/src/views-components/rich-text-editor-dialog/rich-text-editor-dialog.tsx +++ b/src/views-components/rich-text-editor-dialog/rich-text-editor-dialog.tsx @@ -22,12 +22,9 @@ export const RichTextEditorDialog = withDialog(RICH_TEXT_EDITOR_DIALOG_NAME)( maxWidth='sm'> {props.data.title} - - { return; }} /> - +