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

[BUG] Deleting one's default dashboard causes all "Add graph to dashboard" buttons to fail #3150

Open
lunkwill42 opened this issue Nov 4, 2024 · 1 comment
Assignees
Labels

Comments

@lunkwill42
Copy link
Member

lunkwill42 commented Nov 4, 2024

Describe the bug

All users are assigned an initial dashboard when they are created. This dashboard is assigned as their "default" dashboard, meaning this is the dashboard that will displayed first when visiting the NAV home page. The "default" dashboard can be reassigned at will by users.

However, a user will be able to delete their own default dashboard through the UI. When this happens, no dashboards will be assigned as the default for this user. Visiting the home page will still work, though it may be undefined which of the user's dashboards will now be displayed first.

Several parts of the NAV web UI that displays interactive graphs have a button labeled Add graph to dashboard. These are designed to add a graph to the user's default dashboard. However, when the user no longer has a dashboard marked as default, this XHR operation fails as the endpoint raises a 500 error and the button changes color to red (instead of green, which would indicate a successful operation).

To Reproduce

Steps to reproduce the behavior:

  1. Go to the NAV home page.
  2. Click on + to add a new dashboard, give it a name, such as foobar
  3. Click the gear symbol on the right in order to change the new dashboard's properties.
  4. Click the Set as default dashboard button to make this new dashboard the default dashboard.
  5. Click Delete dashboard to remove the new default foobar dashboard entirely.
  6. Browse any graph, such as the port traffic statistics of some port on some switch. Click the Add graph to dashboard button.
  7. Observe the button changing its color to red (with web developer tools open, you will see the background XHR request returns a 500 error)

Expected behavior

A user should have exactly one default dashboard and the user should be prevented from deleting their default dashboard.

Screenshots

image

Tracebacks

Internal Server Error: /navlets/add-user-navlet/graph/
Traceback (most recent call last):
  File "/opt/venvs/nav/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/opt/venvs/nav/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/source/python/nav/web/navlets/__init__.py", line 411, in add_user_navlet_graph
    add_navlet(
  File "/source/python/nav/web/navlets/__init__.py", line 285, in add_navlet
    dashboard = AccountDashboard.objects.get(account=account, is_default=True)
  File "/opt/venvs/nav/lib/python3.9/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/opt/venvs/nav/lib/python3.9/site-packages/django/db/models/query.py", line 435, in get
    raise self.model.DoesNotExist(
nav.models.profiles.AccountDashboard.DoesNotExist: AccountDashboard matching query does not exist.

Environment (please complete the following information):

  • NAV version installed: 5.11.0
@johannaengland
Copy link
Contributor

This fix will be split up into multiple PR's:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants