Archive labels: remove :labels_archive feature flag

What does this MR do and why?

This commit removes the feature flag :labels_archive thus enabling the archival of labels.

With this, users can:

  • archive a label from the labels index view
  • unarchive a label from the label detail view or the archived labels index
  • no longer find archived labels in the label dropdowns and auto-complete

🛠️ with ❤️ at Siemens

References

How to set up and validate locally

UI

We have not yet disabled the feature flag :labels_archive in the UI. So, with the feature flag disabled, you should not see the Archive tab. However, when archiving labels using the API, /label is expected to filter the labels, as this uses only backend services.

  1. With the GDK seed data, you can go to https://gdk.test:3443/gitlab-org/gitlab-shell/-/labels. Choose Archive in the Three-dot-menu to archive a label.
  2. It should now show up in the Archive tab.
  3. Now, in the same project, go to an existing issue or create a new issue. In the labels dropdown, you should no longer see the label you've archived. You should also not be able to add it with /label ~your-archived-label
  4. You can Unarchive labels either by going to the edit view or by using the three-dot-menu from the Archived tab.

This should work for Group and Project labels. The entry must not be visible for Admin labels, as they are template labels and cannot be archived.

REST API

GET

Use false to retrieve only unarchived labels, true to retrieve only archived labels and omit the parameter to receive all labels. You can use the other endpoints or the UI to archive a label. Change the project id, group id or label id in the request as necessary:

Projects
curl --request GET \
  --url https://gdk.test:3443/api/v4/projects/3/labels \
  --header 'Authorization: Bearer <YOUR PAT>' \
  --header 'Content-Type: application/json' \
  --data '{"archived": "false"}'
Groups
curl --request GET \
  --url https://gdk.test:3443/api/v4/groups/31/labels \
  --header 'Authorization: Bearer <YOUR PAT>' \
  --header 'Content-Type: application/json' \
  --data '{"archived": "false"}'

PUT

curl --request PUT \
  --url https://gdk.test:3443/api/v4/projects/3/labels/80 \
  --header 'Authorization: Bearer <YOUR PAT>' \
  --header 'Content-Type: application/json' \
  --data '{"archived": "true"}'

POST

curl --request POST \
  --url https://gdk.test:3443/api/v4/projects/3/labels \
  --header 'Authorization: Bearer <YOUR PAT>' \
  --header 'Content-Type: application/json' \
  --data '{"name": "new name", "color": "#a22b2c", "archived": true}' 
GraphQL API

Get the global label id from a label with Label.last.to_global_id

curl --request POST \
  --url https://gdk.test:3443/api/graphql \
  --header 'Authorization: Bearer <glpat>' \
  --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      archived\n    }\n    errors\n  }\n}\n",
  "operationName": "labelUpdate",
  "variables": {
    "id": "gid://gitlab/ProjectLabel/78",
    "archived": true
  }
}'

MR acceptance checklist

MR Checklist ( @nwittstruck)

Related to #4233

Edited by Nicholas Wittstruck

Merge request reports

Loading