From 7e89568aa1b1c531aa34860fbd9e77d9e988b9b2 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 7 Dec 2022 00:08:34 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../layout/first_hash_element_indentation.yml | 16 -- .../dashboard/components/issues_dashboard_app.vue | 78 +++++++++- app/assets/javascripts/issues/dashboard/index.js | 2 + .../dashboard/queries/get_issues.query.graphql | 2 + .../issues/list/components/issues_list_app.vue | 18 +++ app/assets/javascripts/issues/list/constants.js | 20 ++- .../issues/list/queries/get_issues.query.graphql | 3 + .../components/filtered_search_bar/constants.js | 3 + app/components/diffs/stats_component.rb | 16 +- app/controllers/admin/ci/variables_controller.rb | 4 +- app/controllers/admin/system_info_controller.rb | 10 +- app/controllers/concerns/milestone_actions.rb | 24 +-- app/controllers/concerns/render_service_results.rb | 24 +-- app/controllers/concerns/sourcegraph_decorator.rb | 4 +- .../profiles/two_factor_auths_controller.rb | 12 +- app/controllers/projects/badges_controller.rb | 30 ++-- .../repositories/lfs_locks_api_controller.rb | 6 +- app/experiments/concerns/project_commit_count.rb | 6 +- .../mutations/clusters/agent_tokens/create.rb | 6 +- app/graphql/mutations/notes/create/diff_note.rb | 8 +- .../mutations/notes/create/image_diff_note.rb | 6 +- app/graphql/mutations/notes/create/note.rb | 6 +- app/graphql/mutations/todos/restore_many.rb | 6 +- app/graphql/resolvers/group_packages_resolver.rb | 6 +- app/helpers/issues_helper.rb | 1 + app/models/integrations/base_slack_notification.rb | 1 + app/models/integrations/jira.rb | 1 + app/models/project.rb | 32 +++- app/models/project_export_job.rb | 14 ++ app/policies/base_policy.rb | 13 +- app/policies/merge_request_policy.rb | 2 +- app/views/dashboard/_activities.html.haml | 3 +- app/views/dashboard/_projects_head.html.haml | 3 +- app/views/dashboard/_snippets_head.html.haml | 3 +- app/workers/all_queues.yml | 9 ++ .../migration/enqueuer_worker.rb | 4 +- .../export/prune_project_export_jobs_worker.rb | 23 +++ bin/audit-event-type | 24 +-- .../audit_events/types/policy_project_updated.yml | 2 +- config/audit_events/types/type_schema.json | 6 +- .../development/approval_rules_pagination.yml | 8 - .../development/cache_project_integrations.yml | 8 + .../ops/purge_stale_security_findings.yml | 8 - config/initializers/1_settings.rb | 3 + danger/plugins/stable_branch.rb | 9 ++ danger/stable_branch_patch/Dangerfile | 3 + ...20634_schedule_fixing_security_scan_statuses.rb | 52 +++++++ ...29124240_remove_flowdock_integration_records.rb | 23 +++ db/schema_migrations/20221128120634 | 1 + db/schema_migrations/20221129124240 | 1 + doc/api/merge_request_approvals.md | 2 + doc/development/code_review.md | 3 + lib/api/merge_request_approvals.rb | 1 + lib/gitlab/audit/type/shared.rb | 2 +- .../fix_security_scan_statuses.rb | 14 ++ lib/gitlab/import_export/project/import_export.yml | 17 ++- locale/gitlab.pot | 9 ++ qa/qa/support/loglinking.rb | 6 +- qa/spec/resource/api_fabricator_spec.rb | 2 +- qa/spec/support/loglinking_spec.rb | 6 +- spec/bin/audit_event_type_spec.rb | 30 ++-- spec/db/schema_spec.rb | 3 +- .../import_export/relation_export_upload.rb | 2 +- .../components/issues_dashboard_app_spec.js | 143 ++++++++++++++++- .../issues/list/components/issues_list_app_spec.js | 2 + spec/helpers/issues_helper_spec.rb | 6 +- spec/lib/gitlab/audit/type/definition_spec.rb | 6 +- spec/lib/gitlab/import_export/all_models.yml | 14 ++ .../project/exported_relations_merger_spec.rb | 6 +- .../remove_flowdock_integration_records_spec.rb | 23 +++ .../schedule_fixing_security_scan_statuses_spec.rb | 76 +++++++++ spec/models/integrations/jira_spec.rb | 4 +- spec/models/project_export_job_spec.rb | 52 ++++++- spec/models/project_spec.rb | 41 ++++- spec/policies/merge_request_policy_spec.rb | 102 ++++++++++++- spec/requests/api/merge_request_approvals_spec.rb | 81 ++++++++++ spec/requests/api/merge_requests_spec.rb | 80 ---------- .../base_slack_notification_shared_examples.rb | 2 +- spec/tooling/danger/stable_branch_spec.rb | 169 +++++++++++++++++++++ .../prune_project_export_jobs_worker_spec.rb | 52 +++++++ tooling/danger/stable_branch.rb | 138 +++++++++++++++++ 81 files changed, 1382 insertions(+), 285 deletions(-) create mode 100644 app/workers/gitlab/export/prune_project_export_jobs_worker.rb delete mode 100644 config/feature_flags/development/approval_rules_pagination.yml create mode 100644 config/feature_flags/development/cache_project_integrations.yml delete mode 100644 config/feature_flags/ops/purge_stale_security_findings.yml create mode 100644 danger/plugins/stable_branch.rb create mode 100644 danger/stable_branch_patch/Dangerfile create mode 100644 db/post_migrate/20221128120634_schedule_fixing_security_scan_statuses.rb create mode 100644 db/post_migrate/20221129124240_remove_flowdock_integration_records.rb create mode 100644 db/schema_migrations/20221128120634 create mode 100644 db/schema_migrations/20221129124240 create mode 100644 lib/gitlab/background_migration/fix_security_scan_statuses.rb create mode 100644 spec/migrations/remove_flowdock_integration_records_spec.rb create mode 100644 spec/migrations/schedule_fixing_security_scan_statuses_spec.rb create mode 100644 spec/tooling/danger/stable_branch_spec.rb create mode 100644 spec/workers/gitlab/export/prune_project_export_jobs_worker_spec.rb create mode 100644 tooling/danger/stable_branch.rb diff --git a/.rubocop_todo/layout/first_hash_element_indentation.yml b/.rubocop_todo/layout/first_hash_element_indentation.yml index 34446f2cb61..2f20d2ec239 100644 --- a/.rubocop_todo/layout/first_hash_element_indentation.yml +++ b/.rubocop_todo/layout/first_hash_element_indentation.yml @@ -2,22 +2,6 @@ # Cop supports --autocorrect. Layout/FirstHashElementIndentation: Exclude: - - 'app/components/diffs/stats_component.rb' - - 'app/controllers/admin/ci/variables_controller.rb' - - 'app/controllers/admin/system_info_controller.rb' - - 'app/controllers/concerns/milestone_actions.rb' - - 'app/controllers/concerns/render_service_results.rb' - - 'app/controllers/concerns/sourcegraph_decorator.rb' - - 'app/controllers/profiles/two_factor_auths_controller.rb' - - 'app/controllers/projects/badges_controller.rb' - - 'app/controllers/repositories/lfs_locks_api_controller.rb' - - 'app/experiments/concerns/project_commit_count.rb' - - 'app/graphql/mutations/clusters/agent_tokens/create.rb' - - 'app/graphql/mutations/notes/create/diff_note.rb' - - 'app/graphql/mutations/notes/create/image_diff_note.rb' - - 'app/graphql/mutations/notes/create/note.rb' - - 'app/graphql/mutations/todos/restore_many.rb' - - 'app/graphql/resolvers/group_packages_resolver.rb' - 'app/helpers/avatars_helper.rb' - 'app/helpers/breadcrumbs_helper.rb' - 'app/helpers/broadcast_messages_helper.rb' diff --git a/app/assets/javascripts/issues/dashboard/components/issues_dashboard_app.vue b/app/assets/javascripts/issues/dashboard/components/issues_dashboard_app.vue index 080f1fe222c..5e2bd096534 100644 --- a/app/assets/javascripts/issues/dashboard/components/issues_dashboard_app.vue +++ b/app/assets/javascripts/issues/dashboard/components/issues_dashboard_app.vue @@ -5,9 +5,17 @@ import getIssuesQuery from 'ee_else_ce/issues/dashboard/queries/get_issues.query import IssueCardStatistics from 'ee_else_ce/issues/list/components/issue_card_statistics.vue'; import IssueCardTimeInfo from 'ee_else_ce/issues/list/components/issue_card_time_info.vue'; import { IssuableStatus } from '~/issues/constants'; -import { PAGE_SIZE } from '~/issues/list/constants'; -import { getInitialPageParams } from '~/issues/list/utils'; +import { + CREATED_DESC, + PAGE_SIZE, + PARAM_STATE, + UPDATED_DESC, + urlSortParams, +} from '~/issues/list/constants'; +import setSortPreferenceMutation from '~/issues/list/queries/set_sort_preference.mutation.graphql'; +import { getInitialPageParams, getSortKey, getSortOptions, isSortKey } from '~/issues/list/utils'; import { scrollUp } from '~/lib/utils/scroll_utils'; +import { getParameterByName } from '~/lib/utils/url_utility'; import { __ } from '~/locale'; import IssuableList from '~/vue_shared/issuable/list/components/issuable_list_root.vue'; import { IssuableListTabs, IssuableStates } from '~/vue_shared/issuable/list/constants'; @@ -17,13 +25,10 @@ export default { calendarButtonText: __('Subscribe to calendar'), closed: __('CLOSED'), closedMoved: __('CLOSED (MOVED)'), - downvotes: __('Downvotes'), emptyStateTitle: __('Please select at least one filter to see results'), errorFetchingIssues: __('An error occurred while loading issues'), - relatedMergeRequests: __('Related merge requests'), rssButtonText: __('Subscribe to RSS feed'), searchInputPlaceholder: __('Search or filter results...'), - upvotes: __('Upvotes'), }, IssuableListTabs, components: { @@ -39,20 +44,35 @@ export default { inject: [ 'calendarPath', 'emptyStateSvgPath', + 'hasBlockedIssuesFeature', + 'hasIssuableHealthStatusFeature', + 'hasIssueWeightsFeature', 'hasScopedLabelsFeature', + 'initialSort', 'isPublicVisibilityRestricted', 'isSignedIn', 'rssPath', ], data() { + const state = getParameterByName(PARAM_STATE); + + const defaultSortKey = state === IssuableStates.Closed ? UPDATED_DESC : CREATED_DESC; + const dashboardSortKey = getSortKey(this.initialSort); + const graphQLSortKey = + isSortKey(this.initialSort?.toUpperCase()) && this.initialSort.toUpperCase(); + + // The initial sort is an old enum value when it is saved on the dashboard issues page. + // The initial sort is a GraphQL enum value when it is saved on the Vue issues list page. + const sortKey = dashboardSortKey || graphQLSortKey || defaultSortKey; + return { issues: [], issuesError: null, pageInfo: {}, pageParams: getInitialPageParams(), searchTokens: [], - sortOptions: [], - state: IssuableStates.Opened, + sortKey, + state: state || IssuableStates.Opened, }; }, apollo: { @@ -62,6 +82,7 @@ export default { return { hideUsers: this.isPublicVisibilityRestricted && !this.isSignedIn, isSignedIn: this.isSignedIn, + sort: this.sortKey, state: this.state, ...this.pageParams, }; @@ -82,6 +103,19 @@ export default { showPaginationControls() { return this.issues.length > 0 && (this.pageInfo.hasNextPage || this.pageInfo.hasPreviousPage); }, + sortOptions() { + return getSortOptions({ + hasBlockedIssuesFeature: this.hasBlockedIssuesFeature, + hasIssuableHealthStatusFeature: this.hasIssuableHealthStatusFeature, + hasIssueWeightsFeature: this.hasIssueWeightsFeature, + }); + }, + urlParams() { + return { + sort: urlSortParams[this.sortKey], + state: this.state, + }; + }, }, methods: { getStatus(issue) { @@ -117,6 +151,33 @@ export default { }; scrollUp(); }, + handleSort(sortKey) { + if (this.sortKey === sortKey) { + return; + } + + this.pageParams = getInitialPageParams(); + this.sortKey = sortKey; + + if (this.isSignedIn) { + this.saveSortPreference(sortKey); + } + }, + saveSortPreference(sortKey) { + this.$apollo + .mutate({ + mutation: setSortPreferenceMutation, + variables: { input: { issuesSort: sortKey } }, + }) + .then(({ data }) => { + if (data.userPreferencesUpdate.errors.length) { + throw new Error(data.userPreferencesUpdate.errors); + } + }) + .catch((error) => { + Sentry.captureException(error); + }); + }, }, }; @@ -128,6 +189,7 @@ export default { :has-next-page="pageInfo.hasNextPage" :has-previous-page="pageInfo.hasPreviousPage" :has-scoped-labels-feature="hasScopedLabelsFeature" + :initial-sort-by="sortKey" :issuables="issues" :issuables-loading="$apollo.queries.issues.loading" namespace="dashboard" @@ -137,11 +199,13 @@ export default { :show-pagination-controls="showPaginationControls" :sort-options="sortOptions" :tabs="$options.IssuableListTabs" + :url-params="urlParams" use-keyset-pagination @click-tab="handleClickTab" @dismiss-alert="handleDismissAlert" @next-page="handleNextPage" @previous-page="handlePreviousPage" + @sort="handleSort" >