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

core-34 Add view-only option on permissioned relationships #12415

Merged
merged 5 commits into from Jul 17, 2018

Conversation

aydun
Copy link
Contributor

@aydun aydun commented Jul 4, 2018

(This is a follow-on from #11922 but I can't reopen that one, which itself was a replacement for #11892 )

Overview

This adds a new option to permissioned relationships to provide view-only access. Previously, a permissioned relationship always provides edit access.

Before

A permissioned relationship provides view and update access to the other contact. There is no option for view-only access.

After

The permissioned relationship can provide View and Update or View Only access.

screenshot from 2018-07-04 12-55-46

Technical Details

The is_permission_a_b and is_permission_b_a fields are changed from 0/1 boolean to 0/1/2. As previously 0 = no access, 1 = edit (view & update). In addition 2 = view only.

For clarity, the constants CRM_Contact_BAO_Relationship::NONE, CRM_Contact_BAO_Relationship::EDIT, CRM_Contact_BAO_Relationship::VIEW are used.

This means all existing permissioned relationships continue to function as now and provide edit access.

Comments

Unit tests are included for normal and second-degree relationships.
Incorporates @agh1's suggestion to use icons on the relationship screen
screenshot from 2018-07-04 12-53-11

https://lab.civicrm.org/dev/core/issues/34

aydun added 4 commits July 4, 2018 12:34
Change is_permission_a_b and is_permission_b_a to 3 values instead of 2.
Update schema, DAO, BAO, view/edit/add, search, report
…was mishandled

We need to check for:
  first_degree_relationship.contact_id_a = second_degree_relationship.contact_id_a
  first_degree_relationship.contact_id_a = second_degree_relationship.contact_id_b
  first_degree_relationship.contact_id_b = second_degree_relationship.contact_id_a
  first_degree_relationship.contact_id_b = second_degree_relationship.contact_id_b
but the last one was mishandled.
@civibot
Copy link

civibot bot commented Jul 4, 2018

(Standard links)

@eileenmcnaughton
Copy link
Contributor

@agh1 are you able to re-review this. It looks generally good, sensible & narrowly-scoped to me. I note the upgrade script line is missing but there is a case to be made for getting the rest of the review first as that is the most likely to go stale

@petednz - you may also have an interest

@agh1
Copy link
Contributor

agh1 commented Jul 6, 2018

Yes, I'd be happy to review. Can't happen today, but early next week. I'm excited this is happening!

@eileenmcnaughton
Copy link
Contributor

@aydun test fail seems unrelated but if you squash your commits & re-push they will run again & hopefully a pretty green tick will follow

@aydun
Copy link
Contributor Author

aydun commented Jul 10, 2018

@eileenmcnaughton - that worked ... pretty green tick now showing!

@eileenmcnaughton
Copy link
Contributor

Passing yay. In your court @agh1

@agh1
Copy link
Contributor

agh1 commented Jul 16, 2018

  • Explain (r-explain)
    • PASS : The goal/problem/solution have been adequately explained in the PR.
  • Test results (r-test)
    • PASS: The test results are all-clear.
  • Code quality (r-code)
    • PASS: The functionality, purpose, and style of the code seems clear+sensible.
  • Documentation (r-doc)
    • ISSUE: The user documentation should be updated.
    • COMMENTS: This shouldn't hold up merging this PR. There's just a passing mention of relationship permissions on the Relationships page, but this will make the screenshot out of date, and the new options should be briefly documented.
  • Maintainability (r-maint)
    • PASS: The change sufficiently improves test coverage, or the change is trivial enough that it does not require tests.
  • Run it (r-run)
    • PASS: Created user "Test 1", granted "Author" role (has no special CiviCRM permissions). Added a relationship with view+edit permission for Test 1 with another contact "Test 2" and one with view-only permission with another contact "Test 3". Logging in as Test 1, I could use a profile in Edit mode to edit Test 2. I could use a profile in View mode to see Test 3, but Edit mode redirected me to the site's home page. Attempting to see any other contact in View mode displayed the error You do not have permission to edit this contact record. Contact the site administrator if you need assistance.
  • User impact (r-user)
    • PASS: The change would be intuitive or unnoticeable for a majority of users who work with this feature.
    • COMMENTS: Sight-impaired users will have trouble identifying which relationships have which permissions (this is not a newly-introduced problem, but one that could be resolved relatively easily). I'd recommend that the icons get title attributes saying "X can be viewed by Y" for each instance.
  • Technical impact (r-tech)
    • PASS: The change potentially affects compatibility, but the risks have been sufficiently managed.
    • COMMENTS: This is handled as reasonably as possible. The value 1, which represented the combined view and edit permission in the past, continues to mean "view and edit". Consequently, no schema upgrade is necessary. Only one potential issue I could imagine: someone might look for is_permission_a_b to be positive/truthy and act like that's sufficient for assuming the contact has edit permission when in fact the value is 2 and it's just read-only. There's no way to accommodate that situation, and it's the smoothest potential way to upgrade I can think of.

@eileenmcnaughton
Copy link
Contributor

merging based on @agh1 thorough review @aydun can you follow up on docs?

@agh1
Copy link
Contributor

agh1 commented Jul 17, 2018

I just wrote a follow-up to this that adds the title attribute I mentioned earlier--see #12487.

@colemanw
Copy link
Member

That eyeball is really creepy looking. Just sayin...

@aydun
Copy link
Contributor Author

aydun commented Jul 17, 2018

@agh1 - many thanks for reviewing, and the title enhancement
@colemanw - any better suggestions?
@eileenmcnaughton - thanks for merging

@colemanw
Copy link
Member

@aydun I'm not sure if there's anything better, at least it's not as bad as this icon that used to be in older versions of CiviCRM! eyeball.gif

But I do think it would be more intuitive to use 2 icons to represent 2 permissions rather than lumping them into 1. So I would do an eye for "view" and an eye plus a pencil for "view + edit"

@agh1
Copy link
Contributor

agh1 commented Jul 18, 2018

@colemanw I think a pencil has usually indicated "go edit this" or "this is editable" rather than "this contact has the power to edit". I had suggested in #11922 (comment) fa-pencil-square-o might be distinct enough, along with some other options.

If you're creeped out by fa-eye, there's fa-binoculars, which may be more implictly creepy but less viscerally weird.

I got experimenting: one idea is to put them in squares and give a little color-coding:
image

Or with binoculars:
image

The one consideration with separate icons is that you'll never have editing without viewing, and the second icon will just be taking up space.

@colemanw
Copy link
Member

I understand that the two permissions are intertwined, nevertheless I think having 2 icons to represent 2 permissions is much more clear visually.
Andrew I really like the way you did those icons. I vote for the eye and the pencil. It looks less creepy in a green box ;)

@eileenmcnaughton
Copy link
Contributor

It's a less clockwork orange look

@aydun
Copy link
Contributor Author

aydun commented Jul 20, 2018

Yes, I like those - eye and pencil in boxes.

@yashodha
Copy link
Contributor

yashodha commented Sep 7, 2018

@aydun does this also handle permission on user dashboard? I mean which links to show or not show depending on the permission granted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants