Skip to content

insights: don't allow duplicate insights to be added to a dashboard

Administrator requested to merge insights/api/unique-attachments into main

Created by: CristinaBirkel

Closes #25924 (closed)

Description

Don't allow users to add the same insight to a dashboard if it's already there.

  1. If an API call is made to the addInsightViewToDashboard mutation that would result in this duplication, we return an error message saying that insight is already attached.
  2. The constraint is enforced at the database level as well.

Testing Steps

Try adding the same insight to a dashboard multiple times. It should only work the first time. Example query:

mutation {
  addInsightViewToDashboard(input: {
    dashboardId:"ZGFzaGJvYXJkOnsiSWRUeXBlIjoiY3VzdG9tIiwiQXJnIjoxNDZ9",
    insightViewId:"aW5zaWdodF92aWV3OiJzZWFyY2hJbnNpZ2h0cy5pbnNpZ2h0LmdvVGFrZTIi"
  }) {
    dashboard { id, title, views { nodes { id }}}
    }
}

Merge request reports

Loading