Skip to content

Commit

Permalink
fix: jans-cli DocString (ref: #2572)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelwahabAdam committed Nov 28, 2022
1 parent 752f141 commit 54cb7d5
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 156 deletions.
58 changes: 30 additions & 28 deletions jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
from collections import OrderedDict
from typing import Any
from urllib import response

from prompt_toolkit.layout.dimension import D
from prompt_toolkit.layout.containers import (
HSplit,
VSplit,
DynamicContainer,
Window
)
from prompt_toolkit.widgets import (
Box,
Button,
Label,
)
from prompt_toolkit.widgets import (
Button,
Frame,
Label,
RadioList,
TextArea,
CheckboxList,
Checkbox,
Dialog
)
from prompt_toolkit.lexers import PygmentsLexer, DynamicLexer

from prompt_toolkit.application.current import get_app
from asyncio import Future, ensure_future


import cli_style
from cli import config_cli
from utils.static import DialogResult
from utils.multi_lang import _
from wui_components.jans_dialog_with_nav import JansDialogWithNav
Expand All @@ -42,18 +26,10 @@
from wui_components.jans_vetrical_nav import JansVerticalNav
from view_uma_dialog import ViewUMADialog
import threading
from prompt_toolkit.widgets import (
Button,
Dialog,
VerticalLine,
)
from prompt_toolkit.layout.containers import AnyContainer
from prompt_toolkit.buffer import Buffer

from prompt_toolkit.formatted_text import AnyFormattedText
from prompt_toolkit.layout.dimension import AnyDimension
from typing import Optional, Sequence, Union
from typing import TypeVar, Callable
from typing import Optional, Sequence
from typing import Callable

import json

Expand Down Expand Up @@ -81,6 +57,7 @@ def __init__(
data (list): selected line data
button_functions (list, optional): Dialog main buttons with their handlers. Defaults to [].
save_handler (method, optional): handler invoked when closing the dialog. Defaults to None.
delete_UMAresource (method, optional): handler invoked when deleting UMA-resources
"""
super().__init__(parent, title, buttons)
self.save_handler = save_handler
Expand All @@ -92,6 +69,8 @@ def __init__(
self.create_window()

def save(self) -> None:
"""method to invoked when saving the dialog (Save button is pressed)
"""

self.data = self.make_data_from_dialog()
self.data['disabled'] = not self.data['disabled']
Expand Down Expand Up @@ -165,6 +144,9 @@ def save(self) -> None:
self.future.set_result(DialogResult.ACCEPT)

def cancel(self) -> None:
"""method to invoked when canceling changes in the dialog (Cancel button is pressed)
"""

self.future.set_result(DialogResult.CANCEL)

def create_window(self) -> None:
Expand Down Expand Up @@ -852,6 +834,12 @@ def search_uma_resources(
self,
tbuffer: Buffer,
) -> None:
"""This method handel the search for UMA resources
Args:
tbuffer (Buffer): Buffer returned from the TextArea widget > GetTitleText
"""

if not len(tbuffer.text) > 2:
self.myparent.show_message(_("Error!"), _("Search string should be at least three characters"))
return
Expand Down Expand Up @@ -961,10 +949,18 @@ def client_dialog_nav_selection_changed(
self,
selection: str
) -> None:
"""This method for client navigation bar when value is changed
Args:
selection (str): the New Value from the nav-bar
"""

self.left_nav = selection

def view_uma_resources(self, **params: Any) -> None:

"""This method view the UMA resources in a dialog
"""

selected_line_data = params['data'] ##self.uma_result
title = _("Edit user Data (Clients)")

Expand All @@ -973,5 +969,11 @@ def view_uma_resources(self, **params: Any) -> None:
self.myparent.show_jans_dialog(dialog)

def __pt_container__(self)-> Dialog:
"""The container for the dialog itself
Returns:
Dialog: The Edit Client Dialog
"""

return self.dialog

36 changes: 34 additions & 2 deletions jans-cli-tui/cli_tui/plugins/010_oxauth/edit_scope_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ def __init__(
"""init for `EditScopeDialog`, inherits from two diffrent classes `JansGDialog` and `DialogUtils`
DialogUtils (methods): Responsable for all `make data from dialog` and `check required fields` in the form for any Edit or Add New
JansGDialog (dialog): This is the main dialog Class Widget for all Jans-cli-tui dialogs except custom dialogs like dialogs with navbar
Args:
Args:
parent (widget): This is the parent widget for the dialog, to access `Pageup` and `Pagedown`
title (str): The Main dialog title
data (list): selected line data
Expand All @@ -80,6 +81,9 @@ def __init__(
self.sope_type = self.data.get('scopeType') or 'oauth'

def save(self) -> None:
"""method to invoked when saving the dialog (Save button is pressed)
"""

self.myparent.logger.debug('SAVE SCOPE')

data = {}
Expand All @@ -105,6 +109,9 @@ def save(self) -> None:
self.future.set_result(DialogResult.ACCEPT)

def cancel(self) -> None:
"""method to invoked when canceling changes in the dialog (Cancel button is pressed)
"""

self.future.set_result(DialogResult.CANCEL)

def create_window(self) -> None:
Expand Down Expand Up @@ -175,12 +182,27 @@ def scope_selection_changed(
self,
cb: RadioList,
) -> None:
"""This method for scope type selection set
Args:
cb (RadioList): the New Value from the nav-bar
"""

self.sope_type = cb.current_value

def get_named_claims(
self,
claims_list:list
) -> list:
"""This method for getting claim name
Args:
claims_list (list): List for Claims
Returns:
list: List with Names retlated to that claims
"""

try :
responce = self.myparent.cli_object.process_command_by_id(
operation_id='get-attributes',
Expand Down Expand Up @@ -208,7 +230,6 @@ def get_named_claims(

return calims_names


def delete_claim(self, **kwargs: Any) -> None:
"""This method for the deletion of claim
Expand Down Expand Up @@ -411,6 +432,11 @@ def search_claims(
self,
textbuffer: Buffer,
) -> None:
"""This method handel the search for claims and adding new claims
Args:
tbuffer (Buffer): Buffer returned from the TextArea widget > GetTitleText
"""

try :
responce = self.myparent.cli_object.process_command_by_id(
Expand Down Expand Up @@ -465,5 +491,11 @@ def add_selected_claims(dialog):
self.myparent.show_jans_dialog(dialog)

def __pt_container__(self) -> Dialog:
"""The container for the dialog itself
Returns:
Dialog: The Edit Scope Dialog
"""

return self.dialog

Loading

0 comments on commit 54cb7d5

Please sign in to comment.