diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-26 12:12:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-26 12:12:46 +0300 |
commit | 844c80c9f7b85f730c83a05b2da360ba4203a007 (patch) | |
tree | c160ad400c2b1b0089ce00f2e0e677f5fa167703 /app | |
parent | 9e9ddb97773012d12cec8973b21576ecf72b4fbf (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/boards/components/board_list.vue | 26 | ||||
-rw-r--r-- | app/assets/javascripts/lib/utils/secret_detection.js | 4 | ||||
-rw-r--r-- | app/models/ci/build.rb | 12 |
3 files changed, 41 insertions, 1 deletions
diff --git a/app/assets/javascripts/boards/components/board_list.vue b/app/assets/javascripts/boards/components/board_list.vue index 8a5c6882e56..58c20c0da91 100644 --- a/app/assets/javascripts/boards/components/board_list.vue +++ b/app/assets/javascripts/boards/components/board_list.vue @@ -3,6 +3,7 @@ import { GlLoadingIcon, GlIntersectionObserver } from '@gitlab/ui'; import Draggable from 'vuedraggable'; import { STATUS_CLOSED } from '~/issues/constants'; import { sprintf, __, s__ } from '~/locale'; +import { ESC_KEY_CODE } from '~/lib/utils/keycodes'; import { defaultSortableOptions, DRAG_DELAY } from '~/sortable/constants'; import { sortableStart, sortableEnd } from '~/sortable/utils'; import Tracking from '~/tracking'; @@ -82,6 +83,7 @@ export default { toList: {}, addItemToListInProgress: false, updateIssueOrderInProgress: false, + dragCancelled: false, }; }, apollo: { @@ -307,6 +309,11 @@ export default { return; } + // Reset dragCancelled flag + this.dragCancelled = false; + // Attach listener to detect `ESC` key press to cancel drag. + document.addEventListener('keyup', this.handleKeyUp.bind(this)); + sortableStart(); this.track('drag_card', { label: 'board' }); }, @@ -323,6 +330,11 @@ export default { return; } + // Detach listener as soon as drag ends. + document.removeEventListener('keyup', this.handleKeyUp.bind(this)); + // Drag was cancelled, prevent reordering. + if (this.dragCancelled) return; + sortableEnd(); let newIndex = originalNewIndex; let { children } = to; @@ -375,6 +387,20 @@ export default { this.updateIssueOrderInProgress = false; }); }, + /** + * This implementation is needed to support `Esc` key press to cancel drag. + * It matches with what we already shipped in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/119311 + */ + handleKeyUp(e) { + if (e.keyCode === ESC_KEY_CODE) { + this.dragCancelled = true; + // Sortable.js internally listens for `mouseup` event on document + // to register drop event, see https://github.com/SortableJS/Sortable/blob/master/src/Sortable.js#L625 + // We need to manually trigger it to simulate cancel behaviour as VueDraggable doesn't + // natively support it, see https://github.com/SortableJS/Vue.Draggable/issues/968. + document.dispatchEvent(new Event('mouseup')); + } + }, isItemInTheList(itemIid) { const items = this.toList?.[`${this.issuableType}s`]?.nodes || []; return items.some((item) => item.iid === itemIid); diff --git a/app/assets/javascripts/lib/utils/secret_detection.js b/app/assets/javascripts/lib/utils/secret_detection.js index 92edd286c76..dad4af004cc 100644 --- a/app/assets/javascripts/lib/utils/secret_detection.js +++ b/app/assets/javascripts/lib/utils/secret_detection.js @@ -36,6 +36,10 @@ export const containsSensitiveToken = (message) => { name: 'GitLab SCIM OAuth Access Token', regex: `glsoat-[0-9a-zA-Z_-]{20}`, }, + { + name: 'GitLab CI Build (Job) Token', + regex: `glcbt-[0-9a-zA-Z]{1,5}_[0-9a-zA-Z_-]{20}`, + }, ]; for (const rule of sensitiveDataPatterns) { diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index e56f3d2536c..23185548554 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -42,6 +42,8 @@ module Ci DEPLOYMENT_NAMES = %w[deploy release rollout].freeze + TOKEN_PREFIX = 'glcbt-' + has_one :pending_state, class_name: 'Ci::BuildPendingState', foreign_key: :build_id, inverse_of: :build has_one :queuing_entry, class_name: 'Ci::PendingBuild', foreign_key: :build_id, inverse_of: :build has_one :runtime_metadata, class_name: 'Ci::RunningBuild', foreign_key: :build_id, inverse_of: :build @@ -204,7 +206,7 @@ module Ci add_authentication_token_field :token, encrypted: :required, - format_with_prefix: :partition_id_prefix_in_16_bit_encode + format_with_prefix: :prefix_and_partition_for_token after_save :stick_build_if_status_changed @@ -1232,6 +1234,14 @@ module Ci def partition_id_prefix_in_16_bit_encode "#{partition_id.to_s(16)}_" end + + def prefix_and_partition_for_token + if Feature.enabled?(:prefix_ci_build_tokens, project, type: :beta) + TOKEN_PREFIX + partition_id_prefix_in_16_bit_encode + else + partition_id_prefix_in_16_bit_encode + end + end end end |