Skip to content

Commit

Permalink
fix(jans-cli-tui): container focus on page enter (#4564)
Browse files Browse the repository at this point in the history
* fix(jans-cli-tui): don't hide cursor on JansVerticalNav

* fix(jans-cli-tui): container focus on page enter
  • Loading branch information
devrimyatar authored Apr 12, 2023
1 parent 25dfe69 commit 41147ef
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
7 changes: 6 additions & 1 deletion jans-cli-tui/cli_tui/plugins/010_auth_server/agama.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(

self.app = app
self.data = []
self.first_enter = False

self.working_container = JansVerticalNav(
myparent=app,
Expand Down Expand Up @@ -63,6 +64,7 @@ def __init__(
self.main_container.on_page_enter = self.on_page_enter

def on_page_enter(self) -> None:
self.first_enter = True
self.get_agama_projects()

def display_config(self, event):
Expand Down Expand Up @@ -247,7 +249,10 @@ def update_agama_container(self, start_index=0, search_str=''):
for datum in data_display[start_index:start_index+self.app.entries_per_page]:
self.working_container.add_item(datum)

self.app.layout.focus(self.working_container)
if not self.first_enter:
self.app.layout.focus(self.working_container)

self.first_enter = False


async def get_projects_coroutine(self, search_str=''):
Expand Down
13 changes: 7 additions & 6 deletions jans-cli-tui/cli_tui/plugins/010_auth_server/authn.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def on_cli_object_ready(self):
self.app.create_background_task(self.get_default_acr())


def on_page_enter(self) -> None:
def on_page_enter(self, focus_container=False) -> None:


def populate_acr_list():
Expand Down Expand Up @@ -86,7 +86,8 @@ def populate_acr_list():


self.acr_container.all_data = self.acr_container.data[:]
self.app.layout.focus(self.acr_container)
if focus_container:
self.app.layout.focus(self.acr_container)


async def coroutine():
Expand All @@ -109,7 +110,7 @@ async def coroutine():
result = response.json()
if result.get('entriesCount', 0) > 0:
for scr in result['entries']:
if scr.get('enabled'):
if scr.get('enabled') and scr not in self.auth_scripts:
self.auth_scripts.append(scr)
self.app.stop_progressing()
populate_acr_list()
Expand Down Expand Up @@ -239,7 +240,7 @@ async def coroutine():
if data['default'] and data['default'] != data['configId']:
self.save_default_acr(data['configId'])
else:
self.on_page_enter()
self.on_page_enter(focus_container=True)

asyncio.ensure_future(coroutine())

Expand Down Expand Up @@ -390,7 +391,7 @@ async def coroutine(config_id):
self.app.start_progressing(_("Deleting Source LDAP..."))
await get_event_loop().run_in_executor(self.app.executor, self.app.cli_requests, cli_args)
self.app.stop_progressing()
self.on_page_enter()
self.on_page_enter(focus_container=True)

def do_delete_ldap_server(config_id, dialog):
asyncio.ensure_future(coroutine(config_id))
Expand All @@ -416,6 +417,6 @@ async def coroutine():
await get_event_loop().run_in_executor(self.app.executor, self.app.cli_requests, cli_args)
self.app.stop_progressing()
await self.get_default_acr()
self.on_page_enter()
self.on_page_enter(focus_container=True)

asyncio.ensure_future(coroutine())
2 changes: 1 addition & 1 deletion jans-cli-tui/cli_tui/wui_components/jans_vetrical_nav.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def create_window(self) -> None:
style='class:select-box',
height=D(preferred=len(self.data), max=len(self.data)),
cursorline=True,
always_hide_cursor=True,
#always_hide_cursor=True,
right_margins=[ScrollbarMargin(display_arrows=True)],
)
if self.jans_help:
Expand Down

0 comments on commit 41147ef

Please sign in to comment.