Skip to content

Conversation

@jasonyuezhang
Copy link
Owner

Copied PR


Copied from getsentry#104133
Original PR: getsentry#104133

Comment on lines +83 to +90
const hasEditAccess =
checkUserHasEditAccess(
currentUser,
userTeams,
organization,
dashboardPermissions,
dashboardCreator
) && !isPrebuiltDashboard;

Choose a reason for hiding this comment

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

[BestPractice]

The hasEditAccess logic now prevents editing on prebuilt dashboards by adding && !isPrebuiltDashboard to the permission check. This implementation looks correct and follows the existing permission pattern.

However, consider if this is the right place for this check. Currently, prebuilt dashboards will show as having edit access in the checkUserHasEditAccess function but then have it revoked at the component level. If prebuilt dashboards should never be editable regardless of user permissions, it might be cleaner to include this check inside the checkUserHasEditAccess utility function itself.

Current approach:

const hasEditAccess =
  checkUserHasEditAccess(...) && !isPrebuiltDashboard;

Alternative approach (in checkUserHasEditAccess function):

export function checkUserHasEditAccess(
  currentUser: User,
  userTeams: Team[],
  organization: Organization,
  dashboardPermissions?: DashboardPermissions,
  dashboardCreator?: User,
  isPrebuiltDashboard?: boolean
): boolean {
  if (isPrebuiltDashboard) {
    return false;
  }
  // ... rest of existing logic
}

This would centralize the permission logic and make it clear that prebuilt dashboards are never editable.

Context for Agents
The `hasEditAccess` logic now prevents editing on prebuilt dashboards by adding `&& !isPrebuiltDashboard` to the permission check. This implementation looks correct and follows the existing permission pattern.

However, consider if this is the right place for this check. Currently, prebuilt dashboards will show as having edit access in the `checkUserHasEditAccess` function but then have it revoked at the component level. If prebuilt dashboards should never be editable regardless of user permissions, it might be cleaner to include this check inside the `checkUserHasEditAccess` utility function itself.

Current approach:
```typescript
const hasEditAccess =
  checkUserHasEditAccess(...) && !isPrebuiltDashboard;
```

Alternative approach (in `checkUserHasEditAccess` function):
```typescript
export function checkUserHasEditAccess(
  currentUser: User,
  userTeams: Team[],
  organization: Organization,
  dashboardPermissions?: DashboardPermissions,
  dashboardCreator?: User,
  isPrebuiltDashboard?: boolean
): boolean {
  if (isPrebuiltDashboard) {
    return false;
  }
  // ... rest of existing logic
}
```

This would centralize the permission logic and make it clear that prebuilt dashboards are never editable.

File: static/app/views/dashboards/sortableWidget.tsx
Line: 90

@jasonyuezhang
Copy link
Owner Author

/propel review

4 similar comments
@jasonyuezhang
Copy link
Owner Author

/propel review

@jasonyuezhang
Copy link
Owner Author

/propel review

@jasonyuezhang
Copy link
Owner Author

/propel review

@jasonyuezhang
Copy link
Owner Author

/propel review

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.

3 participants