diff --git a/my_egeria/my_egeria/CommunitiesScreen.py b/my_egeria/my_egeria/CommunitiesScreen.py index 886dd70d..2ec355ba 100644 --- a/my_egeria/my_egeria/CommunitiesScreen.py +++ b/my_egeria/my_egeria/CommunitiesScreen.py @@ -5,9 +5,9 @@ This file provides the Work with Communities screen for My Profile. """ -from textual import on +from textual import events, on from textual.app import ComposeResult -from textual.containers import ScrollableContainer, Horizontal +from textual.containers import ScrollableContainer, Horizontal, Vertical from textual.screen import ModalScreen from textual.widgets import DataTable, Header, Static, Footer, Input, Button, Select, TextArea @@ -49,15 +49,16 @@ def compose(self) -> ComposeResult: yield Header(show_clock=True) yield Static("Create Community", classes="span-3", id="create_community_title") yield ScrollableContainer( - Static("Name *"), - Input(placeholder="Name of the community", id="community_name_input"), - Static("Description *"), - Input(placeholder="What the community is about", id="community_description_input"), + Horizontal( + Input(placeholder="Name of the community *", id="community_name_input"), + Input(placeholder="What the community is about *", id="community_description_input"), + ), + Horizontal( + Select([(t, t) for t in CREATOR_ASSIGNMENT_TYPES] + [("Don't join", NOT_JOINING)], + value=CREATOR_ASSIGNMENT_TYPES[0], allow_blank=False, id="creator_assignment_type"), + ), Static("Mission"), TextArea(id="community_mission_text"), - Static("Your part in it"), - Select([(t, t) for t in CREATOR_ASSIGNMENT_TYPES] + [("Don't join", NOT_JOINING)], - value=CREATOR_ASSIGNMENT_TYPES[0], allow_blank=False, id="creator_assignment_type"), Horizontal( Button("Create", id="submit_create_community_btn", variant="primary"), Button("Cancel", id="cancel_create_community_btn", variant="warning"), @@ -149,6 +150,7 @@ class CommunitiesScreen(ModalScreen): ("escape", "quit", "Back"), ("q", "quit", "Main Menu"), ("ctrl+o", "open_community", "Open Community"), + ("enter", "open_community", "Open Community"), ("ctrl+n", "join_community", "Join Community"), ("ctrl+t", "create_community", "Create Community"), ("ctrl+d", "leave_community", "Leave Community"), @@ -164,6 +166,7 @@ def __init__(self, my_communities, *args, focus_search: bool = False, **kwargs): self.focus_search = focus_search # The last search, repeated after joining or leaving so the found list stays current self.search_string = "*" + self.last_active_table: str = "communities_found_table" if focus_search else "my_communities_table" def compose(self) -> ComposeResult: yield Header(show_clock=True) @@ -185,11 +188,14 @@ def compose(self) -> ComposeResult: Static("Find other communities: enter a search term ('*' for all) and press return"), Input(value=self.search_string, placeholder="Search term, or * for all", id="community_search_input"), DataTable(id="communities_found_table", zebra_stripes=True, cursor_type="row"), - Horizontal( + Vertical( Select([(t, t) for t in JOIN_ASSIGNMENT_TYPES], value=JOIN_ASSIGNMENT_TYPES[0], allow_blank=False, id="join_assignment_type"), - Button("Join Community", id="join_community_btn", variant="primary"), - Button("Open Community", id="open_found_community_btn", variant="primary"), + Horizontal( + Button("Join Community", id="join_community_btn", variant="primary"), + Button("Open Community", id="open_found_community_btn", variant="primary"), + id="found_communities_buttons_row", + ), id="found_communities_buttons", ), id="find_communities_container", @@ -268,10 +274,15 @@ def on_close(result) -> None: self.app.push_screen(community_screen, callback=on_close) + def on_descendant_focus(self, event: events.DescendantFocus) -> None: + """Track which DataTable was last focused.""" + if isinstance(event.widget, DataTable): + self.last_active_table = event.widget.id or self.last_active_table + def action_open_community(self) -> None: - """ Open the highlighted community in whichever list has focus """ + """Open the highlighted community in whichever list was last active or focused.""" found_table = self.query_one("#communities_found_table", DataTable) - if self.focused is found_table: + if self.focused is found_table or (self.focused is None and self.last_active_table == "communities_found_table"): self._open_found() else: self._open_mine() diff --git a/my_egeria/my_egeria/CommunityScreen.py b/my_egeria/my_egeria/CommunityScreen.py index 5b4042b5..4879fc33 100644 --- a/my_egeria/my_egeria/CommunityScreen.py +++ b/my_egeria/my_egeria/CommunityScreen.py @@ -8,9 +8,9 @@ a like, a star rating) on a blog post or resource. """ -from textual import on +from textual import events, on from textual.app import ComposeResult -from textual.containers import ScrollableContainer, Horizontal +from textual.containers import ScrollableContainer, Horizontal, Vertical from textual.screen import ModalScreen from textual.widgets import DataTable, Header, Static, Footer, Input, Button, Select, TextArea @@ -383,6 +383,7 @@ class CommunityScreen(ModalScreen): ("q", "quit", "Main Menu"), ("ctrl+n", "add_item", "New Post / Comment"), ("ctrl+o", "feedback", "Feedback on Post / Resource"), + ("enter", "feedback", "Feedback on Post / Resource"), ("ctrl+w", "join", "Join Community"), ] @@ -397,6 +398,7 @@ def __init__(self, community_guid: str, community_name: str, *args, **kwargs): # Whether the user is a member (directly or through a role); None until the members are read self.is_member: bool | None = None self.joined = False + self.last_active_table: str = "community_posts_table" def compose(self) -> ComposeResult: yield Header(show_clock=True) @@ -416,7 +418,7 @@ def compose(self) -> ComposeResult: Static("[b]Members[/b] [dim](people linked to the community, directly or through a role they hold)[/dim]"), DataTable(id="community_members_table", zebra_stripes=True, cursor_type="row"), Static("", id="community_membership_text"), - Horizontal( + Vertical( Select([(t, t) for t in JOIN_ASSIGNMENT_TYPES], value=JOIN_ASSIGNMENT_TYPES[0], allow_blank=False, id="community_join_assignment_type"), Button("Join Community", id="community_join_btn", variant="primary"), @@ -457,7 +459,7 @@ def _load_members(self) -> None: members = self.app.get_community_members(self.community_guid) if members is None: # Membership is unknown, so neither offer joining nor claim the user is a member - self.query_one("#community_join_controls", Horizontal).display = False + self.query_one("#community_join_controls", Vertical).display = False return table = self.query_one("#community_members_table", DataTable) table.clear() @@ -465,7 +467,7 @@ def _load_members(self) -> None: table.add_row(*row) user_guid = getattr(self.app, "user_GUID", "") self.is_member = bool(user_guid) and any(row[4] == user_guid for row in members) - self.query_one("#community_join_controls", Horizontal).display = not self.is_member + self.query_one("#community_join_controls", Vertical).display = not self.is_member self.query_one("#community_membership_text", Static).update( "[dim]You are a member[/dim]" if self.is_member else "[dim]You are not a member - join as a contributor or an observer[/dim]") @@ -513,6 +515,11 @@ def _show_post_text(self) -> None: text = f"[dim]{none_words('posts', complete=False)}[/dim]" self.query_one("#community_post_text", Static).update(text) + def on_descendant_focus(self, event: events.DescendantFocus) -> None: + """Track which DataTable was last focused.""" + if isinstance(event.widget, DataTable): + self.last_active_table = event.widget.id or self.last_active_table + @on(DataTable.RowHighlighted, "#community_posts_table") def handle_post_highlighted(self, event: DataTable.RowHighlighted) -> None: self._show_post_text() @@ -526,8 +533,9 @@ def action_quit(self) -> None: self.dismiss(210) def action_add_item(self) -> None: - """ Add a comment if the comments list has focus, otherwise a blog post """ - if self.focused is self.query_one("#community_comments_table", DataTable): + """ Add a comment if the comments list was last active, otherwise a blog post """ + comments_table = self.query_one("#community_comments_table", DataTable) + if self.focused is comments_table or (self.focused is None and self.last_active_table == "community_comments_table"): self.action_add_comment() else: self.action_new_post() @@ -575,8 +583,9 @@ def _open_resource_feedback(self) -> None: self._open_feedback("#community_resources_table", 4, "Resource") def action_feedback(self) -> None: - """ Feedback on the highlighted resource if the resources list has focus, otherwise on the post """ - if self.focused is self.query_one("#community_resources_table", DataTable): + """ Feedback on the highlighted resource if resources list was last active, otherwise on the post """ + resources_table = self.query_one("#community_resources_table", DataTable) + if self.focused is resources_table or (self.focused is None and self.last_active_table == "community_resources_table"): self._open_resource_feedback() else: self._open_post_feedback() diff --git a/my_egeria/my_egeria/MainScreen.py b/my_egeria/my_egeria/MainScreen.py index dc53dd1c..675056aa 100644 --- a/my_egeria/my_egeria/MainScreen.py +++ b/my_egeria/my_egeria/MainScreen.py @@ -8,7 +8,8 @@ from typing import Any from textual import events, on from textual.app import ComposeResult -from textual.containers import ScrollableContainer +from textual.containers import Vertical, ScrollableContainer +from textual.coordinate import Coordinate from textual.screen import Screen from textual.widgets import DataTable, OptionList, Header, Static, Footer from textual.widgets._option_list import Option @@ -22,7 +23,7 @@ class MainScreen(Screen): BINDINGS = [ ("q", "app.quit", "Quit"), - ("ctrl+t", "edit_table", "Edit Selected Table"), + ("ctrl+t", "edit_table", "Edit Table"), ("ctrl+o", "show_comments", "Show Comments"), ("ctrl+n", "add_comment", "Add Comment"), ("ctrl+k", "bookmark_row", "Bookmark Row"), @@ -52,17 +53,17 @@ def compose(self) -> ComposeResult: # place widgets into grid on screen, note sequence determines position! yield Header(show_clock=True, id="main_header") - yield ScrollableContainer( + yield Vertical( Static("User Associations [dim](Enter on a community: open it)[/dim]"), DataTable(id="associations_table"), id="main_associations_container" ) - yield ScrollableContainer( + yield Vertical( Static(f"My Collections"), DataTable(id=("my_collections_table")), id="my_collections_container" - ) - yield ScrollableContainer( + ) + yield Vertical( Static(f"Other Functions"), Static(f"[b]Select a function[/b]"), OptionList( @@ -84,17 +85,17 @@ def compose(self) -> ComposeResult: ), id="other_function_container" ) - yield ScrollableContainer( + yield Vertical( Static("Roles [dim](Enter on a TeamLeader/TeamMember role: show team)[/dim]"), DataTable(id="roles_table"), id="main_roles_container" ) - yield ScrollableContainer( + yield Vertical( Static("Teams"), DataTable(id="teams_table"), id="main_teams_container" ) - yield ScrollableContainer( + yield Vertical( Static("Blogs"), DataTable(id="blogs_table"), Static("Journal"), @@ -104,12 +105,12 @@ def compose(self) -> ComposeResult: id="main_activities_container" ) - yield ScrollableContainer( + yield Vertical( Static("User Identity"), DataTable(id="user_identity_table"), id="main_identities_container" ) - yield ScrollableContainer( + yield Vertical( Static("Projects [dim](Enter on a project: open it)[/dim]"), DataTable(id="projects_table"), id="main_projects_container" @@ -181,11 +182,25 @@ def get_current_table_and_row(self) -> tuple[str | None, Any]: row_key = None if focused_table.row_count > 0 and 0 <= focused_table.cursor_row < focused_table.row_count: try: - row_key = focused_table.coordinate_to_cell_key(focused_table.cursor_coordinate).row_key + row_key = focused_table.coordinate_to_cell_key(Coordinate(focused_table.cursor_row, 0)).row_key except Exception: - row_key = None + try: + row_key = list(focused_table.rows.keys())[focused_table.cursor_row] + except Exception: + row_key = None + if row_key is None and self.selected_table == table_id: + row_key = self.selected_row return table_id, row_key - return self.selected_table, self.selected_row + table_id = self.selected_table or "associations_table" + row_key = self.selected_row + if table_id and row_key is None: + try: + table = self.query_one(f"#{table_id}", DataTable) + if table.row_count > 0 and 0 <= table.cursor_row < table.row_count: + row_key = table.coordinate_to_cell_key(Coordinate(table.cursor_row, 0)).row_key + except Exception: + pass + return table_id, row_key def action_edit_table(self): """ Edit the selected table """ diff --git a/my_egeria/my_egeria/ProjectScreen.py b/my_egeria/my_egeria/ProjectScreen.py index bdca40f2..df172ef4 100644 --- a/my_egeria/my_egeria/ProjectScreen.py +++ b/my_egeria/my_egeria/ProjectScreen.py @@ -6,9 +6,9 @@ resources and comments) for My Profile. """ -from textual import on +from textual import events, on from textual.app import ComposeResult -from textual.containers import ScrollableContainer, Horizontal +from textual.containers import ScrollableContainer, Horizontal, Vertical from textual.screen import ModalScreen from textual.widgets import DataTable, Header, Static, Footer, Input, Button, Select, TextArea @@ -155,6 +155,7 @@ class ProjectScreen(ModalScreen): ("q", "quit", "Main Menu"), ("ctrl+n", "add_item", "New Post / Comment"), ("ctrl+o", "feedback", "Feedback on Post / Resource"), + ("enter", "feedback", "Feedback on Post / Resource"), ("ctrl+w", "join", "Join Project"), ] @@ -169,6 +170,7 @@ def __init__(self, project_guid: str, project_name: str, *args, **kwargs): # Whether the user is a member (directly or through a role); None until the members are read self.is_member: bool | None = None self.joined = False + self.last_active_table: str = "project_posts_table" def compose(self) -> ComposeResult: yield Header(show_clock=True) @@ -188,7 +190,7 @@ def compose(self) -> ComposeResult: Static("[b]Members / Team[/b] [dim](people linked to the project, directly or through a role they hold)[/dim]"), DataTable(id="project_members_table", zebra_stripes=True, cursor_type="row"), Static("", id="project_membership_text"), - Horizontal( + Vertical( Select([(t, t) for t in JOIN_ASSIGNMENT_TYPES], value=JOIN_ASSIGNMENT_TYPES[0], allow_blank=False, id="project_join_assignment_type"), Button("Join Project", id="project_join_btn", variant="primary"), @@ -228,7 +230,7 @@ def on_mount(self) -> None: def _load_members(self) -> None: members = self.app.get_project_members(self.project_guid) if members is None: - self.query_one("#project_join_controls", Horizontal).display = False + self.query_one("#project_join_controls", Vertical).display = False return table = self.query_one("#project_members_table", DataTable) table.clear() @@ -240,7 +242,7 @@ def _load_members(self) -> None: through = f" (through {row[2]})" if row[2] != "Direct" else "" self.query_one("#project_membership_text", Static).update( f"You are a member{through} with assignment type: {row[1]}") - self.query_one("#project_join_controls", Horizontal).display = not self.is_member + self.query_one("#project_join_controls", Vertical).display = not self.is_member if not self.is_member: self.query_one("#project_membership_text", Static).update("You are not a member of this project") @@ -283,6 +285,11 @@ def _load_comments(self) -> None: # --- selection and display ------------------------------------------------ + def on_descendant_focus(self, event: events.DescendantFocus) -> None: + """Track which DataTable was last focused.""" + if isinstance(event.widget, DataTable): + self.last_active_table = event.widget.id or self.last_active_table + @on(DataTable.RowHighlighted, "#project_posts_table") def handle_posts_table_highlighted(self, event: DataTable.RowHighlighted) -> None: """Display the highlighted blog post's text.""" @@ -375,17 +382,17 @@ def handle_add_comment_button(self, event: Button.Pressed) -> None: # --- general actions (bindings) ------------------------------------------- def action_feedback(self) -> None: - """ctrl+o gives feedback on whichever of a post or a resource currently has focus.""" + """ctrl+o or Enter gives feedback on whichever of a post or a resource was last active.""" resources_table = self.query_one("#project_resources_table", DataTable) - if self.focused is resources_table: + if self.focused is resources_table or self.last_active_table == "project_resources_table": self.action_resource_feedback() else: self.action_post_feedback() def action_add_item(self) -> None: - """ctrl+n adds a comment when the comments list has focus, a blog post otherwise.""" + """ctrl+n adds a comment when the comments list was last active, a blog post otherwise.""" comments_table = self.query_one("#project_comments_table", DataTable) - if self.focused is comments_table: + if self.focused is comments_table or self.last_active_table == "project_comments_table": self.action_add_comment() else: self.action_new_blog_post() diff --git a/my_egeria/my_egeria/ProjectsScreen.py b/my_egeria/my_egeria/ProjectsScreen.py index 28c93624..399b01bc 100644 --- a/my_egeria/my_egeria/ProjectsScreen.py +++ b/my_egeria/my_egeria/ProjectsScreen.py @@ -5,9 +5,9 @@ This file provides the Work with Projects screen for My Profile. """ -from textual import on +from textual import events, on from textual.app import ComposeResult -from textual.containers import ScrollableContainer, Horizontal +from textual.containers import ScrollableContainer, Horizontal, Vertical from textual.screen import ModalScreen from textual.widgets import DataTable, Header, Static, Footer, Input, Button, Select, TextArea @@ -50,18 +50,18 @@ def compose(self) -> ComposeResult: yield Header(show_clock=True) yield Static("Create Project", classes="span-3", id="create_project_title") yield ScrollableContainer( - Static("Name *"), - Input(placeholder="Name of the project", id="project_name_input"), - Static("Description *"), - Input(placeholder="What the project is about", id="project_description_input"), - Static("Project Type"), - Select([(t, t) for t in PROJECT_TYPES], value=PROJECT_TYPES[0], allow_blank=False, - id="project_type_select"), + Horizontal( + Input(placeholder="Name of the project *", id="project_name_input"), + Input(placeholder="What the project is about *", id="project_description_input"), + ), + Horizontal( + Select([(t, t) for t in PROJECT_TYPES], value=PROJECT_TYPES[0], allow_blank=False, + id="project_type_select"), + Select([(t, t) for t in CREATOR_ASSIGNMENT_TYPES] + [("Don't join", NOT_JOINING)], + value=CREATOR_ASSIGNMENT_TYPES[0], allow_blank=False, id="project_creator_assignment_type"), + ), Static("Mission / Planned Results"), TextArea(id="project_mission_text"), - Static("Your part in it"), - Select([(t, t) for t in CREATOR_ASSIGNMENT_TYPES] + [("Don't join", NOT_JOINING)], - value=CREATOR_ASSIGNMENT_TYPES[0], allow_blank=False, id="project_creator_assignment_type"), Horizontal( Button("Create", id="submit_create_project_btn", variant="primary"), Button("Cancel", id="cancel_create_project_btn", variant="warning"), @@ -154,6 +154,7 @@ class ProjectsScreen(ModalScreen): ("escape", "quit", "Back"), ("q", "quit", "Main Menu"), ("ctrl+o", "open_project", "Open Project"), + ("enter", "open_project", "Open Project"), ("ctrl+n", "join_project", "Join Project"), ("ctrl+t", "create_project", "Create Project"), ("ctrl+d", "leave_project", "Leave Project"), @@ -167,6 +168,7 @@ def __init__(self, my_projects: list[tuple[str, str, str, str, str]], focus_sear self.my_projects_data = my_projects or [] self.focus_search = focus_search self.search_string = "*" + self.last_active_table: str = "projects_found_table" if focus_search else "my_projects_table" def compose(self) -> ComposeResult: yield Header(show_clock=True) @@ -188,11 +190,14 @@ def compose(self) -> ComposeResult: "ctrl+n joins the highlighted project; Enter or ctrl+o opens it[/dim]"), Input(placeholder="Search term or *", id="project_search_input"), DataTable(id="projects_found_table", zebra_stripes=True, cursor_type="row"), - Horizontal( + Vertical( Select([(t, t) for t in JOIN_ASSIGNMENT_TYPES], value=JOIN_ASSIGNMENT_TYPES[0], allow_blank=False, id="project_join_assignment_type"), - Button("Join Project", id="join_project_btn", variant="primary"), - Button("Open Project", id="open_found_project_btn", variant="primary"), + Horizontal( + Button("Join Project", id="join_project_btn", variant="primary"), + Button("Open Project", id="open_found_project_btn", variant="primary"), + id="found_projects_buttons_row", + ), id="found_projects_buttons", ), id="find_projects_container", @@ -271,10 +276,15 @@ def on_close(result) -> None: self.app.push_screen(project_screen, callback=on_close) + def on_descendant_focus(self, event: events.DescendantFocus) -> None: + """Track which DataTable was last focused.""" + if isinstance(event.widget, DataTable): + self.last_active_table = event.widget.id or self.last_active_table + def action_open_project(self) -> None: - """Open the highlighted project in whichever list has focus.""" + """Open the highlighted project in whichever list was last active or focused.""" found_table = self.query_one("#projects_found_table", DataTable) - if self.focused is found_table: + if self.focused is found_table or (self.focused is None and self.last_active_table == "projects_found_table"): self._open_found() else: self._open_mine() diff --git a/my_egeria/my_egeria/SplashScreen.py b/my_egeria/my_egeria/SplashScreen.py index 7e1b4c13..83bf53f4 100644 --- a/my_egeria/my_egeria/SplashScreen.py +++ b/my_egeria/my_egeria/SplashScreen.py @@ -44,7 +44,7 @@ def on_mount(self) -> None: set_screen_heading(self, "Welcome to my_egeria") def compose(self) -> ComposeResult: - yield Header(show_clock=True,id="splash") + yield Header(show_clock=True, id="splash") # 1. Define multi-line layout with line breaks splash_content = ( f"Welcome to My_Profile for Egeria Users, {self.user_name}!\n" @@ -53,20 +53,16 @@ def compose(self) -> ComposeResult: "© PDX-License-Identifier: Apache-2.0\n" "Copyright Contributors to the ODPi Egeria project.\n\n" "This file provides a set of profile related functions for my_egeria." - ) + ) # 2. Build the UI components - yield Static(classes="empty") with Vertical(id="splash-card"): yield Label(splash_content, id="splash-text") - # yield Static(classes="empty") - # yield Static(classes="empty") yield Horizontal( Button("Continue to App", id="continue", variant="success", classes="splash_buttons"), Button("Change User", variant="warning", id="change_user", classes="splash_buttons"), id="SplashButtons" ) - # yield Static(classes="empty") yield Footer() def action_continue_to_app(self): diff --git a/my_egeria/my_egeria/my_profile.py b/my_egeria/my_egeria/my_profile.py index d17fc2fb..f4e9fffd 100644 --- a/my_egeria/my_egeria/my_profile.py +++ b/my_egeria/my_egeria/my_profile.py @@ -29,10 +29,20 @@ print_basic_exception, exec_report_spec, Egeria, ) -from textual import on +from textual import on, constants as textual_constants from textual.app import App, ComposeResult from textual.binding import Binding from textual.widgets import DataTable, OptionList, Header, Footer + +# Turn off Textual's pixel-precise mouse mode. Terminals that support in-band resize +# (Ghostty, kitty, WezTerm, ...) get it by default, and on the user's Mac it turned every +# click into the row above the pointer: tables selected the wrong line and footer keys +# never fired. The parser reads this flag when the terminal answers at startup, so +# setting it at import time works whether the app starts from `textual run` or the +# `my_profile` command. Setting TEXTUAL_SMOOTH_SCROLL explicitly still wins. +if "TEXTUAL_SMOOTH_SCROLL" not in os.environ: + textual_constants.SMOOTH_SCROLL = False + from SplashScreen import SplashScreen from ConnectionErrorScreen import ConnectionErrorScreen from ChangeUserScreen import ChangeUserScreen @@ -119,6 +129,7 @@ class MyProfileApp(App, TechTypesMixin, ShopForDataMixin, TeamRolesMixin, Elemen ] CSS_PATH = "my_profile.tcss" + ENABLE_COMMAND_PALETTE = False SCREENS = { "splash": SplashScreen, diff --git a/my_egeria/my_egeria/my_profile.tcss b/my_egeria/my_egeria/my_profile.tcss index 7c92ae91..8699f858 100644 --- a/my_egeria/my_egeria/my_profile.tcss +++ b/my_egeria/my_egeria/my_profile.tcss @@ -21,7 +21,6 @@ Screen { layout: grid; grid-size: 3; grid-columns: 1fr 1fr 1fr; - /*grid-rows: 3 1fr 1fr 1fr 1;*/ grid-rows: 1fr 1fr 1fr; grid-gutter: 1; background: #1e1e2e; @@ -51,20 +50,20 @@ ModalScreen { grid-gutter: 2; } -.EditProfileScreen { +EditProfileScreen { grid-rows: auto auto 1fr auto; } -.EditTeamsScreen { +EditTeamsScreen { grid-rows: auto auto auto 1fr auto; } -.EditRolesScreen, .EditCommunitiesScreen, .EditIdentitiesScreen,.StatusScreen, .GenericDataViewScreen { +EditRolesScreen, EditCommunitiesScreen, EditIdentitiesScreen, StatusScreen, GenericDataViewScreen { grid-rows: auto auto 1fr auto; } /* Header and Footer are docked, so the grid holds only the title and the container */ -FeedbackScreen, FeedbackLogScreen { +FeedbackScreen, FeedbackLogScreen, CreateProjectScreen, CreateCommunityScreen { grid-rows: auto 1fr; background: $background; } @@ -153,32 +152,57 @@ ProjectsScreen { height: 100%; } -#my_communities_table { - width: 100%; - height: 1fr; -} - +#my_communities_table, #my_projects_table { width: 100%; - height: 1fr; + height: auto; + max-height: 6; } #my_communities_buttons, +#my_projects_buttons { + height: auto; + margin-top: 1; +} + #found_communities_buttons, -#my_projects_buttons, #found_projects_buttons { height: auto; + margin-top: 1; + width: 100%; } -#join_assignment_type, #creator_assignment_type, -#project_join_assignment_type, #project_creator_assignment_type, #project_type_select { +#found_communities_buttons_row, +#found_projects_buttons_row { + width: 100%; + height: auto; +} + +#found_communities_buttons_row Button, +#found_projects_buttons_row Button { + width: 1fr; + min-width: 8; + margin: 0; +} + +#join_assignment_type, +#project_join_assignment_type, +#community_join_assignment_type { + width: 100%; + margin-bottom: 1; +} + +#creator_assignment_type, +#project_creator_assignment_type, +#project_type_select { width: 20; } #communities_found_table, #projects_found_table { + width: 100%; height: auto; - max-height: 12; + max-height: 4; } /* Title row, then the blog + members side by side, then the resources + comments */ @@ -227,18 +251,25 @@ ProjectScreen { #project_resources_table, #project_comments_table { height: auto; - max-height: 12; + max-height: 4; } #community_blog_buttons, +#project_blog_buttons { + height: auto; + margin-top: 1; +} + #community_join_controls, -#project_blog_buttons, #project_join_controls { height: auto; + margin-top: 1; + width: 100%; } -#community_join_assignment_type { - width: 20; +#community_join_controls Button, +#project_join_controls Button { + width: 100%; } /* Title row, the like/rating summary, then the ratings + comments side by side */ @@ -319,7 +350,6 @@ ModalScreen > Header, ModalScreen > Footer { #main_roles_container, #main_teams_container, #other_function_container, -#other_function_list, #main_associations_container, #my_collections_container { width: 100%; @@ -328,12 +358,25 @@ ModalScreen > Header, ModalScreen > Footer { background: #181825; } +#other_function_list { + width: 100%; + height: 1fr; + border: none; + background: #181825; +} + #main_activities_container { width: 100%; height: 100%; + border: round #89b4fa; background: #181825; } +#main_activities_container DataTable { + height: 1fr; + width: 100%; +} + #main_identities_container { column-span: 2; width: 100%; @@ -342,6 +385,7 @@ ModalScreen > Header, ModalScreen > Footer { background: #181825; } +#main_screen Vertical > Static, #main_screen ScrollableContainer > Static { color: #89b4fa; text-style: bold; @@ -371,6 +415,11 @@ ModalScreen > Header, ModalScreen > Footer { background: #181825; } +#main_screen Vertical DataTable { + width: 100%; + height: 1fr; +} + #technology_types_table, #business_domain_table, #communities_table, @@ -380,10 +429,6 @@ ModalScreen > Header, ModalScreen > Footer { #glossary_table, #generic_data_view_table, #feedback_log_table, -#projects_table, -#roles_table, -#teams_table, -#user_identity_table, #user_identity_datatable, #status_table, #root_collection_table, @@ -406,6 +451,8 @@ Button { color: #11111b; border: none; text-style: bold; + height: auto; + min-height: 1; } Button:focus { @@ -425,10 +472,10 @@ DataTable, TextArea, SelectionList, Tree, OptionList { DataTable { text-style: bold; + border: none; } DataTable:focus { - border: heavy #a6e3a1; background: #1e1e2e; } DataTable > .datatable--header { @@ -495,37 +542,52 @@ Input:focus { height: auto; } -.SplashScreen { - align: center middle; /* 1. Center the entire card on the screen */ - background: rgba(30, 30, 46, 0.7); /* Dim the 3x3 grid behind it */ +#project_mission_text, +#community_mission_text { + width: 100%; + height: 4; + border: round #89b4fa; + background: #11111b; + color: #cdd6f4; +} + +SplashScreen { + layout: vertical; + align: center middle; + background: rgba(30, 30, 46, 0.7); } #splash-card { background: #181825; border: thick #89b4fa; - padding: 2 4; - width: 80; - height: 24; - /* 2. Vertically pushes layout content down and horizontally centers items */ - align: center bottom; + padding: 1 2; + width: 72; + max-width: 90%; + height: auto; + max-height: 18; + align: center middle; } #splash-text { text-align: center; width: 100%; - margin-bottom: 2; + margin-bottom: 1; color: #cdd6f4; } +#SplashButtons, #splash_buttons { layout: horizontal; align: center middle; height: auto; - margin-bottom: 1; + margin-top: 1; } +#SplashButtons Button, #splash_buttons Button { - margin: 0 1; /* Space out the two buttons side by side */ + margin: 0 1; + min-width: 18; + height: 3; } .empty { @@ -541,7 +603,8 @@ ConnectionErrorScreen, ChangeUserScreen { background: #181825; border: thick #f38ba8; padding: 1 2; - width: 90; + width: 72; + max-width: 90%; height: auto; } @@ -549,7 +612,8 @@ ConnectionErrorScreen, ChangeUserScreen { background: #181825; border: thick #89b4fa; padding: 1 2; - width: 90; + width: 72; + max-width: 90%; height: auto; } #connection_error_reason { diff --git a/tests/micro-tests/my_profile/test_screens.py b/tests/micro-tests/my_profile/test_screens.py index 646fa5fa..8dfe7c6a 100644 --- a/tests/micro-tests/my_profile/test_screens.py +++ b/tests/micro-tests/my_profile/test_screens.py @@ -846,6 +846,8 @@ class TestMainScreen: async def test_main_screen_edit_selected_table(self, table_id): """Verify clicking any DataTable selects it and edit action targets that table.""" class MockMainHostApp(App): + CSS_PATH = "../../../my_egeria/my_egeria/my_profile.tcss" + def __init__(self): super().__init__() self.edited_calls = [] @@ -880,8 +882,9 @@ def edit_tables(self, table_name, row_k): await pilot.pause() - # Click on target table - await pilot.click(f"#{table_id}") + # Focus target table and trigger edit + target_table = main_screen.query_one(f"#{table_id}", DataTable) + target_table.focus() await pilot.pause() # Trigger edit table hotkey @@ -890,3 +893,47 @@ def edit_tables(self, table_name, row_k): assert len(app.edited_calls) == 1 assert app.edited_calls[0][0] == table_id + + @pytest.mark.asyncio + async def test_main_screen_footer_mouse_click_edit_table(self): + """Verify mouse clicking on the FooterKey triggers the edit action.""" + from textual.widgets import Footer + from textual.widgets._footer import FooterKey + + class MockMainHostApp(App): + CSS_PATH = "../../../my_egeria/my_egeria/my_profile.tcss" + + def __init__(self): + super().__init__() + self.edited_calls = [] + + async def on_mount(self): + self.main_screen = MainScreen() + self.install_screen(self.main_screen, name="main") + await self.push_screen("main") + + def edit_tables(self, table_name, row_k): + self.edited_calls.append((table_name, row_k)) + + app = MockMainHostApp() + async with app.run_test(size=(120, 30)) as pilot: + main_screen = app.main_screen + assoc_table = main_screen.query_one("#associations_table", DataTable) + assoc_table.cursor_type = "row" + assoc_table.add_columns("Col1", "Col2") + assoc_table.add_row("val1", "val2", key="assoc_row_1") + assoc_table.focus() + await pilot.pause() + + footer = main_screen.query_one(Footer) + ctrl_t_key = None + for key in footer.query(FooterKey): + if key.key == "ctrl+t": + ctrl_t_key = key + break + assert ctrl_t_key is not None + await pilot.click(ctrl_t_key) + await pilot.pause() + + assert len(app.edited_calls) == 1 + assert app.edited_calls[0][0] == "associations_table"