Insights/user permissions
Created by: coury-clark
Closes https://github.com/sourcegraph/sourcegraph/issues/24438
To summarize this PR, previously any backend insights were unrestricted based on user / org permissions, and the GraphQL API would return all insights to all users. In preparation for building an API for insights and dashboards, we obviously had to solve this problem.
- Permission grant associations for insight views to user, org, and global
- Eventually this will get partitioned into more granular permission levels, but for now everyone is assumed to have read / write to match feature parity of frontend insights.
- Insights defined in a users private settings will get associated with that user ID
- Insights defined in an org will get associated with that org ID, and any user in that org can view them
- The sync job from settings -> the database had to be updated to capture permissions updates as insights move between dashboards.
- The sync job will now just optimistically delete and replace any insight view that is defined in settings. This will still leave dangling insights that have been removed from the dashboard, but that's okay for the interm without an API.