Skip to content

Commit 471eade

Browse files
committed
Remove favorite connection
1 parent e1d2bbd commit 471eade

File tree

19 files changed

+31
-252
lines changed

19 files changed

+31
-252
lines changed

sqlit/core/keymap.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ def _build_action_keys(self) -> list[ActionKeyDef]:
310310
ActionKeyDef("d", "delete_connection", "tree"),
311311
ActionKeyDef("delete", "delete_connection", "tree", primary=False),
312312
ActionKeyDef("D", "duplicate_connection", "tree"),
313-
ActionKeyDef("asterisk", "toggle_connection_favorite", "tree"),
314313
ActionKeyDef("m", "move_connection_to_folder", "tree"),
315314
ActionKeyDef("x", "disconnect", "tree"),
316315
ActionKeyDef("z", "collapse_tree", "tree"),

sqlit/domains/connections/domain/config.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ class ConnectionConfig:
126126
tunnel: TunnelConfig | None = None
127127
source: str | None = None
128128
connection_url: str | None = None
129-
favorite: bool = False
130129
folder_path: str = ""
131130
extra_options: dict[str, str] = field(default_factory=dict)
132131
options: dict[str, Any] = field(default_factory=dict)
@@ -218,7 +217,6 @@ def from_dict(cls, data: Mapping[str, Any]) -> ConnectionConfig:
218217
"db_type",
219218
"source",
220219
"connection_url",
221-
"favorite",
222220
"folder_path",
223221
"extra_options",
224222
}
@@ -230,10 +228,6 @@ def from_dict(cls, data: Mapping[str, Any]) -> ConnectionConfig:
230228
else:
231229
payload.pop(key)
232230

233-
raw_favorite = payload.get("favorite", False)
234-
favorite = bool(raw_favorite)
235-
if isinstance(raw_favorite, str):
236-
favorite = raw_favorite.strip().lower() in {"1", "true", "yes", "y", "on"}
237231
folder_path = normalize_folder_path(payload.get("folder_path", ""))
238232

239233
return cls(
@@ -243,7 +237,6 @@ def from_dict(cls, data: Mapping[str, Any]) -> ConnectionConfig:
243237
tunnel=tunnel,
244238
source=payload.get("source"),
245239
connection_url=payload.get("connection_url"),
246-
favorite=favorite,
247240
folder_path=folder_path,
248241
extra_options=dict(payload.get("extra_options") or {}),
249242
options=options,
@@ -311,7 +304,6 @@ def to_dict(self, *, include_passwords: bool = True) -> dict[str, Any]:
311304
"db_type": self.db_type,
312305
"source": self.source,
313306
"connection_url": self.connection_url,
314-
"favorite": self.favorite,
315307
"folder_path": self.folder_path,
316308
"extra_options": dict(self.extra_options),
317309
"options": dict(self.options),
@@ -538,7 +530,7 @@ def ssh_key_path(self, value: str) -> None:
538530

539531

540532
SOURCE_EMOJIS: dict[str, str] = {
541-
"docker": "🐳 ",
533+
"docker": "",
542534
"azure": "",
543535
}
544536

sqlit/domains/connections/ui/mixins/connection.py

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -797,79 +797,6 @@ def _update_visual_selection(self: ConnectionMixinHost) -> None:
797797

798798
self._update_footer_bindings()
799799

800-
def action_toggle_connection_favorite(self: ConnectionMixinHost) -> None:
801-
from sqlit.domains.connections.app.credentials import CredentialsPersistError
802-
from sqlit.shared.ui.screens.error import ErrorScreen
803-
804-
selected = self._get_selected_connection_configs()
805-
if selected:
806-
previous = {c.name: c.favorite for c in selected}
807-
set_favorite = not all(c.favorite for c in selected)
808-
for conn in selected:
809-
conn.favorite = set_favorite
810-
credentials_error: CredentialsPersistError | None = None
811-
812-
try:
813-
self.services.connection_store.save_all(self.connections)
814-
except CredentialsPersistError as exc:
815-
credentials_error = exc
816-
except Exception as exc:
817-
for conn in selected:
818-
conn.favorite = previous.get(conn.name, conn.favorite)
819-
self.notify(f"Failed to update favorite: {exc}", severity="error")
820-
return
821-
822-
if not self.services.connection_store.is_persistent:
823-
self.notify("Connections are not persisted in this session", severity="warning")
824-
825-
self._get_selected_connection_names().clear()
826-
setattr(self, "_tree_visual_mode_anchor", None)
827-
self._refresh_connection_tree()
828-
action_label = "starred" if set_favorite else "unstarred"
829-
if len(selected) == 1:
830-
self.notify(f"Connection {action_label}")
831-
else:
832-
self.notify(f"{len(selected)} connections {action_label}")
833-
if credentials_error:
834-
self.push_screen(ErrorScreen("Keyring Error", str(credentials_error)))
835-
return
836-
837-
node = self.object_tree.cursor_node
838-
if not node:
839-
return
840-
841-
config = self._get_connection_config_from_node(node)
842-
if not config:
843-
return
844-
845-
if not any(c.name == config.name for c in self.connections):
846-
self.notify("Only saved connections can be starred", severity="warning")
847-
return
848-
849-
previous = config.favorite
850-
config.favorite = not previous
851-
credentials_error: CredentialsPersistError | None = None
852-
853-
try:
854-
self.services.connection_store.save_all(self.connections)
855-
except CredentialsPersistError as exc:
856-
credentials_error = exc
857-
except Exception as exc:
858-
config.favorite = previous
859-
self.notify(f"Failed to update favorite: {exc}", severity="error")
860-
return
861-
862-
if not self.services.connection_store.is_persistent:
863-
self.notify("Connections are not persisted in this session", severity="warning")
864-
865-
self._refresh_connection_tree()
866-
if config.favorite:
867-
self.notify("Connection starred")
868-
else:
869-
self.notify("Connection unstarred")
870-
if credentials_error:
871-
self.push_screen(ErrorScreen("Keyring Error", str(credentials_error)))
872-
873800
def action_move_connection_to_folder(self: ConnectionMixinHost) -> None:
874801
from sqlit.domains.connections.app.credentials import CredentialsPersistError
875802
from sqlit.domains.connections.domain.config import normalize_folder_path

sqlit/domains/connections/ui/screens/connection.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,6 @@ def _get_config(self) -> ConnectionConfig | None:
665665
config_data["endpoint"] = endpoint
666666
config_data["tunnel"] = tunnel
667667
if self.editing and self.config is not None:
668-
config_data["favorite"] = getattr(self.config, "favorite", False)
669668
config_data["folder_path"] = getattr(self.config, "folder_path", "")
670669

671670
config = ConnectionConfig.from_dict(config_data)

sqlit/domains/connections/ui/screens/connection_picker/screen.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class ConnectionPickerScreen(ModalScreen):
5151
BINDINGS = [
5252
Binding("escape", "cancel_or_close_filter", "Cancel"),
5353
Binding("enter", "select", "Select"),
54-
Binding("asterisk", "toggle_star", "Star", show=False),
5554
Binding("s", "save", "Save", show=False),
5655
Binding("n", "new_connection", "New", show=False),
5756
Binding("f", "refresh", "Refresh", show=False),
@@ -539,45 +538,6 @@ def action_save(self) -> None:
539538
self._save_connection_and_refresh(config, option_id)
540539
return
541540

542-
def action_toggle_star(self) -> None:
543-
if self._current_tab == TAB_CLOUD:
544-
return
545-
546-
option = self._get_highlighted_option()
547-
if not option or option.disabled:
548-
return
549-
550-
option_id = str(option.id) if option.id else ""
551-
if not option_id or is_docker_option_id(option_id):
552-
return
553-
554-
config = find_connection_by_name(self.connections, option_id)
555-
if not config:
556-
return
557-
558-
from sqlit.domains.connections.app.credentials import CredentialsPersistError
559-
560-
was_favorite = config.favorite
561-
config.favorite = not was_favorite
562-
try:
563-
self._app().services.connection_store.save_all(self.connections)
564-
except CredentialsPersistError as exc:
565-
self.notify(str(exc), severity="error")
566-
except Exception as exc:
567-
config.favorite = was_favorite
568-
self.notify(f"Failed to update favorite: {exc}", severity="error")
569-
self._update_list()
570-
return
571-
572-
if not self._app().services.connection_store.is_persistent:
573-
self.notify("Connections are not persisted in this session", severity="warning")
574-
575-
if config.favorite:
576-
self.notify("Connection starred")
577-
else:
578-
self.notify("Connection unstarred")
579-
self._update_list()
580-
581541
def _save_cloud_selection(self) -> None:
582542
tree_node = self._get_highlighted_tree_node()
583543
if not tree_node or not tree_node.data:

sqlit/domains/connections/ui/screens/connection_picker/shortcuts.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
find_container_by_id,
2323
is_container_saved,
2424
)
25-
from sqlit.domains.connections.ui.screens.connection_picker.tabs.connections import find_connection_by_name
2625

2726

2827
def build_picker_shortcuts(
@@ -69,7 +68,6 @@ def _build_list_shortcuts(
6968
show_save = False
7069
is_connectable = False
7170
provider_shortcuts: list[tuple[str, str]] = []
72-
star_action: tuple[str, str] | None = None
7371

7472
if option:
7573
option_id = str(option.id) if option.id else ""
@@ -97,24 +95,14 @@ def _build_list_shortcuts(
9795
if current_tab == TAB_CONNECTIONS and option_id:
9896
is_connectable = True
9997

100-
if option_id and not option_id.startswith(DOCKER_PREFIX):
101-
conn = find_connection_by_name(connections, option_id)
102-
if conn:
103-
star_label = "Unstar" if conn.favorite else "Star"
104-
star_action = (star_label, "*")
105-
10698
shortcuts = provider_shortcuts
10799
if not shortcuts:
108100
action_label = "Connect" if is_connectable else "Select"
109101
shortcuts = [(action_label, "enter")]
110102
if show_save:
111103
shortcuts.append(("Save", "s"))
112-
if star_action:
113-
shortcuts.append(star_action)
114104
if current_tab == TAB_CONNECTIONS:
115105
shortcuts.append(("New", "n"))
116-
elif star_action:
117-
shortcuts.append(star_action)
118106

119107
if current_tab in (TAB_DOCKER, TAB_CLOUD):
120108
shortcuts.append(("Refresh", "f"))

sqlit/domains/connections/ui/screens/connection_picker/tabs/connections.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,20 @@ def build_connections_options(
1515
) -> list[Option]:
1616
options: list[Option] = []
1717

18-
favorite_options: list[Option] = []
1918
saved_options: list[Option] = []
2019
for conn in connections:
2120
matches, indices = fuzzy_match(pattern, conn.name)
2221
if matches or not pattern:
2322
display = highlight_matches(conn.name, indices)
2423
db_type = conn.db_type.upper() if conn.db_type else "DB"
2524
info = get_connection_display_info(conn)
26-
source_prefix = ""
27-
if conn.source == "docker":
28-
source_prefix = "docker "
29-
star = "[yellow]*[/] " if conn.favorite else " "
30-
option = Option(f"{star}{source_prefix}{display} [{db_type}] [dim]({info})[/]", id=conn.name)
31-
if conn.favorite:
32-
favorite_options.append(option)
33-
else:
34-
saved_options.append(option)
25+
option = Option(f"{display} [{db_type}] [dim]({info})[/]", id=conn.name)
26+
saved_options.append(option)
3527

3628
options.append(Option("[bold]Saved[/]", id="_header_saved", disabled=True))
3729

38-
if favorite_options or saved_options:
39-
options.extend(favorite_options + saved_options)
30+
if saved_options:
31+
options.extend(saved_options)
4032
else:
4133
options.append(Option("[dim](no saved connections)[/]", id="_empty_saved", disabled=True))
4234

sqlit/domains/connections/ui/screens/connection_picker/tabs/docker.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ def build_docker_options(
9090
) -> list[Option]:
9191
options: list[Option] = []
9292

93-
favorite_options: list[Option] = []
9493
saved_options: list[Option] = []
9594
for conn in connections:
9695
if conn.source != "docker":
@@ -100,12 +99,8 @@ def build_docker_options(
10099
display = highlight_matches(conn.name, indices)
101100
db_type = conn.db_type.upper() if conn.db_type else "DB"
102101
info = get_connection_display_info(conn)
103-
star = "[yellow]*[/] " if conn.favorite else " "
104-
option = Option(f"{star}docker {display} [{db_type}] [dim]({info})[/]", id=conn.name)
105-
if conn.favorite:
106-
favorite_options.append(option)
107-
else:
108-
saved_options.append(option)
102+
option = Option(f"{display} [{db_type}] [dim]({info})[/]", id=conn.name)
103+
saved_options.append(option)
109104

110105
running_options: list[Option] = []
111106
exited_options: list[Option] = []
@@ -123,30 +118,30 @@ def build_docker_options(
123118
if container.connectable:
124119
running_options.append(
125120
Option(
126-
f"docker {display} [{db_label}] [dim](localhost{port_info})[/]",
121+
f"{display} [{db_label}] [dim](localhost{port_info})[/]",
127122
id=f"{DOCKER_PREFIX}{container.container_id}",
128123
)
129124
)
130125
else:
131126
running_options.append(
132127
Option(
133-
f"docker {display} [{db_label}] [dim](not exposed)[/]",
128+
f"{display} [{db_label}] [dim](not exposed)[/]",
134129
id=f"{DOCKER_PREFIX}{container.container_id}",
135130
disabled=True,
136131
)
137132
)
138133
else:
139134
exited_options.append(
140135
Option(
141-
f"[dim]docker {display} [{db_label}] (Stopped)[/]",
136+
f"[dim]{display} [{db_label}] (Stopped)[/]",
142137
id=f"{DOCKER_PREFIX}{container.container_id}",
143138
)
144139
)
145140

146141
options.append(Option("[bold]Saved[/]", id="_header_docker_saved", disabled=True))
147142

148-
if favorite_options or saved_options:
149-
options.extend(favorite_options + saved_options)
143+
if saved_options:
144+
options.extend(saved_options)
150145
else:
151146
options.append(Option("[dim](no saved Docker connections)[/]", id="_empty_docker_saved", disabled=True))
152147

sqlit/domains/explorer/state/tree_multi_select.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ def _setup_actions(self) -> None:
1717
label="Clear",
1818
help="Clear selection",
1919
)
20-
self.allows(
21-
"toggle_connection_favorite",
22-
label="Star",
23-
help="Star selected connections",
24-
)
2520
self.allows(
2621
"move_connection_to_folder",
2722
label="Move",
@@ -45,14 +40,6 @@ def get_display_bindings(self, app: InputContext) -> tuple[list[DisplayBinding],
4540
)
4641
)
4742
seen.add("clear_connection_selection")
48-
left.append(
49-
DisplayBinding(
50-
key=resolve_display_key("toggle_connection_favorite") or "*",
51-
label="Star",
52-
action="toggle_connection_favorite",
53-
)
54-
)
55-
seen.add("toggle_connection_favorite")
5643
left.append(
5744
DisplayBinding(
5845
key=resolve_display_key("move_connection_to_folder") or "m",

sqlit/domains/explorer/state/tree_on_connection.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ def is_connected_to_this(app: InputContext) -> bool:
3737
self.allows("edit_connection", label="Edit", help="Edit connection")
3838
self.allows("delete_connection", label="Delete", help="Delete connection")
3939
self.allows("duplicate_connection", label="Duplicate", help="Duplicate connection")
40-
self.allows(
41-
"toggle_connection_favorite",
42-
label="Star",
43-
help="Toggle favorite connection",
44-
)
4540
self.allows(
4641
"move_connection_to_folder",
4742
label="Move",
@@ -98,14 +93,6 @@ def get_display_bindings(self, app: InputContext) -> tuple[list[DisplayBinding],
9893
)
9994
)
10095
seen.add("duplicate_connection")
101-
left.append(
102-
DisplayBinding(
103-
key=resolve_display_key("toggle_connection_favorite") or "*",
104-
label="Star",
105-
action="toggle_connection_favorite",
106-
)
107-
)
108-
seen.add("toggle_connection_favorite")
10996
left.append(
11097
DisplayBinding(
11198
key=resolve_display_key("move_connection_to_folder") or "m",

0 commit comments

Comments
 (0)