Skip to content

Remove conditional UI views#914

Closed
jtdub wants to merge 3 commits intodevelopfrom
remove-conditional-ui-views
Closed

Remove conditional UI views#914
jtdub wants to merge 3 commits intodevelopfrom
remove-conditional-ui-views

Conversation

@jtdub
Copy link
Copy Markdown
Contributor

@jtdub jtdub commented Mar 26, 2025

What's Changed

Addresses the requirement of #842 to remove conditional UI views when compliance, intended, or backup settings are enabled / disabled.

These items can be hidden from the UI with saved UI views. However, there are scenarios where displaying that information is necessary, even if the setting is disabled. For example, we have a job that backs up devices through a separate process and updates the backup timestamps in the ORM. Since the built-in golden config setting is disabled, the ability to see the last time backups were run is unavailable by default. This adjustment ensures that view is still accessible.

To Do

  • Explanation of Change(s)

@jtdub jtdub marked this pull request as draft March 26, 2025 18:53
@jtdub jtdub marked this pull request as ready for review March 27, 2025 18:22
@itdependsnetworks
Copy link
Copy Markdown
Contributor

We just need to test locally, will try to over next two weeks.

@itdependsnetworks
Copy link
Copy Markdown
Contributor

I do notice there is logic that needs to be removed in tables.py.

@itdependsnetworks
Copy link
Copy Markdown
Contributor

Remove:

  • def get_extra_context(self, request, instance=None, **kwargs):
    """Get extra context data."""
    context = super().get_extra_context(request, instance)
    context["compliance"] = constant.ENABLE_COMPLIANCE
    context["backup"] = constant.ENABLE_BACKUP
    context["intended"] = constant.ENABLE_INTENDED
    jobs = []
    jobs.append(["BackupJob", constant.ENABLE_BACKUP])
    jobs.append(["IntendedJob", constant.ENABLE_INTENDED])
    jobs.append(["ComplianceJob", constant.ENABLE_COMPLIANCE])
  • jobs.py in general, including
    if constant.ENABLE_BACKUP and job_name == "nautobot_golden_config.jobs.BackupJob":
    repo_types.extend(["backup_repository"])
    if constant.ENABLE_INTENDED and job_name == "nautobot_golden_config.jobs.IntendedJob":
    repo_types.extend(["jinja_repository", "intended_repository"])
    if constant.ENABLE_COMPLIANCE and job_name == "nautobot_golden_config.jobs.ComplianceJob":
    repo_types.extend(["intended_repository", "backup_repository"])
    if "All" in job_name:
    repo_types.extend(["backup_repository", "jinja_repository", "intended_repository"])
  • tables.py in general, including
    if ENABLE_BACKUP:
    active_fields.append("backup_last_success_date")
    if ENABLE_INTENDED:
    active_fields.append("intended_last_success_date")
    if ENABLE_COMPLIANCE:
    active_fields.append("compliance_last_success_date")
  • datasource.py in general including
    from nautobot_golden_config.utilities.constant import ENABLE_BACKUP, ENABLE_COMPLIANCE, ENABLE_INTENDED
  • remove from adr:
    ## Dynamic Application Features
    There are features within the application that can be turned on/off for backup, compliance, and intended. When they are toggled, this will update what is shown in:
    - Navigation
    - Jobs
    - Data Sources
    - Tables
    - Template Contents
    This is generally handled with a pattern similar to:
    ```python
    jobs = []
    if ENABLE_BACKUP:
    jobs.append(BackupJob)
    if ENABLE_INTENDED:
    jobs.append(IntendedJob)
    if ENABLE_COMPLIANCE:
    jobs.append(ComplianceJob)
    jobs.extend([AllGoldenConfig, AllDevicesGoldenConfig])
    ```

@jtdub jtdub force-pushed the remove-conditional-ui-views branch from a894c2b to 90caf91 Compare June 27, 2025 21:26
@github-actions
Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  nautobot_golden_config
  navigation.py
Project Total  

This report was generated by python-coverage-comment-action

@jeffkala
Copy link
Copy Markdown
Contributor

closing as its being covered in: #984

@jeffkala jeffkala closed this Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants