04/22 user dashboard view, no credentials popup automatically

This commit is contained in:
2026-04-22 18:38:57 -04:00
parent b7e2a164c7
commit eab4207e1f
10 changed files with 479 additions and 62 deletions
+52 -12
View File
@@ -288,18 +288,34 @@ class WebsiteDialog(tk.Toplevel):
# Hide initially; shown when visibility='assigned'
self._user_assign_frame.pack_forget()
# ── Credentials section ───────────────────────────────────────────────
# ── Credentials section (collapsed by default) ───────────────────────
ttk.Separator(self.inner, orient="horizontal").pack(
fill="x", padx=24, pady=12)
cred_header = ttk.Frame(self.inner)
cred_header.pack(fill="x", padx=24)
ttk.Label(cred_header, text="Login Credentials",
style="Heading.TLabel").pack(side="left")
ttk.Button(cred_header, text=" Add Credential",
command=self._add_cred_row).pack(side="right")
self.creds_container = ttk.Frame(self.inner)
self.creds_container.pack(fill="x", padx=24, pady=8)
# Toggle header row
cred_toggle = ttk.Frame(self.inner)
cred_toggle.pack(fill="x", padx=24)
ttk.Label(cred_toggle, text="Login Credentials",
style="Heading.TLabel").pack(side="left")
self._cred_expanded = False
self._cred_toggle_btn = ttk.Button(
cred_toggle,
text="🔑 Show Credentials",
style="Ghost.TButton",
command=self._toggle_credentials,
)
self._cred_toggle_btn.pack(side="right")
ttk.Button(cred_toggle, text=" Add Credential",
command=self._add_cred_row_visible).pack(side="right", padx=(0, 6))
# Collapsible body
self._cred_body = ttk.Frame(self.inner)
self.creds_container = ttk.Frame(self._cred_body)
self.creds_container.pack(fill="x")
# _cred_body is NOT packed initially — hidden by default
# ── Buttons ───────────────────────────────────────────────────────────
ttk.Separator(self.inner, orient="horizontal").pack(
@@ -325,10 +341,13 @@ class WebsiteDialog(tk.Toplevel):
for uid, var in self._user_vars.items():
var.set(uid in assigned_ids)
self._on_visibility_change()
for cred in d.get("credentials", []):
existing_creds = d.get("credentials", [])
for cred in existing_creds:
self._add_cred_row(cred)
else:
self._add_cred_row()
# Auto-expand credentials section if creds already exist
if existing_creds:
self._expand_credentials()
# For new websites: credentials section stays collapsed
def _on_visibility_change(self):
"""Show or hide the user assignment panel based on visibility selection."""
@@ -338,6 +357,27 @@ class WebsiteDialog(tk.Toplevel):
else:
self._user_assign_frame.pack_forget()
def _expand_credentials(self):
"""Show the credentials body and update the toggle button label."""
self._cred_expanded = True
self._cred_body.pack(fill="x", padx=24, pady=(4, 0))
self._cred_toggle_btn.config(text="🔒 Hide Credentials")
def _toggle_credentials(self):
"""Show or hide the collapsible credentials section."""
if self._cred_expanded:
self._cred_expanded = False
self._cred_body.pack_forget()
self._cred_toggle_btn.config(text="🔑 Show Credentials")
else:
self._expand_credentials()
def _add_cred_row_visible(self):
"""Expand the section (if collapsed) then add an empty credential row."""
if not self._cred_expanded:
self._expand_credentials()
self._add_cred_row()
def _add_cred_row(self, cred=None):
frame = ttk.Frame(self.creds_container, style="Surface.TFrame")
frame.pack(fill="x", pady=4, ipady=4)