Commit 3ecdd280 authored by Filipa Lacerda's avatar Filipa Lacerda

Fix conflicts for:

 - app/assets/javascripts/dispatcher.js
 - app/assets/javascripts/project_find_file.js
 - app/assets/javascripts/render_gfm.js
 - app/assets/javascripts/search.js
 - app/assets/javascripts/search_autocomplete.js
 - app/assets/stylesheets/pages/merge_requests.scss
 - spec/javascripts/search_autocomplete_spec.js
parent 1e2cacf0
......@@ -24,10 +24,7 @@ import projectAvatar from './project_avatar';
/* global MergeRequest */
import Compare from './compare';
import initCompareAutocomplete from './compare_autocomplete';
<<<<<<< HEAD
/* global PathLocks */
=======
>>>>>>> upstream/master
import ProjectFindFile from './project_find_file';
import ProjectNew from './project_new';
import projectImport from './project_import';
......
......@@ -28,12 +28,7 @@ const highlighter = function(element, text, matches) {
};
export default class ProjectFindFile {
<<<<<<< HEAD
constructor (element1, options) {
=======
constructor(element1, options) {
>>>>>>> upstream/master
this.element = element1;
this.options = options;
this.goToBlob = this.goToBlob.bind(this);
......@@ -75,11 +70,7 @@ export default class ProjectFindFile {
// find file
}
<<<<<<< HEAD
// files pathes load
=======
// files pathes load
>>>>>>> upstream/master
load(url) {
return $.ajax({
url: url,
......
import renderMath from './render_math';
import renderMermaid from './render_mermaid';
import syntaxHighlight from './syntax_highlight';
<<<<<<< HEAD
=======
>>>>>>> upstream/master
// Render Gitlab flavoured Markdown
//
// Delegates to syntax highlight and render math & mermaid diagrams.
......
......@@ -79,11 +79,7 @@ export default class Search {
.on('keyup', this.searchInput, this.searchKeyUp);
$(document)
.off('click', this.searchClear)
<<<<<<< HEAD
.on('click', this.searchClear, this.clearSearchField);
=======
.on('click', this.searchClear, this.clearSearchField.bind(this));
>>>>>>> upstream/master
}
static submitSearch() {
......
/* eslint-disable comma-dangle, no-return-assign, one-var, no-var, no-underscore-dangle, one-var-declaration-per-line, no-unused-vars, no-cond-assign, consistent-return, object-shorthand, prefer-arrow-callback, func-names, space-before-function-paren, prefer-template, quotes, class-methods-use-this, no-unused-expressions, no-sequences, wrap-iife, no-lonely-if, no-else-return, no-param-reassign, vars-on-top, max-len */
/* eslint-disable no-return-assign, one-var, no-var, no-underscore-dangle, one-var-declaration-per-line, no-unused-vars, no-cond-assign, consistent-return, object-shorthand, prefer-arrow-callback, func-names, space-before-function-paren, prefer-template, quotes, class-methods-use-this, no-sequences, wrap-iife, no-lonely-if, no-else-return, no-param-reassign, vars-on-top, max-len */
import { isInGroupsPage, isInProjectPage, getGroupSlug, getProjectSlug } from './lib/utils/common_utils';
<<<<<<< HEAD
=======
/**
* Search input in top navigation bar.
* On click, opens a dropdown
......@@ -10,17 +8,12 @@ import { isInGroupsPage, isInProjectPage, getGroupSlug, getProjectSlug } from '.
* When the user clicks `x` button it cleans the input and closes the dropdown.
*/
>>>>>>> upstream/master
const KEYCODE = {
ESCAPE: 27,
BACKSPACE: 8,
ENTER: 13,
UP: 38,
<<<<<<< HEAD
DOWN: 40
=======
DOWN: 40,
>>>>>>> upstream/master
};
function setSearchOptions() {
......@@ -37,11 +30,7 @@ function setSearchOptions() {
name: $projectOptionsDataEl.data('name'),
issuesPath: $projectOptionsDataEl.data('issues-path'),
issuesDisabled: $projectOptionsDataEl.data('issues-disabled'),
<<<<<<< HEAD
mrPath: $projectOptionsDataEl.data('mr-path')
=======
mrPath: $projectOptionsDataEl.data('mr-path'),
>>>>>>> upstream/master
};
}
......@@ -49,47 +38,6 @@ function setSearchOptions() {
gl.groupOptions = gl.groupOptions || {};
var groupPath = $groupOptionsDataEl.data('group-path');
<<<<<<< HEAD
gl.groupOptions[groupPath] = {
name: $groupOptionsDataEl.data('name'),
issuesPath: $groupOptionsDataEl.data('issues-path'),
mrPath: $groupOptionsDataEl.data('mr-path')
};
}
if ($dashboardOptionsDataEl.length) {
gl.dashboardOptions = {
issuesPath: $dashboardOptionsDataEl.data('issues-path'),
mrPath: $dashboardOptionsDataEl.data('mr-path')
};
}
}
export default class SearchAutocomplete {
constructor({ wrap, optsEl, autocompletePath, projectId, projectRef } = {}) {
setSearchOptions();
this.bindEventContext();
this.wrap = wrap || $('.search');
this.optsEl = optsEl || this.wrap.find('.search-autocomplete-opts');
this.autocompletePath = autocompletePath || this.optsEl.data('autocomplete-path');
this.projectId = projectId || (this.optsEl.data('autocomplete-project-id') || '');
this.projectRef = projectRef || (this.optsEl.data('autocomplete-project-ref') || '');
this.dropdown = this.wrap.find('.dropdown');
this.dropdownContent = this.dropdown.find('.dropdown-content');
this.locationBadgeEl = this.getElement('.location-badge');
this.scopeInputEl = this.getElement('#scope');
this.searchInput = this.getElement('.search-input');
this.projectInputEl = this.getElement('#search_project_id');
this.groupInputEl = this.getElement('#group_id');
this.searchCodeInputEl = this.getElement('#search_code');
this.repositoryInputEl = this.getElement('#repository_ref');
this.clearInput = this.getElement('.js-clear-input');
this.saveOriginalState();
// Only when user is logged in
if (gon.current_user_id) {
this.createAutocomplete();
=======
gl.groupOptions[groupPath] = {
name: $groupOptionsDataEl.data('name'),
......@@ -189,85 +137,8 @@ export default class SearchAutocomplete {
this.enableAutocomplete();
}
return;
>>>>>>> upstream/master
}
this.searchInput.addClass('disabled');
this.saveTextLength();
this.bindEvents();
}
<<<<<<< HEAD
// Finds an element inside wrapper element
bindEventContext() {
this.onSearchInputBlur = this.onSearchInputBlur.bind(this);
this.onClearInputClick = this.onClearInputClick.bind(this);
this.onSearchInputFocus = this.onSearchInputFocus.bind(this);
this.onSearchInputClick = this.onSearchInputClick.bind(this);
this.onSearchInputKeyUp = this.onSearchInputKeyUp.bind(this);
this.onSearchInputKeyDown = this.onSearchInputKeyDown.bind(this);
}
getElement(selector) {
return this.wrap.find(selector);
}
saveOriginalState() {
return this.originalState = this.serializeState();
}
saveTextLength() {
return this.lastTextLength = this.searchInput.val().length;
}
createAutocomplete() {
return this.searchInput.glDropdown({
filterInputBlur: false,
filterable: true,
filterRemote: true,
highlight: true,
enterCallback: false,
filterInput: 'input#search',
search: {
fields: ['text']
},
id: this.getSearchText,
data: this.getData.bind(this),
selectable: true,
clicked: this.onClick.bind(this)
});
}
getSearchText(selectedObject, el) {
return selectedObject.id ? selectedObject.text : '';
}
getData(term, callback) {
var _this, contents, jqXHR;
_this = this;
if (!term) {
if (contents = this.getCategoryContents()) {
this.searchInput.data('glDropdown').filter.options.callback(contents);
this.enableAutocomplete();
}
return;
}
// Prevent multiple ajax calls
if (this.loadingSuggestions) {
return;
}
this.loadingSuggestions = true;
return jqXHR = $.get(this.autocompletePath, {
project_id: this.projectId,
project_ref: this.projectRef,
term: term
}, function(response) {
var data, firstCategory, i, lastCategory, len, suggestion;
// Hide dropdown menu if no suggestions returns
if (!response.length) {
_this.disableAutocomplete();
return;
}
data = [];
=======
// Prevent multiple ajax calls
if (this.loadingSuggestions) {
return;
......@@ -288,7 +159,6 @@ export default class SearchAutocomplete {
}
const data = [];
>>>>>>> upstream/master
// List results
firstCategory = true;
for (i = 0, len = response.length; i < len; i += 1) {
......@@ -302,11 +172,7 @@ export default class SearchAutocomplete {
firstCategory = false;
}
data.push({
<<<<<<< HEAD
header: suggestion.category
=======
header: suggestion.category,
>>>>>>> upstream/master
});
lastCategory = suggestion.category;
}
......@@ -314,11 +180,7 @@ export default class SearchAutocomplete {
id: (suggestion.category.toLowerCase()) + "-" + suggestion.id,
category: suggestion.category,
text: suggestion.label,
<<<<<<< HEAD
url: suggestion.url
=======
url: suggestion.url,
>>>>>>> upstream/master
});
}
// Add option to proceed with the search
......@@ -326,22 +188,6 @@ export default class SearchAutocomplete {
data.push('separator');
data.push({
text: "Result name contains \"" + term + "\"",
<<<<<<< HEAD
url: "/search?search=" + term + "&project_id=" + (_this.projectInputEl.val()) + "&group_id=" + (_this.groupInputEl.val())
});
}
return callback(data);
}).always(function() {
return _this.loadingSuggestions = false;
});
}
getCategoryContents() {
var dashboardOptions, groupOptions, issuesPath, items, mrPath, name, options, projectOptions, userId, userName;
userId = gon.current_user_id;
userName = gon.current_username;
projectOptions = gl.projectOptions, groupOptions = gl.groupOptions, dashboardOptions = gl.dashboardOptions;
=======
url: "/search?search=" + term + "&project_id=" + (this.projectInputEl.val()) + "&group_id=" + (this.groupInputEl.val()),
});
}
......@@ -357,47 +203,12 @@ export default class SearchAutocomplete {
// Get options
let options;
>>>>>>> upstream/master
if (isInGroupsPage() && groupOptions) {
options = groupOptions[getGroupSlug()];
} else if (isInProjectPage() && projectOptions) {
options = projectOptions[getProjectSlug()];
} else if (dashboardOptions) {
options = dashboardOptions;
<<<<<<< HEAD
}
issuesPath = options.issuesPath, mrPath = options.mrPath, name = options.name;
items = [
{
header: "" + name
}
];
const issueItems = [
{
text: 'Issues assigned to me',
url: issuesPath + "/?assignee_username=" + userName
}, {
text: "Issues I've created",
url: issuesPath + "/?author_username=" + userName
}
];
const mergeRequestItems = [
{
text: 'Merge requests assigned to me',
url: mrPath + "/?assignee_username=" + userName
}, {
text: "Merge requests I've created",
url: mrPath + "/?author_username=" + userName
}
];
if (options.issuesDisabled) {
items = items.concat(mergeRequestItems);
} else {
items = items.concat(...issueItems, 'separator', ...mergeRequestItems);
}
if (!name) {
items.splice(0, 1);
=======
}
const { issuesPath, mrPath, name, issuesDisabled } = options;
......@@ -407,51 +218,8 @@ export default class SearchAutocomplete {
baseItems.push({
header: `${name}`,
});
>>>>>>> upstream/master
}
return items;
}
<<<<<<< HEAD
serializeState() {
return {
// Search Criteria
search_project_id: this.projectInputEl.val(),
group_id: this.groupInputEl.val(),
search_code: this.searchCodeInputEl.val(),
repository_ref: this.repositoryInputEl.val(),
scope: this.scopeInputEl.val(),
// Location badge
_location: this.locationBadgeEl.text()
};
}
bindEvents() {
this.searchInput.on('keydown', this.onSearchInputKeyDown);
this.searchInput.on('keyup', this.onSearchInputKeyUp);
this.searchInput.on('click', this.onSearchInputClick);
this.searchInput.on('focus', this.onSearchInputFocus);
this.searchInput.on('blur', this.onSearchInputBlur);
this.clearInput.on('click', this.onClearInputClick);
return this.locationBadgeEl.on('click', (function(_this) {
return function() {
return _this.searchInput.focus();
};
})(this));
}
enableAutocomplete() {
var _this;
// No need to enable anything if user is not logged in
if (!gon.current_user_id) {
return;
}
if (!this.dropdown.hasClass('open')) {
_this = this;
this.loadingSuggestions = false;
this.dropdown.addClass('open').trigger('shown.bs.dropdown');
return this.searchInput.removeClass('disabled');
=======
const issueItems = [
{
text: 'Issues assigned to me',
......@@ -508,17 +276,8 @@ export default class SearchAutocomplete {
// No need to enable anything if user is not logged in
if (!gon.current_user_id) {
return;
>>>>>>> upstream/master
}
}
<<<<<<< HEAD
// Saves last length of the entered text
onSearchInputKeyDown() {
return this.saveTextLength();
}
=======
// If the dropdown is closed, we'll open it
if (!this.dropdown.hasClass('open')) {
this.loadingSuggestions = false;
......@@ -532,7 +291,6 @@ export default class SearchAutocomplete {
return this.saveTextLength();
}
>>>>>>> upstream/master
onSearchInputKeyUp(e) {
switch (e.keyCode) {
case KEYCODE.BACKSPACE:
......@@ -542,7 +300,6 @@ export default class SearchAutocomplete {
}
// When removing the last character and no badge is present
if (this.lastTextLength === 1) {
<<<<<<< HEAD
this.disableAutocomplete();
}
// When removing any character from existin value
......@@ -564,29 +321,6 @@ export default class SearchAutocomplete {
// e.g. Pressing ctrl + backspace or ctrl + x
if (this.searchInput.val() === '') {
this.disableAutocomplete();
=======
this.disableAutocomplete();
}
// When removing any character from existin value
if (this.lastTextLength > 1) {
this.enableAutocomplete();
}
break;
case KEYCODE.ESCAPE:
this.restoreOriginalState();
break;
case KEYCODE.ENTER:
this.disableAutocomplete();
break;
case KEYCODE.UP:
case KEYCODE.DOWN:
return;
default:
// Handle the case when deleting the input value other than backspace
// e.g. Pressing ctrl + backspace or ctrl + x
if (this.searchInput.val() === '') {
this.disableAutocomplete();
>>>>>>> upstream/master
} else {
// We should display the menu only when input is not empty
if (e.keyCode !== KEYCODE.ENTER) {
......@@ -596,85 +330,6 @@ export default class SearchAutocomplete {
}
this.wrap.toggleClass('has-value', !!e.target.value);
}
<<<<<<< HEAD
// Avoid falsy value to be returned
onSearchInputClick(e) {
return e.stopImmediatePropagation();
}
onSearchInputFocus() {
this.isFocused = true;
this.wrap.addClass('search-active');
if (this.getValue() === '') {
return this.getData();
}
}
getValue() {
return this.searchInput.val();
}
onClearInputClick(e) {
e.preventDefault();
this.wrap.toggleClass('has-value', !!e.target.value);
return this.searchInput.val('').focus();
}
onSearchInputBlur(e) {
this.isFocused = false;
this.wrap.removeClass('search-active');
// If input is blank then restore state
if (this.searchInput.val() === '') {
return this.restoreOriginalState();
}
}
addLocationBadge(item) {
var badgeText, category, value;
category = item.category != null ? item.category + ": " : '';
value = item.value != null ? item.value : '';
badgeText = "" + category + value;
this.locationBadgeEl.text(badgeText).show();
return this.wrap.addClass('has-location-badge');
}
hasLocationBadge() {
return this.wrap.is('.has-location-badge');
}
restoreOriginalState() {
var i, input, inputs, len;
inputs = Object.keys(this.originalState);
for (i = 0, len = inputs.length; i < len; i += 1) {
input = inputs[i];
this.getElement("#" + input).val(this.originalState[input]);
}
if (this.originalState._location === '') {
return this.locationBadgeEl.hide();
} else {
return this.addLocationBadge({
value: this.originalState._location
});
}
}
badgePresent() {
return this.locationBadgeEl.length;
}
resetSearchState() {
var i, input, inputs, len, results;
inputs = Object.keys(this.originalState);
results = [];
for (i = 0, len = inputs.length; i < len; i += 1) {
input = inputs[i];
// _location isnt a input
if (input === '_location') {
break;
}
results.push(this.getElement("#" + input).val(''));
=======
onSearchInputFocus() {
this.isFocused = true;
......@@ -792,55 +447,6 @@ export default class SearchAutocomplete {
$el.removeClass('is-active');
this.disableAutocomplete();
return this.searchInput.val('').focus();
>>>>>>> upstream/master
}
return results;
}
<<<<<<< HEAD
removeLocationBadge() {
this.locationBadgeEl.hide();
this.resetSearchState();
this.wrap.removeClass('has-location-badge');
return this.disableAutocomplete();
}
disableAutocomplete() {
if (!this.searchInput.hasClass('disabled') && this.dropdown.hasClass('open')) {
this.searchInput.addClass('disabled');
this.dropdown.removeClass('open').trigger('hidden.bs.dropdown');
this.restoreMenu();
}
}
restoreMenu() {
var html;
html = '<ul><li class="dropdown-menu-empty-item"><a>Loading...</a></li></ul>';
return this.dropdownContent.html(html);
}
onClick(item, $el, e) {
if (location.pathname.indexOf(item.url) !== -1) {
if (!e.metaKey) e.preventDefault();
if (!this.badgePresent) {
if (item.category === 'Projects') {
this.projectInputEl.val(item.id);
this.addLocationBadge({
value: 'This project'
});
}
if (item.category === 'Groups') {
this.groupInputEl.val(item.id);
this.addLocationBadge({
value: 'This group'
});
}
}
$el.removeClass('is-active');
this.disableAutocomplete();
return this.searchInput.val('').focus();
}
}
=======
>>>>>>> upstream/master
}
......@@ -773,7 +773,6 @@
font-size: 16px;
}
}
<<<<<<< HEAD
.mr-widget-icon {
font-size: 22px;
......@@ -825,5 +824,3 @@
}
}
}
=======
>>>>>>> upstream/master
......@@ -128,11 +128,7 @@ import * as urlUtils from '~/lib/utils/url_utility';
window.gon.current_user_id = userId;
window.gon.current_username = userName;
<<<<<<< HEAD
return widget = new SearchAutocomplete;
=======
return widget = new SearchAutocomplete();
>>>>>>> upstream/master
});
afterEach(function() {
......
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