@@ -81,8 +81,7 @@ internal final class MainWindowToolbar: NSObject, NSToolbarDelegate {
8181
8282 // MARK: - Identifiers
8383
84- private static let connection = NSToolbarItem . Identifier ( " com.TablePro.toolbar.connection " )
85- private static let database = NSToolbarItem . Identifier ( " com.TablePro.toolbar.database " )
84+ private static let connectionGroup = NSToolbarItem . Identifier ( " com.TablePro.toolbar.connectionGroup " )
8685 private static let refresh = NSToolbarItem . Identifier ( " com.TablePro.toolbar.refresh " )
8786 private static let saveChanges = NSToolbarItem . Identifier ( " com.TablePro.toolbar.saveChanges " )
8887 private static let principal = NSToolbarItem . Identifier ( " com.TablePro.toolbar.principal " )
@@ -106,8 +105,7 @@ internal final class MainWindowToolbar: NSObject, NSToolbarDelegate {
106105 [
107106 Self . sidebarToggle,
108107 . sidebarTrackingSeparator,
109- Self . connection,
110- Self . database,
108+ Self . connectionGroup,
111109 Self . refreshSaveGroup,
112110 . flexibleSpace,
113111 Self . principal,
@@ -150,12 +148,12 @@ internal final class MainWindowToolbar: NSObject, NSToolbarDelegate {
150148 switch itemIdentifier {
151149 case Self . sidebarToggle:
152150 return makeSidebarToggleItem ( coordinator: coordinator)
153- case Self . connection :
151+ case Self . connectionGroup :
154152 return hostingItem ( id: itemIdentifier, label: String ( localized: " Connection " ) ,
155- content: ConnectionToolbarButton ( coordinator : coordinator ) )
156- case Self . database :
157- return hostingItem ( id : itemIdentifier , label : String ( localized : " Database " ) ,
158- content : DatabaseToolbarButton ( coordinator : coordinator ) )
153+ content: HStack ( spacing : 4 ) {
154+ ConnectionToolbarButton ( coordinator : coordinator )
155+ DatabaseToolbarButton ( coordinator : coordinator )
156+ } )
159157 case Self . refresh:
160158 return hostingItem ( id: itemIdentifier, label: String ( localized: " Refresh " ) ,
161159 content: RefreshToolbarButton ( coordinator: coordinator) )
@@ -283,19 +281,18 @@ private struct DatabaseToolbarButton: View {
283281 var body : some View {
284282 let state = coordinator. toolbarState
285283 let supportsSwitch = PluginManager . shared. supportsDatabaseSwitching ( for: state. databaseType)
286- Button {
287- coordinator. commandActions? . openDatabaseSwitcher ( )
288- } label: {
289- Label ( " Database " , systemImage: " cylinder " )
284+ if supportsSwitch {
285+ Button {
286+ coordinator. commandActions? . openDatabaseSwitcher ( )
287+ } label: {
288+ Label ( " Database " , systemImage: " cylinder " )
289+ }
290+ . help ( String ( localized: " Open Database (⌘K) " ) )
291+ . disabled (
292+ state. connectionState != . connected
293+ || PluginManager . shared. connectionMode ( for: state. databaseType) == . fileBased
294+ )
290295 }
291- . help ( String ( localized: " Open Database (⌘K) " ) )
292- . disabled (
293- !supportsSwitch
294- || state. connectionState != . connected
295- || PluginManager . shared. connectionMode ( for: state. databaseType) == . fileBased
296- )
297- . opacity ( supportsSwitch ? 1 : 0 )
298- . allowsHitTesting ( supportsSwitch)
299296 }
300297}
301298
@@ -415,20 +412,20 @@ private struct ResultsToolbarButton: View {
415412
416413 var body : some View {
417414 let state = coordinator. toolbarState
418- Button {
419- coordinator. commandActions? . toggleResults ( )
420- } label: {
421- Label (
422- " Results " ,
423- systemImage: state. isResultsCollapsed
424- ? " rectangle.bottomhalf.inset.filled "
425- : " rectangle.inset.filled "
426- )
415+ if !state. isTableTab {
416+ Button {
417+ coordinator. commandActions? . toggleResults ( )
418+ } label: {
419+ Label (
420+ " Results " ,
421+ systemImage: state. isResultsCollapsed
422+ ? " rectangle.bottomhalf.inset.filled "
423+ : " rectangle.inset.filled "
424+ )
425+ }
426+ . help ( String ( localized: " Toggle Results (⌘⌥R) " ) )
427+ . disabled ( state. connectionState != . connected)
427428 }
428- . help ( String ( localized: " Toggle Results (⌘⌥R) " ) )
429- . disabled ( state. connectionState != . connected)
430- . opacity ( state. isTableTab ? 0 : 1 )
431- . allowsHitTesting ( !state. isTableTab)
432429 }
433430}
434431
@@ -496,20 +493,18 @@ private struct ImportToolbarButton: View {
496493
497494 var body : some View {
498495 let state = coordinator. toolbarState
499- let supportsImport = PluginManager . shared. supportsImport ( for: state. databaseType)
500- Button {
501- coordinator. commandActions? . importTables ( )
502- } label: {
503- Label ( " Import " , systemImage: " square.and.arrow.down " )
496+ if PluginManager . shared. supportsImport ( for: state. databaseType) {
497+ Button {
498+ coordinator. commandActions? . importTables ( )
499+ } label: {
500+ Label ( " Import " , systemImage: " square.and.arrow.down " )
501+ }
502+ . help ( String ( localized: " Import Data (⌘⇧I) " ) )
503+ . disabled (
504+ state. connectionState != . connected
505+ || state. safeModeLevel. blocksAllWrites
506+ )
504507 }
505- . help ( String ( localized: " Import Data (⌘⇧I) " ) )
506- . disabled (
507- state. connectionState != . connected
508- || state. safeModeLevel. blocksAllWrites
509- || !supportsImport
510- )
511- . opacity ( supportsImport ? 1 : 0 )
512- . allowsHitTesting ( supportsImport)
513508 }
514509}
515510
0 commit comments