Archive labels: Prevent policy error for admin labels

What does this MR do and why?

Archive labels: Prevent policy error for admin labels

The :admin_label policy is only defined for GroupLabels and ProjectLabels

For Admin Labels, an internal server occured since the policy is missing:

Internal server error: no policy for Label

This MR fixes this issue by checking the type.

🛠️ with ❤️ at Siemens

References

How to set up and validate locally

  1. Enable feature flag via rails c:
Feature.enable(:labels_archive, :instance)
  1. Create an admin label.
  2. Try to update this admin label before and after applying this MR. Before, you should get the above erorr, afterwards you should get Label is not a project or group label.
 curl --request POST \                                                                                                                         
  --url https://gdk.test:3443/api/graphql \
  --header 'Authorization: Bearer <PAT>' \
  --header 'Content-Type: application/json' \
  --data '{
  "query": "mutation labelUpdate($id: LabelID!, $archived: Boolean) {\n  labelUpdate(input: { id: $id, archived: $archived }) {\n    label {\n      id\n\t\t\tarchived\n    }\n    errors\n  }\n}\n",
  "operationName": "labelUpdate",
  "variables": {
    "id": "gid://gitlab/Label/<ADMIN LABEL ID>",
    "archived": true
  }
}'

MR acceptance checklist

MR Checklist ( @nwittstruck)

Related to #4233

Edited by Nicholas Wittstruck

Merge request reports

Loading