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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
fed51d1e
Commit
fed51d1e
authored
Oct 27, 2017
by
Filipa Lacerda
Committed by
Phil Hughes
Oct 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove groups_select from global namespace & simplifies the code
parent
a1aa4f00
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
114 deletions
+78
-114
app/assets/javascripts/dispatcher.js
app/assets/javascripts/dispatcher.js
+2
-2
app/assets/javascripts/groups_select.js
app/assets/javascripts/groups_select.js
+75
-110
app/assets/javascripts/main.js
app/assets/javascripts/main.js
+0
-1
spec/features/projects/members/share_with_group_spec.rb
spec/features/projects/members/share_with_group_spec.rb
+1
-1
No files found.
app/assets/javascripts/dispatcher.js
View file @
fed51d1e
...
@@ -13,7 +13,7 @@ import GroupLabelSubscription from './group_label_subscription';
...
@@ -13,7 +13,7 @@ import GroupLabelSubscription from './group_label_subscription';
/* global LineHighlighter */
/* global LineHighlighter */
import
BuildArtifacts
from
'
./build_artifacts
'
;
import
BuildArtifacts
from
'
./build_artifacts
'
;
import
CILintEditor
from
'
./ci_lint_editor
'
;
import
CILintEditor
from
'
./ci_lint_editor
'
;
/* global GroupsSelect */
import
groupsSelect
from
'
./groups_select
'
;
/* global Search */
/* global Search */
/* global Admin */
/* global Admin */
/* global NamespaceSelects */
/* global NamespaceSelects */
...
@@ -414,7 +414,7 @@ import Diff from './diff';
...
@@ -414,7 +414,7 @@ import Diff from './diff';
break
;
break
;
case
'
projects:project_members:index
'
:
case
'
projects:project_members:index
'
:
memberExpirationDate
(
'
.js-access-expiration-date-groups
'
);
memberExpirationDate
(
'
.js-access-expiration-date-groups
'
);
new
G
roupsSelect
();
g
roupsSelect
();
memberExpirationDate
();
memberExpirationDate
();
new
Members
();
new
Members
();
new
UsersSelect
();
new
UsersSelect
();
...
...
app/assets/javascripts/groups_select.js
View file @
fed51d1e
/* eslint-disable func-names, space-before-function-paren, no-var, wrap-iife, one-var,
camelcase, one-var-declaration-per-line, quotes, object-shorthand,
prefer-arrow-callback, comma-dangle, consistent-return, yoda,
prefer-rest-params, prefer-spread, no-unused-vars, prefer-template,
promise/catch-or-return */
import
Api
from
'
./api
'
;
import
Api
from
'
./api
'
;
import
{
normalizeCRLFHeaders
}
from
'
./lib/utils/common_utils
'
;
import
{
normalizeCRLFHeaders
}
from
'
./lib/utils/common_utils
'
;
var
slice
=
[].
slice
;
export
default
function
groupsSelect
()
{
// Needs to be accessible in rspec
window
.
GroupsSelect
=
(
function
()
{
window
.
GROUP_SELECT_PER_PAGE
=
20
;
function
GroupsSelect
()
{
$
(
'
.ajax-groups-select
'
).
each
(
function
setAjaxGroupsSelect2
()
{
$
(
'
.ajax-groups-select
'
).
each
((
function
(
_this
)
{
const
$select
=
$
(
this
);
const
self
=
_this
;
const
allAvailable
=
$select
.
data
(
'
all-available
'
);
const
skipGroups
=
$select
.
data
(
'
skip-groups
'
)
||
[];
return
function
(
i
,
select
)
{
var
all_available
,
skip_groups
;
const
$select
=
$
(
select
);
all_available
=
$select
.
data
(
'
all-available
'
);
skip_groups
=
$select
.
data
(
'
skip-groups
'
)
||
[];
$select
.
select2
({
$select
.
select2
({
placeholder
:
"
Search for a group
"
,
placeholder
:
'
Search for a group
'
,
multiple
:
$select
.
hasClass
(
'
multiselect
'
),
multiple
:
$select
.
hasClass
(
'
multiselect
'
),
minimumInputLength
:
0
,
minimumInputLength
:
0
,
ajax
:
{
ajax
:
{
url
:
Api
.
buildUrl
(
Api
.
groupsPath
),
url
:
Api
.
buildUrl
(
Api
.
groupsPath
),
dataType
:
'
json
'
,
dataType
:
'
json
'
,
quietMillis
:
250
,
quietMillis
:
250
,
transport
:
function
(
params
)
{
transport
(
params
)
{
$
.
ajax
(
params
).
then
((
data
,
status
,
xhr
)
=>
{
return
$
.
ajax
(
params
)
.
then
((
data
,
status
,
xhr
)
=>
{
const
results
=
data
||
[];
const
results
=
data
||
[];
const
headers
=
normalizeCRLFHeaders
(
xhr
.
getAllResponseHeaders
());
const
headers
=
normalizeCRLFHeaders
(
xhr
.
getAllResponseHeaders
());
...
@@ -42,22 +32,24 @@ window.GroupsSelect = (function() {
...
@@ -42,22 +32,24 @@ window.GroupsSelect = (function() {
more
,
more
,
},
},
};
};
}).
then
(
params
.
success
).
fail
(
params
.
error
);
})
.
then
(
params
.
success
)
.
fail
(
params
.
error
);
},
},
data
:
function
(
search
,
page
)
{
data
(
search
,
page
)
{
return
{
return
{
search
,
search
,
page
,
page
,
per_page
:
GroupsSelect
.
PER_PAGE
,
per_page
:
window
.
GROUP_SELECT_
PER_PAGE
,
all_a
vailable
,
all_available
:
allA
vailable
,
};
};
},
},
results
:
function
(
data
,
page
)
{
results
(
data
,
page
)
{
if
(
data
.
length
)
return
{
results
:
[]
};
if
(
data
.
length
)
return
{
results
:
[]
};
const
groups
=
data
.
length
?
data
:
data
.
results
||
[];
const
groups
=
data
.
length
?
data
:
data
.
results
||
[];
const
more
=
data
.
pagination
?
data
.
pagination
.
more
:
false
;
const
more
=
data
.
pagination
?
data
.
pagination
.
more
:
false
;
const
results
=
groups
.
filter
(
group
=>
skip_g
roups
.
indexOf
(
group
.
id
)
===
-
1
);
const
results
=
groups
.
filter
(
group
=>
skipG
roups
.
indexOf
(
group
.
id
)
===
-
1
);
return
{
return
{
results
,
results
,
...
@@ -66,56 +58,29 @@ window.GroupsSelect = (function() {
...
@@ -66,56 +58,29 @@ window.GroupsSelect = (function() {
};
};
},
},
},
},
initSelection
:
function
(
element
,
callback
)
{
// eslint-disable-next-line consistent-return
var
id
;
initSelection
(
element
,
callback
)
{
id
=
$
(
element
).
val
();
const
id
=
$
(
element
).
val
();
if
(
id
!==
""
)
{
if
(
id
!==
''
)
{
return
Api
.
group
(
id
,
callback
);
return
Api
.
group
(
id
,
callback
);
}
}
},
},
formatResult
:
function
()
{
formatResult
(
object
)
{
var
args
;
return
`<div class='group-result'> <div class='group-name'>
${
object
.
full_name
}
</div> <div class='group-path'>
${
object
.
full_path
}
</div> </div>`
;
args
=
1
<=
arguments
.
length
?
slice
.
call
(
arguments
,
0
)
:
[];
return
self
.
formatResult
.
apply
(
self
,
args
);
},
},
formatSelection
:
function
()
{
formatSelection
(
object
)
{
var
args
;
return
object
.
full_name
;
args
=
1
<=
arguments
.
length
?
slice
.
call
(
arguments
,
0
)
:
[];
return
self
.
formatSelection
.
apply
(
self
,
args
);
},
},
dropdownCssClass
:
"
ajax-groups-dropdown select2-infinite
"
,
dropdownCssClass
:
'
ajax-groups-dropdown select2-infinite
'
,
// we do not want to escape markup since we are displaying html in results
// we do not want to escape markup since we are displaying html in results
escapeMarkup
:
function
(
m
)
{
escapeMarkup
(
m
)
{
return
m
;
return
m
;
}
},
});
});
self
.
dropdown
=
document
.
querySelector
(
'
.select2-infinite .select2-results
'
);
$select
.
on
(
'
select2-loaded
'
,
()
=>
{
const
dropdown
=
document
.
querySelector
(
'
.select2-infinite .select2-results
'
);
$select
.
on
(
'
select2-loaded
'
,
self
.
forceOverflow
.
bind
(
self
));
dropdown
.
style
.
height
=
`
${
Math
.
floor
(
dropdown
.
scrollHeight
)}
px`
;
};
});
})(
this
));
});
}
}
GroupsSelect
.
prototype
.
formatResult
=
function
(
group
)
{
var
avatar
;
if
(
group
.
avatar_url
)
{
avatar
=
group
.
avatar_url
;
}
else
{
avatar
=
gon
.
default_avatar_url
;
}
return
"
<div class='group-result'> <div class='group-name'>
"
+
group
.
full_name
+
"
</div> <div class='group-path'>
"
+
group
.
full_path
+
"
</div> </div>
"
;
};
GroupsSelect
.
prototype
.
formatSelection
=
function
(
group
)
{
return
group
.
full_name
;
};
GroupsSelect
.
prototype
.
forceOverflow
=
function
(
e
)
{
this
.
dropdown
.
style
.
height
=
`
${
Math
.
floor
(
this
.
dropdown
.
scrollHeight
)}
px`
;
};
GroupsSelect
.
PER_PAGE
=
20
;
return
GroupsSelect
;
})();
app/assets/javascripts/main.js
View file @
fed51d1e
...
@@ -55,7 +55,6 @@ import './gl_dropdown';
...
@@ -55,7 +55,6 @@ import './gl_dropdown';
import
'
./gl_field_error
'
;
import
'
./gl_field_error
'
;
import
'
./gl_field_errors
'
;
import
'
./gl_field_errors
'
;
import
'
./gl_form
'
;
import
'
./gl_form
'
;
import
'
./groups_select
'
;
import
'
./header
'
;
import
'
./header
'
;
import
'
./importer_status
'
;
import
'
./importer_status
'
;
import
'
./issuable_index
'
;
import
'
./issuable_index
'
;
...
...
spec/features/projects/members/share_with_group_spec.rb
View file @
fed51d1e
...
@@ -149,7 +149,7 @@ feature 'Project > Members > Share with Group', :js do
...
@@ -149,7 +149,7 @@ feature 'Project > Members > Share with Group', :js do
create
(
:group
).
add_owner
(
master
)
create
(
:group
).
add_owner
(
master
)
visit
project_settings_members_path
(
project
)
visit
project_settings_members_path
(
project
)
execute_script
'G
roupsSelect.
PER_PAGE = 1;'
execute_script
'G
ROUP_SELECT_
PER_PAGE = 1;'
open_select2
'#link_group_id'
open_select2
'#link_group_id'
end
end
...
...
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