Skip to content

[Tagging] Use object permissions in frontend #160

Closed

Description

@pomegranited

"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 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.

Activity

  1. bradenmacdonald commented on Jan 8, 2024

    @bradenmacdonald
    Contributor

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions