From 25e0b7a2e2be19666aaf9a4c2aae1f81a1a9f80d Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Mon, 9 Jan 2023 20:26:02 +0300 Subject: [PATCH] fix: jans-cli-tui close dialog after updating client (ref: #3510) --- .../010_auth_server/edit_client_dialog.py | 6 ++-- .../cli_tui/plugins/010_auth_server/main.py | 29 ++++++++++--------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py index b4fc06134d6..495a03df1ac 100755 --- a/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/010_auth_server/edit_client_dialog.py @@ -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) diff --git a/jans-cli-tui/cli_tui/plugins/010_auth_server/main.py b/jans-cli-tui/cli_tui/plugins/010_auth_server/main.py index 1265e95a79e..c8282166c9b 100755 --- a/jans-cli-tui/cli_tui/plugins/010_auth_server/main.py +++ b/jans-cli-tui/cli_tui/plugins/010_auth_server/main.py @@ -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