Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-06-08 06:08:19 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-08 06:08:19 +0300
commitbf293d47937b3332462689c3fecc868706553f3a (patch)
tree47f0f1063aa27e4529c23068537ce45d6adb4cf0 /app
parent356e3c444dc8fab920d3547461b6ae721c5eb50f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/analytics/shared/constants.js12
-rw-r--r--app/assets/javascripts/diffs/components/app.vue85
-rw-r--r--app/assets/javascripts/diffs/index.js32
-rw-r--r--app/assets/javascripts/lib/utils/constants.js2
-rw-r--r--app/assets/javascripts/lib/utils/number_utils.js2
-rw-r--r--app/assets/javascripts/mr_notes/init.js29
-rw-r--r--app/assets/javascripts/mr_notes/init_mr_notes.js2
-rw-r--r--app/assets/javascripts/packages_and_registries/container_registry/explorer/constants/details.js2
-rw-r--r--app/assets/javascripts/packages_and_registries/harbor_registry/constants/details.js2
-rw-r--r--app/assets/javascripts/super_sidebar/components/help_center.vue6
-rw-r--r--app/assets/stylesheets/framework/sidebar.scss8
-rw-r--r--app/models/personal_access_token.rb9
-rw-r--r--app/services/personal_access_tokens/create_service.rb20
-rw-r--r--app/services/resource_access_tokens/create_service.rb6
14 files changed, 59 insertions, 158 deletions
diff --git a/app/assets/javascripts/analytics/shared/constants.js b/app/assets/javascripts/analytics/shared/constants.js
index 9463286e53e..25699c17b10 100644
--- a/app/assets/javascripts/analytics/shared/constants.js
+++ b/app/assets/javascripts/analytics/shared/constants.js
@@ -133,15 +133,15 @@ export const METRIC_TOOLTIPS = {
},
[VULNERABILITY_METRICS.CRITICAL]: {
description: s__('ValueStreamAnalytics|Critical vulnerabilities over time.'),
- groupLink: '-/security/vulnerabilities',
- projectLink: '-/security/vulnerability_report',
- docsLink: helpPagePath('user/application_security/vulnerability_report/index'),
+ groupLink: '-/security/vulnerabilities?severity=CRITICAL',
+ projectLink: '-/security/vulnerability_report?severity=CRITICAL',
+ docsLink: helpPagePath('user/application_security/vulnerabilities/severities.html'),
},
[VULNERABILITY_METRICS.HIGH]: {
description: s__('ValueStreamAnalytics|High vulnerabilities over time.'),
- groupLink: '-/security/vulnerabilities',
- projectLink: '-/security/vulnerability_report',
- docsLink: helpPagePath('user/application_security/vulnerability_report/index'),
+ groupLink: '-/security/vulnerabilities?severity=HIGH',
+ projectLink: '-/security/vulnerability_report?severity=HIGH',
+ docsLink: helpPagePath('user/application_security/vulnerabilities/severities.html'),
},
[MERGE_REQUEST_METRICS.THROUGHPUT]: {
description: s__('ValueStreamAnalytics|The number of merge requests merged by month.'),
diff --git a/app/assets/javascripts/diffs/components/app.vue b/app/assets/javascripts/diffs/components/app.vue
index f644c69f0a0..c0a9643e59e 100644
--- a/app/assets/javascripts/diffs/components/app.vue
+++ b/app/assets/javascripts/diffs/components/app.vue
@@ -90,22 +90,6 @@ export default {
ALERT_COLLAPSED_FILES,
},
props: {
- endpoint: {
- type: String,
- required: true,
- },
- endpointMetadata: {
- type: String,
- required: true,
- },
- endpointBatch: {
- type: String,
- required: true,
- },
- endpointDiffForPath: {
- type: String,
- required: true,
- },
endpointCoverage: {
type: String,
required: false,
@@ -116,15 +100,6 @@ export default {
required: false,
default: '',
},
- endpointUpdateUser: {
- type: String,
- required: false,
- default: '',
- },
- projectPath: {
- type: String,
- required: true,
- },
shouldShow: {
type: Boolean,
required: false,
@@ -144,51 +119,6 @@ export default {
required: false,
default: '',
},
- isFluidLayout: {
- type: Boolean,
- required: false,
- default: false,
- },
- dismissEndpoint: {
- type: String,
- required: false,
- default: '',
- },
- showSuggestPopover: {
- type: Boolean,
- required: false,
- default: false,
- },
- fileByFileUserPreference: {
- type: Boolean,
- required: false,
- default: false,
- },
- defaultSuggestionCommitMessage: {
- type: String,
- required: false,
- default: '',
- },
- rehydratedMrReviews: {
- type: Object,
- required: false,
- default: () => ({}),
- },
- sourceProjectDefaultUrl: {
- type: String,
- required: false,
- default: '',
- },
- sourceProjectFullPath: {
- type: String,
- required: false,
- default: '',
- },
- isForked: {
- type: Boolean,
- required: false,
- default: false,
- },
},
data() {
const treeWidth =
@@ -343,21 +273,6 @@ export default {
renderFileTree: 'adjustView',
},
mounted() {
- this.setBaseConfig({
- endpoint: this.endpoint,
- endpointMetadata: this.endpointMetadata,
- endpointBatch: this.endpointBatch,
- endpointDiffForPath: this.endpointDiffForPath,
- endpointCoverage: this.endpointCoverage,
- endpointUpdateUser: this.endpointUpdateUser,
- projectPath: this.projectPath,
- dismissEndpoint: this.dismissEndpoint,
- showSuggestPopover: this.showSuggestPopover,
- viewDiffsFileByFile: this.fileByFileUserPreference || false,
- defaultSuggestionCommitMessage: this.defaultSuggestionCommitMessage,
- mrReviews: this.rehydratedMrReviews,
- });
-
if (this.endpointCodequality) {
this.setCodequalityEndpoint(this.endpointCodequality);
}
diff --git a/app/assets/javascripts/diffs/index.js b/app/assets/javascripts/diffs/index.js
index 53c27632c4f..29cf90dcbe2 100644
--- a/app/assets/javascripts/diffs/index.js
+++ b/app/assets/javascripts/diffs/index.js
@@ -9,8 +9,6 @@ import eventHub from '../notes/event_hub';
import DiffsApp from './components/app.vue';
import { TREE_LIST_STORAGE_KEY, DIFF_WHITESPACE_COOKIE_NAME } from './constants';
-import { getReviewsForMergeRequest } from './utils/file_reviews';
-import { getDerivedMergeRequestInformation } from './utils/merge_request';
export default function initDiffsApp(store = notesStore) {
const el = document.getElementById('js-diffs-app');
@@ -32,26 +30,13 @@ export default function initDiffsApp(store = notesStore) {
},
data() {
return {
- endpoint: dataset.endpoint,
- endpointMetadata: dataset.endpointMetadata || '',
- endpointBatch: dataset.endpointBatch || '',
- endpointDiffForPath: dataset.endpointDiffForPath || '',
endpointCoverage: dataset.endpointCoverage || '',
endpointCodequality: dataset.endpointCodequality || '',
- endpointUpdateUser: dataset.updateCurrentUserPath,
- projectPath: dataset.projectPath,
helpPagePath: dataset.helpPagePath,
currentUser: JSON.parse(dataset.currentUserData) || {},
changesEmptyStateIllustration: dataset.changesEmptyStateIllustration,
- isFluidLayout: parseBoolean(dataset.isFluidLayout),
dismissEndpoint: dataset.dismissEndpoint,
- showSuggestPopover: parseBoolean(dataset.showSuggestPopover),
showWhitespaceDefault: parseBoolean(dataset.showWhitespaceDefault),
- viewDiffsFileByFile: parseBoolean(dataset.fileByFileDefault),
- defaultSuggestionCommitMessage: dataset.defaultSuggestionCommitMessage,
- sourceProjectDefaultUrl: dataset.sourceProjectDefaultUrl,
- sourceProjectFullPath: dataset.sourceProjectFullPath,
- isForked: parseBoolean(dataset.isForked),
};
},
computed: {
@@ -90,31 +75,14 @@ export default function initDiffsApp(store = notesStore) {
...mapActions('diffs', ['setRenderTreeList', 'setShowWhitespace']),
},
render(createElement) {
- const { mrPath } = getDerivedMergeRequestInformation({ endpoint: this.endpoint });
-
return createElement('diffs-app', {
props: {
- endpoint: this.endpoint,
- endpointMetadata: this.endpointMetadata,
- endpointBatch: this.endpointBatch,
- endpointDiffForPath: this.endpointDiffForPath,
endpointCoverage: this.endpointCoverage,
endpointCodequality: this.endpointCodequality,
- endpointUpdateUser: this.endpointUpdateUser,
currentUser: this.currentUser,
- projectPath: this.projectPath,
helpPagePath: this.helpPagePath,
shouldShow: this.activeTab === 'diffs',
changesEmptyStateIllustration: this.changesEmptyStateIllustration,
- isFluidLayout: this.isFluidLayout,
- dismissEndpoint: this.dismissEndpoint,
- showSuggestPopover: this.showSuggestPopover,
- fileByFileUserPreference: this.viewDiffsFileByFile,
- defaultSuggestionCommitMessage: this.defaultSuggestionCommitMessage,
- rehydratedMrReviews: getReviewsForMergeRequest(mrPath),
- sourceProjectDefaultUrl: this.sourceProjectDefaultUrl,
- sourceProjectFullPath: this.sourceProjectFullPath,
- isForked: this.isForked,
},
});
},
diff --git a/app/assets/javascripts/lib/utils/constants.js b/app/assets/javascripts/lib/utils/constants.js
index fb69a61880a..d1e5e4eea13 100644
--- a/app/assets/javascripts/lib/utils/constants.js
+++ b/app/assets/javascripts/lib/utils/constants.js
@@ -27,7 +27,7 @@ export const DRAWER_Z_INDEX = 252;
export const MIN_USERNAME_LENGTH = 2;
-export const BYTES_FORMAT_BYTES = 'Bytes';
+export const BYTES_FORMAT_BYTES = 'B';
export const BYTES_FORMAT_KIB = 'KiB';
export const BYTES_FORMAT_MIB = 'MiB';
export const BYTES_FORMAT_GIB = 'GiB';
diff --git a/app/assets/javascripts/lib/utils/number_utils.js b/app/assets/javascripts/lib/utils/number_utils.js
index d64f84d2040..0e943cdb623 100644
--- a/app/assets/javascripts/lib/utils/number_utils.js
+++ b/app/assets/javascripts/lib/utils/number_utils.js
@@ -106,7 +106,7 @@ export function numberToHumanSize(size, digits = 2) {
switch (format) {
case BYTES_FORMAT_BYTES:
- return sprintf(__('%{size} bytes'), { size: humanSize });
+ return sprintf(__('%{size} B'), { size: humanSize });
case BYTES_FORMAT_KIB:
return sprintf(__('%{size} KiB'), { size: humanSize });
case BYTES_FORMAT_MIB:
diff --git a/app/assets/javascripts/mr_notes/init.js b/app/assets/javascripts/mr_notes/init.js
index 9852efea95f..e8e3376cee2 100644
--- a/app/assets/javascripts/mr_notes/init.js
+++ b/app/assets/javascripts/mr_notes/init.js
@@ -1,12 +1,14 @@
import { parseBoolean } from '~/lib/utils/common_utils';
-import store from '~/mr_notes/stores';
+import mrNotes from '~/mr_notes/stores';
import { getLocationHash } from '~/lib/utils/url_utility';
import eventHub from '~/notes/event_hub';
import { initReviewBar } from '~/batch_comments';
import { initDiscussionCounter } from '~/mr_notes/discussion_counter';
import { initOverviewTabCounter } from '~/mr_notes/init_count';
+import { getDerivedMergeRequestInformation } from '~/diffs/utils/merge_request';
+import { getReviewsForMergeRequest } from '~/diffs/utils/file_reviews';
-function setupMrNotesState(notesDataset) {
+function setupMrNotesState(store, notesDataset, diffsDataset) {
const noteableData = JSON.parse(notesDataset.noteableData);
noteableData.noteableType = notesDataset.noteableType;
noteableData.targetType = notesDataset.targetType;
@@ -15,26 +17,43 @@ function setupMrNotesState(notesDataset) {
const currentUserData = JSON.parse(notesDataset.currentUserData);
const endpoints = { metadata: notesDataset.endpointMetadata };
+ const { mrPath } = getDerivedMergeRequestInformation({ endpoint: diffsDataset.endpoint });
+
store.dispatch('setNotesData', notesData);
store.dispatch('setNoteableData', noteableData);
store.dispatch('setUserData', currentUserData);
store.dispatch('setTargetNoteHash', getLocationHash());
store.dispatch('setEndpoints', endpoints);
+ store.dispatch('diffs/setBaseConfig', {
+ endpoint: diffsDataset.endpoint,
+ endpointMetadata: diffsDataset.endpointMetadata,
+ endpointBatch: diffsDataset.endpointBatch,
+ endpointDiffForPath: diffsDataset.endpointDiffForPath,
+ endpointCoverage: diffsDataset.endpointCoverage,
+ endpointUpdateUser: diffsDataset.updateCurrentUserPath,
+ projectPath: diffsDataset.projectPath,
+ dismissEndpoint: diffsDataset.dismissEndpoint,
+ showSuggestPopover: parseBoolean(diffsDataset.showSuggestPopover),
+ viewDiffsFileByFile: parseBoolean(diffsDataset.fileByFileDefault),
+ defaultSuggestionCommitMessage: diffsDataset.defaultSuggestionCommitMessage,
+ mrReviews: getReviewsForMergeRequest(mrPath),
+ });
}
-export function initMrStateLazyLoad({ reviewBarParams } = {}) {
+export function initMrStateLazyLoad(store = mrNotes, { reviewBarParams } = {}) {
store.dispatch('setActiveTab', window.mrTabs.getCurrentAction());
window.mrTabs.eventHub.$on('MergeRequestTabChange', (value) =>
store.dispatch('setActiveTab', value),
);
const discussionsEl = document.getElementById('js-vue-mr-discussions');
- const notesDataset = discussionsEl.dataset;
+ const diffsEl = document.getElementById('js-diffs-app');
+
let stop = () => {};
stop = store.watch(
(state) => state.page.activeTab,
(activeTab) => {
- setupMrNotesState(notesDataset);
+ setupMrNotesState(store, discussionsEl.dataset, diffsEl.dataset);
// prevent loading MR state on commits and pipelines pages
// this is due to them having a shared controller with the Overview page
diff --git a/app/assets/javascripts/mr_notes/init_mr_notes.js b/app/assets/javascripts/mr_notes/init_mr_notes.js
index e0a8d1f7e7d..3fcf0958868 100644
--- a/app/assets/javascripts/mr_notes/init_mr_notes.js
+++ b/app/assets/javascripts/mr_notes/init_mr_notes.js
@@ -13,7 +13,7 @@ export default function initMrNotes(lazyLoadParams) {
action: mrShowNode.dataset.mrAction,
});
- initMrStateLazyLoad(lazyLoadParams);
+ initMrStateLazyLoad(undefined, lazyLoadParams);
document.addEventListener('merged:UpdateActions', () => {
initRevertCommitModal('i_code_review_post_merge_submit_revert_modal');
diff --git a/app/assets/javascripts/packages_and_registries/container_registry/explorer/constants/details.js b/app/assets/javascripts/packages_and_registries/container_registry/explorer/constants/details.js
index 7ac803a8ece..3a5992d182a 100644
--- a/app/assets/javascripts/packages_and_registries/container_registry/explorer/constants/details.js
+++ b/app/assets/javascripts/packages_and_registries/container_registry/explorer/constants/details.js
@@ -68,7 +68,7 @@ export const MISSING_MANIFEST_WARNING_TOOLTIP = s__(
export const CREATED_AT = s__('ContainerRegistry|Created %{time}');
export const NOT_AVAILABLE_TEXT = __('Not applicable.');
-export const NOT_AVAILABLE_SIZE = __('0 bytes');
+export const NOT_AVAILABLE_SIZE = __('0 B');
export const CLEANUP_UNSCHEDULED_TEXT = s__('ContainerRegistry|Cleanup will run %{time}');
export const CLEANUP_SCHEDULED_TEXT = s__('ContainerRegistry|Cleanup pending');
diff --git a/app/assets/javascripts/packages_and_registries/harbor_registry/constants/details.js b/app/assets/javascripts/packages_and_registries/harbor_registry/constants/details.js
index 5b4b85ec31e..ce98be914ae 100644
--- a/app/assets/javascripts/packages_and_registries/harbor_registry/constants/details.js
+++ b/app/assets/javascripts/packages_and_registries/harbor_registry/constants/details.js
@@ -16,7 +16,7 @@ export const DIGEST_LABEL = s__('HarborRegistry|Digest: %{imageId}');
export const CREATED_AT_LABEL = s__('HarborRegistry|Published %{timeInfo}');
export const NOT_AVAILABLE_TEXT = __('Not applicable.');
-export const NOT_AVAILABLE_SIZE = __('0 bytes');
+export const NOT_AVAILABLE_SIZE = __('0 B');
export const TOKEN_TYPE_TAG_NAME = 'tag_name';
diff --git a/app/assets/javascripts/super_sidebar/components/help_center.vue b/app/assets/javascripts/super_sidebar/components/help_center.vue
index 1a965f21ef5..6d51063dbfb 100644
--- a/app/assets/javascripts/super_sidebar/components/help_center.vue
+++ b/app/assets/javascripts/super_sidebar/components/help_center.vue
@@ -216,7 +216,11 @@ export default {
>
<template #toggle>
<gl-button category="tertiary" icon="question-o" class="btn-with-notification">
- <span v-if="showWhatsNewNotification" class="notification-dot-info"></span>
+ <span
+ v-if="showWhatsNewNotification"
+ data-testid="notification-dot"
+ class="notification-dot-info"
+ ></span>
{{ $options.i18n.help }}
</gl-button>
</template>
diff --git a/app/assets/stylesheets/framework/sidebar.scss b/app/assets/stylesheets/framework/sidebar.scss
index 7a3db63b478..b7a674a35e7 100644
--- a/app/assets/stylesheets/framework/sidebar.scss
+++ b/app/assets/stylesheets/framework/sidebar.scss
@@ -489,14 +489,12 @@
padding: 0;
.issuable-context-form {
- $issue-sticky-header-height: 76px;
-
- top: calc(#{$calc-application-header-height} + #{$issue-sticky-header-height});
- height: calc(#{$calc-application-viewport-height} - #{$issue-sticky-header-height} - var(--mr-review-bar-height) - $content-wrapper-padding);
+ top: calc(#{$calc-application-header-height} + #{$mr-sticky-header-height});
+ height: calc(#{$calc-application-viewport-height} - #{$mr-sticky-header-height} - var(--mr-review-bar-height));
position: sticky;
overflow: auto;
padding: 0 15px;
- margin-bottom: calc((#{$header-height} + $issue-sticky-header-height) * -1);
+ margin-bottom: calc((#{$content-wrapper-padding} * -1) + var(--mr-review-bar-height));
}
}
}
diff --git a/app/models/personal_access_token.rb b/app/models/personal_access_token.rb
index 80825c4bf08..2749404b7b5 100644
--- a/app/models/personal_access_token.rb
+++ b/app/models/personal_access_token.rb
@@ -44,6 +44,7 @@ class PersonalAccessToken < ApplicationRecord
validates :scopes, presence: true
validate :validate_scopes
+ validates :expires_at, presence: true, on: :create
validate :expires_at_before_instance_max_expiry_date, on: :create
def revoke!
@@ -54,14 +55,6 @@ class PersonalAccessToken < ApplicationRecord
!revoked? && !expired?
end
- # fall back to default value until background migration has updated all
- # existing PATs and we can add a validation
- # https://gitlab.com/gitlab-org/gitlab/-/issues/369123
- def expires_at=(value)
- datetime = value.presence || MAX_PERSONAL_ACCESS_TOKEN_LIFETIME_IN_DAYS.days.from_now
- super(datetime)
- end
-
override :simple_sorts
def self.simple_sorts
super.merge(
diff --git a/app/services/personal_access_tokens/create_service.rb b/app/services/personal_access_tokens/create_service.rb
index adb7924f35e..31ba88af46c 100644
--- a/app/services/personal_access_tokens/create_service.rb
+++ b/app/services/personal_access_tokens/create_service.rb
@@ -13,7 +13,7 @@ module PersonalAccessTokens
def execute
return ServiceResponse.error(message: 'Not permitted to create') unless creation_permitted?
- token = target_user.personal_access_tokens.create(params.slice(*allowed_params))
+ token = target_user.personal_access_tokens.create(personal_access_token_params)
if token.persisted?
log_event(token)
@@ -31,13 +31,17 @@ module PersonalAccessTokens
attr_reader :target_user, :ip_address
- def allowed_params
- [
- :name,
- :impersonation,
- :scopes,
- :expires_at
- ]
+ def personal_access_token_params
+ {
+ name: params[:name],
+ impersonation: params[:impersonation] || false,
+ scopes: params[:scopes],
+ expires_at: pat_expiration
+ }
+ end
+
+ def pat_expiration
+ params[:expires_at].presence || PersonalAccessToken::MAX_PERSONAL_ACCESS_TOKEN_LIFETIME_IN_DAYS.days.from_now
end
def creation_permitted?
diff --git a/app/services/resource_access_tokens/create_service.rb b/app/services/resource_access_tokens/create_service.rb
index b184c2f8f58..1fea894a599 100644
--- a/app/services/resource_access_tokens/create_service.rb
+++ b/app/services/resource_access_tokens/create_service.rb
@@ -97,7 +97,7 @@ module ResourceAccessTokens
name: params[:name] || "#{resource_type}_bot",
impersonation: false,
scopes: params[:scopes] || default_scopes,
- expires_at: params[:expires_at] || nil
+ expires_at: pat_expiration
}
end
@@ -106,10 +106,10 @@ module ResourceAccessTokens
end
def create_membership(resource, user, access_level)
- resource.add_member(user, access_level, expires_at: default_pat_expiration)
+ resource.add_member(user, access_level, expires_at: pat_expiration)
end
- def default_pat_expiration
+ def pat_expiration
params[:expires_at].presence || PersonalAccessToken::MAX_PERSONAL_ACCESS_TOKEN_LIFETIME_IN_DAYS.days.from_now
end