Skip to content

Commit 62e4a50

Browse files
refactor: consolidate connection switcher and Connections button
Merge the connection dropdown and the separate Connections button into a single unified control. The connection dropdown now includes a 'Manage connections...' action at the bottom (for users with MANAGE_CONNECTIONS permission), eliminating the redundant separate button that cluttered the sidebar. Changes: - Move 'Manage connections...' action inside the connection dropdown - Remove separate Connections button from sidebar bottom section - Add dropdownDivider and dropdownManage CSS styles - Allow dropdown to open even with no connections (for admins to add) Sidebar bottom now has: View as → Connection dropdown → User profile (instead of: View as → Connection dropdown → Connections button → User) Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
1 parent 360a7bd commit 62e4a50

2 files changed

Lines changed: 81 additions & 46 deletions

File tree

‎src/components/layout/AppSidebar.jsx‎

Lines changed: 53 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export default function AppSidebar() {
144144
className={styles.bottomItem}
145145
onClick={() => setShowConnectionDropdown((v) => !v)}
146146
title={collapsed ? connectionLabel : undefined}
147-
disabled={isLoading || connections.length === 0}
147+
disabled={isLoading || (connections.length === 0 && !canManageConnections)}
148148
>
149149
<Database size={15} className={styles.navIcon} />
150150
<span className={`${styles.navLabel} ${collapsed ? styles.navLabelHidden : ''}`}>
@@ -156,62 +156,69 @@ export default function AppSidebar() {
156156
{!collapsed && <ChevronDown size={14} className={styles.chevronIcon} />}
157157
</button>
158158

159-
{showConnectionDropdown && !collapsed && connections.length > 0 && (
159+
{showConnectionDropdown && !collapsed && (
160160
<div className={styles.connectionDropdown}>
161-
<div className={styles.dropdownLabel}>Connections</div>
162-
{connections.map((conn) => (
163-
<div
164-
key={conn.id}
165-
className={`${styles.dropdownRow} ${conn.id === connectionId ? styles.dropdownItemActive : ''}`}
166-
>
161+
{connections.length > 0 && (
162+
<>
163+
<div className={styles.dropdownLabel}>Connections</div>
164+
{connections.map((conn) => (
165+
<div
166+
key={conn.id}
167+
className={`${styles.dropdownRow} ${conn.id === connectionId ? styles.dropdownItemActive : ''}`}
168+
>
169+
<button
170+
className={styles.dropdownItem}
171+
onClick={() => {
172+
changeConnection(conn.id)
173+
setShowConnectionDropdown(false)
174+
}}
175+
>
176+
<Database size={14} />
177+
<span className={styles.dropdownItemName}>
178+
{conn.connectionName}
179+
{getConnectionAccessLabel(conn) ? ` · ${getConnectionAccessLabel(conn)}` : ''}
180+
</span>
181+
<span className={styles.dbTypeBadge}>{getConnectionAccessBadge(conn) || conn.dbType}</span>
182+
{conn.id === connectionId && <Check size={13} className={styles.dropdownItemCheck} />}
183+
</button>
184+
<button
185+
className={`${styles.dropdownPin} ${conn.pinned ? styles.dropdownPinActive : ''}`}
186+
onClick={() =>
187+
setConnectionPin.mutate({ connectionId: conn.id, pinned: !conn.pinned })
188+
}
189+
disabled={setConnectionPin.isPending}
190+
aria-pressed={Boolean(conn.pinned)}
191+
title={
192+
conn.pinned
193+
? 'Pinned as your default — DeepSQL opens on this connection. Click to unpin.'
194+
: 'Pin as your default — DeepSQL will open on this connection every time you load it.'
195+
}
196+
>
197+
<Pin size={13} />
198+
</button>
199+
</div>
200+
))}
201+
</>
202+
)}
203+
{canManageConnections && (
204+
<>
205+
{connections.length > 0 && <div className={styles.dropdownDivider} />}
167206
<button
168-
className={styles.dropdownItem}
207+
className={styles.dropdownManage}
169208
onClick={() => {
170-
changeConnection(conn.id)
171209
setShowConnectionDropdown(false)
210+
setShowConnections(true)
172211
}}
173212
>
174-
<Database size={14} />
175-
<span className={styles.dropdownItemName}>
176-
{conn.connectionName}
177-
{getConnectionAccessLabel(conn) ? ` · ${getConnectionAccessLabel(conn)}` : ''}
178-
</span>
179-
<span className={styles.dbTypeBadge}>{getConnectionAccessBadge(conn) || conn.dbType}</span>
180-
{conn.id === connectionId && <Check size={13} className={styles.dropdownItemCheck} />}
213+
<Settings size={14} />
214+
<span>Manage connections…</span>
181215
</button>
182-
<button
183-
className={`${styles.dropdownPin} ${conn.pinned ? styles.dropdownPinActive : ''}`}
184-
onClick={() =>
185-
setConnectionPin.mutate({ connectionId: conn.id, pinned: !conn.pinned })
186-
}
187-
disabled={setConnectionPin.isPending}
188-
aria-pressed={Boolean(conn.pinned)}
189-
title={
190-
conn.pinned
191-
? 'Pinned as your default — DeepSQL opens on this connection. Click to unpin.'
192-
: 'Pin as your default — DeepSQL will open on this connection every time you load it.'
193-
}
194-
>
195-
<Pin size={13} />
196-
</button>
197-
</div>
198-
))}
216+
</>
217+
)}
199218
</div>
200219
)}
201220
</div>
202221

203-
{canManageConnections && (
204-
<button
205-
className={styles.bottomItem}
206-
onClick={() => setShowConnections(true)}
207-
title={collapsed ? 'Connections' : undefined}
208-
>
209-
<Settings size={15} className={styles.navIcon} />
210-
<span className={`${styles.navLabel} ${collapsed ? styles.navLabelHidden : ''}`}>
211-
Connections
212-
</span>
213-
</button>
214-
)}
215222
<div className={styles.userMenuWrap} ref={userMenuRef}>
216223
<button
217224
className={styles.bottomItem}

‎src/components/layout/AppSidebar.module.css‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,34 @@
338338
color: #111827;
339339
}
340340

341+
.dropdownDivider {
342+
height: 1px;
343+
background: #e5e7eb;
344+
margin: 4px 8px;
345+
}
346+
347+
.dropdownManage {
348+
display: flex;
349+
align-items: center;
350+
gap: 8px;
351+
width: calc(100% - 8px);
352+
margin: 4px;
353+
padding: 8px 10px;
354+
border: none;
355+
border-radius: 8px;
356+
background: transparent;
357+
font-size: 13px;
358+
color: #6b7280;
359+
cursor: pointer;
360+
text-align: left;
361+
transition: background 0.1s, color 0.1s;
362+
}
363+
364+
.dropdownManage:hover {
365+
background: #f3f4f6;
366+
color: #111827;
367+
}
368+
341369
/* ── User profile dropdown ── */
342370
.userMenuWrap {
343371
position: relative;

0 commit comments

Comments
 (0)