Skip to content

Commit

Permalink
Fix: upload item action should show tooltip properly (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
wenboyu2 authored Jan 16, 2018
1 parent 4ba6132 commit 041f9ba
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions src/components/ContentUploader/ItemAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,32 @@ type Props = {

const ItemAction = ({ status, onClick, intl, rootElement }: Props) => {
let icon = <IconClose />;
let title = intl.formatMessage(messages.cancel);
let tooltip = '';
let tooltip = intl.formatMessage(messages.uploadsCancelButtonTooltip);

switch (status) {
case STATUS_COMPLETE:
icon = <IconCheck color={ICON_CHECK_COLOR} />;
title = intl.formatMessage(messages.remove);
tooltip = intl.formatMessage(messages.remove);
break;
case STATUS_ERROR:
icon = <IconRetry />;
title = intl.formatMessage(messages.retry);
tooltip = intl.formatMessage(messages.retry);
break;
case STATUS_IN_PROGRESS:
icon = <IconInProgress />;
title = intl.formatMessage(messages.remove);
tooltip = intl.formatMessage(messages.uploadsCancelButtonTooltip);
break;
case STATUS_PENDING:
default:
// empty
}

const button = (
<PlainButton type='button' onClick={onClick} title={title}>
{icon}
</PlainButton>
);

return (
<div className='bcu-item-action'>
{tooltip ? (
<Tooltip text={tooltip} position='top-left' bodyElement={rootElement}>
{button}
</Tooltip>
) : (
button
)}
<Tooltip text={tooltip} position='top-left' bodyElement={rootElement}>
<PlainButton type='button' onClick={onClick}>
{icon}
</PlainButton>
</Tooltip>
</div>
);
};
Expand Down

0 comments on commit 041f9ba

Please sign in to comment.