// 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';
content: string;
}
-type RichTextEditorLinkProps = RichTextEditorLinkData & WithStyles<CssRules>;
+interface RichTextEditorLinkActions {
+ onClick: (title: string, content: string) => void;
+}
+
+type RichTextEditorLinkProps = RichTextEditorLinkData & RichTextEditorLinkActions & WithStyles<CssRules>;
+
+const mapDispatchToProps = (dispatch: Dispatch) => ({
+ onClick: (title: string, content: string) => dispatch<any>(openRichTextEditorDialog(title, content))
+});
-export const RichTextEditorLink = withStyles(styles)(
- ({ classes, title, content, label }: RichTextEditorLinkProps) =>
- <Typography component='span' className={classes.root}
- // onClick={() => dispatch<any>(openRichTextEditorDialog(title, content))}
- >
+export const RichTextEditorLink = connect(undefined, mapDispatchToProps)(
+ withStyles(styles)(({ classes, title, content, label, onClick }: RichTextEditorLinkProps) =>
+ <Typography component='span' className={classes.root}
+ onClick={() => onClick(title, content) }>
{label}
</Typography>
-);
\ No newline at end of file
+ ));
\ No newline at end of file
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
{/* Missing attr */}
<DetailsAttribute label='File size' value='1.4 GB' />
<DetailsAttribute label='Description'>
- <RichTextEditorLink
- title={`Description of ${this.item.name}`}
- content={this.item.description}
- label='Show full description' />
+ {this.item.description ?
+ <RichTextEditorLink
+ title={`Description of ${this.item.name}`}
+ content={this.item.description}
+ label='Show full description' />
+ : '---'
+ }
</DetailsAttribute>
</div>;
}