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

Grey out linting errors button when inactive #287

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Changes from all commits
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
6 changes: 5 additions & 1 deletion dtool_lookup_gui/views/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,9 @@ def __init__(self, *args, **kwargs):
style_context = self.curr_page_button.get_style_context()
style_context.add_class('suggested-action')

# initialize linting_problems cache
# Initialize linting_problems cache and make the linting_errors_button non-clickable (greyed out)
self.linting_problems = None
self.linting_errors_button.set_sensitive(False)

# utility methods
def refresh(self):
Expand Down Expand Up @@ -800,6 +801,7 @@ def on_save_metadata_button_clicked(self, widget):
start_iter, end_iter = text_buffer.get_bounds()
yaml_content = text_buffer.get_text(start_iter, end_iter, True)


# Check the state of the linting switch before linting
if settings.yaml_linting_enabled:
# Lint the YAML content if the above condition wasn't met (i.e., linting is enabled)
Expand All @@ -808,6 +810,7 @@ def on_save_metadata_button_clicked(self, widget):
_logger.debug(str(self.linting_problems))
total_errors = len(self.linting_problems)
if total_errors > 0:
self.linting_errors_button.set_sensitive(True)
if total_errors == 1:
error_message = f"YAML Linter Error:\n{str(self.linting_problems[0])}"
else:
Expand All @@ -820,6 +823,7 @@ def on_save_metadata_button_clicked(self, widget):
else:
# if linting is turned off, just save as is
self.linting_errors_button.set_label("YAML linting turned off.")

_logger.debug("YAML linting turned off.")
self.dataset_list_box.get_selected_row().dataset.put_readme(yaml_content)

Expand Down
Loading