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>2020-09-30 06:09:46 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-30 06:09:46 +0300
commitbfb1d5b17bdb47db29956a33b85e6ef2adc47ac0 (patch)
treec362e390c20d57bc7ceb3681efa1bfa10369fae7 /app
parentae4a39e57ec63134297bce23acd677f806b45dea (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/boards/components/board_blank_state.vue104
-rw-r--r--app/assets/javascripts/boards/components/board_column.vue5
-rw-r--r--app/assets/javascripts/boards/stores/boards_store.js24
-rw-r--r--app/controllers/concerns/authenticates_with_two_factor.rb21
-rw-r--r--app/controllers/concerns/authenticates_with_two_factor_for_admin_mode.rb17
-rw-r--r--app/controllers/search_controller.rb3
-rw-r--r--app/graphql/types/sort_enum.rb8
-rw-r--r--app/helpers/application_helper.rb12
-rw-r--r--app/services/search/global_service.rb1
-rw-r--r--app/views/search/_category.html.haml1
-rw-r--r--app/views/search/_results.html.haml2
11 files changed, 47 insertions, 151 deletions
diff --git a/app/assets/javascripts/boards/components/board_blank_state.vue b/app/assets/javascripts/boards/components/board_blank_state.vue
deleted file mode 100644
index 55e3e4a6329..00000000000
--- a/app/assets/javascripts/boards/components/board_blank_state.vue
+++ /dev/null
@@ -1,104 +0,0 @@
-<script>
-import { GlButton } from '@gitlab/ui';
-import Cookies from 'js-cookie';
-import { __ } from '~/locale';
-import ListLabel from '~/boards/models/label';
-import boardsStore from '../stores/boards_store';
-
-export default {
- components: {
- GlButton,
- },
- data() {
- return {
- predefinedLabels: [
- new ListLabel({ title: __('To Do'), color: '#F0AD4E' }),
- new ListLabel({ title: __('Doing'), color: '#5CB85C' }),
- ],
- };
- },
- methods: {
- addDefaultLists() {
- this.clearBlankState();
-
- this.predefinedLabels.forEach((label, i) => {
- boardsStore.addList({
- title: label.title,
- position: i,
- list_type: 'label',
- label: {
- title: label.title,
- color: label.color,
- },
- });
- });
-
- const loadListIssues = listObj => {
- const list = boardsStore.findList('title', listObj.title);
-
- if (!list) {
- return null;
- }
-
- list.id = listObj.id;
- list.label.id = listObj.label.id;
- return list.getIssues().catch(() => {
- // TODO: handle request error
- });
- };
-
- // Save the labels
- boardsStore
- .generateDefaultLists()
- .then(res => res.data)
- .then(data => Promise.all(data.map(loadListIssues)))
- .catch(() => {
- boardsStore.removeList(undefined, 'label');
- Cookies.remove('issue_board_welcome_hidden', {
- path: '',
- });
- boardsStore.addBlankState();
- });
- },
- clearBlankState: boardsStore.removeBlankState.bind(boardsStore),
- },
-};
-</script>
-
-<template>
- <div class="board-blank-state p-3">
- <p>
- {{
- s__('BoardBlankState|Add the following default lists to your Issue Board with one click:')
- }}
- </p>
- <ul class="list-unstyled board-blank-state-list">
- <li v-for="(label, index) in predefinedLabels" :key="index">
- <span
- :style="{ backgroundColor: label.color }"
- class="label-color position-relative d-inline-block rounded"
- ></span>
- {{ label.title }}
- </li>
- </ul>
- <p>
- {{
- s__(
- 'BoardBlankState|Starting out with the default set of lists will get you right on the way to making the most of your board.',
- )
- }}
- </p>
- <gl-button
- category="secondary"
- variant="success"
- block="block"
- class="gl-mb-0"
- @click.stop="addDefaultLists"
- >
- {{ s__('BoardBlankState|Add default lists') }}
- </gl-button>
- <gl-button category="secondary" variant="default" block="block" @click.stop="clearBlankState">
- {{ s__("BoardBlankState|Nevermind, I'll use my own") }}
- </gl-button>
- </div>
-</template>
diff --git a/app/assets/javascripts/boards/components/board_column.vue b/app/assets/javascripts/boards/components/board_column.vue
index 6d216911798..6aff5f0c3c3 100644
--- a/app/assets/javascripts/boards/components/board_column.vue
+++ b/app/assets/javascripts/boards/components/board_column.vue
@@ -6,7 +6,6 @@ import BoardListHeader from 'ee_else_ce/boards/components/board_list_header.vue'
import Tooltip from '~/vue_shared/directives/tooltip';
import EmptyComponent from '~/vue_shared/components/empty_component';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
-import BoardBlankState from './board_blank_state.vue';
import BoardList from './board_list.vue';
import boardsStore from '../stores/boards_store';
import eventHub from '../eventhub';
@@ -16,7 +15,6 @@ import { ListType } from '../constants';
export default {
components: {
BoardPromotionState: EmptyComponent,
- BoardBlankState,
BoardListHeader,
BoardList,
},
@@ -54,7 +52,7 @@ export default {
computed: {
...mapGetters(['getIssues']),
showBoardListAndBoardInfo() {
- return this.list.type !== ListType.blank && this.list.type !== ListType.promotion;
+ return this.list.type !== ListType.promotion;
},
uniqueKey() {
// eslint-disable-next-line @gitlab/require-i18n-strings
@@ -148,7 +146,6 @@ export default {
:list="list"
:loading="list.loading"
/>
- <board-blank-state v-if="canAdminList && list.id === 'blank'" />
<!-- Will be only available in EE -->
<board-promotion-state v-if="list.id === 'promotion'" />
diff --git a/app/assets/javascripts/boards/stores/boards_store.js b/app/assets/javascripts/boards/stores/boards_store.js
index cbbec70ada9..d1a5db1bcc5 100644
--- a/app/assets/javascripts/boards/stores/boards_store.js
+++ b/app/assets/javascripts/boards/stores/boards_store.js
@@ -13,7 +13,6 @@ import {
convertObjectPropsToCamelCase,
} from '~/lib/utils/common_utils';
import createDefaultClient from '~/lib/graphql';
-import { __ } from '~/locale';
import axios from '~/lib/utils/axios_utils';
import { mergeUrlParams } from '~/lib/utils/url_utility';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
@@ -119,7 +118,6 @@ const boardsStore = {
.catch(() => {
// https://gitlab.com/gitlab-org/gitlab-foss/issues/30821
});
- this.removeBlankState();
},
updateNewListDropdown(listId) {
$(`.js-board-list-${listId}`).removeClass('is-active');
@@ -129,22 +127,14 @@ const boardsStore = {
return !this.state.lists.filter(list => list.type !== 'backlog' && list.type !== 'closed')[0];
},
addBlankState() {
- if (!this.shouldAddBlankState() || this.welcomeIsHidden() || this.disabled) return;
+ if (!this.shouldAddBlankState() || this.welcomeIsHidden()) return;
- this.addList({
- id: 'blank',
- list_type: 'blank',
- title: __('Welcome to your Issue Board!'),
- position: 0,
- });
- },
- removeBlankState() {
- this.removeList('blank');
-
- Cookies.set('issue_board_welcome_hidden', 'true', {
- expires: 365 * 10,
- path: '',
- });
+ this.generateDefaultLists()
+ .then(res => res.data)
+ .then(data => Promise.all(data.map(list => this.addList(list))))
+ .catch(() => {
+ this.removeList(undefined, 'label');
+ });
},
findIssueLabel(issue, findLabel) {
diff --git a/app/controllers/concerns/authenticates_with_two_factor.rb b/app/controllers/concerns/authenticates_with_two_factor.rb
index 9ff97f398f5..5c74d79951f 100644
--- a/app/controllers/concerns/authenticates_with_two_factor.rb
+++ b/app/controllers/concerns/authenticates_with_two_factor.rb
@@ -89,10 +89,7 @@ module AuthenticatesWithTwoFactor
user.save!
sign_in(user, message: :two_factor_authenticated, event: :authentication)
else
- user.increment_failed_attempts!
- Gitlab::AppLogger.info("Failed Login: user=#{user.username} ip=#{request.remote_ip} method=OTP")
- flash.now[:alert] = _('Invalid two-factor code.')
- prompt_for_two_factor(user)
+ handle_two_factor_failure(user, 'OTP', _('Invalid two-factor code.'))
end
end
@@ -101,7 +98,7 @@ module AuthenticatesWithTwoFactor
if U2fRegistration.authenticate(user, u2f_app_id, user_params[:device_response], session[:challenge])
handle_two_factor_success(user)
else
- handle_two_factor_failure(user, 'U2F')
+ handle_two_factor_failure(user, 'U2F', _('Authentication via U2F device failed.'))
end
end
@@ -109,7 +106,7 @@ module AuthenticatesWithTwoFactor
if Webauthn::AuthenticateService.new(user, user_params[:device_response], session[:challenge]).execute
handle_two_factor_success(user)
else
- handle_two_factor_failure(user, 'WebAuthn')
+ handle_two_factor_failure(user, 'WebAuthn', _('Authentication via WebAuthn device failed.'))
end
end
@@ -152,13 +149,19 @@ module AuthenticatesWithTwoFactor
sign_in(user, message: :two_factor_authenticated, event: :authentication)
end
- def handle_two_factor_failure(user, method)
+ def handle_two_factor_failure(user, method, message)
user.increment_failed_attempts!
+ log_failed_two_factor(user, method, request.remote_ip)
+
Gitlab::AppLogger.info("Failed Login: user=#{user.username} ip=#{request.remote_ip} method=#{method}")
- flash.now[:alert] = _('Authentication via %{method} device failed.') % { method: method }
+ flash.now[:alert] = message
prompt_for_two_factor(user)
end
+ def log_failed_two_factor(user, method, ip_address)
+ # overridden in EE
+ end
+
def handle_changed_user(user)
clear_two_factor_attempt!
@@ -173,3 +176,5 @@ module AuthenticatesWithTwoFactor
Digest::SHA256.hexdigest(user.encrypted_password) != session[:user_password_hash]
end
end
+
+AuthenticatesWithTwoFactor.prepend_if_ee('EE::AuthenticatesWithTwoFactor')
diff --git a/app/controllers/concerns/authenticates_with_two_factor_for_admin_mode.rb b/app/controllers/concerns/authenticates_with_two_factor_for_admin_mode.rb
index b7d2ce1eeb0..a8155f1e639 100644
--- a/app/controllers/concerns/authenticates_with_two_factor_for_admin_mode.rb
+++ b/app/controllers/concerns/authenticates_with_two_factor_for_admin_mode.rb
@@ -52,11 +52,7 @@ module AuthenticatesWithTwoFactorForAdminMode
# The admin user has successfully passed 2fa, enable admin mode ignoring password
enable_admin_mode
else
- user.increment_failed_attempts!
- Gitlab::AppLogger.info("Failed Admin Mode Login: user=#{user.username} ip=#{request.remote_ip} method=OTP")
- flash.now[:alert] = _('Invalid two-factor code.')
-
- admin_mode_prompt_for_two_factor(user)
+ admin_handle_two_factor_failure(user, 'OTP', _('Invalid two-factor code.'))
end
end
@@ -64,7 +60,7 @@ module AuthenticatesWithTwoFactorForAdminMode
if U2fRegistration.authenticate(user, u2f_app_id, user_params[:device_response], session[:challenge])
admin_handle_two_factor_success
else
- admin_handle_two_factor_failure(user, 'U2F')
+ admin_handle_two_factor_failure(user, 'U2F', _('Authentication via U2F device failed.'))
end
end
@@ -72,7 +68,7 @@ module AuthenticatesWithTwoFactorForAdminMode
if Webauthn::AuthenticateService.new(user, user_params[:device_response], session[:challenge]).execute
admin_handle_two_factor_success
else
- admin_handle_two_factor_failure(user, 'WebAuthn')
+ admin_handle_two_factor_failure(user, 'WebAuthn', _('Authentication via WebAuthn device failed.'))
end
end
@@ -100,11 +96,12 @@ module AuthenticatesWithTwoFactorForAdminMode
enable_admin_mode
end
- def admin_handle_two_factor_failure(user, method)
+ def admin_handle_two_factor_failure(user, method, message)
user.increment_failed_attempts!
- Gitlab::AppLogger.info("Failed Admin Mode Login: user=#{user.username} ip=#{request.remote_ip} method=#{method}")
- flash.now[:alert] = _('Authentication via %{method} device failed.') % { method: method }
+ log_failed_two_factor(user, method, request.remote_ip)
+ Gitlab::AppLogger.info("Failed Admin Mode Login: user=#{user.username} ip=#{request.remote_ip} method=#{method}")
+ flash.now[:alert] = message
admin_mode_prompt_for_two_factor(user)
end
end
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index dedaf0c903a..ae7aab7ab36 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -8,7 +8,8 @@ class SearchController < ApplicationController
SCOPE_PRELOAD_METHOD = {
projects: :with_web_entity_associations,
- issues: :with_web_entity_associations
+ issues: :with_web_entity_associations,
+ epics: :with_web_entity_associations
}.freeze
track_redis_hll_event :show, name: 'i_search_total', feature: :search_track_unique_users, feature_default_enabled: true
diff --git a/app/graphql/types/sort_enum.rb b/app/graphql/types/sort_enum.rb
index f9fa8829c7d..d0a6eecb672 100644
--- a/app/graphql/types/sort_enum.rb
+++ b/app/graphql/types/sort_enum.rb
@@ -7,10 +7,10 @@ module Types
# Deprecated, as we prefer uppercase enums
# https://gitlab.com/groups/gitlab-org/-/epics/1838
- value 'updated_desc', 'Updated at descending order'
- value 'updated_asc', 'Updated at ascending order'
- value 'created_desc', 'Created at descending order'
- value 'created_asc', 'Created at ascending order'
+ value 'updated_desc', 'Updated at descending order', deprecated: { reason: 'Use UPDATED_DESC', milestone: '13.5' }
+ value 'updated_asc', 'Updated at ascending order', deprecated: { reason: 'Use UPDATED_ASC', milestone: '13.5' }
+ value 'created_desc', 'Created at descending order', deprecated: { reason: 'Use CREATED_DESC', milestone: '13.5' }
+ value 'created_asc', 'Created at ascending order', deprecated: { reason: 'Use CREATED_ASC', milestone: '13.5' }
value 'UPDATED_DESC', 'Updated at descending order', value: :updated_desc
value 'UPDATED_ASC', 'Updated at ascending order', value: :updated_asc
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index a81225c8954..68b8a2e23f2 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -8,8 +8,16 @@ module ApplicationHelper
# See https://docs.gitlab.com/ee/development/ee_features.html#code-in-app-views
# rubocop: disable CodeReuse/ActiveRecord
- def render_if_exists(partial, locals = {})
- render(partial, locals) if partial_exists?(partial)
+ # We allow partial to be nil so that collection views can be passed in
+ # `render partial: 'some/view', collection: @some_collection`
+ def render_if_exists(partial = nil, **options)
+ return unless partial_exists?(partial || options[:partial])
+
+ if partial.nil?
+ render(**options)
+ else
+ render(partial, options)
+ end
end
def partial_exists?(partial)
diff --git a/app/services/search/global_service.rb b/app/services/search/global_service.rb
index e4907bf0761..68700cff715 100644
--- a/app/services/search/global_service.rb
+++ b/app/services/search/global_service.rb
@@ -25,6 +25,7 @@ module Search
strong_memoize(:allowed_scopes) do
allowed_scopes = %w[issues merge_requests milestones]
allowed_scopes << 'users' if Feature.enabled?(:users_search, default_enabled: true)
+ allowed_scopes
end
end
diff --git a/app/views/search/_category.html.haml b/app/views/search/_category.html.haml
index d6e38ddd5c6..f094a6f5e3b 100644
--- a/app/views/search/_category.html.haml
+++ b/app/views/search/_category.html.haml
@@ -30,5 +30,6 @@
= search_filter_link 'issues', _("Issues")
= search_filter_link 'merge_requests', _("Merge requests")
= search_filter_link 'milestones', _("Milestones")
+ = render_if_exists 'search/epics_filter_link'
= render_if_exists 'search/category_elasticsearch'
= users
diff --git a/app/views/search/_results.html.haml b/app/views/search/_results.html.haml
index cfe7b45d79a..95c378bff7c 100644
--- a/app/views/search/_results.html.haml
+++ b/app/views/search/_results.html.haml
@@ -32,7 +32,7 @@
.term
= render 'shared/projects/list', projects: @search_objects, pipeline_status: false
- else
- = render partial: "search/results/#{@scope.singularize}", collection: @search_objects
+ = render_if_exists partial: "search/results/#{@scope.singularize}", collection: @search_objects
- if @scope != 'projects'
= paginate_collection(@search_objects)