Feature: Archive Labels
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA. As a benefit of being a GitLab Community Contributor, you receive complimentary access to GitLab Duo.
What does this MR do and why?
This MR adds an archive attribute to labels to implement Archived labels (#4233)
I'll follow this implementation plan.
To have a first, usable MVC, this MR does the following protected by a feature flag:
- It adds an
archived
attribute to label, defaulting to false. - The attribute can currently only be changed in the
edit
view ofLabel
to keep this MR smaller. In future MRs, we can allow changing this attribute right in the list view next toedit
anddelete
to make this more comfortable. - Archived labels are shown in a seaprate tab.
- By default, archived labels are not returned with the GraphQL API. Therefore, archived labels will no longer show up in the issues dropdown.
References
Screenshots or screen recordings
Viewing and editing archived labels
Select labels dropdown in Issues Before / After
How to set up and validate locally
- Enable feature flag via
rails c
:
Feature.enable(:labels_archive)
-
Run migrations with
bin/rails db:migrate
(and down withbin/rails db:migrate:down:main db:migrate:down:ci VERSION=20250721135148
) -
Now, edit an existing label. With the GDK seed data, you can go to https://gdk.test:3443/gitlab-org/gitlab-shell/-/labels. Choose
edit
and toggle the Archived checkbox. -
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. When disabling the feature flag you should see it again.
Database Query
I'd say the most relevant place for this query is the labels dropdown in the Issue
view. It uses the LabelsFinder
to retrieve labels. Therefore I've run explain on that query:
Explain Query
pry(#<LabelsFinder>)> items.explain
=> EXPLAIN SELECT "labels".* FROM "labels" WHERE ("labels"."type" = 'GroupLabel' AND "labels"."group_id" IN (24) OR "labels"."type" = 'ProjectLabel' AND "labels"."project_id" = 3) AND "labels"."archived" = FALSE ORDER BY "labels"."title" ASC /*application:web,correlation_id:123,endpoint_id:GraphqlController#execute,db_config_database:gitlabhq_development,db_config_name:main,line:(pry):2:in `execute'*/
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sort (cost=4.15..4.16 rows=1 width=207)
Sort Key: title
-> Seq Scan on labels (cost=0.00..4.14 rows=1 width=207)
Filter: ((NOT archived) AND ((((type)::text = 'GroupLabel'::text) AND (group_id = 24)) OR (((type)::text = 'ProjectLabel'::text) AND (project_id = 3))))
(4 rows)
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