diff --git a/app/controllers/dashboard/projects_controller.rb b/app/controllers/dashboard/projects_controller.rb index aa3592ff209f019f2684208b4ae6ae9b12d408c5..832d278c8910e193bafcb96da428a458768c0ae3 100644 --- a/app/controllers/dashboard/projects_controller.rb +++ b/app/controllers/dashboard/projects_controller.rb @@ -36,7 +36,7 @@ def index # rubocop: disable CodeReuse/ActiveRecord def starred @projects = load_projects(params.merge(starred: true)) - .includes(:forked_from_project, :tags) + .includes(:forked_from_project, :topics) @groups = [] diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 575b9642efe0d1925185d1636585cdb91638d692..7a24c07a0bfa6835187d4cde9dab38bf32f507b4 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -435,7 +435,7 @@ def project_params_attributes :remove_source_branch_after_merge, :request_access_enabled, :runners_token, - :tag_list, + :topic_list, :visibility_level, :template_name, :template_project_id, diff --git a/app/finders/group_projects_finder.rb b/app/finders/group_projects_finder.rb index dfdf821e3f0ba72923239eddc10a4be150228104..c825f13bb645557c95bf15b042b094053d9101d8 100644 --- a/app/finders/group_projects_finder.rb +++ b/app/finders/group_projects_finder.rb @@ -16,7 +16,7 @@ # params: # sort: string # visibility_level: int -# tags: string[] +# topics: string[] # personal: boolean # search: string # non_archived: boolean diff --git a/app/finders/projects_finder.rb b/app/finders/projects_finder.rb index 893e89daa3c81608b1a5e6f9b6b14d5c6a823e7a..5fc15d9146cd1bd0c2a206ea5fa4dd33fffe0234 100644 --- a/app/finders/projects_finder.rb +++ b/app/finders/projects_finder.rb @@ -14,7 +14,7 @@ # starred: boolean # sort: string # visibility_level: int -# tags: string[] +# topics: string[] # personal: boolean # search: string # search_namespaces: boolean @@ -76,7 +76,7 @@ def filter_projects(collection) collection = by_starred(collection) collection = by_trending(collection) collection = by_visibility_level(collection) - collection = by_tags(collection) + collection = by_topics(collection) collection = by_search(collection) collection = by_archived(collection) collection = by_custom_attributes(collection) @@ -176,8 +176,8 @@ def by_visibility_level(items) end # rubocop: enable CodeReuse/ActiveRecord - def by_tags(items) - params[:tag].present? ? items.tagged_with(params[:tag]) : items + def by_topics(items) + params[:topic].present? ? items.tagged_with(params[:topic], on: :topics) : items end def by_search(items) diff --git a/app/graphql/types/project_type.rb b/app/graphql/types/project_type.rb index 21534f40499ea54cd1c34c3d92d8d85103396bc2..dd676a4aa80d94b290f935b830cb9d9a83856646 100644 --- a/app/graphql/types/project_type.rb +++ b/app/graphql/types/project_type.rb @@ -29,8 +29,8 @@ class ProjectType < BaseObject description: 'Short description of the project.' markdown_field :description_html, null: true - field :tag_list, GraphQL::STRING_TYPE, null: true, - description: 'List of project topics (not Git tags).' + field :topic_list, GraphQL::STRING_TYPE, null: true, + description: 'List of project topics.' field :ssh_url_to_repo, GraphQL::STRING_TYPE, null: true, description: 'URL to connect to the project via SSH.' diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb index bfc8803f5147630f4583b91f1b43f1a19c7061a1..86289ec8ed24e8df69f581b7591fb129ce3a1914 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -15,16 +15,6 @@ def filter_tags_path(options = {}) project_tags_path(@project, @id, options) end - def tag_list(project) - html = [] - - project.tag_list.each do |tag| - html << link_to(tag, tag_path(tag)) - end - - html.join.html_safe - end - def protected_tag?(project, tag) ProtectedTag.protected?(project, tag.name) end diff --git a/app/models/project.rb b/app/models/project.rb index 4aa094fed29985f39139b9bdb8f32c60387fbd0d..f988790d277e63c5faaf73a7c7902ab97d6e6755 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -128,8 +128,7 @@ class Project < ApplicationRecord after_initialize :use_hashed_storage after_create :check_repository_absence! - acts_as_ordered_taggable - alias_method :topics, :tag_list + acts_as_ordered_taggable_on :topics attr_accessor :old_path_with_namespace attr_accessor :template_name @@ -618,7 +617,7 @@ class Project < ApplicationRecord mount_uploader :bfg_object_map, AttachmentUploader def self.with_api_entity_associations - preload(:project_feature, :route, :tags, :group, :timelogs, namespace: [:route, :owner]) + preload(:project_feature, :route, :topics, :group, :timelogs, namespace: [:route, :owner]) end def self.with_web_entity_associations diff --git a/app/presenters/project_presenter.rb b/app/presenters/project_presenter.rb index 681c5cfca741dee10122c55d207e9e00823142f3..394e6275cd1d59991753adcac118c34708b39445 100644 --- a/app/presenters/project_presenter.rb +++ b/app/presenters/project_presenter.rb @@ -390,16 +390,16 @@ def gitlab_ci_anchor_data end def topics_to_show - project.topics.take(MAX_TOPICS_TO_SHOW) # rubocop: disable CodeReuse/ActiveRecord + project.topic_list.take(MAX_TOPICS_TO_SHOW) # rubocop: disable CodeReuse/ActiveRecord end def topics_not_shown - project.topics - topics_to_show + project.topic_list - topics_to_show end def count_of_extra_topics_not_shown - if project.topics.count > MAX_TOPICS_TO_SHOW - project.topics.count - MAX_TOPICS_TO_SHOW + if project.topic_list.count > MAX_TOPICS_TO_SHOW + project.topic_list.count - MAX_TOPICS_TO_SHOW else 0 end diff --git a/app/views/projects/_home_panel.html.haml b/app/views/projects/_home_panel.html.haml index a70679dab5f286232f3f7a89c7ba680358ef07ad..26291c0358e265199419b43a27d4f842efb14319 100644 --- a/app/views/projects/_home_panel.html.haml +++ b/app/views/projects/_home_panel.html.haml @@ -25,14 +25,14 @@ %span.access-request-links.gl-ml-3 = render 'shared/members/access_request_links', source: @project - - if @project.tag_list.present? - = cache_if(cache_enabled, [@project, :tag_list], expires_in: 1.day) do + - if @project.topic_list.present? + = cache_if(cache_enabled, [@project, :topic_list], expires_in: 1.day) do %span.home-panel-topic-list.mt-2.w-100.d-inline-flex.gl-font-base.gl-font-weight-normal.gl-align-items-center = sprite_icon('tag', css_class: 'icon gl-relative gl-mr-2') - @project.topics_to_show.each do |topic| - project_topics_classes = "badge badge-pill badge-secondary gl-mr-2" - - explore_project_topic_path = explore_projects_path(tag: topic) + - explore_project_topic_path = explore_projects_path(topic: topic) - if topic.length > max_project_topic_length %a{ class: "#{ project_topics_classes } str-truncated-30 has-tooltip", data: { container: "body" }, title: topic, href: explore_project_topic_path, itemprop: 'keywords' } = topic.titleize diff --git a/app/views/projects/settings/_general.html.haml b/app/views/projects/settings/_general.html.haml index 845fb299b74e3f17ee54065095e9d8602479a459..f89abeef6b755a3a5eb56103509d82df26b12411 100644 --- a/app/views/projects/settings/_general.html.haml +++ b/app/views/projects/settings/_general.html.haml @@ -15,8 +15,8 @@ .row .form-group.col-md-9 - = f.label :tag_list, _('Topics (optional)'), class: 'label-bold' - = f.text_field :tag_list, value: @project.tag_list.join(', '), maxlength: 2000, class: "form-control gl-form-input" + = f.label :topic_list, _('Topics (optional)'), class: 'label-bold' + = f.text_field :topic_list, value: @project.topic_list.join(', '), maxlength: 2000, class: "form-control gl-form-input" %p.form-text.text-muted= _('Separate topics with commas.') = render_if_exists 'compliance_management/compliance_framework/project_settings', f: f diff --git a/changelogs/unreleased/feat-rename-project-tags-to-topics.yml b/changelogs/unreleased/feat-rename-project-tags-to-topics.yml new file mode 100644 index 0000000000000000000000000000000000000000..12227ca898d44f52642b5a1b8c61c74f173997a8 --- /dev/null +++ b/changelogs/unreleased/feat-rename-project-tags-to-topics.yml @@ -0,0 +1,5 @@ +--- +title: Enforce term 'topic' instead of 'tag' in project context +merge_request: 60834 +author: Jonas Wälter @wwwjon +type: changed diff --git a/db/migrate/20210505093539_migrate_project_tags_to_topics.rb b/db/migrate/20210505093539_migrate_project_tags_to_topics.rb new file mode 100644 index 0000000000000000000000000000000000000000..964c0e18ada9fa4277842db8afec9ce934265008 --- /dev/null +++ b/db/migrate/20210505093539_migrate_project_tags_to_topics.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class MigrateProjectTagsToTopics < ActiveRecord::Migration[6.0] + DOWNTIME = false + + def up + execute("UPDATE taggings SET context = 'topics' WHERE taggable_type = 'Project' AND context = 'tags'") + end + + def down + execute("UPDATE taggings SET context = 'tags' WHERE taggable_type = 'Project' AND context = 'topics'") + end +end diff --git a/db/schema_migrations/20210505093539 b/db/schema_migrations/20210505093539 new file mode 100644 index 0000000000000000000000000000000000000000..cbfb1f4a75e427c9d74ba59251a13827394bf51d --- /dev/null +++ b/db/schema_migrations/20210505093539 @@ -0,0 +1 @@ +4fa374e6565d6bc18f5779b12e54e7f1c47e441f0a95267e3c476789302cee27 \ No newline at end of file diff --git a/doc/api/boards.md b/doc/api/boards.md index 3252036c8409cb29cb14bd743c119cb9d3b96a65..cecd0ead1bf5cb09d587dc336ad2625e0994ddcb 100644 --- a/doc/api/boards.md +++ b/doc/api/boards.md @@ -250,7 +250,7 @@ Example response: "path_with_namespace": "diaspora/diaspora-project-site", "created_at": "2018-07-03T05:48:49.982Z", "default_branch": null, - "tag_list": [], + "topic_list": [], "ssh_url_to_repo": "ssh://user@example.com/diaspora/diaspora-project-site.git", "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git", "web_url": "http://example.com/diaspora/diaspora-project-site", diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index 6c170bab6e7487d4dc586cdb92a4d2ab525f153e..c061ea3ec1b36e7724db54e79ad33ae6ae8e568f 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -10621,8 +10621,8 @@ Represents vulnerability finding of a security report on the pipeline. | `starCount` | [`Int!`](#int) | Number of times the project has been starred. | | `statistics` | [`ProjectStatistics`](#projectstatistics) | Statistics of the project. | | `suggestionCommitMessage` | [`String`](#string) | The commit message used to apply merge request suggestions. | -| `tagList` | [`String`](#string) | List of project topics (not Git tags). | | `terraformStates` | [`TerraformStateConnection`](#terraformstateconnection) | Terraform states associated with the project. (see [Connections](#connections)) | +| `topicList` | [`String`](#string) | List of project topics. | | `userPermissions` | [`ProjectPermissions!`](#projectpermissions) | Permissions for the current user on the resource. | | `visibility` | [`String`](#string) | Visibility of the project. | | `vulnerabilityScanners` | [`VulnerabilityScannerConnection`](#vulnerabilityscannerconnection) | Vulnerability scanners reported on the project vulnerabilities. (see [Connections](#connections)) | diff --git a/doc/api/groups.md b/doc/api/groups.md index b1e1e2bb6c5ec6bee9102cc080fa01d9785a54bc..61ca9a92d8d3b2528db3530d7047bd251cab7de6 100644 --- a/doc/api/groups.md +++ b/doc/api/groups.md @@ -302,7 +302,7 @@ Example response: "id": 9, "description": "foo", "default_branch": "master", - "tag_list": [], + "topic_list": [], "archived": false, "visibility": "internal", "ssh_url_to_repo": "git@gitlab.example.com/html5-boilerplate.git", @@ -381,7 +381,7 @@ Example response: "path_with_namespace":"h5bp/html5-boilerplate", "created_at":"2020-04-27T06:13:22.642Z", "default_branch":"master", - "tag_list":[ + "topic_list":[ ], "ssh_url_to_repo":"ssh://git@gitlab.com/h5bp/html5-boilerplate.git", @@ -540,7 +540,7 @@ Example response: "id": 7, "description": "Voluptas veniam qui et beatae voluptas doloremque explicabo facilis.", "default_branch": "master", - "tag_list": [], + "topic_list": [], "archived": false, "visibility": "public", "ssh_url_to_repo": "git@gitlab.example.com:twitter/typeahead-js.git", @@ -578,7 +578,7 @@ Example response: "id": 6, "description": "Aspernatur omnis repudiandae qui voluptatibus eaque.", "default_branch": "master", - "tag_list": [], + "topic_list": [], "archived": false, "visibility": "internal", "ssh_url_to_repo": "git@gitlab.example.com:twitter/flight.git", @@ -618,7 +618,7 @@ Example response: "id": 8, "description": "Velit eveniet provident fugiat saepe eligendi autem.", "default_branch": "master", - "tag_list": [], + "topic_list": [], "archived": false, "visibility": "private", "ssh_url_to_repo": "git@gitlab.example.com:h5bp/html5-boilerplate.git", @@ -880,7 +880,7 @@ Example response: "id": 9, "description": "foo", "default_branch": "master", - "tag_list": [], + "topic_list": [], "public": false, "archived": false, "visibility": "internal", diff --git a/doc/api/project_clusters.md b/doc/api/project_clusters.md index a431e75477401b286045346372044f5f1bd34824..f6e1ce186b78a253e7e73b86526835dec122f453 100644 --- a/doc/api/project_clusters.md +++ b/doc/api/project_clusters.md @@ -151,7 +151,7 @@ Example response: "path_with_namespace":"root/project-with-clusters-api", "created_at":"2019-01-02T20:13:32.600Z", "default_branch":null, - "tag_list":[], + "topic_list":[], "ssh_url_to_repo":"ssh://gitlab.example.com/root/project-with-clusters-api.git", "http_url_to_repo":"https://gitlab.example.com/root/project-with-clusters-api.git", "web_url":"https://gitlab.example.com/root/project-with-clusters-api", @@ -247,7 +247,7 @@ Example response: "path_with_namespace":"root/project-with-clusters-api", "created_at":"2019-01-02T20:13:32.600Z", "default_branch":null, - "tag_list":[], + "topic_list":[], "ssh_url_to_repo":"ssh:://gitlab.example.com/root/project-with-clusters-api.git", "http_url_to_repo":"https://gitlab.example.com/root/project-with-clusters-api.git", "web_url":"https://gitlab.example.com/root/project-with-clusters-api", @@ -357,7 +357,7 @@ Example response: "path_with_namespace":"root/project-with-clusters-api", "created_at":"2019-01-02T20:13:32.600Z", "default_branch":null, - "tag_list":[], + "topic_list":[], "ssh_url_to_repo":"ssh:://gitlab.example.com/root/project-with-clusters-api.git", "http_url_to_repo":"https://gitlab.example.com/root/project-with-clusters-api.git", "web_url":"https://gitlab.example.com/root/project-with-clusters-api", diff --git a/doc/api/projects.md b/doc/api/projects.md index 3e4f41caaabbbbfd8327bb313f1025fc8669bf90..bc3cc9448bdff17ec22244c6ce4a95bed673cd02 100644 --- a/doc/api/projects.md +++ b/doc/api/projects.md @@ -59,7 +59,7 @@ GET /projects | `sort` | string | **{dotted-circle}** No | Return projects sorted in `asc` or `desc` order. Default is `desc`. | | `starred` | boolean | **{dotted-circle}** No | Limit by projects starred by the current user. | | `statistics` | boolean | **{dotted-circle}** No | Include project statistics. | -| `topic` | string | **{dotted-circle}** No | Comma-separated topic names. Limit results to projects that match all of given topics. See `tag_list` attribute. | +| `topic` | string | **{dotted-circle}** No | Comma-separated topic names. Limit results to projects that match all of given topics. See `topic_list` attribute. | | `visibility` | string | **{dotted-circle}** No | Limit by visibility `public`, `internal`, or `private`. | | `wiki_checksum_failed` **(PREMIUM)** | boolean | **{dotted-circle}** No | Limit projects where the wiki checksum calculation has failed ([Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/6137) in [GitLab Premium](https://about.gitlab.com/pricing/) 11.2). | | `with_custom_attributes` | boolean | **{dotted-circle}** No | Include [custom attributes](custom_attributes.md) in response. _(admins only)_ | @@ -82,7 +82,7 @@ When `simple=true` or the user is unauthenticated this returns something like: "http_url_to_repo": "http://example.com/diaspora/diaspora-client.git", "web_url": "http://example.com/diaspora/diaspora-client", "readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md", - "tag_list": [ + "topic_list": [ "example", "disapora client" ], @@ -116,7 +116,7 @@ When the user is authenticated and `simple` is not set this returns something li "http_url_to_repo": "http://example.com/diaspora/diaspora-client.git", "web_url": "http://example.com/diaspora/diaspora-client", "readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md", - "tag_list": [ + "topic_list": [ "example", "disapora client" ], @@ -200,7 +200,7 @@ When the user is authenticated and `simple` is not set this returns something li "http_url_to_repo": "http://example.com/brightbox/puppet.git", "web_url": "http://example.com/brightbox/puppet", "readme_url": "http://example.com/brightbox/puppet/blob/master/README.md", - "tag_list": [ + "topic_list": [ "example", "puppet" ], @@ -378,7 +378,7 @@ GET /users/:user_id/projects "http_url_to_repo": "http://example.com/diaspora/diaspora-client.git", "web_url": "http://example.com/diaspora/diaspora-client", "readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md", - "tag_list": [ + "topic_list": [ "example", "disapora client" ], @@ -462,7 +462,7 @@ GET /users/:user_id/projects "http_url_to_repo": "http://example.com/brightbox/puppet.git", "web_url": "http://example.com/brightbox/puppet", "readme_url": "http://example.com/brightbox/puppet/blob/master/README.md", - "tag_list": [ + "topic_list": [ "example", "puppet" ], @@ -606,7 +606,7 @@ Example response: "http_url_to_repo": "http://example.com/diaspora/diaspora-client.git", "web_url": "http://example.com/diaspora/diaspora-client", "readme_url": "http://example.com/diaspora/diaspora-client/blob/master/README.md", - "tag_list": [ + "topic_list": [ "example", "disapora client" ], @@ -683,7 +683,7 @@ Example response: "http_url_to_repo": "http://example.com/brightbox/puppet.git", "web_url": "http://example.com/brightbox/puppet", "readme_url": "http://example.com/brightbox/puppet/blob/master/README.md", - "tag_list": [ + "topic_list": [ "example", "puppet" ], @@ -804,7 +804,7 @@ GET /projects/:id "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git", "web_url": "http://example.com/diaspora/diaspora-project-site", "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md", - "tag_list": [ + "topic_list": [ "example", "disapora project" ], @@ -974,7 +974,7 @@ If the project is a fork, and you provide a valid token to authenticate, the "path_with_namespace":"gitlab-org/gitlab-foss", "created_at":"2013-09-26T06:02:36.000Z", "default_branch":"master", - "tag_list":[], + "topic_list":[], "ssh_url_to_repo":"git@gitlab.com:gitlab-org/gitlab-foss.git", "http_url_to_repo":"https://gitlab.com/gitlab-org/gitlab-foss.git", "web_url":"https://gitlab.com/gitlab-org/gitlab-foss", @@ -1164,9 +1164,10 @@ POST /projects | `show_default_award_emojis` | boolean | **{dotted-circle}** No | Show default award emojis. | | `snippets_access_level` | string | **{dotted-circle}** No | One of `disabled`, `private`, or `enabled`. | | `snippets_enabled` | boolean | **{dotted-circle}** No | _(Deprecated)_ Enable snippets for this project. Use `snippets_access_level` instead. | -| `tag_list` | array | **{dotted-circle}** No | The list of tags for a project; put array of tags, that should be finally assigned to a project. | +| `tag_list` | array | **{dotted-circle}** No | _([Deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/328226) in GitLab 13.12)_ The list of tags for a project; put array of tags, that should be finally assigned to a project. Use `topic_list` instead. | | `template_name` | string | **{dotted-circle}** No | When used without `use_custom_template`, name of a [built-in project template](../user/project/working_with_projects.md#built-in-templates). When used with `use_custom_template`, name of a custom project template. | | `template_project_id` **(PREMIUM)** | integer | **{dotted-circle}** No | When used with `use_custom_template`, project ID of a custom project template. This is preferable to using `template_name` since `template_name` may be ambiguous. | +| `topic_list` | array | **{dotted-circle}** No | The list of topics for a project; put array of topics, that should be finally assigned to a project. _([Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/328226) in GitLab 13.12.)_ | | `use_custom_template` **(PREMIUM)** | boolean | **{dotted-circle}** No | Use either custom [instance](../user/admin_area/custom_project_templates.md) or [group](../user/group/custom_project_templates.md) (with `group_with_project_templates_id`) project template. | | `visibility` | string | **{dotted-circle}** No | See [project visibility level](#project-visibility-level). | | `wiki_access_level` | string | **{dotted-circle}** No | One of `disabled`, `private`, or `enabled`. | @@ -1238,8 +1239,9 @@ POST /projects/user/:user_id | `snippets_access_level` | string | **{dotted-circle}** No | One of `disabled`, `private`, or `enabled`. | | `snippets_enabled` | boolean | **{dotted-circle}** No | _(Deprecated)_ Enable snippets for this project. Use `snippets_access_level` instead. | | `suggestion_commit_message` | string | **{dotted-circle}** No | The commit message used to apply merge request suggestions. | -| `tag_list` | array | **{dotted-circle}** No | The list of tags for a project; put array of tags, that should be finally assigned to a project. | +| `tag_list` | array | **{dotted-circle}** No | _([Deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/328226) in GitLab 13.12)_ The list of tags for a project; put array of tags, that should be finally assigned to a project. Use `topic_list` instead. | | `template_name` | string | **{dotted-circle}** No | When used without `use_custom_template`, name of a [built-in project template](../user/project/working_with_projects.md#built-in-templates). When used with `use_custom_template`, name of a custom project template. | +| `topic_list` | array | **{dotted-circle}** No | The list of topics for a project; put array of topics, that should be finally assigned to a project. _([Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/328226) in GitLab 13.12.)_ | | `use_custom_template` **(PREMIUM)** | boolean | **{dotted-circle}** No | Use either custom [instance](../user/admin_area/custom_project_templates.md) or [group](../user/group/custom_project_templates.md) (with `group_with_project_templates_id`) project template. | | `visibility` | string | **{dotted-circle}** No | See [project visibility level](#project-visibility-level). | | `wiki_access_level` | string | **{dotted-circle}** No | One of `disabled`, `private`, or `enabled`. | @@ -1316,7 +1318,8 @@ PUT /projects/:id | `snippets_access_level` | string | **{dotted-circle}** No | One of `disabled`, `private`, or `enabled`. | | `snippets_enabled` | boolean | **{dotted-circle}** No | _(Deprecated)_ Enable snippets for this project. Use `snippets_access_level` instead. | | `suggestion_commit_message` | string | **{dotted-circle}** No | The commit message used to apply merge request suggestions. | -| `tag_list` | array | **{dotted-circle}** No | The list of tags for a project; put array of tags, that should be finally assigned to a project. | +| `tag_list` | array | **{dotted-circle}** No | _([Deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/328226) in GitLab 13.12)_ The list of tags for a project; put array of tags, that should be finally assigned to a project. Use `topic_list` instead. | +| `topic_list` | array | **{dotted-circle}** No | The list of topics for a project; put array of topics, that should be finally assigned to a project. _([Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/328226) in GitLab 13.12.)_ | | `visibility` | string | **{dotted-circle}** No | See [project visibility level](#project-visibility-level). | | `wiki_access_level` | string | **{dotted-circle}** No | One of `disabled`, `private`, or `enabled`. | | `wiki_enabled` | boolean | **{dotted-circle}** No | _(Deprecated)_ Enable wiki for this project. Use `wiki_access_level` instead. | @@ -1392,7 +1395,7 @@ Example responses: "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git", "web_url": "http://example.com/diaspora/diaspora-project-site", "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md", - "tag_list": [ + "topic_list": [ "example", "disapora project" ], @@ -1479,7 +1482,7 @@ Example response: "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git", "web_url": "http://example.com/diaspora/diaspora-project-site", "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md", - "tag_list": [ + "topic_list": [ "example", "disapora project" ], @@ -1572,7 +1575,7 @@ Example response: "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git", "web_url": "http://example.com/diaspora/diaspora-project-site", "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md", - "tag_list": [ + "topic_list": [ "example", "disapora project" ], @@ -1740,7 +1743,7 @@ Example response: "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git", "web_url": "http://example.com/diaspora/diaspora-project-site", "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md", - "tag_list": [ + "topic_list": [ "example", "disapora project" ], @@ -1854,7 +1857,7 @@ Example response: "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git", "web_url": "http://example.com/diaspora/diaspora-project-site", "readme_url": "http://example.com/diaspora/diaspora-project-site/blob/master/README.md", - "tag_list": [ + "topic_list": [ "example", "disapora project" ], @@ -2438,7 +2441,7 @@ Example response: "path_with_namespace": "cute-cats/hello-world", "created_at": "2020-10-15T16:25:22.415Z", "default_branch": "master", - "tag_list": [], + "topic_list": [], "ssh_url_to_repo": "git@gitlab.example.com:cute-cats/hello-world.git", "http_url_to_repo": "https://gitlab.example.com/cute-cats/hello-world.git", "web_url": "https://gitlab.example.com/cute-cats/hello-world", diff --git a/doc/api/search.md b/doc/api/search.md index c8f24c0924ab3c0ddd4082e9b52e4348380607ac..8b66d76f4eb728c60499a7d39d6ba5fb4e9bb57d 100644 --- a/doc/api/search.md +++ b/doc/api/search.md @@ -54,7 +54,7 @@ Example response: "path_with_namespace": "twitter/flight", "created_at": "2017-09-05T07:58:01.621Z", "default_branch": "master", - "tag_list":[], + "topic_list":[], "ssh_url_to_repo": "ssh://jarka@localhost:2222/twitter/flight.git", "http_url_to_repo": "http://localhost:3000/twitter/flight.git", "web_url": "http://localhost:3000/twitter/flight", @@ -475,7 +475,7 @@ Example response: "path_with_namespace": "twitter/flight", "created_at": "2017-09-05T07:58:01.621Z", "default_branch": "master", - "tag_list":[], + "topic_list":[], "ssh_url_to_repo": "ssh://jarka@localhost:2222/twitter/flight.git", "http_url_to_repo": "http://localhost:3000/twitter/flight.git", "web_url": "http://localhost:3000/twitter/flight", diff --git a/ee/spec/frontend/security_dashboard/store/modules/projects/data/mock_data.json b/ee/spec/frontend/security_dashboard/store/modules/projects/data/mock_data.json index e834a0c58f1c6158e88b9d993e170846a7b43463..d79bf0229a073d4797c792cbbc0f95bc77a961e4 100644 --- a/ee/spec/frontend/security_dashboard/store/modules/projects/data/mock_data.json +++ b/ee/spec/frontend/security_dashboard/store/modules/projects/data/mock_data.json @@ -3,7 +3,7 @@ "id": 9, "description": "foo", "default_branch": "master", - "tag_list": [], + "topic_list": [], "archived": false, "visibility": "internal", "ssh_url_to_repo": "git@gitlab.example.com/html5-boilerplate.git", diff --git a/ee/spec/frontend/vue_shared/dashboards/mock_data.js b/ee/spec/frontend/vue_shared/dashboards/mock_data.js index 5eb49348acdac4809c82f89d140f92e9f196a7cc..5151e2e41b0824b17cc04078e0c6ab08c7b214ca 100644 --- a/ee/spec/frontend/vue_shared/dashboards/mock_data.js +++ b/ee/spec/frontend/vue_shared/dashboards/mock_data.js @@ -101,7 +101,7 @@ export function mockProjectData( path_with_namespace: 'test/test-project', created_at: '2019-02-01T15:40:27.522Z', default_branch: 'main', - tag_list: [], + topic_list: [], avatar_url: null, web_url: 'https://mock-web_url/', namespace: { diff --git a/lib/api/entities/basic_project_details.rb b/lib/api/entities/basic_project_details.rb index 2de49d6ed40318d62e0a78d2b544011e783b8a4b..2419521af37f56385ee1272905fde0ff585955d6 100644 --- a/lib/api/entities/basic_project_details.rb +++ b/lib/api/entities/basic_project_details.rb @@ -7,11 +7,11 @@ class BasicProjectDetails < Entities::ProjectIdentity expose :default_branch, if: -> (project, options) { Ability.allowed?(options[:current_user], :download_code, project) } # Avoids an N+1 query: https://github.com/mbleigh/acts-as-taggable-on/issues/91#issuecomment-168273770 - expose :tag_list do |project| - # Tags is a preloaded association. If we perform then sorting + expose :topic_list do |project| + # Topics is a preloaded association. If we perform then sorting # through the database, it will trigger a new query, ending up # in an N+1 if we have several projects - project.tags.pluck(:name).sort # rubocop:disable CodeReuse/ActiveRecord + project.topics.pluck(:name).sort # rubocop:disable CodeReuse/ActiveRecord end expose :ssh_url_to_repo, :http_url_to_repo, :web_url, :readme_url @@ -40,12 +40,12 @@ class BasicProjectDetails < Entities::ProjectIdentity # rubocop: disable CodeReuse/ActiveRecord def self.preload_relation(projects_relation, options = {}) - # Preloading tags, should be done with using only `:tags`, - # as `:tags` are defined as: `has_many :tags, through: :taggings` - # N+1 is solved then by using `subject.tags.map(&:name)` + # Preloading topics, should be done with using only `:topics`, + # as `:topics` are defined as: `has_many :topics, through: :taggings` + # N+1 is solved then by using `subject.topics.map(&:name)` # MR describing the solution: https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/20555 projects_relation.preload(:project_feature, :route) - .preload(:import_state, :tags) + .preload(:import_state, :topics) .preload(:auto_devops) .preload(namespace: [:route, :owner]) end diff --git a/lib/api/entities/project.rb b/lib/api/entities/project.rb index 690bc5d419dc264e649cba8e8fbf1b9b8a65f135..24f072cc1d3401f28b7fb9c1033b3702deaf7382 100644 --- a/lib/api/entities/project.rb +++ b/lib/api/entities/project.rb @@ -123,9 +123,9 @@ class Project < BasicProjectDetails # rubocop: disable CodeReuse/ActiveRecord def self.preload_relation(projects_relation, options = {}) - # Preloading tags, should be done with using only `:tags`, - # as `:tags` are defined as: `has_many :tags, through: :taggings` - # N+1 is solved then by using `subject.tags.map(&:name)` + # Preloading topics, should be done with using only `:topics`, + # as `:topics` are defined as: `has_many :topics, through: :taggings` + # N+1 is solved then by using `subject.topics.map(&:name)` # MR describing the solution: https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/20555 super(projects_relation).preload(group: :namespace_settings) .preload(:ci_cd_settings) @@ -136,7 +136,7 @@ def self.preload_relation(projects_relation, options = {}) .preload(project_group_links: { group: :route }, fork_network: :root_project, fork_network_member: :forked_from_project, - forked_from_project: [:route, :forks, :tags, :group, :project_feature, namespace: [:route, :owner]]) + forked_from_project: [:route, :forks, :topics, :group, :project_feature, namespace: [:route, :owner]]) end # rubocop: enable CodeReuse/ActiveRecord diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 12edb77d46f4abd0ecf33656b5a29da9c09ac571..f5658d2cda8197eb0a89715c59088c2d1dfb770b 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -611,7 +611,7 @@ def project_finder_params_ce finder_params[:user] = params.delete(:user) if params[:user] finder_params[:id_after] = sanitize_id_param(params[:id_after]) if params[:id_after] finder_params[:id_before] = sanitize_id_param(params[:id_before]) if params[:id_before] - finder_params[:tag] = params[:topic] if params[:topic].present? + finder_params[:topic] = params[:topic] if params[:topic].present? finder_params end diff --git a/lib/api/helpers/projects_helpers.rb b/lib/api/helpers/projects_helpers.rb index cf2bcace33b31e7924121196ca1ab1dfae145e65..faceaa706aacf45cfdf1f77fce3ddbb3269635b0 100644 --- a/lib/api/helpers/projects_helpers.rb +++ b/lib/api/helpers/projects_helpers.rb @@ -51,7 +51,7 @@ module ProjectsHelpers optional :only_allow_merge_if_pipeline_succeeds, type: Boolean, desc: 'Only allow to merge if builds succeed' optional :allow_merge_on_skipped_pipeline, type: Boolean, desc: 'Allow to merge if pipeline is skipped' optional :only_allow_merge_if_all_discussions_are_resolved, type: Boolean, desc: 'Only allow to merge if all discussions are resolved' - optional :tag_list, type: Array[String], coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'The list of tags for a project' + optional :topic_list, type: Array[String], coerce_with: ::API::Validations::Types::CommaSeparatedToArray.coerce, desc: 'The list of topics for a project' # TODO: remove rubocop disable - https://gitlab.com/gitlab-org/gitlab/issues/14960 optional :avatar, type: File, desc: 'Avatar image for project' # rubocop:disable Scalability/FileUploads optional :printing_merge_request_link_enabled, type: Boolean, desc: 'Show link to create/view merge request when pushing from the command line' @@ -145,7 +145,7 @@ def self.update_params_at_least_one_of :restrict_user_defined_variables, :shared_runners_enabled, :snippets_access_level, - :tag_list, + :topic_list, :visibility, :wiki_access_level, :avatar, diff --git a/lib/gitlab/import_export/project/import_export.yml b/lib/gitlab/import_export/project/import_export.yml index 00c5d143b9da2643a876caf72ac771cb1263e88c..06fab72fe2e48c5a35f9ae3fc0882e374c5dbcfd 100644 --- a/lib/gitlab/import_export/project/import_export.yml +++ b/lib/gitlab/import_export/project/import_export.yml @@ -151,7 +151,7 @@ excluded_attributes: - :repository_languages - :bfg_object_map - :detected_repository_languages - - :tag_list + - :topic_list - :mirror_user_id - :mirror_trigger_builds - :only_mirror_protected_branches diff --git a/spec/features/projects/show/schema_markup_spec.rb b/spec/features/projects/show/schema_markup_spec.rb index 1777b72cbf5fbf2c45f97635484b61729791239e..28803db924acc0517b9333581c45be28b400ff46 100644 --- a/spec/features/projects/show/schema_markup_spec.rb +++ b/spec/features/projects/show/schema_markup_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Projects > Show > Schema Markup' do - let_it_be(:project) { create(:project, :repository, :public, :with_avatar, description: 'foobar', tag_list: 'tag1, tag2') } + let_it_be(:project) { create(:project, :repository, :public, :with_avatar, description: 'foobar', topic_list: 'topic1, topic2') } it 'shows SoftwareSourceCode structured markup', :js do visit project_path(project) @@ -16,7 +16,7 @@ expect(page).to have_selector('[itemprop="identifier"]', text: "Project ID: #{project.id}") expect(page).to have_selector('[itemprop="description"]', text: project.description) expect(page).to have_selector('[itemprop="license"]', text: project.repository.license.name) - expect(find_all('[itemprop="keywords"]').map(&:text)).to match_array(project.tag_list.map(&:capitalize)) + expect(find_all('[itemprop="keywords"]').map(&:text)).to match_array(project.topic_list.map(&:capitalize)) expect(page).to have_selector('[itemprop="about"]') end end diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb index c18b0f2688b2c91b01c7cdfb8a1d6fe8485f83b2..2ac829d406c49e783c336be464579ddf518111a1 100644 --- a/spec/features/projects_spec.rb +++ b/spec/features/projects_spec.rb @@ -128,23 +128,23 @@ end it 'shows project topics' do - project.update_attribute(:tag_list, 'topic1') + project.update_attribute(:topic_list, 'topic1') visit path expect(page).to have_css('.home-panel-topic-list') - expect(page).to have_link('Topic1', href: explore_projects_path(tag: 'topic1')) + expect(page).to have_link('Topic1', href: explore_projects_path(topic: 'topic1')) end - it 'shows up to 3 project tags' do - project.update_attribute(:tag_list, 'topic1, topic2, topic3, topic4') + it 'shows up to 3 project topics' do + project.update_attribute(:topic_list, 'topic1, topic2, topic3, topic4') visit path expect(page).to have_css('.home-panel-topic-list') - expect(page).to have_link('Topic1', href: explore_projects_path(tag: 'topic1')) - expect(page).to have_link('Topic2', href: explore_projects_path(tag: 'topic2')) - expect(page).to have_link('Topic3', href: explore_projects_path(tag: 'topic3')) + expect(page).to have_link('Topic1', href: explore_projects_path(topic: 'topic1')) + expect(page).to have_link('Topic2', href: explore_projects_path(topic: 'topic2')) + expect(page).to have_link('Topic3', href: explore_projects_path(topic: 'topic3')) expect(page).to have_content('+ 1 more') end end diff --git a/spec/finders/projects_finder_spec.rb b/spec/finders/projects_finder_spec.rb index a178261e8993213621e2b30f20d6f53f59102b7f..5e768bdc62a65396a39b21986fb5908249a7d39f 100644 --- a/spec/finders/projects_finder_spec.rb +++ b/spec/finders/projects_finder_spec.rb @@ -137,13 +137,13 @@ end end - describe 'filter by tags' do + describe 'filter by topics' do before do - public_project.tag_list.add('foo') + public_project.topic_list.add('foo') public_project.save! end - let(:params) { { tag: 'foo' } } + let(:params) { { topic: 'foo' } } it { is_expected.to eq([public_project]) } end diff --git a/spec/fixtures/api/schemas/public_api/v4/board.json b/spec/fixtures/api/schemas/public_api/v4/board.json index c3a140c1bd7384e7e5b9eadf463204779778d3ea..f57a952b286ebce6424d5c056a72896d7c6beb96 100644 --- a/spec/fixtures/api/schemas/public_api/v4/board.json +++ b/spec/fixtures/api/schemas/public_api/v4/board.json @@ -14,7 +14,7 @@ "avatar_url", "description", "default_branch", - "tag_list", + "topic_list", "ssh_url_to_repo", "http_url_to_repo", "web_url", @@ -33,7 +33,7 @@ "readme_url": { "type": ["string", "null"] }, "description": { "type": ["string", "null"] }, "default_branch": { "type": ["string", "null"] }, - "tag_list": { "type": "array" }, + "topic_list": { "type": "array" }, "ssh_url_to_repo": { "type": "string" }, "http_url_to_repo": { "type": "string" }, "web_url": { "type": "string" }, diff --git a/spec/fixtures/api/schemas/public_api/v4/project.json b/spec/fixtures/api/schemas/public_api/v4/project.json index 4a3149f2bdcddd550e6a6aed1714a14a31d2d545..e18e0a9a4ae245d0f632274bb072e060e018e7c1 100644 --- a/spec/fixtures/api/schemas/public_api/v4/project.json +++ b/spec/fixtures/api/schemas/public_api/v4/project.json @@ -9,7 +9,7 @@ "path_with_namespace": { "type": "string" }, "created_at": { "type": "string", "format": "date-time" }, "default_branch": { "type": ["string", "null"] }, - "tag_list": { + "topic_list": { "type": "array", "items": { "type": "string" @@ -37,7 +37,7 @@ }, "required": [ "id", "name", "name_with_namespace", "description", "path", - "path_with_namespace", "created_at", "default_branch", "tag_list", + "path_with_namespace", "created_at", "default_branch", "topic_list", "ssh_url_to_repo", "http_url_to_repo", "web_url", "readme_url", "avatar_url", "star_count", "forks_count", "last_activity_at", "namespace" ], diff --git a/spec/frontend/fixtures/static/projects.json b/spec/frontend/fixtures/static/projects.json index f28d9899099d0ac5f969a19b3999ec248db5ff9e..6e4772850bdb74e694d6bf20469f1cfcc9577f6d 100644 --- a/spec/frontend/fixtures/static/projects.json +++ b/spec/frontend/fixtures/static/projects.json @@ -2,7 +2,7 @@ "id": 9, "description": "", "default_branch": null, - "tag_list": [], + "topic_list": [], "public": true, "archived": false, "visibility_level": 20, @@ -53,7 +53,7 @@ "id": 8, "description": "Voluptatem quae nulla eius numquam ullam voluptatibus quia modi.", "default_branch": "master", - "tag_list": [], + "topic_list": [], "public": false, "archived": false, "visibility_level": 0, @@ -113,7 +113,7 @@ "id": 7, "description": "Modi odio mollitia dolorem qui.", "default_branch": "master", - "tag_list": [], + "topic_list": [], "public": false, "archived": false, "visibility_level": 0, @@ -161,7 +161,7 @@ "id": 6, "description": "Omnis asperiores ipsa et beatae quidem necessitatibus quia.", "default_branch": "master", - "tag_list": [], + "topic_list": [], "public": true, "archived": false, "visibility_level": 20, @@ -209,7 +209,7 @@ "id": 5, "description": "Voluptatem commodi voluptate placeat architecto beatae illum dolores fugiat.", "default_branch": "master", - "tag_list": [], + "topic_list": [], "public": false, "archived": false, "visibility_level": 0, @@ -257,7 +257,7 @@ "id": 4, "description": "Aut molestias quas est ut aperiam officia quod libero.", "default_branch": "master", - "tag_list": [], + "topic_list": [], "public": true, "archived": false, "visibility_level": 20, @@ -308,7 +308,7 @@ "id": 3, "description": "Excepturi molestiae quia repellendus omnis est illo illum eligendi.", "default_branch": "master", - "tag_list": [], + "topic_list": [], "public": true, "archived": false, "visibility_level": 20, @@ -356,7 +356,7 @@ "id": 2, "description": "Adipisci quaerat dignissimos enim sed ipsam dolorem quia.", "default_branch": "master", - "tag_list": [], + "topic_list": [], "public": false, "archived": false, "visibility_level": 10, @@ -407,7 +407,7 @@ "id": 1, "description": "Vel voluptatem maxime saepe ex quia.", "default_branch": "master", - "tag_list": [], + "topic_list": [], "public": false, "archived": false, "visibility_level": 0, diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb index f2c4068f0486476eac8b6ea9c7ba17774d42f6e9..571c99c698e3f15c0991482d5ea428e0515ee30e 100644 --- a/spec/graphql/types/project_type_spec.rb +++ b/spec/graphql/types/project_type_spec.rb @@ -14,7 +14,7 @@ it 'has the expected fields' do expected_fields = %w[ user_permissions id full_path path name_with_namespace - name description description_html tag_list ssh_url_to_repo + name description description_html topic_list ssh_url_to_repo http_url_to_repo web_url star_count forks_count created_at last_activity_at archived visibility container_registry_enabled shared_runners_enabled diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml index 340556c0dc4acfe8adb0ffc59c72b157ef68b9bf..f30950c7179e956ce9d069fd82777552a4594cc0 100644 --- a/spec/lib/gitlab/import_export/all_models.yml +++ b/spec/lib/gitlab/import_export/all_models.yml @@ -342,8 +342,8 @@ project: - external_approval_rules - taggings - base_tags -- tag_taggings -- tags +- topic_taggings +- topics - chat_services - cluster - clusters diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index f293fb7f27bd0cf25ee0096825e741709c0c7e4d..4a0edacfef5a3a009092c86385e27944f7113226 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -184,13 +184,13 @@ end end - it 'includes the project labels as the tag_list' do + it 'includes the project topics as the topic_list' do get api('/projects', user) expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array - expect(json_response.first.keys).to include('tag_list') + expect(json_response.first.keys).to include('topic_list') end it 'includes open_issues_count' do @@ -223,9 +223,9 @@ expect(json_response.find { |hash| hash['id'] == project.id }.keys).not_to include('open_issues_count') end - context 'filter by topic (column tag_list)' do + context 'filter by topic (column topic_list)' do before do - project.update!(tag_list: %w(ruby javascript)) + project.update!(topic_list: %w(ruby javascript)) end it 'returns no projects' do @@ -1050,12 +1050,12 @@ expect(json_response['readme_url']).to eql("#{Gitlab.config.gitlab.url}/#{json_response['namespace']['full_path']}/somewhere/-/blob/master/README.md") end - it 'sets tag list to a project' do - project = attributes_for(:project, tag_list: %w[tagFirst tagSecond]) + it 'sets topic list to a project' do + project = attributes_for(:project, topic_list: %w[topicFirst topicSecond]) post api('/projects', user), params: project - expect(json_response['tag_list']).to eq(%w[tagFirst tagSecond]) + expect(json_response['topic_list']).to eq(%w[topicFirst topicSecond]) end it 'uploads avatar for project a project' do @@ -1901,7 +1901,7 @@ expect(json_response['id']).to eq(project.id) expect(json_response['description']).to eq(project.description) expect(json_response['default_branch']).to eq(project.default_branch) - expect(json_response['tag_list']).to be_an Array + expect(json_response['topic_list']).to be_an Array expect(json_response['archived']).to be_falsey expect(json_response['visibility']).to be_present expect(json_response['ssh_url_to_repo']).to be_present @@ -1978,7 +1978,7 @@ def failure_message(diff) expect(json_response['id']).to eq(project.id) expect(json_response['description']).to eq(project.description) expect(json_response['default_branch']).to eq(project.default_branch) - expect(json_response['tag_list']).to be_an Array + expect(json_response['topic_list']).to be_an Array expect(json_response['archived']).to be_falsey expect(json_response['visibility']).to be_present expect(json_response['ssh_url_to_repo']).to be_present