Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save customized search if user has member level permissions #4947

Merged

Conversation

nimishsinghal
Copy link
Contributor

No description provided.

@nimishsinghal
Copy link
Contributor Author

nimishsinghal commented Feb 21, 2017

Hi,
I have tried to solve #4921 issue. Please review and comment for required changes.
Thanks

@@ -17,6 +17,8 @@ class SavedSearchSerializer(serializers.Serializer):


class ProjectSearchesEndpoint(ProjectEndpoint):
permission_classes = (ProjectSearchPermission,)
Copy link
Member

Choose a reason for hiding this comment

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

So we likely dont want to introduce new permissions for this. Searches are a low impact item. We'd need to either:

  1. Make the UI respect the existing permissions (e.g. members cant add new saved searches, and definitely cant set team defaults).
  2. OR create some unshared saved search behavior, where members can create their own saved searches but they cant share them with the team without having permissions.

I would side with #1, which is generally what the original API implementation was intended to support.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dcramer As the issue stated "members can't add new saved search", I tried to resolve it by adding new permission keeping in mind that a member would be allowed to add and change his default search view. Also API should be robust enough to prevent deleting of search view by members.
Existing permissions shouldn't mix with search permissions as both serve different purpose thats the reason I created separate permissions.

If still we don't require separate permissions, I will remove that and simply hide the button in UI depending on existing permissions.

Copy link
Member

Choose a reason for hiding this comment

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

@nimishsinghal we already have permissions for this though. We dont really want/need granular per-search permissions (which is what these would suggest).

We could do something like:

  • project:read => can set their own default saved search
  • project:write => can set default team saved search
  • project:write => can remove saved searches

Now if we want to allow them to create new saved searches, we'd have to augment the data model, because we wouldn't really want those exposed to the team by default. IMO those are two diff concerns from defaulting a saved search and exposing member-only saved searches.

If we allowed member level saved searches, it'd be something along the lines of:

  • an optional owner field on SavedSearch model (must be nullable)
  • an option to "share this saved search with the team"
  • members with project:write can share with team
  • members with project:read can only create private searches
  • private searches show up differently in the UI to suggest they're private

Copy link
Contributor Author

@nimishsinghal nimishsinghal Feb 22, 2017

Choose a reason for hiding this comment

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

@dcramer as suggested by you I have tried to implement "allowing member level saved search". I have tried to follow above points.

Wasn't sure about following
=> private searches show up differently in the UI to suggest they're private
Should I add P label aligned with private searches to show that they are private?

@nimishsinghal
Copy link
Contributor Author

nimishsinghal commented Feb 24, 2017

@dcramer I made the requested changes. Please review and let me know if anything else needs to be changed. :)

Copy link
Contributor

@mattrobenolt mattrobenolt left a comment

Choose a reason for hiding this comment

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

  • Updating the migration is absolutely mandatory since it can't be merged without that.
  • Some tests would be useful, especially since we're talking about security and permissions.

Note: I haven't looked at any of the frontend changes, so will need to get eyes on that from @benvinegar or @macqueen.

@@ -32,4 +32,5 @@ def serialize(self, obj, attrs, user):
'isDefault': obj.is_default,
'isUserDefault': attrs['isUserDefault'],
'dateCreated': obj.date_added,
'isPrivate': True if obj.owner else False,
Copy link
Contributor

Choose a reason for hiding this comment

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

This can/should just be bool(obj.owner)

@@ -0,0 +1,730 @@
# -*- coding: utf-8 -*-
Copy link
Contributor

Choose a reason for hiding this comment

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

So.... this is kinda shitty, but I can't merge this without this migration being recreated off of master. If merged as-is, the migration won't run since it's one in the past and the world will not be happy. So this needs to be deleted, then recreated off of master to give the right id. You can't just rename the file either since the frozen state at the bottom needs to be correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mattrobenolt Yup, It's a very valid point I have created a new migration.

@mattrobenolt
Copy link
Contributor

Backend stuff looks reasonable, but want a frontend person to double check over those changes to make sure nothing is bad there. @benvinegar @macqueen

@nimishsinghal
Copy link
Contributor Author

@benvinegar @macqueen Can you please review the changes will resolve the conflicts post that and update the migration again :)

nimishsinghal and others added 2 commits March 23, 2017 13:18
fixup: Save customized search if user has member level permissions

fixup: make new migration
@macqueen macqueen force-pushed the feature-saved-role-member-level branch from 16f9888 to 893b530 Compare March 23, 2017 20:25
@getsentry-bot
Copy link
Contributor

1 Error
🚫 You need to update CHANGES due to the size of this PR
1 Warning
⚠️ Big PR – consider splitting it up into multiple changesets

Generated by 🚫 danger

@macqueen
Copy link
Contributor

@nimishsinghal thanks!

@macqueen macqueen merged commit 7ccadc4 into getsentry:master Mar 23, 2017
@nimishsinghal
Copy link
Contributor Author

Thanks @macqueen :)

@nimishsinghal nimishsinghal deleted the feature-saved-role-member-level branch March 25, 2017 18:03
@github-actions github-actions bot locked and limited conversation to collaborators Dec 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants