Skip to content

Feature: Archive Labels

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 of Label to keep this MR smaller. In future MRs, we can allow changing this attribute right in the list view next to edit and delete 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.

🛠️ with ❤️ at Siemens

References

Screenshots or screen recordings

Viewing and editing archived labels

archived-index edit-label

Select labels dropdown in Issues Before / After

issue-list-archived-filtered issue-list-archived-not-filtered

How to set up and validate locally

  1. Enable feature flag via rails c:
Feature.enable(:labels_archive)
  1. Run migrations with bin/rails db:migrate (and down with bin/rails db:migrate:down:main db:migrate:down:ci VERSION=20250721135148)

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

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

Related to #4233

Edited by Nicholas Wittstruck

Merge request reports

Loading