diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-02-09 12:23:57 +0100 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2022-02-09 13:23:12 +0100 |
commit | f87ce13afc25b4ea56b6d7e4a85eac4cee5591da (patch) | |
tree | 2745f24178289799ab4a617a1f7defe9a77229c9 /app/javascript/flavours/glitch/features/ui | |
parent | 2fd1db7c9d0fe8c1cca159b9b0818c72e7c318aa (diff) |
Refactor dropdown and action modal code slightly
Simplify it a bit and make it closer to upstream
Diffstat (limited to 'app/javascript/flavours/glitch/features/ui')
-rw-r--r-- | app/javascript/flavours/glitch/features/ui/components/actions_modal.js | 48 |
1 files changed, 16 insertions, 32 deletions
diff --git a/app/javascript/flavours/glitch/features/ui/components/actions_modal.js b/app/javascript/flavours/glitch/features/ui/components/actions_modal.js index 24169036c..4ae3a4766 100644 --- a/app/javascript/flavours/glitch/features/ui/components/actions_modal.js +++ b/app/javascript/flavours/glitch/features/ui/components/actions_modal.js @@ -8,13 +8,13 @@ import RelativeTimestamp from 'flavours/glitch/components/relative_timestamp'; import DisplayName from 'flavours/glitch/components/display_name'; import classNames from 'classnames'; import Icon from 'flavours/glitch/components/icon'; -import Link from 'flavours/glitch/components/link'; import Toggle from 'react-toggle'; export default class ActionsModal extends ImmutablePureComponent { static propTypes = { status: ImmutablePropTypes.map, + onClick: PropTypes.func, actions: PropTypes.arrayOf(PropTypes.shape({ active: PropTypes.bool, href: PropTypes.string, @@ -46,43 +46,27 @@ export default class ActionsModal extends ImmutablePureComponent { return ( <li key={name || i}> - <Link - className={classNames('link', { active })} - href={href} - onClick={on !== null && typeof on !== 'undefined' && onPassiveClick || onClick} - role={onClick ? 'button' : null} - > - {function () { - - // We render a `<Toggle>` if we were provided an `on` - // property, and otherwise show an `<Icon>` if available. - switch (true) { - case on !== null && typeof on !== 'undefined': - return ( - <Toggle - checked={on} - onChange={onPassiveClick || onClick} - /> - ); - case !!icon: - return ( - <Icon - className='icon' - fixedWidth - id={icon} - /> - ); - default: - return null; - } - }()} + <a href={href} target='_blank' rel='noopener noreferrer' onClick={on !== null && typeof on !== 'undefined' && onPassiveClick || onClick || this.props.onClick} data-index={i} className={classNames('link', { active })}> + {on !== null && typeof on !== 'undefined' && ( + <Toggle + checked={on} + onChange={onPassiveClick || onClick} + /> + )} + {icon && ( + <Icon + className='icon' + fixedWidth + id={icon} + /> + )} {meta ? ( <div> <strong>{text}</strong> {meta} </div> ) : <div>{text}</div>} - </Link> + </a> </li> ); } |