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
Jérome Perrin
gitlab-ce
Commits
97a02fca
Commit
97a02fca
authored
Mar 21, 2017
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Protected Tags Classes
parent
d20c5427
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
153 additions
and
0 deletions
+153
-0
app/assets/javascripts/protected_tags/protected_tag_access_dropdown.js
...vascripts/protected_tags/protected_tag_access_dropdown.js
+29
-0
app/assets/javascripts/protected_tags/protected_tag_create.js
...assets/javascripts/protected_tags/protected_tag_create.js
+45
-0
app/assets/javascripts/protected_tags/protected_tag_dropdown.js
...sets/javascripts/protected_tags/protected_tag_dropdown.js
+79
-0
No files found.
app/assets/javascripts/protected_tags/protected_tag_access_dropdown.js
0 → 100644
View file @
97a02fca
/* eslint-disable arrow-parens, no-param-reassign, object-shorthand, no-else-return, comma-dangle, max-len */
(
global
=>
{
global
.
gl
=
global
.
gl
||
{};
gl
.
ProtectedTagAccessDropdown
=
class
{
constructor
(
options
)
{
const
{
$dropdown
,
data
,
onSelect
}
=
options
;
$dropdown
.
glDropdown
({
data
:
data
,
selectable
:
true
,
inputId
:
$dropdown
.
data
(
'
input-id
'
),
fieldName
:
$dropdown
.
data
(
'
field-name
'
),
toggleLabel
(
item
,
el
)
{
if
(
el
.
is
(
'
.is-active
'
))
{
return
item
.
text
;
}
else
{
return
'
Select
'
;
}
},
clicked
(
item
,
$el
,
e
)
{
e
.
preventDefault
();
onSelect
();
}
});
}
};
})(
window
);
app/assets/javascripts/protected_tags/protected_tag_create.js
0 → 100644
View file @
97a02fca
/* eslint-disable no-new, arrow-parens, no-param-reassign, comma-dangle, max-len */
/* global ProtectedTagDropdown */
(
global
=>
{
global
.
gl
=
global
.
gl
||
{};
gl
.
ProtectedTagCreate
=
class
{
constructor
()
{
this
.
$wrap
=
this
.
$form
=
$
(
'
.new_protected_tag
'
);
this
.
buildDropdowns
();
}
buildDropdowns
()
{
const
$allowedToPushDropdown
=
this
.
$wrap
.
find
(
'
.js-allowed-to-push
'
);
// Cache callback
this
.
onSelectCallback
=
this
.
onSelect
.
bind
(
this
);
// Allowed to Push dropdown
new
gl
.
ProtectedTagAccessDropdown
({
$dropdown
:
$allowedToPushDropdown
,
data
:
gon
.
push_access_levels
,
onSelect
:
this
.
onSelectCallback
});
// Select default
$allowedToPushDropdown
.
data
(
'
glDropdown
'
).
selectRowAtIndex
(
0
);
// Protected tag dropdown
new
ProtectedTagDropdown
({
$dropdown
:
this
.
$wrap
.
find
(
'
.js-protected-tag-select
'
),
onSelect
:
this
.
onSelectCallback
});
}
// This will run after clicked callback
onSelect
()
{
// Enable submit button
const
$tagInput
=
this
.
$wrap
.
find
(
'
input[name="protected_tag[name]"]
'
);
const
$allowedToPushInput
=
this
.
$wrap
.
find
(
'
input[name="protected_tag[push_access_levels_attributes][0][access_level]"]
'
);
this
.
$form
.
find
(
'
input[type="submit"]
'
).
attr
(
'
disabled
'
,
!
(
$tagInput
.
val
()
&&
$allowedToPushInput
.
length
));
}
};
})(
window
);
app/assets/javascripts/protected_tags/protected_tag_dropdown.js
0 → 100644
View file @
97a02fca
/* eslint-disable comma-dangle, no-unused-vars */
class
ProtectedTagDropdown
{
constructor
(
options
)
{
this
.
onSelect
=
options
.
onSelect
;
this
.
$dropdown
=
options
.
$dropdown
;
this
.
$dropdownContainer
=
this
.
$dropdown
.
parent
();
this
.
$dropdownFooter
=
this
.
$dropdownContainer
.
find
(
'
.dropdown-footer
'
);
this
.
$protectedTag
=
this
.
$dropdownContainer
.
find
(
'
.create-new-protected-tag
'
);
this
.
buildDropdown
();
this
.
bindEvents
();
// Hide footer
this
.
$dropdownFooter
.
addClass
(
'
hidden
'
);
}
buildDropdown
()
{
this
.
$dropdown
.
glDropdown
({
data
:
this
.
getProtectedTags
.
bind
(
this
),
filterable
:
true
,
remote
:
false
,
search
:
{
fields
:
[
'
title
'
]
},
selectable
:
true
,
toggleLabel
(
selected
)
{
return
(
selected
&&
'
id
'
in
selected
)
?
selected
.
title
:
'
Protected Tag
'
;
},
fieldName
:
'
protected_tag[name]
'
,
text
(
protectedTag
)
{
return
_
.
escape
(
protectedTag
.
title
);
},
id
(
protectedTag
)
{
return
_
.
escape
(
protectedTag
.
id
);
},
onFilter
:
this
.
toggleCreateNewButton
.
bind
(
this
),
clicked
:
(
item
,
$el
,
e
)
=>
{
e
.
preventDefault
();
this
.
onSelect
();
}
});
}
bindEvents
()
{
this
.
$protectedTag
.
on
(
'
click
'
,
this
.
onClickCreateWildcard
.
bind
(
this
));
}
onClickCreateWildcard
()
{
this
.
$dropdown
.
data
(
'
glDropdown
'
).
remote
.
execute
();
this
.
$dropdown
.
data
(
'
glDropdown
'
).
selectRowAtIndex
();
}
getProtectedTags
(
term
,
callback
)
{
if
(
this
.
selectedTag
)
{
callback
(
gon
.
open_branches
.
concat
(
this
.
selectedTag
));
}
else
{
callback
(
gon
.
open_branches
);
}
}
toggleCreateNewButton
(
tagName
)
{
this
.
selectedTag
=
{
title
:
tagName
,
id
:
tagName
,
text
:
tagName
};
if
(
tagName
)
{
this
.
$dropdownContainer
.
find
(
'
.create-new-protected-tag code
'
)
.
text
(
tagName
);
}
this
.
$dropdownFooter
.
toggleClass
(
'
hidden
'
,
!
tagName
);
}
}
window
.
ProtectedTagDropdown
=
ProtectedTagDropdown
;
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