diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-26 15:10:48 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-26 15:10:48 +0300 |
commit | cd5179ede2020b45b4de70a10fb09cfcfe85c3df (patch) | |
tree | 57e78abcff2613b8915228bf1a01c8db0aa3caee /app | |
parent | 576bba90f9b4b4fdd604871805469f57c147e07c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/diffs/components/app.vue | 24 | ||||
-rw-r--r-- | app/assets/javascripts/diffs/components/diff_file.vue | 12 | ||||
-rw-r--r-- | app/assets/javascripts/diffs/components/diff_file_header.vue | 9 | ||||
-rw-r--r-- | app/assets/javascripts/diffs/store/actions.js | 6 | ||||
-rw-r--r-- | app/assets/javascripts/diffs/store/mutation_types.js | 1 | ||||
-rw-r--r-- | app/assets/javascripts/diffs/store/mutations.js | 5 | ||||
-rw-r--r-- | app/assets/javascripts/diffs/utils/diff_file.js | 1 | ||||
-rw-r--r-- | app/assets/javascripts/diffs/utils/merge_request.js | 7 | ||||
-rw-r--r-- | app/assets/javascripts/members/components/members_tabs.vue | 1 | ||||
-rw-r--r-- | app/controllers/admin/identities_controller.rb | 2 | ||||
-rw-r--r-- | app/helpers/sidekiq_helper.rb | 17 | ||||
-rw-r--r-- | app/helpers/sorting_helper.rb | 39 | ||||
-rw-r--r-- | app/views/admin/identities/_form.html.haml | 2 |
13 files changed, 66 insertions, 60 deletions
diff --git a/app/assets/javascripts/diffs/components/app.vue b/app/assets/javascripts/diffs/components/app.vue index 08306312c2e..dcf2595edb8 100644 --- a/app/assets/javascripts/diffs/components/app.vue +++ b/app/assets/javascripts/diffs/components/app.vue @@ -42,7 +42,7 @@ import { import diffsEventHub from '../event_hub'; import { reviewStatuses } from '../utils/file_reviews'; import { diffsApp } from '../utils/performance'; -import { updateChangesTabCount } from '../utils/merge_request'; +import { updateChangesTabCount, extractFileHash } from '../utils/merge_request'; import { queueRedisHllEvents } from '../utils/queue_events'; import FindingsDrawer from './shared/findings_drawer.vue'; import CollapsedFilesWarning from './collapsed_files_warning.vue'; @@ -344,12 +344,13 @@ export default { ...mapActions(['startTaskList']), ...mapActions('diffs', [ 'moveToNeighboringCommit', - 'setBaseConfig', 'setCodequalityEndpoint', 'setSastEndpoint', 'fetchDiffFilesMeta', 'fetchDiffFilesBatch', 'fetchFileByFile', + 'loadCollapsedDiff', + 'setFileForcedOpen', 'fetchCoverageFiles', 'fetchCodequality', 'fetchSast', @@ -373,15 +374,34 @@ export default { notesEventHub.$on('refetchDiffData', this.refetchDiffData); notesEventHub.$on('fetchedNotesData', this.rereadNoteHash); diffsEventHub.$on('diffFilesModified', this.setDiscussions); + diffsEventHub.$on('doneLoadingBatches', this.autoScroll); diffsEventHub.$on(EVT_MR_PREPARED, this.fetchData); }, unsubscribeFromEvents() { diffsEventHub.$off(EVT_MR_PREPARED, this.fetchData); + diffsEventHub.$off('doneLoadingBatches', this.autoScroll); diffsEventHub.$off('diffFilesModified', this.setDiscussions); notesEventHub.$off('fetchedNotesData', this.rereadNoteHash); notesEventHub.$off('refetchDiffData', this.refetchDiffData); notesEventHub.$off('fetchDiffData', this.fetchData); }, + autoScroll() { + const lineCode = window.location.hash; + const sha1InHash = extractFileHash({ input: lineCode }); + + if (sha1InHash) { + const idx = this.diffs.findIndex((diffFile) => diffFile.file_hash === sha1InHash); + const file = this.diffs[idx]; + + this.loadCollapsedDiff({ file }) + .then(() => { + this.setDiscussions(); + this.scrollVirtualScrollerToIndex(idx); + this.setFileForcedOpen({ filePath: file.new_path }); + }) + .catch(() => {}); + } + }, navigateToDiffFileNumber(number) { this.navigateToDiffFileIndex(number - 1); }, diff --git a/app/assets/javascripts/diffs/components/diff_file.vue b/app/assets/javascripts/diffs/components/diff_file.vue index f99edced361..13274129f1d 100644 --- a/app/assets/javascripts/diffs/components/diff_file.vue +++ b/app/assets/javascripts/diffs/components/diff_file.vue @@ -161,6 +161,9 @@ export default { manuallyCollapsed() { return collapsedType(this.file) === DIFF_FILE_MANUAL_COLLAPSE; }, + forcedOpen() { + return this.file.viewer.forceOpen; + }, showBody() { return !this.isCollapsed || this.automaticallyCollapsed; }, @@ -174,6 +177,10 @@ export default { return Boolean(gon.current_user_id); }, isCollapsed() { + if (this.forcedOpen) { + return false; + } + if (collapsedType(this.file) !== DIFF_FILE_MANUAL_COLLAPSE) { return this.viewDiffsFileByFile ? false : this.file.viewer?.automaticallyCollapsed; } @@ -201,6 +208,11 @@ export default { this.manageViewedEffects(); }, }, + 'file.viewer.forceOpen': { + handler: function fileForcedOpenHandler() { + this.handleToggle(); + }, + }, 'file.file_hash': { handler: function hashChangeWatch(newHash, oldHash) { if ( diff --git a/app/assets/javascripts/diffs/components/diff_file_header.vue b/app/assets/javascripts/diffs/components/diff_file_header.vue index a9e63ad53bb..d72b0c76425 100644 --- a/app/assets/javascripts/diffs/components/diff_file_header.vue +++ b/app/assets/javascripts/diffs/components/diff_file_header.vue @@ -232,10 +232,15 @@ export default { 'setCurrentFileHash', 'reviewFile', 'setFileCollapsedByUser', + 'setFileForcedOpen', 'setGenerateTestFilePath', 'toggleFileCommentForm', ]), handleToggleFile() { + this.setFileForcedOpen({ + filePath: this.diffFile.file_path, + forced: false, + }); this.$emit('toggleFile'); }, showForkMessage(e) { @@ -278,6 +283,10 @@ export default { } if ((open && reviewed) || (closed && !reviewed)) { + this.setFileForcedOpen({ + filePath: this.diffFile.file_path, + forced: false, + }); this.$emit('toggleFile'); } }, diff --git a/app/assets/javascripts/diffs/store/actions.js b/app/assets/javascripts/diffs/store/actions.js index 7c68b5f69f1..ed8ae795bda 100644 --- a/app/assets/javascripts/diffs/store/actions.js +++ b/app/assets/javascripts/diffs/store/actions.js @@ -254,6 +254,7 @@ export const fetchDiffFilesBatch = ({ commit, state, dispatch }) => { if (totalLoaded === pagination.total_pages || pagination.total_pages === null) { commit(types.SET_RETRIEVING_BATCHES, false); + eventHub.$emit('doneLoadingBatches'); // We need to check that the currentDiffFileId points to a file that exists if ( @@ -879,6 +880,7 @@ export function switchToFullDiffFromRenamedFile({ commit }, { diffFile }) { ...diffFile.alternate_viewer, automaticallyCollapsed: false, manuallyCollapsed: false, + forceOpen: false, }, }); commit(types.SET_CURRENT_VIEW_DIFF_FILE_LINES, { filePath: diffFile.file_path, lines }); @@ -893,6 +895,10 @@ export const setFileCollapsedAutomatically = ({ commit }, { filePath, collapsed commit(types.SET_FILE_COLLAPSED, { filePath, collapsed, trigger: DIFF_FILE_AUTOMATIC_COLLAPSE }); }; +export function setFileForcedOpen({ commit }, { filePath, forced }) { + commit(types.SET_FILE_FORCED_OPEN, { filePath, forced }); +} + export const setSuggestPopoverDismissed = ({ commit, state }) => axios .post(state.dismissEndpoint, { diff --git a/app/assets/javascripts/diffs/store/mutation_types.js b/app/assets/javascripts/diffs/store/mutation_types.js index 3df491503a4..c2177bacbcc 100644 --- a/app/assets/javascripts/diffs/store/mutation_types.js +++ b/app/assets/javascripts/diffs/store/mutation_types.js @@ -39,6 +39,7 @@ export const REQUEST_FULL_DIFF = 'REQUEST_FULL_DIFF'; export const RECEIVE_FULL_DIFF_SUCCESS = 'RECEIVE_FULL_DIFF_SUCCESS'; export const RECEIVE_FULL_DIFF_ERROR = 'RECEIVE_FULL_DIFF_ERROR'; export const SET_FILE_COLLAPSED = 'SET_FILE_COLLAPSED'; +export const SET_FILE_FORCED_OPEN = 'SET_FILE_FORCED_OPEN'; export const SET_CURRENT_VIEW_DIFF_FILE_LINES = 'SET_CURRENT_VIEW_DIFF_FILE_LINES'; export const ADD_CURRENT_VIEW_DIFF_FILE_LINES = 'ADD_CURRENT_VIEW_DIFF_FILE_LINES'; diff --git a/app/assets/javascripts/diffs/store/mutations.js b/app/assets/javascripts/diffs/store/mutations.js index 3af2d6ee6b1..31369b169f5 100644 --- a/app/assets/javascripts/diffs/store/mutations.js +++ b/app/assets/javascripts/diffs/store/mutations.js @@ -349,6 +349,11 @@ export default { } } }, + [types.SET_FILE_FORCED_OPEN](state, { filePath, forced = true }) { + const file = state.diffFiles.find((f) => f.file_path === filePath); + + Vue.set(file.viewer, 'forceOpen', forced); + }, [types.SET_CURRENT_VIEW_DIFF_FILE_LINES](state, { filePath, lines }) { const file = state.diffFiles.find((f) => f.file_path === filePath); diff --git a/app/assets/javascripts/diffs/utils/diff_file.js b/app/assets/javascripts/diffs/utils/diff_file.js index 98e1c1cc849..f20ae6464ae 100644 --- a/app/assets/javascripts/diffs/utils/diff_file.js +++ b/app/assets/javascripts/diffs/utils/diff_file.js @@ -35,6 +35,7 @@ function collapsed(file) { return { automaticallyCollapsed: viewer.automaticallyCollapsed || viewer.collapsed || false, manuallyCollapsed: null, + forceOpen: false, }; } diff --git a/app/assets/javascripts/diffs/utils/merge_request.js b/app/assets/javascripts/diffs/utils/merge_request.js index bc81c0b0a05..a74c9fe7fac 100644 --- a/app/assets/javascripts/diffs/utils/merge_request.js +++ b/app/assets/javascripts/diffs/utils/merge_request.js @@ -1,6 +1,7 @@ import { ZERO_CHANGES_ALT_DISPLAY } from '../constants'; const endpointRE = /^(\/?(.+\/)+(.+)\/-\/merge_requests\/(\d+)).*$/i; +const SHA1RE = /([a-f0-9]{40})/g; function getVersionInfo({ endpoint } = {}) { const dummyRoot = 'https://gitlab.com'; @@ -51,3 +52,9 @@ export function getDerivedMergeRequestInformation({ endpoint } = {}) { startSha, }; } + +export function extractFileHash({ input = '' } = {}) { + const matches = input.match(SHA1RE); + + return matches?.[0]; +} diff --git a/app/assets/javascripts/members/components/members_tabs.vue b/app/assets/javascripts/members/components/members_tabs.vue index 75241d1ff26..de5c9eb5a55 100644 --- a/app/assets/javascripts/members/components/members_tabs.vue +++ b/app/assets/javascripts/members/components/members_tabs.vue @@ -112,6 +112,7 @@ export default { <template> <gl-tabs v-model="selectedTabIndex" + content-class="gl-py-0" sync-active-tab-with-query-params :query-param-name="$options.ACTIVE_TAB_QUERY_PARAM_NAME" > diff --git a/app/controllers/admin/identities_controller.rb b/app/controllers/admin/identities_controller.rb index 15c4103a781..17b0adb868e 100644 --- a/app/controllers/admin/identities_controller.rb +++ b/app/controllers/admin/identities_controller.rb @@ -63,6 +63,6 @@ class Admin::IdentitiesController < Admin::ApplicationController end def identity_params - params.require(:identity).permit(:provider, :extern_uid) + params.require(:identity).permit(:provider, :extern_uid, :saml_provider_id) end end diff --git a/app/helpers/sidekiq_helper.rb b/app/helpers/sidekiq_helper.rb deleted file mode 100644 index 21aa82aff1c..00000000000 --- a/app/helpers/sidekiq_helper.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -module SidekiqHelper - SIDEKIQ_PS_REGEXP = %r{\A - (?<pid>\d+)\s+ - (?<cpu>[\d\.,]+)\s+ - (?<mem>[\d\.,]+)\s+ - (?<state>[DIEKNRSTVWXZLpsl\+<>/\d]+)\s+ - (?<start>.+?)\s+ - (?<command>(?:ruby\d+:\s+)?sidekiq.*\].*) - \z}x - - def parse_sidekiq_ps(line) - match = line.strip.match(SIDEKIQ_PS_REGEXP) - match ? match[1..6] : Array.new(6, '?') - end -end diff --git a/app/helpers/sorting_helper.rb b/app/helpers/sorting_helper.rb index 1405bc7be37..94445564c22 100644 --- a/app/helpers/sorting_helper.rb +++ b/app/helpers/sorting_helper.rb @@ -64,15 +64,6 @@ module SortingHelper options end - def forks_sort_options_hash - { - sort_value_recently_created => sort_title_created_date, - sort_value_oldest_created => sort_title_created_date, - sort_value_latest_activity => sort_title_latest_activity, - sort_value_oldest_activity => sort_title_latest_activity - } - end - def forks_reverse_sort_options_hash { sort_value_recently_created => sort_value_oldest_created, @@ -93,12 +84,6 @@ module SortingHelper } end - def subgroups_sort_options_hash - groups_sort_options_hash.merge( - sort_value_stars_desc => sort_title_most_stars - ) - end - def admin_groups_sort_options_hash groups_sort_options_hash.merge( sort_value_largest_group => sort_title_largest_group @@ -199,19 +184,6 @@ module SortingHelper }.merge(issuable_sort_option_overrides) end - def audit_logs_sort_order_hash - { - sort_value_recently_created => sort_title_recently_created, - sort_value_oldest_created => sort_title_oldest_created - } - end - - def issuable_sort_option_title(sort_value) - sort_value = issuable_sort_option_overrides[sort_value] || sort_value - - sort_options_hash[sort_value] - end - def issuable_sort_options(viewing_issues, viewing_merge_requests) options = [ { value: sort_value_priority, text: sort_title_priority, href: page_filter_path(sort: sort_value_priority) }, @@ -321,17 +293,6 @@ module SortingHelper } end - def packages_sort_option_title(sort_value) - packages_sort_options_hash[sort_value] || sort_title_created_date - end - - def packages_sort_direction_button(sort_value) - reverse_sort = packages_reverse_sort_order_hash[sort_value] - url = package_sort_path(sort: reverse_sort) - - sort_direction_button(url, reverse_sort, sort_value) - end - def forks_sort_direction_button(sort_value, without = [:state, :scope, :label_name, :milestone_id, :assignee_id, :author_id]) reverse_sort = forks_reverse_sort_options_hash[sort_value] url = page_filter_path(sort: reverse_sort, without: without) diff --git a/app/views/admin/identities/_form.html.haml b/app/views/admin/identities/_form.html.haml index ad78c677da1..dec35e9cf15 100644 --- a/app/views/admin/identities/_form.html.haml +++ b/app/views/admin/identities/_form.html.haml @@ -7,6 +7,7 @@ .col-sm-10 - values = Gitlab::Auth::OAuth::Provider.providers.map { |name| ["#{Gitlab::Auth::OAuth::Provider.label_for(name)} (#{name})", name] } = f.select :provider, values, { allow_blank: false }, class: 'form-control' + = render_if_exists partial: 'admin/identities/provider_id', locals: { f: f } .form-group.row .col-sm-2.col-form-label = f.label :extern_uid, _("Identifier") @@ -15,4 +16,3 @@ .form-actions = f.submit _('Save changes'), pajamas_button: true - |