Skip to content

Add shareable dashboard functionality#3551

Merged
Simrayz merged 19 commits intomasterfrom
feat/2344-add-shareable-dashboards
Oct 6, 2025
Merged

Add shareable dashboard functionality#3551
Simrayz merged 19 commits intomasterfrom
feat/2344-add-shareable-dashboards

Conversation

@Simrayz
Copy link
Copy Markdown
Contributor

@Simrayz Simrayz commented Sep 22, 2025

Scope and purpose

This PR will resolve #2344 when all dependent PRs are merged.
This PR resolves #3554 in itself.

Dependent PRs: #3553, #3557 (see dependency graph)

  graph LR;
      A(#3551: Base PR)
      B(#3553: Loading and subscription - merged)
      C(#3557: Dashboard search - merged)
      D(#3559: Export and import - merged)
      A-->B;
      B-->C;
      B-->D;
Loading

This PR adds support for sharing dashboards in NAV by modifying the account_dashboard table and adds a new account_dashboard_subscription table to hold account-dashboard joins.. A dashboard owner can set the dashboard as shared, which in turn will make it visible to other accounts in the follow-up PR.

This pull request

  • Adds an is_shared property to the AccountDashboard model
  • Adds new AccountDashboardSubscription to support account subscriptions on a dashboard
  • Adds two new methods to the AccountDashboard model
    • can_edit(self, account): Used in views to determine if the request account has edit rights.
    • is_subscribed(self, account): Used in views to determine if the request account is subscribed to the dashboard.
  • Adds a "Shared" section to the dashboard settings form
    • A shared dashboard shows a warning if the owner unchecks the shared checkbox, as this will remove any existing subscriptions.

Screenshots

A new Sharing form has been added to dashboard settings

This form shows a currently unshared dashboard.

image

Unsharing a dashboard

Shared dashboard form Shared dashboard with "Share" unchecked
image image

Contributor Checklist

Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to NAV can be found in the
Hacker's guide to NAV.

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • Added/changed documentation
  • Linted/formatted the code with ruff, easiest by using pre-commit
  • The first line of the commit message continues the sentence "If applied, this commit will ...", starts with a capital letter, does not end with punctuation and is 50 characters or less long. See https://cbea.ms/git-commit/
  • This pull request is based on the correct upstream branch: For a patch/bugfix affecting the latest stable version, it should be based on that version's branch (<major>.<minor>.x). For a new feature or other additions, it should be based on master.
  • If applicable: Created new issues if this PR does not fix the issue completely/there is further work to be done
  • If this results in changes in the UI: Added screenshots of the before and after
  • If this adds a new Python source code file: Added the boilerplate header to that file

@Simrayz Simrayz self-assigned this Sep 22, 2025
@Simrayz Simrayz force-pushed the feat/2344-add-shareable-dashboards branch from 1c1060e to 438483a Compare September 22, 2025 12:14
@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 22, 2025

Test results

    27 files      27 suites   45m 1s ⏱️
 2 586 tests  2 586 ✅ 0 💤 0 ❌
19 078 runs  19 078 ✅ 0 💤 0 ❌

Results for commit d43d895.

♻️ This comment has been updated with latest results.

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.21%. Comparing base (c802780) to head (d43d895).
⚠️ Report is 311 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3551      +/-   ##
==========================================
+ Coverage   62.11%   62.21%   +0.10%     
==========================================
  Files         611      611              
  Lines       44880    44939      +59     
  Branches       43       43              
==========================================
+ Hits        27876    27960      +84     
+ Misses      16994    16969      -25     
  Partials       10       10              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Simrayz Simrayz force-pushed the feat/2344-add-shareable-dashboards branch 2 times, most recently from 868fce8 to 21864ab Compare September 23, 2025 13:15
@Simrayz Simrayz changed the title Feat/2344 add shareable dashboards Add shareable dashboard functionality Sep 23, 2025
@Simrayz Simrayz force-pushed the feat/2344-add-shareable-dashboards branch from 21864ab to 0c69b79 Compare September 23, 2025 14:53
@Simrayz Simrayz force-pushed the feat/2344-add-shareable-dashboards branch from 0c69b79 to 6549854 Compare September 24, 2025 07:32
@Simrayz Simrayz requested a review from a team September 24, 2025 07:34
@Simrayz Simrayz marked this pull request as ready for review September 24, 2025 07:34
Copy link
Copy Markdown
Contributor

@hmpf hmpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question, one suggestion, the question is more important.

@Simrayz Simrayz force-pushed the feat/2344-add-shareable-dashboards branch 2 times, most recently from 1821850 to cde7e99 Compare September 25, 2025 07:37
Copy link
Copy Markdown
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM

Edit: Though, while reviewing dependent PRs, I noticed there is no user feedback when the "Save sharing settings" button is clicked. How do I know the save was successful? If I turn off the web server, there is still no feedback that the request failed.

@Simrayz Simrayz force-pushed the feat/2344-add-shareable-dashboards branch 2 times, most recently from 959b877 to 82fc7f9 Compare September 26, 2025 10:42
@Simrayz
Copy link
Copy Markdown
Contributor Author

Simrayz commented Sep 26, 2025

@lunkwill42 Added a few fixups with changes:

  • Added a proper feedback message after changing the "shared" setting. I also fixed a bug where the feedback for name changes was rendered inside the settings trigger (oops). It now properly adds "Dashboard name changed" to the bottom of the popover. Changing the shared setting replaces the message.
  • Adjusted tests according to your suggestions.
  • Added a new can_access method to AccountDashboard, and modified can_edit to return False if user is anonymous (as pointed out by @hmpf)

All PRs have been rebased to match these changes. See #3553 to re-test dashboard access when anonymous.

@Simrayz Simrayz requested review from hmpf and lunkwill42 September 26, 2025 10:47
Copy link
Copy Markdown
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much nicer now :)

Only a single nitpick so far: Much better feedback about changes taking place when I click the share-button now. But the new "share badge" should also appear when I do this. Now it appears only if I switch to a different dashboard and back again, which is a bit confusing.

@Simrayz Simrayz force-pushed the feat/2344-add-shareable-dashboards branch from 4fff2e7 to d43d895 Compare October 6, 2025 07:26
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Oct 6, 2025

@Simrayz Simrayz merged commit 12c53ba into master Oct 6, 2025
19 checks passed
@Simrayz Simrayz deleted the feat/2344-add-shareable-dashboards branch October 6, 2025 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for setting dashboards as shared Add shareable dashboards to NAV

4 participants