OCI Policy Analysis Presentation

Desktop UI

The desktop reference lists the maintained tab and reusable table modules. UI callbacks and private widget helpers remain implementation details.

class oci_policy_analysis.presentation.desktop.base_tab.BaseUITab(*args: Any, **kwargs: Any)[source]

Bases: Frame

Provide shared help, documentation-link, and timing behavior for UI tabs.

DOCROOT = 'https://agregory999.github.io/oci-policy-analysis'

Create a styled label that opens a documentation URL when clicked.

Open a link in the user’s web browser. If browser opening fails, display the URL in a messagebox.

apply_settings(context_help: bool, font_size: str)[source]

Apply application settings for context help and font size.

Parameters:
  • context_help (bool) – Whether to show context (page) help.

  • font_size (str) – Font size as ‘Small’, ‘Medium’, etc.

set_page_help_text(text: str, temporary: bool = False)[source]

Sets help label text, ensuring the area always shows (at least) 2 lines for layout stability.

add_context_help(widget, message: str, restore_message: str | None = None)[source]

Adds hover-based context help to given widget. If restore_message is not given, restores self.default_help_text.

Set or change the persistent permalink in the Page Help area (right 10%).

update_page_help_visibility()[source]

Show/hide (and re-pin) the page help frame at the top of the tab. Always keeps help fixed before all other widgets—never at the bottom.

refresh_context_help()[source]

Re-applies page help styles/colors after theme/font change or context visibility event.

timed_step(label, fn, *args, **kwargs)[source]

Run a callable, log its elapsed time, and return its result.

class oci_policy_analysis.presentation.desktop.settings_tab.SettingsTab(*args: Any, **kwargs: Any)[source]

Bases: BaseUITab

Settings Tab for OCI Policy Analysis UI. Allows configuration of tenancy, profile, MCP server, and AI settings. All tenancy data is loaded via this tab.

refresh_context_help()[source]

Refresh style/visibility of Page Help label. (SettingsTab extension point)

refresh_cache_list()[source]

Update the cache list OptionMenu in the Settings tab to reflect the current state, preserving selection.

apply_config()[source]

Apply changes to Model ID and Endpoint in AI client.

class oci_policy_analysis.presentation.desktop.policies_tab.PoliciesTab(*args: Any, **kwargs: Any)[source]

Bases: BaseUITab

Tab for displaying and filtering OCI policies.

  • Supports searching and filtering by multiple criteria (OR via | character in fields).

  • Includes saved search/load, policy export, and summary displays.

  • Context help is unified and appears at the top, per app setting.

  • Provides right-click analysis and integration with other app tabs.

clear_policy_filters()[source]
export_policy_to_csv()[source]
populate_data(*args)[source]

Populate the policy output using per-step timing ala BaseUITab.timed_step (sub-timings).

update_policy_output(*args, **kwargs)[source]

[DEPRECATED] Use populate_data instead for sub-timing and improved logging.

enable_widgets_after_load()[source]

Enable widgets after load.

class oci_policy_analysis.presentation.desktop.policy_browser_tab.PolicyBrowserTab(*args: Any, **kwargs: Any)[source]

Bases: BaseUITab

Tab for browsing all compartments, policies, and policy statements in a JSON-style tree. Hierarchy: compartments → policies → statements (with statement text). No filtering or distinction of policy type; all statements appear under their policy.

Perform case-insensitive search with highlighting and rebuild tree.

Clear search box and show full unfiltered tree.

post_load_update_ui()[source]

Populate Policy Browser data widgets after repository data has been loaded.

refresh_tree()[source]

Refresh the compartment/policy/statement tree from latest repo data.

expand_collapse_all(expand: bool = True)[source]

Expand or collapse all nodes in the tree.

expand_collapse_compartments(only=True, expand=True)[source]

Expand/collapse all compartments, but collapse their Policies nodes and below.

class oci_policy_analysis.presentation.desktop.policy_recommendations_tab.PolicyRecommendationsTab(*args: Any, **kwargs: Any)[source]

Bases: BaseUITab

Unified UI tab for displaying Oracle Cloud Policy Recommendations and analytics.

STATEMENTS_PER_COMPARTMENT_LIMIT = 500
populate_data()[source]

Called after policy analysis/intelligence is refreshed. Reload all analytics/tables, using timing. Also launches OCI tenancy limits fetch (policies-count, statements-count).

update_limits_tab_output()[source]
fetch_tenancy_policy_statement_limits()[source]
reload_all_analytics()[source]
on_enabled_cleanup_checks_changed()[source]

Called when Settings > Recommendation/Consolidation cleanup check toggles change. Re-runs analytics with new checks.

update_policy_risk_tab_output()[source]

Aggregates risk per policy (from statement risk) and updates the table. Adds globally normalized risk and supporting stats.

update_risk_tab_output()[source]

Update statement risk table: only allow statements, columns: Policy Path, Effective Path, Score, Relative Risk, Risk Notes, Statement Text (truncated).

update_overlap_tab_output()[source]
update_consolidation_tab_output()[source]

Refresh the consolidation tab’s data after analytics reload.

update_cleanup_tab_output()[source]

Refresh the cleanup tab’s data after analytics reload.

apply_settings(context_help: bool, font_size: str)[source]

Apply context help and font size settings for the recommendations tab.

class oci_policy_analysis.presentation.desktop.workload_principals_tab.WorkloadPrincipalsTab(*args: Any, **kwargs: Any)[source]

Bases: BaseUITab

Display workload principals and their associated policy statements.

update_principals_sheets(*args)[source]

Update view: show or hide tables depending on dropdown, update data in both tables.

  • In DG mode, show both tables; in other principal modes, show only matching policy table, hiding DG table.

  • Refresh table data for all cases.

  • Text filter field applies to Matching Rule (DG) or Policy Statement (any-user modes).

apply_settings(context_help: bool, font_size: str)[source]

Update help area and style on global context help and font size change (from main.py).

class oci_policy_analysis.presentation.desktop.dynamic_group_tab.DynamicGroupsTab(*args: Any, **kwargs: Any)[source]

Bases: BaseUITab

Dynamic Groups Tab for OCI Policy Analysis UI.

Browse, filter, and analyze dynamic groups and related policies. Select dynamic groups to reveal matching policy statements below.

set_show_all_data(checked: bool | None = None) None[source]

Sync table display columns with the Show all Data checkbox.

If checked is provided, force the checkbox to that state. If checked is None, rely on the current BooleanVar value (used when invoked by the Checkbutton command, since Tkinter has already toggled it).

Set the DG OCID filter from a list of OCIDs and refresh the table.

Intended for cross-tab integrations (e.g., Policies tab right-click actions) to programmatically focus on one or more dynamic groups by OCID. OCIDs are joined with | to leverage existing OR semantics.

populate_data() None[source]

Populate / refresh Dynamic Groups tab data after a load.

This is the single entry point used by the main application after repository data is (re)loaded. It enables filter controls and refreshes the dynamic groups table using the current filter state.

apply_settings(context_help: bool, font_size: str)[source]

Update context help and font settings (called globally from main app).

enable_controls()[source]

Called from main app when data is loaded to enable the controls

class oci_policy_analysis.presentation.desktop.users_tab.UsersTab(*args: Any, **kwargs: Any)[source]

Bases: BaseUITab

Users Tab for OCI Policy Analysis UI. Allows selection of Groups or Users, and displays associated policy statements. Supports filtering and detailed policy statement views.

populate_data()[source]

Populate / refresh Users tab data after a tenancy or cache load.

This is the single entry point used by the main application after repository data is (re)loaded. It ensures that:

  • The GROUPS/USERS dropdown reflects the current repository state (including load_all_users and whether users were actually loaded).

  • The top tables (groups/users) and counts are refreshed using the current search text and selection.

Behavior-wise this is equivalent to the previous sequence of calls from main:

  • update_user_analysis_output()

  • update_users_dropdown_options()

set_show_all_data(checked=None)[source]

Sync table display columns with the Show all Data checkbox.

If checked is provided, force the checkbox to that state. If checked is None, rely on the current BooleanVar value (used when invoked by the Checkbutton command, since Tkinter has already toggled it).

sync_load_all_users_checkbox()[source]

Ensures the checkbox/UI for load_all_users matches the repository state. Should be called after loading data/cache if UI lags behind data model.

should_show_users_option()[source]

Returns True if the USERS option should be available in the dropdown, i.e., only if load_all_users is True AND there are users loaded.

update_users_dropdown_options()[source]

Refresh the GROUPS/USERS dropdown based on current repo state.

This should be called after any tenancy/repository load and is safe to invoke at other times. The method also forces a refresh of the table below by calling update_user_analysis_output() at the end so that the current selection (GROUPS vs USERS) and search term are immediately reflected in the UI.

update_user_analysis_output()[source]

Update the top user/group listing and associated counters.

This method is responsible for:

  • Updating the Total Groups / Total Users labels from the underlying repository.

  • Displaying either the groups table or the users table, depending on the current value of self.groups_option_var ('GROUPS' or 'USERS').

  • Applying the search filter from self.user_group_search using GroupSearch / UserSearch.

It does not compute policy statements; those are handled by _update_user_analysis_policy_output() and update_user_policy_output().

update_user_policy_output()[source]

Refresh the policy statements table and related labels.

This uses the pre-computed self.filtered_policies and self.selected_groups_for_table that are maintained by _update_user_analysis_policy_output() when the selection in the groups/users tables changes.

Responsibilities:

  • Toggle between basic vs expanded policy columns based on the Parsed Output checkbox (self.chk_show_expanded).

  • Optionally include “any-user” / “any-group” statements when the corresponding checkbox is enabled.

  • Push the final policy list into self.users_policy_table and update the Selected Groups helper table and the Policy Statements (Filtered) count label.

on_load_all_users_setting_changed(enabled: bool)[source]

Called if settings change for Load All Users to refresh user/group options and UI. Synchronizes between UI and model: both directions.

class oci_policy_analysis.presentation.desktop.permissions_report_tab.PermissionsReportTab(*args: Any, **kwargs: Any)[source]

Bases: BaseUITab

Tab for displaying permissions by effective compartment and subject in a treeview, with context help.

enable_widgets_after_load()[source]
apply_settings(context_help: bool, font_size: str)[source]

Apply main settings for context help and font size.

populate_tree()[source]
on_tree_selection(event)[source]
expand_all()[source]
collapse_all()[source]
export_to_json()[source]
class oci_policy_analysis.presentation.desktop.historical_tab.HistoricalTab(*args: Any, **kwargs: Any)[source]

Bases: BaseUITab

Compare two cached tenancy states and display policy and identity changes.

populate_cache_dropdowns(tenancy_name=None)[source]
class oci_policy_analysis.presentation.desktop.simulation_tab.SimulationTab(*args: Any, **kwargs: Any)[source]

Bases: BaseUITab

UI Tab for Policy Simulation:
  • Section 1: Compartment and Principal chooser (dropdowns, load button)

  • Section 2: Applies policy statement preview & where-fields preview

  • Section 3: API Operation chooser, dynamic where inputs, simulate button

  • Section 4: Results/tracing output

All major user actions log info/debug for workflow tracking.

populate_data()[source]

Populate Simulation tab data once a tenancy is loaded.

This is invoked from App._post_load_update_ui, after policy_compartment_analysis has a concrete tenancy_ocid. At this point we can safely hydrate the simulation engine’s prospective (what-if) statements from settings for the active tenancy.

refresh_dropdowns()[source]

Refreshes the dropdowns for compartment and principals.

  • If users are not loaded, will hide/remove “user” as a principal type.

on_load_all_users_setting_changed(enabled: bool)[source]

Called if settings change for Load All Users to refresh simulation principal types and UI.

apply_settings(context_help: bool, font_size: str)[source]

Apply main settings for context help and font size.

load_statements()[source]

Loads and displays policy statements for the currently selected compartment and principal.

Filters policy statements based on selection; populates the UI preview table and enables downstream simulation controls.

Returns:

None

add_prospective_statement_from_builder(statement_text: str, compartment_path: str | None = None, description: str | None = None) None[source]

Add a new prospective statement generated by the Tag-based builder.

This now delegates persistence to the tenancy-scoped ProspectiveStatementsService when available, or falls back to the simulation engine’s in-memory list. The Simulation tab itself remains read-only and simply refreshes its prospective preview.

open_prospective_editor(*_)[source]

Open a simple CRUD dialog for managing prospective policy statements.

Users can add/edit/delete “what-if” statements that will be evaluated alongside real tenancy policies during simulation. Only statements applicable to the current compartment/principal will appear in the Applicable Policy Statements table, but this editor allows defining prospective statements anywhere in the tenancy.

load_where_fields(checked_rows=None)[source]

Extracts and displays dynamic where clause input fields based on the selected statements.

Parses checked statements for required where-clause variables, then renders appropriate Tkinter fields for user input.

Returns:

None

on_trace_history_selected(event=None)[source]

Displays simulation results for the selected simulation trace entry.

Parameters:

event (tk.Event, optional) – Optional Tkinter event object from dropdown selection.

Returns:

None

run_simulation()[source]

Runs a policy simulation with the current selections (basic mode).

Triggers the simulation engine and displays allow/deny result and final permission set.

Returns:

None

class oci_policy_analysis.presentation.desktop.condition_tester_tab.ConditionTesterTab(*args: Any, **kwargs: Any)[source]

Bases: BaseUITab

UI Tab for interactively testing OCI Condition (Where) clauses using an AST simulation (ANTLR). Allows user to provide a where clause and simulated environment variables, and see evaluation/log details.

apply_settings(context_help: bool, font_size: str)[source]

Apply main settings for context help and font size.

set_clause_text(text)[source]

Programmatically set the contents of the where clause input.

class oci_policy_analysis.presentation.desktop.data_table.DataTable(*args: Any, **kwargs: Any)[source]

Bases: Frame

A Tkinter table widget with alternating row colors, sortable columns, resizable columns, show/hide columns, row selection with callback, full space utilization, cell copy functionality, and row context menu.

Note: for checklist-style tables with checkboxes and custom action button, see the more generic CheckboxTable class also defined below.

Note: ttk.Treeview does not natively support row-specific heights. This widget adjusts the whole table’s row height to fit the largest visible explicit newline count in the current row set, capped to keep tables usable. Text does not wrap automatically.

parent

The parent Tkinter widget.

columns

List of all possible column names.

display_columns

List of initially displayed column names.

data

List of dictionaries containing row data.

sortable

Enable/disable column sorting (default: True).

row_colors

Tuple of colors for alternating rows (default: white, light gray).

selection_callback

Optional function to call with selected rows (default: None). Can be omitted if no callback is needed.

multi_select

Enable/disable multi-row selection (default: False).

column_widths

Dictionary mapping column names to initial widths (default: None, uses 100 for all columns).

row_context_menu_callback

Optional function to create a context menu for a row (default: None).

set_multi_select(multi_select: bool) None[source]

Set single or multi-select mode.

set_display_columns(display_columns: list[str]) None[source]

Set the displayed columns externally.

update_data(new_data: list[dict]) None[source]

Update table data and refresh display. Re-applies current sort if one was set.

apply_theme(theme: str) None[source]

Apply light or dark theme colors to the Treeview. :param theme: ‘light’ or ‘dark’

class oci_policy_analysis.presentation.desktop.data_table.CheckboxTable(*args: Any, **kwargs: Any)[source]

Bases: Frame

A DataTable-based Tkinter widget for a table with a first-column checkbox and resizable columns, alternating backgrounds, and an action button.

Optional display_columns restricts which columns are shown (subset of columns; the checkbox column is “☑”). Optional sortable enables column header sorting on the inner DataTable (default False).

get_checked_rows()[source]
update_data(data)[source]

Web UI