Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1ef36eab
Commit
1ef36eab
authored
Apr 15, 2020
by
lauraMon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace underscore with lodash
* The easy ones, not the timer based ones
parent
3006fcb9
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
48 additions
and
51 deletions
+48
-51
app/assets/javascripts/awards_handler.js
app/assets/javascripts/awards_handler.js
+3
-5
app/assets/javascripts/dropzone_input.js
app/assets/javascripts/dropzone_input.js
+3
-3
app/assets/javascripts/flash.js
app/assets/javascripts/flash.js
+3
-3
app/assets/javascripts/gfm_auto_complete.js
app/assets/javascripts/gfm_auto_complete.js
+10
-10
app/assets/javascripts/importer_status.js
app/assets/javascripts/importer_status.js
+3
-3
app/assets/javascripts/issuable_bulk_update_sidebar.js
app/assets/javascripts/issuable_bulk_update_sidebar.js
+1
-1
app/assets/javascripts/labels_select.js
app/assets/javascripts/labels_select.js
+12
-12
app/assets/javascripts/locale/sprintf.js
app/assets/javascripts/locale/sprintf.js
+1
-1
app/assets/javascripts/right_sidebar.js
app/assets/javascripts/right_sidebar.js
+1
-2
app/assets/javascripts/users_select.js
app/assets/javascripts/users_select.js
+11
-11
No files found.
app/assets/javascripts/awards_handler.js
View file @
1ef36eab
/* eslint-disable class-methods-use-this, @gitlab/require-i18n-strings */
import
$
from
'
jquery
'
;
import
_
from
'
underscore
'
;
import
{
uniq
}
from
'
lodash
'
;
import
{
GlBreakpointInstance
as
bp
}
from
'
@gitlab/ui/dist/utils
'
;
import
Cookies
from
'
js-cookie
'
;
import
{
__
}
from
'
./locale
'
;
...
...
@@ -513,7 +513,7 @@ export class AwardsHandler {
addEmojiToFrequentlyUsedList
(
emoji
)
{
if
(
this
.
emoji
.
isEmojiNameValid
(
emoji
))
{
this
.
frequentlyUsedEmojis
=
_
.
uniq
(
this
.
getFrequentlyUsedEmojis
().
concat
(
emoji
));
this
.
frequentlyUsedEmojis
=
uniq
(
this
.
getFrequentlyUsedEmojis
().
concat
(
emoji
));
Cookies
.
set
(
'
frequently_used_emojis
'
,
this
.
frequentlyUsedEmojis
.
join
(
'
,
'
),
{
expires
:
365
});
}
}
...
...
@@ -522,9 +522,7 @@ export class AwardsHandler {
return
(
this
.
frequentlyUsedEmojis
||
(()
=>
{
const
frequentlyUsedEmojis
=
_
.
uniq
(
(
Cookies
.
get
(
'
frequently_used_emojis
'
)
||
''
).
split
(
'
,
'
),
);
const
frequentlyUsedEmojis
=
uniq
((
Cookies
.
get
(
'
frequently_used_emojis
'
)
||
''
).
split
(
'
,
'
));
this
.
frequentlyUsedEmojis
=
frequentlyUsedEmojis
.
filter
(
inputName
=>
this
.
emoji
.
isEmojiNameValid
(
inputName
),
);
...
...
app/assets/javascripts/dropzone_input.js
View file @
1ef36eab
import
$
from
'
jquery
'
;
import
Dropzone
from
'
dropzone
'
;
import
_
from
'
underscore
'
;
import
{
escape
as
esc
}
from
'
lodash
'
;
import
'
./behaviors/preview_markdown
'
;
import
PasteMarkdownTable
from
'
./behaviors/markdown/paste_markdown_table
'
;
import
csrf
from
'
./lib/utils/csrf
'
;
...
...
@@ -16,7 +16,7 @@ Dropzone.autoDiscover = false;
* @param {String|Object} res
*/
function
getErrorMessage
(
res
)
{
if
(
!
res
||
_
.
isString
(
res
)
)
{
if
(
!
res
||
typeof
res
===
'
string
'
)
{
return
res
;
}
...
...
@@ -233,7 +233,7 @@ export default function dropzoneInput(form, config = { parallelUploads: 2 }) {
};
addFileToForm
=
path
=>
{
$
(
form
).
append
(
`<input type="hidden" name="files[]" value="
${
_
.
escape
(
path
)}
">`
);
$
(
form
).
append
(
`<input type="hidden" name="files[]" value="
${
esc
(
path
)}
">`
);
};
const
showSpinner
=
()
=>
$uploadingProgressContainer
.
removeClass
(
'
hide
'
);
...
...
app/assets/javascripts/flash.js
View file @
1ef36eab
import
_
from
'
underscore
'
;
import
{
escape
as
esc
}
from
'
lodash
'
;
import
{
spriteIcon
}
from
'
./lib/utils/common_utils
'
;
const
FLASH_TYPES
=
{
...
...
@@ -39,14 +39,14 @@ const createAction = config => `
class="flash-action"
${
config
.
href
?
''
:
'
role="button"
'
}
>
${
_
.
escape
(
config
.
title
)}
${
esc
(
config
.
title
)}
</a>
`
;
const
createFlashEl
=
(
message
,
type
)
=>
`
<div class="flash-
${
type
}
">
<div class="flash-text">
${
_
.
escape
(
message
)}
${
esc
(
message
)}
<div class="close-icon-wrapper js-close-icon">
${
spriteIcon
(
'
close
'
,
'
close-icon
'
)}
</div>
...
...
app/assets/javascripts/gfm_auto_complete.js
View file @
1ef36eab
import
$
from
'
jquery
'
;
import
'
@gitlab/at.js
'
;
import
_
from
'
underscore
'
;
import
{
escape
as
esc
,
template
}
from
'
lodash
'
;
import
SidebarMediator
from
'
~/sidebar/sidebar_mediator
'
;
import
glRegexp
from
'
./lib/utils/regexp
'
;
import
AjaxCache
from
'
./lib/utils/ajax_cache
'
;
...
...
@@ -11,7 +11,7 @@ function sanitize(str) {
}
export
function
membersBeforeSave
(
members
)
{
return
_
.
map
(
members
,
member
=>
{
return
members
.
map
(
member
=>
{
const
GROUP_TYPE
=
'
Group
'
;
let
title
=
''
;
...
...
@@ -122,7 +122,7 @@ class GfmAutoComplete {
cssClasses
.
push
(
'
has-warning
'
);
}
return
_
.
template
(
tpl
)({
return
template
(
tpl
)({
...
value
,
className
:
cssClasses
.
join
(
'
'
),
});
...
...
@@ -137,7 +137,7 @@ class GfmAutoComplete {
tpl
+=
'
<%- referencePrefix %>
'
;
}
}
return
_
.
template
(
tpl
)({
referencePrefix
});
return
template
(
tpl
)({
referencePrefix
});
},
suffix
:
''
,
callbacks
:
{
...
...
@@ -692,14 +692,14 @@ GfmAutoComplete.Emoji = {
// Team Members
GfmAutoComplete
.
Members
=
{
templateFunction
({
avatarTag
,
username
,
title
,
icon
})
{
return
`<li>
${
avatarTag
}
${
username
}
<small>
${
_
.
escape
(
title
)}
</small>
${
icon
}
</li>`
;
return
`<li>
${
avatarTag
}
${
username
}
<small>
${
esc
(
title
)}
</small>
${
icon
}
</li>`
;
},
};
GfmAutoComplete
.
Labels
=
{
templateFunction
(
color
,
title
)
{
return
`<li><span class="dropdown-label-box" style="background:
${
_
.
escape
(
color
,
)}
"></span>
${
_
.
escape
(
title
)}
</li>`
;
return
`<li><span class="dropdown-label-box" style="background:
${
esc
(
color
)}
"></span>
${
esc
(
title
,
)}
</li>`
;
},
};
// Issues, MergeRequests and Snippets
...
...
@@ -709,13 +709,13 @@ GfmAutoComplete.Issues = {
return
value
.
reference
||
'
${atwho-at}${id}
'
;
},
templateFunction
({
id
,
title
,
reference
})
{
return
`<li><small>
${
reference
||
id
}
</small>
${
_
.
escape
(
title
)}
</li>`
;
return
`<li><small>
${
reference
||
id
}
</small>
${
esc
(
title
)}
</li>`
;
},
};
// Milestones
GfmAutoComplete
.
Milestones
=
{
templateFunction
(
title
)
{
return
`<li>
${
_
.
escape
(
title
)}
</li>`
;
return
`<li>
${
esc
(
title
)}
</li>`
;
},
};
GfmAutoComplete
.
Loading
=
{
...
...
app/assets/javascripts/importer_status.js
View file @
1ef36eab
import
$
from
'
jquery
'
;
import
_
from
'
underscore
'
;
import
{
escape
as
esc
}
from
'
lodash
'
;
import
{
__
,
sprintf
}
from
'
./locale
'
;
import
axios
from
'
./lib/utils/axios_utils
'
;
import
flash
from
'
./flash
'
;
...
...
@@ -73,9 +73,9 @@ class ImporterStatus {
const
connectingVerb
=
this
.
ciCdOnly
?
__
(
'
connecting
'
)
:
__
(
'
importing
'
);
job
.
find
(
'
.import-actions
'
).
html
(
sprintf
(
_
.
escape
(
__
(
'
%{loadingIcon} Started
'
)),
esc
(
__
(
'
%{loadingIcon} Started
'
)),
{
loadingIcon
:
`<i class="fa fa-spinner fa-spin" aria-label="
${
_
.
escape
(
loadingIcon
:
`<i class="fa fa-spinner fa-spin" aria-label="
${
esc
(
connectingVerb
,
)}
"></i>`
,
},
...
...
app/assets/javascripts/issuable_bulk_update_sidebar.js
View file @
1ef36eab
/* eslint-disable class-methods-use-this, no-new */
import
$
from
'
jquery
'
;
import
{
property
}
from
'
underscore
'
;
import
{
property
}
from
'
lodash
'
;
import
IssuableBulkUpdateActions
from
'
./issuable_bulk_update_actions
'
;
import
MilestoneSelect
from
'
./milestone_select
'
;
import
issueStatusSelect
from
'
./issue_status_select
'
;
...
...
app/assets/javascripts/labels_select.js
View file @
1ef36eab
...
...
@@ -3,7 +3,7 @@
/* global ListLabel */
import
$
from
'
jquery
'
;
import
_
from
'
underscore
'
;
import
{
isEqual
,
escape
as
esc
,
sortBy
,
template
}
from
'
lodash
'
;
import
{
sprintf
,
s__
,
__
}
from
'
./locale
'
;
import
axios
from
'
./lib/utils/axios_utils
'
;
import
IssuableBulkUpdateActions
from
'
./issuable_bulk_update_actions
'
;
...
...
@@ -76,7 +76,7 @@ export default class LabelsSelect {
})
.
get
();
if
(
_
.
isEqual
(
initialSelected
,
selected
))
return
;
if
(
isEqual
(
initialSelected
,
selected
))
return
;
initialSelected
=
selected
;
const
data
=
{};
...
...
@@ -101,7 +101,7 @@ export default class LabelsSelect {
let
labelCount
=
0
;
if
(
data
.
labels
.
length
&&
issueUpdateURL
)
{
template
=
LabelsSelect
.
getLabelTemplate
({
labels
:
_
.
sortBy
(
data
.
labels
,
'
title
'
),
labels
:
sortBy
(
data
.
labels
,
'
title
'
),
issueUpdateURL
,
enableScopedLabels
:
scopedLabels
,
scopedLabelsDocumentationLink
,
...
...
@@ -269,7 +269,7 @@ export default class LabelsSelect {
}
linkEl
.
className
=
selectedClass
.
join
(
'
'
);
linkEl
.
innerHTML
=
`
${
colorEl
}
${
_
.
escape
(
label
.
title
)}
`
;
linkEl
.
innerHTML
=
`
${
colorEl
}
${
esc
(
label
.
title
)}
`
;
const
listItemEl
=
document
.
createElement
(
'
li
'
);
listItemEl
.
appendChild
(
linkEl
);
...
...
@@ -436,7 +436,7 @@ export default class LabelsSelect {
if
(
isScopedLabel
(
label
))
{
const
prevIds
=
oldLabels
.
map
(
label
=>
label
.
id
);
const
newIds
=
boardsStore
.
detail
.
issue
.
labels
.
map
(
label
=>
label
.
id
);
const
differentIds
=
_
.
difference
(
prevIds
,
newIds
);
const
differentIds
=
prevIds
.
filter
(
x
=>
!
newIds
.
includes
(
x
)
);
$dropdown
.
data
(
'
marked
'
,
newIds
);
$dropdownMenu
.
find
(
differentIds
.
map
(
id
=>
`[data-label-id="
${
id
}
"]`
).
join
(
'
,
'
))
...
...
@@ -483,7 +483,7 @@ export default class LabelsSelect {
'
<a href="<%- issueUpdateURL.slice(0, issueUpdateURL.lastIndexOf("/")) %>?label_name[]=<%- encodeURIComponent(label.title) %>" class="gl-link gl-label-link has-tooltip" <%= linkAttrs %> title="<%= tooltipTitleTemplate({ label, isScopedLabel, enableScopedLabels, escapeStr }) %>">
'
;
const
spanOpenTag
=
'
<span class="gl-label-text" style="background-color: <%= escapeStr(label.color) %>; color: <%= escapeStr(label.text_color) %>;">
'
;
const
labelTemplate
=
_
.
template
(
const
labelTemplate
=
template
(
[
'
<span class="gl-label">
'
,
linkOpenTag
,
...
...
@@ -499,7 +499,7 @@ export default class LabelsSelect {
return
escapeStr
(
label
.
text_color
===
'
#FFFFFF
'
?
label
.
color
:
label
.
text_color
);
};
const
infoIconTemplate
=
_
.
template
(
const
infoIconTemplate
=
template
(
[
'
<a href="<%= scopedLabelsDocumentationLink %>" class="gl-link gl-label-icon" target="_blank" rel="noopener">
'
,
'
<i class="fa fa-question-circle"></i>
'
,
...
...
@@ -507,7 +507,7 @@ export default class LabelsSelect {
].
join
(
''
),
);
const
scopedLabelTemplate
=
_
.
template
(
const
scopedLabelTemplate
=
template
(
[
'
<span class="gl-label gl-label-scoped" style="color: <%= escapeStr(label.color) %>;">
'
,
linkOpenTag
,
...
...
@@ -523,7 +523,7 @@ export default class LabelsSelect {
].
join
(
''
),
);
const
tooltipTitleTemplate
=
_
.
template
(
const
tooltipTitleTemplate
=
template
(
[
'
<% if (isScopedLabel(label) && enableScopedLabels) { %>
'
,
"
<span class='font-weight-bold scoped-label-tooltip-title'>Scoped label</span>
"
,
...
...
@@ -535,9 +535,9 @@ export default class LabelsSelect {
].
join
(
''
),
);
const
tpl
=
_
.
template
(
const
tpl
=
template
(
[
'
<%
_.each(labels,
function(label){ %>
'
,
'
<%
labels.forEach(
function(label){ %>
'
,
'
<% if (isScopedLabel(label) && enableScopedLabels) { %>
'
,
'
<span class="d-inline-block position-relative scoped-label-wrapper">
'
,
'
<%= scopedLabelTemplate({ label, issueUpdateURL, isScopedLabel, enableScopedLabels, rightLabelTextColor, infoIconTemplate, scopedLabelsDocumentationLink, tooltipTitleTemplate, escapeStr, linkAttrs:
\'
data-html="true"
\'
}) %>
'
,
...
...
@@ -557,7 +557,7 @@ export default class LabelsSelect {
scopedLabelTemplate
,
tooltipTitleTemplate
,
isScopedLabel
,
escapeStr
:
_
.
escape
,
escapeStr
:
esc
,
});
}
...
...
app/assets/javascripts/locale/sprintf.js
View file @
1ef36eab
...
...
@@ -5,7 +5,7 @@ import { escape } from 'lodash';
@param input (translated) text with parameters (e.g. '%{num_users} users use us')
@param {Object} parameters object mapping parameter names to values (e.g. { num_users: 5 })
@param {Boolean} escapeParameters whether parameter values should be escaped (see http
://underscorejs.org/
#escape)
@param {Boolean} escapeParameters whether parameter values should be escaped (see http
s://lodash.com/docs/4.17.15
#escape)
@returns {String} the text with parameters replaces (e.g. '5 users use us')
@see https://ruby-doc.org/core-2.3.3/Kernel.html#method-i-sprintf
...
...
app/assets/javascripts/right_sidebar.js
View file @
1ef36eab
/* eslint-disable func-names, consistent-return, no-param-reassign */
import
$
from
'
jquery
'
;
import
_
from
'
underscore
'
;
import
Cookies
from
'
js-cookie
'
;
import
flash
from
'
./flash
'
;
import
axios
from
'
./lib/utils/axios_utils
'
;
...
...
@@ -142,7 +141,7 @@ Sidebar.prototype.sidebarCollapseClicked = function(e) {
};
Sidebar
.
prototype
.
openDropdown
=
function
(
blockOrName
)
{
const
$block
=
_
.
isString
(
blockOrName
)
?
this
.
getBlock
(
blockOrName
)
:
blockOrName
;
const
$block
=
typeof
blockOrName
===
'
string
'
?
this
.
getBlock
(
blockOrName
)
:
blockOrName
;
if
(
!
this
.
isOpen
())
{
this
.
setCollapseAfterUpdate
(
$block
);
this
.
toggleSidebar
(
'
open
'
);
...
...
app/assets/javascripts/users_select.js
View file @
1ef36eab
...
...
@@ -3,7 +3,7 @@
/* global emitSidebarEvent */
import
$
from
'
jquery
'
;
import
_
from
'
underscore
'
;
import
{
escape
as
esc
,
template
,
uniqBy
}
from
'
lodash
'
;
import
axios
from
'
./lib/utils/axios_utils
'
;
import
{
s__
,
__
,
sprintf
}
from
'
./locale
'
;
import
ModalStore
from
'
./boards/stores/modal_store
'
;
...
...
@@ -81,7 +81,7 @@ function UsersSelect(currentUser, els, options = {}) {
const
userName
=
currentUserInfo
.
name
;
const
userId
=
currentUserInfo
.
id
||
currentUser
.
id
;
const
inputHtmlString
=
_
.
template
(
`
const
inputHtmlString
=
template
(
`
<input type="hidden" name="<%- fieldName %>"
data-meta="<%- userName %>"
value="<%- userId %>" />
...
...
@@ -205,7 +205,7 @@ function UsersSelect(currentUser, els, options = {}) {
username
:
data
.
assignee
.
username
,
avatar
:
data
.
assignee
.
avatar_url
,
};
tooltipTitle
=
_
.
escape
(
user
.
name
);
tooltipTitle
=
esc
(
user
.
name
);
}
else
{
user
=
{
name
:
s__
(
'
UsersSelect|Unassigned
'
),
...
...
@@ -219,10 +219,10 @@ function UsersSelect(currentUser, els, options = {}) {
return
$collapsedSidebar
.
html
(
collapsedAssigneeTemplate
(
user
));
});
};
collapsedAssigneeTemplate
=
_
.
template
(
collapsedAssigneeTemplate
=
template
(
'
<% if( avatar ) { %> <a class="author-link" href="/<%- username %>"> <img width="24" class="avatar avatar-inline s24" alt="" src="<%- avatar %>"> </a> <% } else { %> <i class="fa fa-user"></i> <% } %>
'
,
);
assigneeTemplate
=
_
.
template
(
assigneeTemplate
=
template
(
`<% if (username) { %> <a class="author-link bold" href="/<%- username %>"> <% if( avatar ) { %> <img width="32" class="avatar avatar-inline s32" alt="" src="<%- avatar %>"> <% } %> <span class="author"><%- name %></span> <span class="username"> @<%- username %> </span> </a> <% } else { %> <span class="no-value assign-yourself">
${
sprintf
(
s__
(
'
UsersSelect|No assignee - %{openingTag} assign yourself %{closingTag}
'
),
{
openingTag
:
'
<a href="#" class="js-assign-yourself">
'
,
...
...
@@ -248,7 +248,7 @@ function UsersSelect(currentUser, els, options = {}) {
// Potential duplicate entries when dealing with issue board
// because issue board is also managed by vue
const
selectedUsers
=
_
.
uniq
(
selectedInputs
,
false
,
a
=>
a
.
value
)
const
selectedUsers
=
uniqBy
(
selectedInputs
,
a
=>
a
.
value
)
.
filter
(
input
=>
{
const
userId
=
parseInt
(
input
.
value
,
10
);
const
inUsersArray
=
users
.
find
(
u
=>
u
.
id
===
userId
);
...
...
@@ -543,7 +543,7 @@ function UsersSelect(currentUser, els, options = {}) {
let
img
=
''
;
if
(
user
.
beforeDivider
!=
null
)
{
`<li><a href='#' class='
${
selected
===
true
?
'
is-active
'
:
''
}
'>
${
_
.
escape
(
`<li><a href='#' class='
${
selected
===
true
?
'
is-active
'
:
''
}
'>
${
esc
(
user
.
name
,
)}
</a></li>`
;
}
else
{
...
...
@@ -672,10 +672,10 @@ UsersSelect.prototype.formatResult = function(user) {
</div>
<div class='user-info'>
<div class='user-name dropdown-menu-user-full-name'>
${
_
.
escape
(
user
.
name
)}
${
esc
(
user
.
name
)}
</div>
<div class='user-username dropdown-menu-user-username text-secondary'>
${
!
user
.
invite
?
`@
${
_
.
escape
(
user
.
username
)}
`
:
''
}
${
!
user
.
invite
?
`@
${
esc
(
user
.
username
)}
`
:
''
}
</div>
</div>
</div>
...
...
@@ -683,7 +683,7 @@ UsersSelect.prototype.formatResult = function(user) {
};
UsersSelect
.
prototype
.
formatSelection
=
function
(
user
)
{
return
_
.
escape
(
user
.
name
);
return
esc
(
user
.
name
);
};
UsersSelect
.
prototype
.
user
=
function
(
user_id
,
callback
)
{
...
...
@@ -746,7 +746,7 @@ UsersSelect.prototype.renderRow = function(issuableType, user, selected, usernam
${
this
.
renderRowAvatar
(
issuableType
,
user
,
img
)}
<span class="d-flex flex-column overflow-hidden">
<strong class="dropdown-menu-user-full-name">
${
_
.
escape
(
user
.
name
)}
${
esc
(
user
.
name
)}
</strong>
${
username
?
`<span class="dropdown-menu-user-username">
${
username
}
</span>`
:
''
}
</span>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment