diff options
Diffstat (limited to 'src/components/layout/Sidebar.js')
-rw-r--r-- | src/components/layout/Sidebar.js | 86 |
1 files changed, 51 insertions, 35 deletions
diff --git a/src/components/layout/Sidebar.js b/src/components/layout/Sidebar.js index 36c1f2e39..1bf2554b5 100644 --- a/src/components/layout/Sidebar.js +++ b/src/components/layout/Sidebar.js | |||
@@ -3,11 +3,11 @@ import PropTypes from 'prop-types'; | |||
3 | import ReactTooltip from 'react-tooltip'; | 3 | import ReactTooltip from 'react-tooltip'; |
4 | import { defineMessages, intlShape } from 'react-intl'; | 4 | import { defineMessages, intlShape } from 'react-intl'; |
5 | import { observer } from 'mobx-react'; | 5 | import { observer } from 'mobx-react'; |
6 | import { Link } from 'react-router'; | ||
6 | 7 | ||
7 | import Tabbar from '../services/tabs/Tabbar'; | 8 | import Tabbar from '../services/tabs/Tabbar'; |
8 | import { ctrlKey } from '../../environment'; | 9 | import { ctrlKey } from '../../environment'; |
9 | import { GA_CATEGORY_WORKSPACES, workspaceStore } from '../../features/workspaces'; | 10 | import { workspaceStore } from '../../features/workspaces'; |
10 | import { gaEvent } from '../../lib/analytics'; | ||
11 | 11 | ||
12 | const messages = defineMessages({ | 12 | const messages = defineMessages({ |
13 | settings: { | 13 | settings: { |
@@ -82,6 +82,7 @@ export default @observer class Sidebar extends Component { | |||
82 | const workspaceToggleMessage = ( | 82 | const workspaceToggleMessage = ( |
83 | isWorkspaceDrawerOpen ? messages.closeWorkspaceDrawer : messages.openWorkspaceDrawer | 83 | isWorkspaceDrawerOpen ? messages.closeWorkspaceDrawer : messages.openWorkspaceDrawer |
84 | ); | 84 | ); |
85 | const isLoggedIn = Boolean(localStorage.getItem('authToken')); | ||
85 | 86 | ||
86 | return ( | 87 | return ( |
87 | <div className="sidebar"> | 88 | <div className="sidebar"> |
@@ -90,39 +91,54 @@ export default @observer class Sidebar extends Component { | |||
90 | enableToolTip={() => this.enableToolTip()} | 91 | enableToolTip={() => this.enableToolTip()} |
91 | disableToolTip={() => this.disableToolTip()} | 92 | disableToolTip={() => this.disableToolTip()} |
92 | /> | 93 | /> |
93 | {workspaceStore.isFeatureEnabled ? ( | 94 | { |
94 | <button | 95 | isLoggedIn ? ( |
95 | type="button" | 96 | <> |
96 | onClick={() => { | 97 | {workspaceStore.isFeatureEnabled ? ( |
97 | toggleWorkspaceDrawer(); | 98 | <button |
98 | this.updateToolTip(); | 99 | type="button" |
99 | gaEvent(GA_CATEGORY_WORKSPACES, 'toggleDrawer', 'sidebar'); | 100 | onClick={() => { |
100 | }} | 101 | toggleWorkspaceDrawer(); |
101 | className={`sidebar__button sidebar__button--workspaces ${isWorkspaceDrawerOpen ? 'is-active' : ''}`} | 102 | this.updateToolTip(); |
102 | data-tip={`${intl.formatMessage(workspaceToggleMessage)} (${ctrlKey}+D)`} | 103 | }} |
103 | > | 104 | className={`sidebar__button sidebar__button--workspaces ${isWorkspaceDrawerOpen ? 'is-active' : ''}`} |
104 | <i className="mdi mdi-view-grid" /> | 105 | data-tip={`${intl.formatMessage(workspaceToggleMessage)} (${ctrlKey}+D)`} |
105 | </button> | 106 | > |
106 | ) : null} | 107 | <i className="mdi mdi-view-grid" /> |
107 | <button | 108 | </button> |
108 | type="button" | 109 | ) : null} |
109 | onClick={() => { | 110 | |
110 | toggleMuteApp(); | 111 | <button |
111 | this.updateToolTip(); | 112 | type="button" |
112 | }} | 113 | onClick={() => { |
113 | className={`sidebar__button sidebar__button--audio ${isAppMuted ? 'is-muted' : ''}`} | 114 | toggleMuteApp(); |
114 | data-tip={`${intl.formatMessage(isAppMuted ? messages.unmute : messages.mute)} (${ctrlKey}+Shift+M)`} | 115 | this.updateToolTip(); |
115 | > | 116 | }} |
116 | <i className={`mdi mdi-bell${isAppMuted ? '-off' : ''}`} /> | 117 | className={`sidebar__button sidebar__button--audio ${isAppMuted ? 'is-muted' : ''}`} |
117 | </button> | 118 | data-tip={`${intl.formatMessage(isAppMuted ? messages.unmute : messages.mute)} (${ctrlKey}+Shift+M)`} |
118 | <button | 119 | > |
119 | type="button" | 120 | <i className={`mdi mdi-bell${isAppMuted ? '-off' : ''}`} /> |
120 | onClick={() => openSettings({ path: 'recipes' })} | 121 | </button> |
121 | className="sidebar__button sidebar__button--new-service" | 122 | <button |
122 | data-tip={`${intl.formatMessage(messages.addNewService)} (${ctrlKey}+N)`} | 123 | type="button" |
123 | > | 124 | onClick={() => openSettings({ path: 'recipes' })} |
124 | <i className="mdi mdi-plus-box" /> | 125 | className="sidebar__button sidebar__button--new-service" |
125 | </button> | 126 | data-tip={`${intl.formatMessage(messages.addNewService)} (${ctrlKey}+N)`} |
127 | > | ||
128 | <i className="mdi mdi-plus-box" /> | ||
129 | </button> | ||
130 | </> | ||
131 | ) : ( | ||
132 | <Link | ||
133 | to="/auth/welcome" | ||
134 | className="sidebar__button sidebar__button--new-service" | ||
135 | data-tip="Login" | ||
136 | > | ||
137 | <i className="mdi mdi-login-variant" /> | ||
138 | </Link> | ||
139 | ) | ||
140 | } | ||
141 | |||
126 | <button | 142 | <button |
127 | type="button" | 143 | type="button" |
128 | onClick={() => openSettings({ path: 'app' })} | 144 | onClick={() => openSettings({ path: 'app' })} |