Skip to content

Conversation

@harshithadurai
Copy link
Contributor

@harshithadurai harshithadurai commented Nov 6, 2024

Addresses: #79828 and #79833
Corresponding backend change: #80136

  • Add teams as options to the EditAccessSelector component
  • Refactor use of isCreatorOnlyEditable to use isEditableByEveryone
  • Add updateDashbaordPermissions() function to make a separate PUT request to dashboard details endpoint that sends only the perms object
  • Rename 'Everyone' option to 'All users', and modify tests as well

Before:
Screenshot 2024-11-07 at 10 26 47 AM
After:
Screenshot 2024-11-07 at 10 25 38 AM

@harshithadurai harshithadurai requested a review from a team November 6, 2024 22:19
@harshithadurai harshithadurai marked this pull request as draft November 6, 2024 22:20
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 6, 2024
@codecov

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented Nov 7, 2024

Bundle Report

Changes will increase total bundle size by 43.95kB (0.14%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
app-webpack-bundle-array-push 31.92MB 43.95kB (0.14%) ⬆️

@harshithadurai harshithadurai marked this pull request as ready for review November 7, 2024 20:53
): Promise<DashboardDetails> {
const {projects, environment, permissions} = dashboard;
const data = {
projects,
Copy link
Contributor Author

@harshithadurai harshithadurai Nov 7, 2024

Choose a reason for hiding this comment

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

these fields seem to be necessary to pass some backend validation (projects and environment)

Copy link
Member

Choose a reason for hiding this comment

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

Let's just add a small note to explain why that's there. Just curious, what's the error you're seeing? Seems like it's something that we shouldn't be throwing

Copy link
Member

@narsaynorath narsaynorath left a comment

Choose a reason for hiding this comment

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

Just some comments on what I noticed from the different states! This is mostly good to go, just let me know if you want to work on those feedback items in this PR or in other PRs. None of my comments are blockers and can be iterated on. I'd like to see this land and we turn the feature flag back on for the team while this stuff gets worked out

): Promise<DashboardDetails> {
const {projects, environment, permissions} = dashboard;
const data = {
projects,
Copy link
Member

Choose a reason for hiding this comment

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

Let's just add a small note to explain why that's there. Just curious, what's the error you're seeing? Seems like it's something that we shouldn't be throwing

Comment on lines 185 to 187
return dashboard.permissions.isEditableByEveryone
? dashboard.permissions.isEditableByEveryone
: dashboard.createdBy?.id === currentUser.id;
Copy link
Member

Choose a reason for hiding this comment

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

Should this function also check if the user is also in the included teams?

Comment on lines 175 to 177
onClick={() => {
setMenuOpen(false);
}}
Copy link
Member

Choose a reason for hiding this comment

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

I expected clicking "Cancel" would reset my selected state, can we add reset functionality here? We can follow it up in another PR if you want, not a blocker.

Copy link
Member

Choose a reason for hiding this comment

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

Just wanted to note that I noticed opening and closing the selector reset my state, but cancelling didn't. I think we should make these two behaviours consistent 🙏

}}
disabled={!isCurrentUserDashboardOwner}
>
{t('Cancel')}{' '}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{t('Cancel')}{' '}
{t('Cancel')}

if (!isDefaultState && !isEqual(newDashboardPermissions, dashboard.permissions)) {
onChangeEditAccess?.(newDashboardPermissions);
}
setHasUnsavedChanges(true);
Copy link
Member

Choose a reason for hiding this comment

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

Instead of storing this state, is there a way we can derive it from comparing the dashboard prop and the state? e.g. if I select a team and unselect it to return to the original state, it still shows me in an unsaved state when saving wouldn't really change anything.

I think this would be similar to the logic you have for checking when to fire the request. You could possibly extract that logic into a helper

@harshithadurai harshithadurai merged commit d1aca0f into master Nov 8, 2024
44 checks passed
@harshithadurai harshithadurai deleted the harshi/ref/dashboards-edit-access-frontend-modifications branch November 8, 2024 18:44
@github-actions github-actions bot locked and limited conversation to collaborators Nov 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants