Skip to content

Commit

Permalink
fix: jans-cli-tui close dialog after updating client (ref: #3510)
Browse files Browse the repository at this point in the history
  • Loading branch information
devrimyatar committed Jan 9, 2023
1 parent 2c6dcd9 commit 25e0b7a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,9 @@ def save(self) -> None:
if ditem in self.data and self.data[ditem] is None:
self.data.pop(ditem)

close_me = True
if self.save_handler:
close_me = self.save_handler(self)
if close_me:
self.future.set_result(DialogResult.ACCEPT)
self.save_handler(self)


def cancel(self) -> None:
"""method to invoked when canceling changes in the dialog (Cancel button is pressed)
Expand Down
29 changes: 15 additions & 14 deletions jans-cli-tui/cli_tui/plugins/010_auth_server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,21 +688,22 @@ def save_client(self, dialog: Dialog) -> None:
_type_: bool value to check the status code response
"""

async def coroutine():
self.app.start_progressing(_("Saving clinet ..."))
operation_id='put-oauth-openid-client' if dialog.data.get('inum') else 'post-oauth-openid-client'
cli_args = {'operation_id': operation_id, 'data': dialog.data}
response = await self.app.loop.run_in_executor(self.app.executor, self.app.cli_requests, cli_args)

dialog.future.set_result(DialogResult.ACCEPT)
self.app.stop_progressing()

if response.status_code in (200, 201):
self.oauth_update_clients()
else:
self.app.show_message(_("Error!"), _("An error ocurred while saving client:\n") + str(response.text), tobefocused=self.app.center_frame)

asyncio.ensure_future(coroutine())

response = self.app.cli_object.process_command_by_id(
operation_id='put-oauth-openid-client' if dialog.data.get('inum') else 'post-oauth-openid-client',
url_suffix='',
endpoint_args='',
data_fn='',
data=dialog.data
)

self.app.stop_progressing()
if response.status_code in (200, 201):
self.oauth_update_clients()
return None

self.app.show_message(_("Error!"), _("An error ocurred while saving client:\n") + str(response.text))

def save_scope(self, dialog: Dialog) -> None:
"""This method to save the client data to server
Expand Down

0 comments on commit 25e0b7a

Please sign in to comment.