diff options
36 files changed, 307 insertions, 296 deletions
diff --git a/.gitlab/issue_templates/Default.md b/.gitlab/issue_templates/Default.md new file mode 100644 index 00000000000..f87b82e341b --- /dev/null +++ b/.gitlab/issue_templates/Default.md @@ -0,0 +1,11 @@ +Before raising an issue to the GitLab issue tracker, please read through our guide for finding help to determine the best place to post: + +* https://about.gitlab.com/getting-help/ + +If you are experiencing an issue when using GitLab.com, your first port of call should be the Community Forum. Your issue may have already been reported there by another user. Please check: + +* https://forum.gitlab.com/ + +If you feel that your issue can be categorized as a reproducible bug or a feature proposal, please use one of the issue templates provided and include as much information as possible. + +Thank you for helping to make GitLab a better product. diff --git a/.gitlab/merge_request_templates/Default.md b/.gitlab/merge_request_templates/Default.md new file mode 100644 index 00000000000..9d5ab41afbe --- /dev/null +++ b/.gitlab/merge_request_templates/Default.md @@ -0,0 +1,44 @@ +## What does this MR do and why? + +_Describe in detail what your merge request does and why._ + +<!-- +Please keep this description updated with any discussion that takes place so +that reviewers can understand your intent. Keeping the description updated is +especially important if they didn't participate in the discussion. +--> + +## Screenshots or screen recordings + +_These are strongly recommended to assist reviewers and reduce the time to merge your change._ + +<!-- +Please include any relevant screenshots or screen recordings that will assist +reviewers and future readers. If you need help visually verifying the change, +please leave a comment and ping a GitLab reviewer, maintainer, or MR coach. +--> + +## How to set up and validate locally + +_Numbered steps to set up and validate the change are strongly suggested._ + +<!-- +Example below: + +1. Enable the invite modal + ```ruby + Feature.enable(:invite_members_group_modal) + ``` +1. In rails console enable the experiment fully + ```ruby + Feature.enable(:member_areas_of_focus) + ``` +1. Visit any group or project member pages such as `http://127.0.0.1:3000/groups/flightjs/-/group_members` +1. Click the `invite members` button. +--> + +## MR acceptance checklist + +This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability. + +* [ ] I have evaluated the [MR acceptance checklist](https://docs.gitlab.com/ee/development/code_review.html#acceptance-checklist) for this MR. diff --git a/.rubocop.yml b/.rubocop.yml index 99424713bd8..bf74841b3d0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -48,6 +48,7 @@ AllCops: Metrics/ParameterLists: Exclude: + # See https://gitlab.com/gitlab-org/gitlab/-/issues/356771 - 'app/components/**/*' Cop/AvoidKeywordArgumentsInSidekiqWorkers: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 45dc5864773..c3e4bb0c370 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -107,11 +107,6 @@ Lint/MixedRegexpCaptureTypes: Lint/RedundantCopDisableDirective: Enabled: false -# Offense count: 1 -Lint/SelfAssignment: - Exclude: - - 'spec/lib/gitlab/search_context/builder_spec.rb' - # Offense count: 3 Lint/StructNewOverride: Exclude: @@ -125,11 +120,6 @@ Lint/StructNewOverride: Lint/UselessMethodDefinition: Enabled: false -# Offense count: 14 -# Configuration parameters: IgnoredMethods. -Metrics/PerceivedComplexity: - Max: 25 - # Offense count: 11 # Configuration parameters: EnforcedStyle. # SupportedStyles: lowercase, uppercase @@ -333,22 +323,6 @@ Rails/CreateTableWithTimestamps: Rails/FilePath: Enabled: false -# Offense count: 15 -# Cop supports --auto-correct. -Rails/FindById: - Exclude: - - 'app/controllers/projects/pipelines_controller.rb' - - 'app/services/concerns/deploy_token_methods.rb' - - 'ee/app/controllers/ee/groups/group_members_controller.rb' - - 'ee/lib/api/audit_events.rb' - - 'ee/lib/api/merge_request_approval_rules.rb' - - 'ee/lib/ee/api/groups.rb' - - 'ee/lib/ee/api/projects.rb' - - 'ee/spec/finders/audit_log_finder_spec.rb' - - 'lib/api/snippets.rb' - - 'spec/finders/concerns/finder_methods_spec.rb' - - 'spec/finders/concerns/finder_with_cross_project_access_spec.rb' - # Offense count: 354 # Configuration parameters: Include. # Include: app/models/**/*.rb diff --git a/.rubocop_todo/metrics/perceived_complexity.yml b/.rubocop_todo/metrics/perceived_complexity.yml new file mode 100644 index 00000000000..0f2d3030064 --- /dev/null +++ b/.rubocop_todo/metrics/perceived_complexity.yml @@ -0,0 +1,24 @@ +--- +Metrics/PerceivedComplexity: + Exclude: + - 'app/controllers/admin/application_settings_controller.rb' + - 'app/finders/deployments_finder.rb' + - 'app/helpers/button_helper.rb' + - 'app/helpers/nav/top_nav_helper.rb' + - 'app/helpers/submodule_helper.rb' + - 'app/services/projects/create_service.rb' + - 'ee/app/controllers/ee/groups_controller.rb' + - 'ee/lib/elastic/latest/git_class_proxy.rb' + - 'lib/banzai/filter/references/abstract_reference_filter.rb' + - 'lib/banzai/renderer.rb' + - 'lib/gitlab/background_migration/recalculate_vulnerabilities_occurrences_uuid.rb' + - 'lib/gitlab/conflict/file.rb' + - 'lib/gitlab/database/query_analyzers/prevent_cross_database_modification.rb' + - 'lib/gitlab/diff/parser.rb' + - 'lib/gitlab/utils/merge_hash.rb' + - 'qa/qa/runtime/browser.rb' + - 'qa/qa/specs/runner.rb' + - 'qa/qa/support/repeater.rb' + - 'rubocop/cop/gitlab/mark_used_feature_flags.rb' + - 'sidekiq_cluster/cli.rb' + - 'spec/support/cycle_analytics_helpers/test_generation.rb' diff --git a/app/assets/javascripts/sidebar/graphql.js b/app/assets/javascripts/sidebar/graphql.js index fc757922f09..034bdc71122 100644 --- a/app/assets/javascripts/sidebar/graphql.js +++ b/app/assets/javascripts/sidebar/graphql.js @@ -1,11 +1,9 @@ import produce from 'immer'; import VueApollo from 'vue-apollo'; import getIssueStateQuery from '~/issues/show/queries/get_issue_state.query.graphql'; -import { resolvers as workItemResolvers } from '~/work_items/graphql/resolvers'; import createDefaultClient from '~/lib/graphql'; const resolvers = { - ...workItemResolvers, Mutation: { updateIssueState: (_, { issueType = undefined, isDirty = false }, { cache }) => { const sourceData = cache.readQuery({ query: getIssueStateQuery }); @@ -14,7 +12,6 @@ const resolvers = { }); cache.writeQuery({ query: getIssueStateQuery, data }); }, - ...workItemResolvers.Mutation, }, }; diff --git a/app/assets/javascripts/work_items/constants.js b/app/assets/javascripts/work_items/constants.js index 22f24ad8af6..d3bcaf0f95f 100644 --- a/app/assets/javascripts/work_items/constants.js +++ b/app/assets/javascripts/work_items/constants.js @@ -4,7 +4,3 @@ export const i18n = { fetchError: s__('WorkItem|Something went wrong when fetching the work item. Please try again.'), updateError: s__('WorkItem|Something went wrong while updating the work item. Please try again.'), }; - -export const widgetTypes = { - title: 'TITLE', -}; diff --git a/app/assets/javascripts/work_items/graphql/provider.js b/app/assets/javascripts/work_items/graphql/provider.js index c15382874d8..3c2955ce1e2 100644 --- a/app/assets/javascripts/work_items/graphql/provider.js +++ b/app/assets/javascripts/work_items/graphql/provider.js @@ -1,45 +1,11 @@ import Vue from 'vue'; import VueApollo from 'vue-apollo'; import createDefaultClient from '~/lib/graphql'; -import workItemQuery from './work_item.query.graphql'; -import { resolvers } from './resolvers'; -import typeDefs from './typedefs.graphql'; export function createApolloProvider() { Vue.use(VueApollo); - const defaultClient = createDefaultClient(resolvers, { - typeDefs, - cacheConfig: { - possibleTypes: { - LocalWorkItemWidget: ['LocalTitleWidget'], - }, - }, - }); - - defaultClient.cache.writeQuery({ - query: workItemQuery, - variables: { - id: 'gid://gitlab/WorkItem/1', - }, - data: { - workItem: { - __typename: 'WorkItem', - id: 'gid://gitlab/WorkItem/1', - // eslint-disable-next-line @gitlab/require-i18n-strings - title: 'Test Work Item', - workItemType: { - __typename: 'WorkItemType', - id: 'work-item-type-1', - name: 'Type', // eslint-disable-line @gitlab/require-i18n-strings - }, - widgets: { - __typename: 'LocalWorkItemWidgetConnection', - nodes: [], - }, - }, - }, - }); + const defaultClient = createDefaultClient(); return new VueApollo({ defaultClient, diff --git a/app/assets/javascripts/work_items/graphql/resolvers.js b/app/assets/javascripts/work_items/graphql/resolvers.js deleted file mode 100644 index fb74e27f840..00000000000 --- a/app/assets/javascripts/work_items/graphql/resolvers.js +++ /dev/null @@ -1,29 +0,0 @@ -import workItemQuery from './work_item.query.graphql'; - -export const resolvers = { - Mutation: { - localUpdateWorkItem(_, { input }, { cache }) { - const workItem = { - __typename: 'LocalWorkItem', - type: 'FEATURE', - id: input.id, - title: input.title, - widgets: { - __typename: 'LocalWorkItemWidgetConnection', - nodes: [], - }, - }; - - cache.writeQuery({ - query: workItemQuery, - variables: { id: input.id }, - data: { localWorkItem: workItem }, - }); - - return { - __typename: 'LocalUpdateWorkItemPayload', - workItem, - }; - }, - }, -}; diff --git a/app/assets/javascripts/work_items/graphql/typedefs.graphql b/app/assets/javascripts/work_items/graphql/typedefs.graphql deleted file mode 100644 index 9b4811203f5..00000000000 --- a/app/assets/javascripts/work_items/graphql/typedefs.graphql +++ /dev/null @@ -1,56 +0,0 @@ -enum LocalWorkItemType { - FEATURE -} - -enum LocalWidgetType { - TITLE -} - -interface LocalWorkItemWidget { - type: LocalWidgetType! -} - -# Replicating Relay connection type for client schema -type LocalWorkItemWidgetEdge { - cursor: String! - node: LocalWorkItemWidget -} - -type LocalWorkItemWidgetConnection { - edges: [LocalWorkItemWidgetEdge] - nodes: [LocalWorkItemWidget] - pageInfo: PageInfo! -} - -type LocalWorkItem { - id: ID! - type: LocalWorkItemType! - title: String! - widgets: [LocalWorkItemWidgetConnection] -} - -input LocalCreateWorkItemInput { - title: String! -} - -input LocalUpdateWorkItemInput { - id: ID! - title: String -} - -type LocalCreateWorkItemPayload { - workItem: LocalWorkItem! -} - -type LocalUpdateWorkItemPayload { - workItem: LocalWorkItem! -} - -extend type Query { - localWorkItem(id: ID!): LocalWorkItem! -} - -extend type Mutation { - localCreateWorkItem(input: LocalCreateWorkItemInput!): LocalCreateWorkItemPayload! - localUpdateWorkItem(input: LocalUpdateWorkItemInput!): LocalUpdateWorkItemPayload! -} diff --git a/app/assets/javascripts/work_items/graphql/widget.fragment.graphql b/app/assets/javascripts/work_items/graphql/widget.fragment.graphql deleted file mode 100644 index 154367dc0d8..00000000000 --- a/app/assets/javascripts/work_items/graphql/widget.fragment.graphql +++ /dev/null @@ -1,3 +0,0 @@ -fragment WidgetBase on LocalWorkItemWidget { - type -} diff --git a/app/assets/javascripts/work_items/pages/create_work_item.vue b/app/assets/javascripts/work_items/pages/create_work_item.vue index 04d76f12d00..a95da80ac95 100644 --- a/app/assets/javascripts/work_items/pages/create_work_item.vue +++ b/app/assets/javascripts/work_items/pages/create_work_item.vue @@ -128,10 +128,6 @@ export default { id, title, workItemType, - widgets: { - __typename: 'LocalWorkItemWidgetConnection', - nodes: [], - }, }, }, }); diff --git a/app/controllers/dashboard/application_controller.rb b/app/controllers/dashboard/application_controller.rb index 0e9fdc60363..95deacdc5b9 100644 --- a/app/controllers/dashboard/application_controller.rb +++ b/app/controllers/dashboard/application_controller.rb @@ -11,6 +11,6 @@ class Dashboard::ApplicationController < ApplicationController private def projects - @projects ||= current_user.authorized_projects.sorted_by_activity.non_archived + @projects ||= current_user.authorized_projects.sorted_by_updated_desc.non_archived end end diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index b7428826c91..02f041637ba 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -268,7 +268,7 @@ class Projects::PipelinesController < Projects::ApplicationController project .all_pipelines .includes(builds: :tags, user: :status) - .find_by!(id: params[:id]) + .find(params[:id]) .present(current_user: current_user) end end diff --git a/app/helpers/routing/pseudonymization_helper.rb b/app/helpers/routing/pseudonymization_helper.rb index f1fafd563ce..3e5d4ee21c0 100644 --- a/app/helpers/routing/pseudonymization_helper.rb +++ b/app/helpers/routing/pseudonymization_helper.rb @@ -5,7 +5,11 @@ module Routing class MaskHelper QUERY_PARAMS_TO_NOT_MASK = %w[ scope + severity + sortBy + sortDesc state + tab ].freeze def initialize(request_object, group, project) diff --git a/app/models/project.rb b/app/models/project.rb index ab50d61b93f..ba2e4b14042 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -546,8 +546,8 @@ class Project < ApplicationRecord .or(arel_table[:storage_version].eq(nil))) end - # last_activity_at is throttled every minute, but last_repository_updated_at is updated with every push - scope :sorted_by_activity, -> { reorder(Arel.sql("GREATEST(COALESCE(last_activity_at, '1970-01-01'), COALESCE(last_repository_updated_at, '1970-01-01')) DESC")) } + scope :sorted_by_updated_asc, -> { reorder(self.arel_table['updated_at'].asc) } + scope :sorted_by_updated_desc, -> { reorder(self.arel_table['updated_at'].desc) } scope :sorted_by_stars_desc, -> { reorder(self.arel_table['star_count'].desc) } scope :sorted_by_stars_asc, -> { reorder(self.arel_table['star_count'].asc) } # Sometimes queries (e.g. using CTEs) require explicit disambiguation with table name @@ -783,9 +783,9 @@ class Project < ApplicationRecord # pass a string to avoid AR adding the table name reorder('project_statistics.storage_size DESC, projects.id DESC') when 'latest_activity_desc' - reorder(self.arel_table['last_activity_at'].desc) + sorted_by_updated_desc when 'latest_activity_asc' - reorder(self.arel_table['last_activity_at'].asc) + sorted_by_updated_asc when 'stars_desc' sorted_by_stars_desc when 'stars_asc' @@ -1404,7 +1404,7 @@ class Project < ApplicationRecord end def last_activity_date - [last_activity_at, last_repository_updated_at, updated_at].compact.max + updated_at end def project_id diff --git a/app/services/concerns/deploy_token_methods.rb b/app/services/concerns/deploy_token_methods.rb index c792f10fb73..578be53f82c 100644 --- a/app/services/concerns/deploy_token_methods.rb +++ b/app/services/concerns/deploy_token_methods.rb @@ -11,7 +11,7 @@ module DeployTokenMethods end def destroy_deploy_token(entity, params) - deploy_token = entity.deploy_tokens.find_by_id!(params[:token_id]) + deploy_token = entity.deploy_tokens.find(params[:token_id]) deploy_token.destroy end diff --git a/doc/api/linked_epics.md b/doc/api/linked_epics.md index 2f46786251c..df302be0555 100644 --- a/doc/api/linked_epics.md +++ b/doc/api/linked_epics.md @@ -91,6 +91,8 @@ Example response: ## Create a related epic link +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/352840) in GitLab 14.10. + Create a two-way relation between two epics. The user must be allowed to update both epics to succeed. @@ -205,3 +207,120 @@ Example response: "link_type": "relates_to" } ``` + +## Delete a related epic link + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/352840) in GitLab 14.10. + +Delete a two-way relation between two epics. The user must be allowed to +update both epics to succeed. + +```plaintext +DELETE /groups/:id/epics/:epic_iid/related_epics/:related_epic_link_id +``` + +Supported attributes: + +| Attribute | Type | Required | Description | +|--------------------------|----------------|-----------------------------|---------------------------------------| +| `epic_iid` | integer | **{check-circle}** Yes | Internal ID of a group's epic. | +| `id` | integer/string | **{check-circle}** Yes | ID or [URL-encoded path of the group](index.md#namespaced-path-encoding) owned by the authenticated user. | +| `related_epic_link_id` | integer/string | **{check-circle}** Yes | Internal ID of a related epic link. | + +Example request: + +```shell +curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/26/epics/1/related_epics/1" +``` + +Example response: + +```json +{ + "source_epic": { + "id": 21, + "iid": 1, + "color": "#1068bf", + "text_color": "#FFFFFF", + "group_id": 26, + "parent_id": null, + "parent_iid": null, + "title": "Aspernatur recusandae distinctio omnis et qui est iste.", + "description": "some description", + "confidential": false, + "author": { + "id": 15, + "username": "trina", + "name": "Theresia Robel", + "state": "active", + "avatar_url": "https://www.gravatar.com/avatar/085e28df717e16484cbf6ceca75e9a93?s=80&d=identicon", + "web_url": "http://gitlab.example.com/trina" + }, + "start_date": null, + "end_date": null, + "due_date": null, + "state": "opened", + "web_url": "http://gitlab.example.com/groups/flightjs/-/epics/1", + "references": { + "short": "&1", + "relative": "&1", + "full": "flightjs&1" + }, + "created_at": "2022-01-31T15:10:44.988Z", + "updated_at": "2022-03-16T09:32:35.712Z", + "closed_at": null, + "labels": [], + "upvotes": 0, + "downvotes": 0, + "_links": { + "self": "http://gitlab.example.com/api/v4/groups/26/epics/1", + "epic_issues": "http://gitlab.example.com/api/v4/groups/26/epics/1/issues", + "group": "http://gitlab.example.com/api/v4/groups/26", + "parent": null + } + }, + "target_epic": { + "id": 25, + "iid": 5, + "color": "#1068bf", + "text_color": "#FFFFFF", + "group_id": 26, + "parent_id": null, + "parent_iid": null, + "title": "Aut assumenda id nihil distinctio fugiat vel numquam est.", + "description": "some description", + "confidential": false, + "author": { + "id": 3, + "username": "valerie", + "name": "Erika Wolf", + "state": "active", + "avatar_url": "https://www.gravatar.com/avatar/9ef7666abb101418a4716a8ed4dded80?s=80&d=identicon", + "web_url": "http://gitlab.example.com/valerie" + }, + "start_date": null, + "end_date": null, + "due_date": null, + "state": "opened", + "web_url": "http://gitlab.example.com/groups/flightjs/-/epics/5", + "references": { + "short": "&5", + "relative": "&5", + "full": "flightjs&5" + }, + "created_at": "2022-01-31T15:10:45.080Z", + "updated_at": "2022-03-16T09:32:35.842Z", + "closed_at": null, + "labels": [], + "upvotes": 0, + "downvotes": 0, + "_links": { + "self": "http://gitlab.example.com/api/v4/groups/26/epics/5", + "epic_issues": "http://gitlab.example.com/api/v4/groups/26/epics/5/issues", + "group": "http://gitlab.example.com/api/v4/groups/26", + "parent": null + } + }, + "link_type": "relates_to" +} +``` diff --git a/doc/development/testing_guide/best_practices.md b/doc/development/testing_guide/best_practices.md index fe0c4c13ba2..09306dfc2a7 100644 --- a/doc/development/testing_guide/best_practices.md +++ b/doc/development/testing_guide/best_practices.md @@ -404,7 +404,7 @@ click_link _('UI testing docs') fill_in _('Search projects'), with: 'gitlab' # fill in text input with text -select _('Last updated'), from: 'Sort by' # select an option from a select input +select _('Updated date'), from: 'Sort by' # select an option from a select input check _('Checkbox label') uncheck _('Checkbox label') @@ -465,8 +465,8 @@ expect(page).to have_checked_field _('Checkbox label') expect(page).to have_unchecked_field _('Radio input label') expect(page).to have_select _('Sort by') -expect(page).to have_select _('Sort by'), selected: 'Last updated' # assert the option is selected -expect(page).to have_select _('Sort by'), options: ['Last updated', 'Created date', 'Due date'] # assert an exact list of options +expect(page).to have_select _('Sort by'), selected: 'Updated date' # assert the option is selected +expect(page).to have_select _('Sort by'), options: ['Updated date', 'Created date', 'Due date'] # assert an exact list of options expect(page).to have_select _('Sort by'), with_options: ['Created date', 'Due date'] # assert a partial list of options expect(page).to have_text _('Some paragraph text.') diff --git a/doc/integration/jira/issues.md b/doc/integration/jira/issues.md index e24862242e1..28998851697 100644 --- a/doc/integration/jira/issues.md +++ b/doc/integration/jira/issues.md @@ -106,7 +106,7 @@ sorts by **Created date** by default, with the newest issues listed at the top: ![Jira issues integration enabled](img/open_jira_issues_list_v14_6.png) -- To display the most recently updated issues first, select **Last updated**. +- To display the most recently updated issues first, select **Updated date**. - You can [search and filter](#search-and-filter-the-issues-list) the issues list. - In GitLab [versions 13.10 and later](https://gitlab.com/gitlab-org/gitlab/-/issues/299832), you can select an issue from the list to view it in GitLab: diff --git a/doc/user/admin_area/index.md b/doc/user/admin_area/index.md index 08fb756e79f..f57672d3d36 100644 --- a/doc/user/admin_area/index.md +++ b/doc/user/admin_area/index.md @@ -79,28 +79,29 @@ To access the Projects page: By default, all projects are listed, in reverse order of when they were last updated. For each project, the following information is listed: -- Name. -- Namespace. -- Description. -- Size, updated every 15 minutes at most. +- Name +- Namespace +- Description +- Size, updated every 15 minutes at most Projects can be edited or deleted. The list of projects can be sorted by: -- Name. -- Last created. -- Oldest created. -- Last updated. -- Oldest updated. -- Owner. +- Updated date +- Last created +- Name +- Most stars +- Oldest created +- Oldest updated +- Largest repository A user can choose to hide or show archived projects in the list. In the **Filter by name** field, type the project name you want to find, and GitLab filters them as you type. -Select from the **Namespace** dropdown to filter only projects in that namespace. +To filter only projects in that namespace, select from the **Namespace** dropdown list. You can combine the filter options. For example, to list only public projects with `score` in their name: diff --git a/doc/user/project/issues/sorting_issue_lists.md b/doc/user/project/issues/sorting_issue_lists.md index 9311ef590df..95a7e9387e8 100644 --- a/doc/user/project/issues/sorting_issue_lists.md +++ b/doc/user/project/issues/sorting_issue_lists.md @@ -6,20 +6,7 @@ info: To determine the technical writer assigned to the Stage/Group associated w # Sorting and ordering issue lists **(FREE)** -You can sort a list of issues several ways, including by: - -- [Blocking issues](#sorting-by-blocking-issues) -- [Created date](#sorting-by-created-date) -- [Due date](#sorting-by-due-date) -- [Label priority](#sorting-by-label-priority) -- [Last updated](#sorting-by-last-updated) -- [Manual sorting](#manual-sorting) -- [Milestone due date](#sorting-by-milestone-due-date) -- [Popularity](#sorting-by-popularity) -- [Priority](#sorting-by-priority) -- [Title](#sorting-by-title) -- [Weight](#sorting-by-weight) - +You can sort a list of issues several ways. The available sorting options can change based on the context of the list. ## Sorting by blocking issues **(PREMIUM)** @@ -51,10 +38,10 @@ For more information, see [issue 14523](https://gitlab.com/gitlab-org/gitlab/-/i To learn how to change label priority, see [Label priority](../labels.md#set-label-priority). -## Sorting by last updated +## Sorting by updated date -When you sort by **Last updated**, the issue list changes to sort by the time of a last -update. Issues changed the most recently are first. +When you sort by **Updated date**, the issue list changes to sort by the time of a last +update. Issues changed the most recently are shown first. ## Manual sorting diff --git a/doc/user/project/requirements/index.md b/doc/user/project/requirements/index.md index 6abe9c08d28..8b80c494e2f 100644 --- a/doc/user/project/requirements/index.md +++ b/doc/user/project/requirements/index.md @@ -127,7 +127,7 @@ To search for a requirement: You can also sort the requirements list by: - Created date -- Last updated +- Updated date ## Allow requirements to be satisfied from a CI job diff --git a/doc/user/search/img/sort_projects.png b/doc/user/search/img/sort_projects.png Binary files differdeleted file mode 100644 index 9bf2770b299..00000000000 --- a/doc/user/search/img/sort_projects.png +++ /dev/null diff --git a/doc/user/search/index.md b/doc/user/search/index.md index 44327af380e..21f35e76418 100644 --- a/doc/user/search/index.md +++ b/doc/user/search/index.md @@ -207,10 +207,14 @@ You can also look for the projects you [starred](../project/working_with_project You can **Explore** all public and internal projects available in GitLab.com, from which you can filter by visibility, through **Trending**, best rated with **Most stars**, or **All** of them. -You can also sort them by **Name**, **Last created**, **Oldest created**, **Last updated**, -**Oldest updated**, **Owner**, and choose to hide or show **archived projects**: +You can also sort them by: -![sort projects](img/sort_projects.png) +- Name +- Created date +- Updated date +- Owner + +You can also choose to hide or show archived projects. ## Groups @@ -221,7 +225,7 @@ On the field **Filter by name**, type the group name you want to find, and GitLa filters them for you as you type. You can also **Explore** all public and internal groups available in GitLab.com, -and sort them by **Last created**, **Oldest created**, **Last updated**, or **Oldest updated**. +and sort them by **Name**, **Last created**, **Oldest created**, or **Updated date**. ## Issue boards diff --git a/lib/api/snippets.rb b/lib/api/snippets.rb index aa122c13e0c..496532a15b2 100644 --- a/lib/api/snippets.rb +++ b/lib/api/snippets.rb @@ -200,7 +200,7 @@ module API get ":id/user_agent_detail" do authenticated_as_admin! - snippet = Snippet.find_by_id!(params[:id]) + snippet = Snippet.find(params[:id]) break not_found!('UserAgentDetail') unless snippet.user_agent_detail diff --git a/spec/finders/concerns/finder_methods_spec.rb b/spec/finders/concerns/finder_methods_spec.rb index 195449d70c3..98d6ca8da3b 100644 --- a/spec/finders/concerns/finder_methods_spec.rb +++ b/spec/finders/concerns/finder_methods_spec.rb @@ -30,6 +30,7 @@ RSpec.describe FinderMethods do authorized_project.add_developer(user) end + # rubocop:disable Rails/FindById describe '#find_by!' do it 'returns the project if the user has access' do expect(finder.find_by!(id: authorized_project.id)).to eq(authorized_project) @@ -53,6 +54,7 @@ RSpec.describe FinderMethods do finder.find_by!(id: authorized_project.id) end end + # rubocop:enable Rails/FindById describe '#find' do it 'returns the project if the user has access' do diff --git a/spec/finders/concerns/finder_with_cross_project_access_spec.rb b/spec/finders/concerns/finder_with_cross_project_access_spec.rb index 116b523bd99..0798528c200 100644 --- a/spec/finders/concerns/finder_with_cross_project_access_spec.rb +++ b/spec/finders/concerns/finder_with_cross_project_access_spec.rb @@ -93,11 +93,11 @@ RSpec.describe FinderWithCrossProjectAccess do it 'checks the accessibility of the subject directly' do expect_access_check_on_result - finder.find_by!(id: result.id) + finder.find(result.id) end it 're-enables the check after the find failed' do - finder.find_by!(id: non_existing_record_id) rescue ActiveRecord::RecordNotFound + finder.find(non_existing_record_id) rescue ActiveRecord::RecordNotFound expect(finder.instance_variable_get(:@should_skip_cross_project_check)) .to eq(false) diff --git a/spec/frontend/work_items/components/work_item_title_spec.js b/spec/frontend/work_items/components/work_item_title_spec.js index af4692857b3..9b1ef2d14e4 100644 --- a/spec/frontend/work_items/components/work_item_title_spec.js +++ b/spec/frontend/work_items/components/work_item_title_spec.js @@ -22,13 +22,14 @@ describe('WorkItemTitle component', () => { const findItemTitle = () => wrapper.findComponent(ItemTitle); const createComponent = ({ loading = false, mutationHandler = mutationSuccessHandler } = {}) => { + const { id, title, workItemType } = workItemQueryResponse.data.workItem; wrapper = shallowMount(WorkItemTitle, { apolloProvider: createMockApollo([[updateWorkItemMutation, mutationHandler]]), propsData: { loading, - workItemId: workItemQueryResponse.workItem.id, - workItemTitle: workItemQueryResponse.workItem.title, - workItemType: workItemQueryResponse.workItem.workItemType.name, + workItemId: id, + workItemTitle: title, + workItemType: workItemType.name, }, }); }; @@ -61,7 +62,7 @@ describe('WorkItemTitle component', () => { }); it('renders title', () => { - expect(findItemTitle().props('title')).toBe(workItemQueryResponse.workItem.title); + expect(findItemTitle().props('title')).toBe(workItemQueryResponse.data.workItem.title); }); }); @@ -73,13 +74,18 @@ describe('WorkItemTitle component', () => { findItemTitle().vm.$emit('title-changed', title); - expect(mutationSuccessHandler).toHaveBeenCalledWith({ input: { id: '1', title } }); + expect(mutationSuccessHandler).toHaveBeenCalledWith({ + input: { + id: workItemQueryResponse.data.workItem.id, + title, + }, + }); }); it('does not call a mutation when the title has not changed', () => { createComponent(); - findItemTitle().vm.$emit('title-changed', workItemQueryResponse.workItem.title); + findItemTitle().vm.$emit('title-changed', workItemQueryResponse.data.workItem.title); expect(mutationSuccessHandler).not.toHaveBeenCalled(); }); diff --git a/spec/frontend/work_items/mock_data.js b/spec/frontend/work_items/mock_data.js index b6d4a91ec32..2ee0dd14359 100644 --- a/spec/frontend/work_items/mock_data.js +++ b/spec/frontend/work_items/mock_data.js @@ -1,22 +1,14 @@ export const workItemQueryResponse = { - workItem: { - __typename: 'WorkItem', - id: '1', - title: 'Test', - workItemType: { - __typename: 'WorkItemType', - id: 'work-item-type-1', - name: 'Task', - }, - widgets: { - __typename: 'LocalWorkItemWidgetConnection', - nodes: [ - { - __typename: 'LocalTitleWidget', - type: 'TITLE', - contentText: 'Test', - }, - ], + data: { + workItem: { + __typename: 'WorkItem', + id: 'gid://gitlab/WorkItem/1', + title: 'Test', + workItemType: { + __typename: 'WorkItemType', + id: 'gid://gitlab/WorkItems::Type/5', + name: 'Task', + }, }, }, }; @@ -24,27 +16,16 @@ export const workItemQueryResponse = { export const updateWorkItemMutationResponse = { data: { workItemUpdate: { - __typename: 'LocalUpdateWorkItemPayload', + __typename: 'WorkItemUpdatePayload', workItem: { - __typename: 'LocalWorkItem', - id: '1', + __typename: 'WorkItem', + id: 'gid://gitlab/WorkItem/1', title: 'Updated title', workItemType: { __typename: 'WorkItemType', - id: 'work-item-type-1', + id: 'gid://gitlab/WorkItems::Type/5', name: 'Task', }, - widgets: { - __typename: 'LocalWorkItemWidgetConnection', - nodes: [ - { - __typename: 'LocalTitleWidget', - type: 'TITLE', - enabled: true, - contentText: 'Updated title', - }, - ], - }, }, }, }, @@ -53,11 +34,11 @@ export const updateWorkItemMutationResponse = { export const projectWorkItemTypesQueryResponse = { data: { workspace: { - id: '1', + id: 'gid://gitlab/WorkItem/1', workItemTypes: { nodes: [ - { id: 'work-item-1', name: 'Issue' }, - { id: 'work-item-2', name: 'Incident' }, + { id: 'gid://gitlab/WorkItems::Type/1', name: 'Issue' }, + { id: 'gid://gitlab/WorkItems::Type/2', name: 'Incident' }, ], }, }, @@ -70,11 +51,11 @@ export const createWorkItemMutationResponse = { __typename: 'WorkItemCreatePayload', workItem: { __typename: 'WorkItem', - id: '1', + id: 'gid://gitlab/WorkItem/1', title: 'Updated title', workItemType: { __typename: 'WorkItemType', - id: 'work-item-type-1', + id: 'gid://gitlab/WorkItems::Type/5', name: 'Task', }, }, diff --git a/spec/frontend/work_items/pages/create_work_item_spec.js b/spec/frontend/work_items/pages/create_work_item_spec.js index 022c23edd0d..fb1f1d56356 100644 --- a/spec/frontend/work_items/pages/create_work_item_spec.js +++ b/spec/frontend/work_items/pages/create_work_item_spec.js @@ -6,7 +6,6 @@ import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; import CreateWorkItem from '~/work_items/pages/create_work_item.vue'; import ItemTitle from '~/work_items/components/item_title.vue'; -import { resolvers } from '~/work_items/graphql/resolvers'; import projectWorkItemTypesQuery from '~/work_items/graphql/project_work_item_types.query.graphql'; import createWorkItemMutation from '~/work_items/graphql/create_work_item.mutation.graphql'; import createWorkItemFromTaskMutation from '~/work_items/graphql/create_work_item_from_task.mutation.graphql'; @@ -46,14 +45,11 @@ describe('Create work item component', () => { queryHandler = querySuccessHandler, mutationHandler = createWorkItemSuccessHandler, } = {}) => { - fakeApollo = createMockApollo( - [ - [projectWorkItemTypesQuery, queryHandler], - [createWorkItemMutation, mutationHandler], - [createWorkItemFromTaskMutation, mutationHandler], - ], - resolvers, - ); + fakeApollo = createMockApollo([ + [projectWorkItemTypesQuery, queryHandler], + [createWorkItemMutation, mutationHandler], + [createWorkItemFromTaskMutation, mutationHandler], + ]); wrapper = shallowMount(CreateWorkItem, { apolloProvider: fakeApollo, data() { diff --git a/spec/frontend/work_items/pages/work_item_detail_spec.js b/spec/frontend/work_items/pages/work_item_detail_spec.js index 650be38bc04..1eb6c0145e7 100644 --- a/spec/frontend/work_items/pages/work_item_detail_spec.js +++ b/spec/frontend/work_items/pages/work_item_detail_spec.js @@ -16,14 +16,14 @@ describe('WorkItemDetail component', () => { Vue.use(VueApollo); - const successHandler = jest.fn().mockResolvedValue({ data: workItemQueryResponse }); + const successHandler = jest.fn().mockResolvedValue(workItemQueryResponse); const initialSubscriptionHandler = jest.fn().mockResolvedValue(workItemTitleSubscriptionResponse); const findAlert = () => wrapper.findComponent(GlAlert); const findWorkItemTitle = () => wrapper.findComponent(WorkItemTitle); const createComponent = ({ - workItemId = workItemQueryResponse.workItem.id, + workItemId = workItemQueryResponse.data.workItem.id, handler = successHandler, subscriptionHandler = initialSubscriptionHandler, } = {}) => { @@ -93,7 +93,7 @@ describe('WorkItemDetail component', () => { createComponent(); expect(initialSubscriptionHandler).toHaveBeenCalledWith({ - issuableId: workItemQueryResponse.workItem.id, + issuableId: workItemQueryResponse.data.workItem.id, }); }); }); diff --git a/spec/frontend/work_items/router_spec.js b/spec/frontend/work_items/router_spec.js index 8c9054920a8..7e68c5e4f0e 100644 --- a/spec/frontend/work_items/router_spec.js +++ b/spec/frontend/work_items/router_spec.js @@ -37,7 +37,7 @@ describe('Work items router', () => { it('renders work item on `/1` route', async () => { await createComponent('/1'); - expect(wrapper.find(WorkItemsRoot).exists()).toBe(true); + expect(wrapper.findComponent(WorkItemsRoot).exists()).toBe(true); }); it('renders create work item page on `/new` route', async () => { diff --git a/spec/helpers/routing/pseudonymization_helper_spec.rb b/spec/helpers/routing/pseudonymization_helper_spec.rb index 1221917e6b7..cf716931fe2 100644 --- a/spec/helpers/routing/pseudonymization_helper_spec.rb +++ b/spec/helpers/routing/pseudonymization_helper_spec.rb @@ -180,7 +180,7 @@ RSpec.describe ::Routing::PseudonymizationHelper do end context 'when some query params are not required to be masked' do - let(:masked_url) { "http://localhost/dashboard/issues?author_username=masked_author_username&scope=all&state=masked_state" } + let(:masked_url) { "http://localhost/dashboard/issues?author_username=masked_author_username&scope=all&state=masked_state&tab=2" } let(:request) do double(:Request, path_parameters: { @@ -189,11 +189,11 @@ RSpec.describe ::Routing::PseudonymizationHelper do }, protocol: 'http', host: 'localhost', - query_string: 'author_username=root&scope=all&state=opened') + query_string: 'author_username=root&scope=all&state=opened&tab=2') end before do - stub_const('Routing::PseudonymizationHelper::MaskHelper::QUERY_PARAMS_TO_NOT_MASK', %w[scope].freeze) + stub_const('Routing::PseudonymizationHelper::MaskHelper::QUERY_PARAMS_TO_NOT_MASK', %w[scope tab].freeze) allow(helper).to receive(:request).and_return(request) end diff --git a/spec/lib/gitlab/search_context/builder_spec.rb b/spec/lib/gitlab/search_context/builder_spec.rb index 079477115bb..a09115f3f21 100644 --- a/spec/lib/gitlab/search_context/builder_spec.rb +++ b/spec/lib/gitlab/search_context/builder_spec.rb @@ -43,7 +43,6 @@ RSpec.describe Gitlab::SearchContext::Builder, type: :controller do def be_search_context(project: nil, group: nil, snippets: [], ref: nil) group = project ? project.group : group snippets.compact! - ref = ref have_attributes( project: project, diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index fcd2ccf45f5..3bff45f80dd 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1191,29 +1191,8 @@ RSpec.describe Project, factory_default: :keep do end describe 'last_activity_date' do - it 'returns the creation date of the project\'s last event if present' do - new_event = create(:event, :closed, project: project, created_at: Time.current) - - project.reload - expect(project.last_activity_at.to_i).to eq(new_event.created_at.to_i) - end - - it 'returns the project\'s last update date if it has no events' do - expect(project.last_activity_date).to eq(project.updated_at) - end - - it 'returns the most recent timestamp' do - project.update!(updated_at: nil, - last_activity_at: timestamp, - last_repository_updated_at: timestamp - 1.hour) - - expect(project.last_activity_date).to be_like_time(timestamp) - - project.update!(updated_at: timestamp, - last_activity_at: timestamp - 1.hour, - last_repository_updated_at: nil) - - expect(project.last_activity_date).to be_like_time(timestamp) + it 'returns the project\'s last update date' do + expect(project.last_activity_date).to be_like_time(project.updated_at) end end end @@ -1690,15 +1669,27 @@ RSpec.describe Project, factory_default: :keep do end describe '.sort_by_attribute' do - it 'reorders the input relation by start count desc' do - project1 = create(:project, star_count: 2) - project2 = create(:project, star_count: 1) - project3 = create(:project) + let_it_be(:project1) { create(:project, star_count: 2, updated_at: 1.minute.ago) } + let_it_be(:project2) { create(:project, star_count: 1) } + let_it_be(:project3) { create(:project, updated_at: 2.minutes.ago) } + it 'reorders the input relation by start count desc' do projects = described_class.sort_by_attribute(:stars_desc) expect(projects).to eq([project1, project2, project3]) end + + it 'reorders the input relation by last activity desc' do + projects = described_class.sort_by_attribute(:latest_activity_desc) + + expect(projects).to eq([project2, project1, project3]) + end + + it 'reorders the input relation by last activity asc' do + projects = described_class.sort_by_attribute(:latest_activity_asc) + + expect(projects).to eq([project3, project1, project2]) + end end describe '.with_shared_runners' do |