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
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.
- With the GDK seed data, you can go to
https://gdk.test:3443/gitlab-org/gitlab-shell/-/labels. ChooseArchivein theThree-dot-menuto archive a label. - It should now show up in the
Archivetab. - 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 - You can
Unarchivelabels either by going to the edit view or by using thethree-dot-menufrom theArchivedtab.
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)
- Changelog entry added, if necessary
- Documentation created/updated via this MR
- Documentation reviewed by technical writer or follow-up review issue created
- Tests added for this feature/bug
- Tested in all supported browsers
- Conforms to the code review guidelines
- Conforms to the merge request performance guidelines
- Conforms to the style guides
- Conforms to the javascript style guides
- Conforms to the database guides
Related to #4233