Skip to content

Commit 4e856a3

Browse files
committed
Replicate ferdium#497
1 parent 21582fd commit 4e856a3

2 files changed

Lines changed: 93 additions & 19 deletions

File tree

src/features/workspaces/components/WorkspaceDrawer.tsx

Lines changed: 68 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { observer } from 'mobx-react';
33
import withStyles, { WithStylesProps } from 'react-jss';
44
import { defineMessages, injectIntl, WrappedComponentProps } from 'react-intl';
55
import ReactTooltip from 'react-tooltip';
6-
import { mdiPlusBox, mdiCog } from '@mdi/js';
6+
import { mdiPlusBox, mdiCog, mdiMenuUp, mdiMenuDown } from '@mdi/js';
77
import { noop } from 'lodash';
88
import { H1 } from '../../../components/ui/headline';
99
import 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}

src/styles/vertical.scss

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,31 @@ $tabitem-bias: 30px;
9797
}
9898
}
9999

100+
.wrapper-workspaces-drawer-item {
101+
height: fit-content;
102+
display: flex;
103+
align-items: center;
104+
width: 107%;
105+
106+
&__workspaces {
107+
display: flex;
108+
flex-basis: 100%;
109+
110+
& > div {
111+
width: 100%;
112+
overflow: auto;
113+
}
114+
}
115+
&__buttons {
116+
display: flex;
117+
flex-direction: column;
118+
position: relative;
119+
top: 0;
120+
right: 9%;
121+
bottom: 0;
122+
}
123+
}
124+
100125
.theme__dark {
101126
.sidebar .sidebar__button--workspaces.is-active {
102127
background-color: #2d2f31;

0 commit comments

Comments
 (0)