Skip to content

Commit 875a92c

Browse files
committed
UX changes in main nav bar for browse as user;
Toggle new type added - HIDE_LABELS;
1 parent bb8ff85 commit 875a92c

File tree

5 files changed

+37
-37
lines changed

5 files changed

+37
-37
lines changed

src/components/BrowserMenu/BrowserMenu.scss

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
}
3636

3737
&.active {
38-
background: $blue;
38+
background: $orange;
3939
border-radius: 5px;
4040

4141
svg {
@@ -54,7 +54,7 @@
5454
}
5555

5656
&.active {
57-
background: $blue;
57+
background: $orange;
5858
border-radius: 5px;
5959
}
6060
}
@@ -108,24 +108,6 @@
108108
background: none;
109109
}
110110
}
111-
112-
&.active {
113-
background: $blue;
114-
115-
&:hover {
116-
background: white;
117-
color: $blue;
118-
}
119-
}
120-
121-
&.greenActive {
122-
background: $green;
123-
124-
&:hover {
125-
background: white;
126-
color: $blue;
127-
}
128-
}
129111
}
130112

131113
.separator {

src/components/Toggle/Toggle.react.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ export default class Toggle extends React.Component {
8080
left = this.props.value === this.props.optionLeft;
8181
colored = this.props.colored;
8282
break;
83+
case Toggle.Types.HIDE_LABELS:
84+
colored = true;
85+
left = !this.props.value;
86+
break;
8387
default:
8488
labelLeft = 'No';
8589
labelRight = 'Yes';
@@ -90,7 +94,10 @@ export default class Toggle extends React.Component {
9094

9195
let switchClasses = [styles.switch];
9296
if (colored) {
93-
switchClasses.push(styles.colored)
97+
switchClasses.push(styles.colored);
98+
}
99+
if (this.props.switchNoMargin) {
100+
switchClasses.push(styles.switchNoMargin);
94101
}
95102
let toggleClasses = [styles.toggle, unselectable, input];
96103
if (left) {
@@ -101,9 +108,9 @@ export default class Toggle extends React.Component {
101108
}
102109
return (
103110
<div className={toggleClasses.join(' ')} style={this.props.additionalStyles || {}}>
104-
<span className={styles.label} onClick={this.toLeft.bind(this)}>{labelLeft}</span>
111+
{labelLeft && <span className={styles.label} onClick={this.toLeft.bind(this)}>{labelLeft}</span>}
105112
<span className={switchClasses.join(' ')} onClick={this.toggle.bind(this)}></span>
106-
<span className={styles.label} onClick={this.toRight.bind(this)}>{labelRight}</span>
113+
{labelRight && <span className={styles.label} onClick={this.toRight.bind(this)}>{labelRight}</span>}
107114
</div>
108115
);
109116
}

src/components/Toggle/Toggle.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
transition: background-position 0.15s ease-out;
6161
}
6262

63+
.switchNoMargin {
64+
margin: 0;
65+
}
66+
6367
.left {
6468
.label {
6569
&:first-of-type {

src/dashboard/Data/Browser/BrowserToolbar.react.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import SecurityDialog from 'dashboard/Data/Browser/SecurityDialog.react';
1818
import ColumnsConfiguration from 'components/ColumnsConfiguration/ColumnsConfiguration.react';
1919
import SecureFieldsDialog from 'dashboard/Data/Browser/SecureFieldsDialog.react';
2020
import LoginDialog from 'dashboard/Data/Browser/LoginDialog.react';
21+
import Toggle from 'components/Toggle/Toggle.react';
2122

2223
let BrowserToolbar = ({
2324
className,
@@ -224,6 +225,23 @@ let BrowserToolbar = ({
224225
className={classNameForEditors}
225226
blacklistedFilters={onAddRow ? [] : ['unique']}
226227
/>
228+
<div className={styles.toolbarSeparator} />
229+
<LoginDialog
230+
ref={loginDialogRef}
231+
currentUser={currentUser}
232+
login={login}
233+
logout={logout}
234+
/>
235+
<BrowserMenu
236+
setCurrent={setCurrent}
237+
title={currentUser ? "Browsing" : "Browse"}
238+
icon="users-solid"
239+
active={!!currentUser}
240+
>
241+
<MenuItem text={currentUser ? 'Switch User' : 'As User'} onClick={showLogin} />
242+
{currentUser ? <MenuItem text={<span>Use Master Key <Toggle type={Toggle.Types.HIDE_LABELS} value={useMasterKey} onChange={toggleMasterKeyUsage} switchNoMargin={true} additionalStyles={{ display: 'inline', lineHeight: 0, margin: 0, paddingLeft: 5 }} /></span>} onClick={toggleMasterKeyUsage} /> : <noscript />}
243+
{currentUser ? <MenuItem text={<span>Stop browsing (<b>{currentUser.get('username')}</b>)</span>} onClick={logout} /> : <noscript />}
244+
</BrowserMenu>
227245
{onAddRow && <div className={styles.toolbarSeparator} />}
228246
{perms && enableSecurityDialog ? (
229247
<SecurityDialog
@@ -253,26 +271,15 @@ let BrowserToolbar = ({
253271
icon='locked-solid'
254272
onEditPermissions={onEditPermissions}
255273
/>
256-
<LoginDialog
257-
ref={loginDialogRef}
258-
currentUser={currentUser}
259-
login={login}
260-
logout={logout}
261-
/>
262274
{enableSecurityDialog ? (
263275
<BrowserMenu
264276
setCurrent={setCurrent}
265277
title="Security"
266278
icon="locked-solid"
267279
disabled={!!relation || !!isUnique}
268-
active={!!currentUser}
269280
>
270281
<MenuItem text={'Class Level Permissions'} onClick={showCLP} />
271282
<MenuItem text={'Protected Fields'} onClick={showProtected} />
272-
<Separator />
273-
<MenuItem text={currentUser ? 'Switch Parse.User' : 'Browse as Parse.User'} onClick={showLogin} active={!!currentUser} />
274-
{currentUser ? <MenuItem text={useMasterKey ? <span>Browsing with <b>Master Key</b></span> : <span>Browse with <s>Master Key</s></span>} onClick={toggleMasterKeyUsage} active={!!currentUser} greenActive={useMasterKey} /> : <noscript />}
275-
{currentUser ? <MenuItem text={<span>Logout (<b>{currentUser.get('username')}</b>)</span>} onClick={logout} active={!!currentUser} /> : <noscript />}
276283
</BrowserMenu>
277284
) : (
278285
<noscript />

src/dashboard/Data/Browser/LoginDialog.react.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,19 @@ export default class LoginDialog extends React.Component {
6161
open && (
6262
<Modal
6363
type={Modal.Types.INFO}
64-
title={currentUser ? 'Switch Parse.User' : 'Login as Parse.User'}
64+
title={currentUser ? 'Switch User' : 'Browse as User'}
6565
subtitle={
6666
<div style={{ paddingTop: '5px' }}>
6767
{currentUser && (
6868
<p>
69-
Logged in as <strong>{currentUser.get('username')}</strong>
69+
Browsing as <strong>{currentUser.get('username')}</strong>
7070
</p>
7171
)}
7272
</div>
7373
}
7474
onCancel={this.handleClose}
7575
onConfirm={this.login}
76-
confirmText="Login"
76+
confirmText="Browse"
7777
cancelText="Cancel"
7878
>
7979
<LoginRow

0 commit comments

Comments
 (0)