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

[Tagging] Use object permissions in frontend #160

Closed
pomegranited opened this issue Dec 5, 2023 · 1 comment
Closed

[Tagging] Use object permissions in frontend #160

pomegranited opened this issue Dec 5, 2023 · 1 comment

Comments

@pomegranited
Copy link

"As a content author, I want the UI to show me when I can add/update/delete a taxonomy or tag and when I cannot, rather than waiting for a backend error, so that I can easily manage my taxonomies and tags."

Acceptance Criteria

  1. Update the taxonomy, tag, and object tag REST APIs to return a consistent user_permissions record with each object returned by the API, e.g.

    {
     "next": null,
     "previous": null,
     "count": 8,
     "num_pages": 1,
     "current_page": 1,
     "start": 0,
     "results": [
       {
         "id": 2,
         "name": "ESDC Skills and Competencies",
         "description": "Employment and Social Development Canada - Skills and Competencies Taxonomy (EN) 2023 Version 1.0. Licence: Open Government Licence - Canada",
         "enabled": true,
         "allow_multiple": true,
         "allow_free_text": false,
         "system_defined": false,
         "visible_to_authors": true,
         "tags_count": 423,
         "orgs": [],
         "all_orgs": true,
         "user_permissions": {
               "oel_tagging.add_taxonomy": true,
               "oel_tagging.view_taxonomy": true,
               "oel_tagging.change_taxonomy": true,
               "oel_tagging.delete_taxonomy": true,
         },
      },
      {
         "id": 6,
         "name": "FlatTaxonomy",
         "description": "A simple, flat taxonomy used by SampleTaxonomyOrg1",
         "enabled": true,
         "allow_multiple": true,
         "allow_free_text": false,
         "system_defined": false,
         "visible_to_authors": true,
         "tags_count": 5000,
         "orgs": ["SampleTaxonomyOrg1"],
         "all_orgs": false,
       },
       "user_permissions": {
               "oel_tagging.add_taxonomy": true,
               "oel_tagging.view_taxonomy": true,
               "oel_tagging.change_taxonomy": false,
               "oel_tagging.delete_taxonomy": false,
         },
      ...
      ],
    }
    
  2. Update the frontend-app-course-authoring UI to use these user_permissions to determine whether to show/enable the "Import", "Re-import" and "Delete" menu actions for a given taxonomy.

  3. (if done after [Tagging] Rename and delete an individual tag #131 / [Tagging] Add tags to a taxonomy #132) Update the frontend-app-course-authoring UI to use these user_permissions to determine whether to show/enable the "Add", "Rename" and "Delete" menu actions for a given tag.

Developer notes

  1. Edge case: When no "taxonomies" are returned by the REST API for a given user, then we aren't able to see whether that user has oel_tagging.add_taxonomy permission. So in this case, go ahead and show the "Import" button and allow the user to try the import, and let the backend enforce the rule.
@bradenmacdonald
Copy link
Contributor

bradenmacdonald commented Jan 8, 2024

@pomegranited

Edge case: When no "taxonomies" are returned by the REST API for a given user, then we aren't able to see whether that user has oel_tagging.add_taxonomy permission. So in this case, go ahead and show the "Import" button and allow the user to try the import, and let the backend enforce the rule.

It would really be ideal if the can_add permission is included with the List response (outside of the array of items), rather than including it in the serialization of each Taxonomy object. That's a much nicer way to solve this problem.

```
{
 "next": null,
 "previous": null,
 "count": 8,
 "num_pages": 1,
 "current_page": 1,
 "start": 0,
 "user_permissions": {
     "can_add_taxonomy": true
 },
 "results": [
   {
     "id": 2,
     ...
     "user_permissions": {
           "can_view_taxonomy": true,
           "can_change_taxonomy": true,
           "can_delete_taxonomy": true,
     },
  },
  ...
  ],
}
```

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

No branches or pull requests

2 participants