Skip to content

Commit

Permalink
fix: jans-cli add Deletable for config-api roles (ref: #2965)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelwahabAdam committed Nov 12, 2022
1 parent 36a619c commit b940892
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions jans-cli-tui/cli_tui/plugins/040_config_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,16 @@ def edit_adminui_roles(self, **params: Any) -> None:
height=3,
style='class:dialog-titled-widget')

self.adminui_role_deletable = self.app.getTitledCheckBox(
"Deletable",
name='deletable',
checked= False,
jans_help= "Default to False",
style='class:outh-client-checkbox')

def save(dialog: Dialog) -> None:
desc = self.adminui_role_description.me.text
deletable = self.adminui_role_deletable.me.checked

# ------------------------------------------------------------#
# --------------------- Patch to server ----------------------#
Expand All @@ -384,7 +392,7 @@ def save(dialog: Dialog) -> None:
url_suffix='',
endpoint_args='',
data_fn='',
data={'role': '{}'.format(title), 'description': '{}'.format(desc)},
data={'role': '{}'.format(title), 'description': '{}'.format(desc), 'deletable':'{}'.format(deletable)},
)
else:
return
Expand All @@ -401,7 +409,7 @@ def save(dialog: Dialog) -> None:



body = HSplit([self.adminui_role_description])
body = HSplit([self.adminui_role_description,self.adminui_role_deletable])
buttons = [Button(_("Cancel")), Button(_("OK"), handler=save)]
dialog = JansGDialog(self.app, title=title, body=body, buttons=buttons, width=self.app.dialog_width-20)
self.app.show_jans_dialog(dialog)
Expand All @@ -411,7 +419,7 @@ def delete_adminui_roles(self, **kwargs: Any) -> None:

dialog = self.app.get_confirm_dialog(_("Are you sure want to delete adminui_roles :")+"\n {} ?".format(kwargs['selected'][0]))

async def coroutine():
async def coroutine(): ## Need to add editable
focused_before = self.app.layout.current_window
result = await self.app.show_dialog_as_float(dialog)
try:
Expand All @@ -420,7 +428,7 @@ async def coroutine():
self.app.stop_progressing()
self.app.layout.focus(self.app.center_frame)

if result.lower() == 'yes':
if result.lower() == 'yes': ## should we delete the main roles?!
result = self.app.cli_object.process_command_by_id(
operation_id='delete-adminui-role',
url_suffix='adminUIRole:{}'.format(kwargs ['selected'][0]),
Expand All @@ -429,7 +437,7 @@ async def coroutine():
data={}
)
self.app.stop_progressing()
self.get_adminui_roles()
self.get_adminui_roles()

return result ### TODO >> Role cannot be deleted. Please set ‘deletable’ property of role to true.

Expand Down

0 comments on commit b940892

Please sign in to comment.