Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validate config button #979

Merged
merged 4 commits into from
Dec 31, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add button
  • Loading branch information
jw3 committed Dec 30, 2023
commit 04785dfdeaf25531124d85cf068ef92761f42e5e
17 changes: 17 additions & 0 deletions fapolicy_analyzer/ui/config/config_admin_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ def __init__(self):
UIConnectedWidget.__init__(self, features=features)
actions = {
"config": [
UIAction(
name="Validate",
tooltip="Validate Config",
icon="emblem-default",
signals={"clicked": self.on_validate_clicked},
sensitivity_func=self.__config_unvalidated,
),
UIAction(
name="Save",
tooltip="Save Config",
Expand All @@ -67,6 +74,7 @@ def __init__(self):
UIPage.__init__(self, actions)
self.__loading_text: bool = False
self.__config_text: str = ""
self.__config_validated: bool = False
self.__changesets: Sequence[Changeset] = []
self.__modified_config_text: str = ""
self.__config_validated: bool = True
Expand Down Expand Up @@ -111,12 +119,21 @@ def on_save_clicked(self, *args):
self.__status_info.render_config_status(changeset.info())
overrideDialog.hide()

def on_validate_clicked(self, *args):
changeset, _ = self.__build_and_validate_changeset(show_notifications=False)
self.__status_info.render_config_status(changeset.info())
# dispatch to force toolbar refresh
dispatch(modify_config_text(self.__config_validated))

def __config_dirty(self) -> bool:
return (
bool(self.__modified_config_text)
and self.__modified_config_text != self.__config_text
)

def __config_unvalidated(self) -> bool:
return not self.__config_validated

def __build_and_validate_changeset(
self, show_notifications=True
) -> Tuple[ConfigChangeset, bool]:
Expand Down
Loading