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
c0d26698
Commit
c0d26698
authored
Oct 10, 2018
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prettify protected_branches and protected_tags modules
parent
b49c400a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
40 deletions
+68
-40
app/assets/javascripts/protected_branches/protected_branch_create.js
...javascripts/protected_branches/protected_branch_create.js
+6
-2
app/assets/javascripts/protected_branches/protected_branch_edit.js
...s/javascripts/protected_branches/protected_branch_edit.js
+37
-22
app/assets/javascripts/protected_tags/protected_tag_create.js
...assets/javascripts/protected_tags/protected_tag_create.js
+3
-1
app/assets/javascripts/protected_tags/protected_tag_edit.js
app/assets/javascripts/protected_tags/protected_tag_edit.js
+22
-15
No files found.
app/assets/javascripts/protected_branches/protected_branch_create.js
View file @
c0d26698
...
...
@@ -46,8 +46,12 @@ export default class ProtectedBranchCreate {
onSelect
()
{
// Enable submit button
const
$branchInput
=
this
.
$form
.
find
(
'
input[name="protected_branch[name]"]
'
);
const
$allowedToMergeInput
=
this
.
$form
.
find
(
'
input[name="protected_branch[merge_access_levels_attributes][0][access_level]"]
'
);
const
$allowedToPushInput
=
this
.
$form
.
find
(
'
input[name="protected_branch[push_access_levels_attributes][0][access_level]"]
'
);
const
$allowedToMergeInput
=
this
.
$form
.
find
(
'
input[name="protected_branch[merge_access_levels_attributes][0][access_level]"]
'
,
);
const
$allowedToPushInput
=
this
.
$form
.
find
(
'
input[name="protected_branch[push_access_levels_attributes][0][access_level]"]
'
,
);
const
completedForm
=
!
(
$branchInput
.
val
()
&&
$allowedToMergeInput
.
length
&&
...
...
app/assets/javascripts/protected_branches/protected_branch_edit.js
View file @
c0d26698
...
...
@@ -29,8 +29,12 @@ export default class ProtectedBranchEdit {
}
onSelect
()
{
const
$allowedToMergeInput
=
this
.
$wrap
.
find
(
`input[name="
${
this
.
$allowedToMergeDropdown
.
data
(
'
fieldName
'
)}
"]`
);
const
$allowedToPushInput
=
this
.
$wrap
.
find
(
`input[name="
${
this
.
$allowedToPushDropdown
.
data
(
'
fieldName
'
)}
"]`
);
const
$allowedToMergeInput
=
this
.
$wrap
.
find
(
`input[name="
${
this
.
$allowedToMergeDropdown
.
data
(
'
fieldName
'
)}
"]`
,
);
const
$allowedToPushInput
=
this
.
$wrap
.
find
(
`input[name="
${
this
.
$allowedToPushDropdown
.
data
(
'
fieldName
'
)}
"]`
,
);
// Do not update if one dropdown has not selected any option
if
(
!
(
$allowedToMergeInput
.
length
&&
$allowedToPushInput
.
length
))
return
;
...
...
@@ -38,25 +42,36 @@ export default class ProtectedBranchEdit {
this
.
$allowedToMergeDropdown
.
disable
();
this
.
$allowedToPushDropdown
.
disable
();
axios
.
patch
(
this
.
$wrap
.
data
(
'
url
'
),
{
axios
.
patch
(
this
.
$wrap
.
data
(
'
url
'
),
{
protected_branch
:
{
merge_access_levels_attributes
:
[{
merge_access_levels_attributes
:
[
{
id
:
this
.
$allowedToMergeDropdown
.
data
(
'
accessLevelId
'
),
access_level
:
$allowedToMergeInput
.
val
(),
}],
push_access_levels_attributes
:
[{
},
],
push_access_levels_attributes
:
[
{
id
:
this
.
$allowedToPushDropdown
.
data
(
'
accessLevelId
'
),
access_level
:
$allowedToPushInput
.
val
(),
}],
},
}).
then
(()
=>
{
],
},
})
.
then
(()
=>
{
this
.
$allowedToMergeDropdown
.
enable
();
this
.
$allowedToPushDropdown
.
enable
();
}).
catch
(()
=>
{
})
.
catch
(()
=>
{
this
.
$allowedToMergeDropdown
.
enable
();
this
.
$allowedToPushDropdown
.
enable
();
flash
(
'
Failed to update branch!
'
,
'
alert
'
,
document
.
querySelector
(
'
.js-protected-branches-list
'
));
flash
(
'
Failed to update branch!
'
,
'
alert
'
,
document
.
querySelector
(
'
.js-protected-branches-list
'
),
);
});
}
}
app/assets/javascripts/protected_tags/protected_tag_create.js
View file @
c0d26698
...
...
@@ -40,7 +40,9 @@ export default class ProtectedTagCreate {
const
$tagInput
=
this
.
$form
.
find
(
'
input[name="protected_tag[name]"]
'
);
const
$allowedToCreateInput
=
this
.
$form
.
find
(
'
#create_access_levels_attributes
'
);
this
.
$form
.
find
(
'
input[type="submit"]
'
).
prop
(
'
disabled
'
,
!
(
$tagInput
.
val
()
&&
$allowedToCreateInput
.
length
));
this
.
$form
.
find
(
'
input[type="submit"]
'
)
.
prop
(
'
disabled
'
,
!
(
$tagInput
.
val
()
&&
$allowedToCreateInput
.
length
));
}
static
getProtectedTags
(
term
,
callback
)
{
...
...
app/assets/javascripts/protected_tags/protected_tag_edit.js
View file @
c0d26698
...
...
@@ -21,23 +21,30 @@ export default class ProtectedTagEdit {
}
onSelect
()
{
const
$allowedToCreateInput
=
this
.
$wrap
.
find
(
`input[name="
${
this
.
$allowedToCreateDropdownButton
.
data
(
'
fieldName
'
)}
"]`
);
const
$allowedToCreateInput
=
this
.
$wrap
.
find
(
`input[name="
${
this
.
$allowedToCreateDropdownButton
.
data
(
'
fieldName
'
)}
"]`
,
);
// Do not update if one dropdown has not selected any option
if
(
!
$allowedToCreateInput
.
length
)
return
;
this
.
$allowedToCreateDropdownButton
.
disable
();
axios
.
patch
(
this
.
$wrap
.
data
(
'
url
'
),
{
axios
.
patch
(
this
.
$wrap
.
data
(
'
url
'
),
{
protected_tag
:
{
create_access_levels_attributes
:
[{
create_access_levels_attributes
:
[
{
id
:
this
.
$allowedToCreateDropdownButton
.
data
(
'
accessLevelId
'
),
access_level
:
$allowedToCreateInput
.
val
(),
}],
},
}).
then
(()
=>
{
],
},
})
.
then
(()
=>
{
this
.
$allowedToCreateDropdownButton
.
enable
();
}).
catch
(()
=>
{
})
.
catch
(()
=>
{
this
.
$allowedToCreateDropdownButton
.
enable
();
flash
(
'
Failed to update tag!
'
,
'
alert
'
,
document
.
querySelector
(
'
.js-protected-tags-list
'
));
...
...
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