Skip to content

[Tagging] Use object permissions in frontend #160

@pomegranited

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions