From f8a1c22adc9cee58799359deefc378bc2e39cf6c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 1 Apr 2020 18:10:48 -0500 Subject: [PATCH] Refactor tabs_bar.js --- .../features/ui/components/tabs_bar.js | 117 ++++++++++-------- 1 file changed, 64 insertions(+), 53 deletions(-) diff --git a/app/gabsocial/features/ui/components/tabs_bar.js b/app/gabsocial/features/ui/components/tabs_bar.js index ff7a747b8..893e6488d 100644 --- a/app/gabsocial/features/ui/components/tabs_bar.js +++ b/app/gabsocial/features/ui/components/tabs_bar.js @@ -13,43 +13,6 @@ import ActionBar from 'gabsocial/features/compose/components/action_bar'; import { openModal } from '../../../actions/modal'; import { openSidebar } from '../../../actions/sidebar'; -export const privateLinks = ({ logo }) => { return [ - - - , - - - - , - - - - - , - // - // - // - // , - - - - , -]} - -export const publicLinks = ({ logo }) => { return [ - - - , - - - - , - - - - , -]} - @withRouter class TabsBar extends React.PureComponent { @@ -95,6 +58,68 @@ class TabsBar extends React.PureComponent { this.window.removeEventListener('scroll', this.handleScroll); } + getPrivateLinks() { + const { intl: { formatMessage }, logo } = this.props; + let links = []; + if (logo) { + links.push( + + + ) + } + links.push( + + + + , + + + + + , + // + // + // + // , + + + + , + ); + return links.map((link) => + React.cloneElement(link, { + key: link.props.to, + 'aria-label': formatMessage({ + id: link.props['data-preview-title-id'] + }) + })); + } + + getPublicLinks() { + const { intl: { formatMessage }, logo } = this.props; + let links = []; + if (logo) { + links.push( + + + + ); + } + links.push( + + + + , + + + + + ); + return links.map((link, i) => React.cloneElement(link, { + key: i, + })) + } + handleScroll = throttle(() => { if (this.window) { const { pageYOffset, innerWidth } = this.window; @@ -117,9 +142,8 @@ class TabsBar extends React.PureComponent { }); render () { - const { intl: { formatMessage }, account, onOpenCompose, onOpenSidebar, logo } = this.props; + const { intl: { formatMessage }, account, onOpenCompose, onOpenSidebar } = this.props; const { collapsed } = this.state; - const links = account ? privateLinks(this.props) : publicLinks(this.props); const classes = classNames('tabs-bar', { 'tabs-bar--collapsed': collapsed, @@ -129,20 +153,7 @@ class TabsBar extends React.PureComponent {