@@ -3,7 +3,7 @@ import { observer } from 'mobx-react';
33import withStyles , { WithStylesProps } from 'react-jss' ;
44import { defineMessages , injectIntl , WrappedComponentProps } from 'react-intl' ;
55import ReactTooltip from 'react-tooltip' ;
6- import { mdiPlusBox , mdiCog } from '@mdi/js' ;
6+ import { mdiPlusBox , mdiCog , mdiMenuUp , mdiMenuDown } from '@mdi/js' ;
77import { noop } from 'lodash' ;
88import { H1 } from '../../../components/ui/headline' ;
99import Icon from '../../../components/ui/icon' ;
@@ -63,7 +63,7 @@ const styles = theme => ({
6363 } ,
6464 workspaces : {
6565 height : 'auto' ,
66- overflowY : 'auto ' ,
66+ overflowY : 'visible ' ,
6767 } ,
6868 addNewWorkspaceLabel : {
6969 height : 'auto' ,
@@ -103,6 +103,27 @@ class WorkspaceDrawer extends Component<IProps> {
103103 }
104104 }
105105
106+ handleClick ( e , workspaces , index ) {
107+ switch ( e ) {
108+ case 'goUp' :
109+ if ( index !== 0 ) {
110+ const toIndex = index - 1 ;
111+ const element = workspaces . splice ( index , 1 ) [ 0 ] ;
112+ workspaces . splice ( toIndex , 0 , element ) ;
113+ }
114+ break ;
115+ case 'goDown' :
116+ if ( index !== workspaces . length - 1 ) {
117+ const toIndex = index + 1 ;
118+ const element = workspaces . splice ( index , 1 ) [ 0 ] ;
119+ workspaces . splice ( toIndex , 0 , element ) ;
120+ }
121+ break ;
122+ default :
123+ break ;
124+ }
125+ }
126+
106127 render ( ) : ReactElement {
107128 const { classes, getServicesForWorkspace } = this . props ;
108129 const { intl } = this . props ;
@@ -144,23 +165,51 @@ class WorkspaceDrawer extends Component<IProps> {
144165 shortcutIndex = { 0 }
145166 />
146167 { workspaces . map ( ( workspace , index ) => (
147- < WorkspaceDrawerItem
148- key = { workspace . id }
149- name = { workspace . name }
150- isActive = { actualWorkspace === workspace }
151- onClick = { ( ) => {
152- if ( actualWorkspace === workspace ) {
153- return ;
154- }
155- workspaceActions . activate ( { workspace } ) ;
156- workspaceActions . toggleWorkspaceDrawer ( ) ;
157- } }
158- onContextMenuEditClick = { ( ) =>
159- workspaceActions . edit ( { workspace } )
160- }
161- services = { getServicesForWorkspace ( workspace ) }
162- shortcutIndex = { index + 1 }
163- />
168+ < div className = "wrapper-workspaces-drawer-item" >
169+ < div className = "wrapper-workspaces-drawer-item__workspaces" >
170+ < WorkspaceDrawerItem
171+ key = { workspace . id }
172+ name = { workspace . name }
173+ isActive = { actualWorkspace === workspace }
174+ onClick = { ( ) => {
175+ if ( actualWorkspace === workspace ) {
176+ return ;
177+ }
178+ workspaceActions . activate ( { workspace } ) ;
179+ workspaceActions . toggleWorkspaceDrawer ( ) ;
180+ } }
181+ onContextMenuEditClick = { ( ) =>
182+ workspaceActions . edit ( { workspace } )
183+ }
184+ services = { getServicesForWorkspace ( workspace ) }
185+ shortcutIndex = { index + 1 }
186+ />
187+ </ div >
188+ < div className = "wrapper-workspaces-drawer-item__buttons" >
189+ { index !== 0 && (
190+ < button
191+ type = "button"
192+ onClick = { ( ) => {
193+ this . handleClick ( 'goUp' , workspaces , index ) ;
194+ } }
195+ className = "button-up"
196+ >
197+ < Icon icon = { mdiMenuUp } size = { 1.5 } />
198+ </ button >
199+ ) }
200+ { index !== workspaces . length - 1 && (
201+ < button
202+ type = "button"
203+ onClick = { ( ) => {
204+ this . handleClick ( 'goDown' , workspaces , index ) ;
205+ } }
206+ className = "button-down"
207+ >
208+ < Icon icon = { mdiMenuDown } size = { 1.5 } />
209+ </ button >
210+ ) }
211+ </ div >
212+ </ div >
164213 ) ) }
165214 < div
166215 className = { classes . addNewWorkspaceLabel }
0 commit comments