Commit 87052128 authored by Clement Ho's avatar Clement Ho

Merge branch 'master' into ee-dispatcher-dashboard-projects

parents 2f642c3c 0fa15a51
......@@ -57,7 +57,6 @@ import GfmAutoComplete from './gfm_auto_complete';
import ShortcutsBlob from './shortcuts_blob';
import SigninTabsMemoizer from './signin_tabs_memoizer';
import Star from './star';
import Todos from './todos';
import TreeView from './tree';
import UsagePing from './usage_ping';
import UsernameValidator from './username_validator';
......@@ -123,6 +122,7 @@ import initLDAPGroupsSelect from 'ee/ldap_groups_select'; // eslint-disable-line
}
const fail = () => Flash('Error loading dynamic module');
const callDefault = m => m.default();
path = page.split(':');
shortcut_handler = null;
......@@ -240,7 +240,7 @@ import initLDAPGroupsSelect from 'ee/ldap_groups_select'; // eslint-disable-line
projectSelect();
break;
case 'dashboard:todos:index':
new Todos();
import('./pages/dashboard/todos/index').then(callDefault).catch(fail);
break;
case 'dashboard:projects:index':
case 'dashboard:projects:starred':
......@@ -609,7 +609,7 @@ import initLDAPGroupsSelect from 'ee/ldap_groups_select'; // eslint-disable-line
new CILintEditor();
break;
case 'users:show':
import('./pages/users/show').then(m => m.default()).catch(fail);
import('./pages/users/show').then(callDefault).catch(fail);
break;
case 'admin:conversational_development_index:show':
new UserCallout();
......
import Todos from './todos';
export default () => new Todos();
/* eslint-disable class-methods-use-this, no-unneeded-ternary, quote-props */
import { visitUrl } from './lib/utils/url_utility';
import UsersSelect from './users_select';
import { isMetaClick } from './lib/utils/common_utils';
import { visitUrl } from '~/lib/utils/url_utility';
import UsersSelect from '~/users_select';
import { isMetaClick } from '~/lib/utils/common_utils';
export default class Todos {
constructor() {
......
---
title: Properly memoize ChangeAccess#validate_path_locks? to avoid excessive queries
merge_request:
author:
type: performance
......@@ -2,6 +2,7 @@ module Gitlab
module Checks
class ChangeAccess
include PathLocksHelper
include Gitlab::Utils::StrongMemoize
ERROR_MESSAGES = {
push_code: 'You are not allowed to push code to this project.',
......@@ -300,9 +301,11 @@ module Gitlab
end
def validate_path_locks?
@validate_path_locks ||= @project.feature_available?(:file_locks) &&
project.path_locks.any? && @newrev && @oldrev &&
project.default_branch == @branch_name # locks protect default branch only
strong_memoize(:validate_path_locks) do
@project.feature_available?(:file_locks) &&
project.path_locks.any? && @newrev && @oldrev &&
project.default_branch == @branch_name # locks protect default branch only
end
end
def path_locks_validation
......
import * as urlUtils from '~/lib/utils/url_utility';
import Todos from '~/todos';
import Todos from '~/pages/dashboard/todos/index/todos';
import '~/lib/utils/common_utils';
describe('Todos', () => {
......
......@@ -319,6 +319,12 @@ describe Gitlab::Checks::ChangeAccess do
it 'allows the default branch even if it does not match push rule' do
expect { subject.exec }.not_to raise_error
end
it 'memoizes the validate_path_locks? call' do
expect(project.path_locks).to receive(:any?).once.and_call_original
2.times { subject.exec }
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment