Fix class names and move each class to its own file
This commit is contained in:
parent
2b2c42a1fa
commit
bc5bc7cb9e
|
@ -0,0 +1,13 @@
|
|||
class AllowedToMergeDropdowns {
|
||||
constructor (options) {
|
||||
const { $dropdowns, onSelect } = options;
|
||||
|
||||
$dropdowns.each((i, el) => {
|
||||
new ProtectedBranchAccessDropdown({
|
||||
$dropdown: $(el),
|
||||
data: gon.merge_access_levels,
|
||||
onSelect: onSelect
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
class AllowedToPushDropdowns {
|
||||
constructor (options) {
|
||||
const { $dropdowns, onSelect } = options;
|
||||
|
||||
$dropdowns.each((i, el) => {
|
||||
new ProtectedBranchAccessDropdown({
|
||||
$dropdown: $(el),
|
||||
data: gon.push_access_levels,
|
||||
onSelect: onSelect
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
class ProtectedBranchAccessDropdown {
|
||||
constructor(options) {
|
||||
const { $dropdown, data, onSelect } = options;
|
||||
|
||||
$dropdown.glDropdown({
|
||||
data: data,
|
||||
selectable: true,
|
||||
fieldName: $dropdown.data('field-name'),
|
||||
toggleLabel(item) {
|
||||
return item.text;
|
||||
},
|
||||
clicked(item, $el, e) {
|
||||
e.preventDefault();
|
||||
onSelect();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,50 +1,3 @@
|
|||
class ProtectedBranchesAccessDropdown {
|
||||
constructor(options) {
|
||||
const { $dropdown, data, onSelect } = options;
|
||||
|
||||
$dropdown.glDropdown({
|
||||
data: data,
|
||||
selectable: true,
|
||||
fieldName: $dropdown.data('field-name'),
|
||||
toggleLabel(item) {
|
||||
return item.text;
|
||||
},
|
||||
clicked(item, $el, e) {
|
||||
e.preventDefault();
|
||||
onSelect();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class AllowedToMergeDropdowns {
|
||||
constructor (options) {
|
||||
const { $dropdowns, onSelect } = options;
|
||||
|
||||
$dropdowns.each((i, el) => {
|
||||
new ProtectedBranchesAccessDropdown({
|
||||
$dropdown: $(el),
|
||||
data: gon.merge_access_levels,
|
||||
onSelect: onSelect
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class AllowedToPushSelects {
|
||||
constructor (options) {
|
||||
const { $dropdowns, onSelect } = options;
|
||||
|
||||
$dropdowns.each((i, el) => {
|
||||
new ProtectedBranchesAccessDropdown({
|
||||
$dropdown: $(el),
|
||||
data: gon.push_access_levels,
|
||||
onSelect: onSelect
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class ProtectedBranchCreate {
|
||||
constructor() {
|
||||
this.$wrap = this.$form = $('#new_protected_branch');
|
||||
|
@ -59,12 +12,12 @@ class ProtectedBranchCreate {
|
|||
});
|
||||
|
||||
// Allowed to Push dropdowns
|
||||
new AllowedToPushSelects({
|
||||
new AllowedToPushDropdowns({
|
||||
$dropdowns: this.$wrap.find('.js-allowed-to-push'),
|
||||
onSelect: this.onSelect.bind(this)
|
||||
});
|
||||
|
||||
new ProtectedBranchSelects({
|
||||
new ProtectedBranchDropdowns({
|
||||
$dropdowns: this.$wrap.find('.js-protected-branch-select'),
|
||||
onSelect: this.onSelect.bind(this)
|
||||
});
|
|
@ -10,14 +10,14 @@ class ProtectedBranchEdit {
|
|||
buildDropdowns() {
|
||||
|
||||
// Allowed to merge dropdown
|
||||
new ProtectedBranchesAccessDropdown({
|
||||
new ProtectedBranchAccessDropdown({
|
||||
$dropdown: this.$allowedToMergeDropdown,
|
||||
data: gon.merge_access_levels,
|
||||
onSelect: this.onSelect.bind(this)
|
||||
});
|
||||
|
||||
// Allowed to push dropdown
|
||||
new ProtectedBranchesAccessDropdown({
|
||||
new ProtectedBranchAccessDropdown({
|
||||
$dropdown: this.$allowedToPushDropdown,
|
||||
data: gon.push_access_levels,
|
||||
onSelect: this.onSelect.bind(this)
|
||||
|
@ -47,23 +47,10 @@ class ProtectedBranchEdit {
|
|||
success: () => {
|
||||
this.$wrap.effect('highlight');
|
||||
},
|
||||
error: function() {
|
||||
error() {
|
||||
$.scrollTo(0);
|
||||
new Flash('Failed to update branch!');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class ProtectedBranchEditList {
|
||||
constructor() {
|
||||
this.$wrap = $('.protected-branches-list');
|
||||
|
||||
// Build edit forms
|
||||
this.$wrap.find('.js-protected-branch-edit-form').each((i, el) => {
|
||||
new ProtectedBranchEdit({
|
||||
$wrap: $(el)
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
class ProtectedBranchEditList {
|
||||
constructor() {
|
||||
this.$wrap = $('.protected-branches-list');
|
||||
|
||||
// Build edit forms
|
||||
this.$wrap.find('.js-protected-branch-edit-form').each((i, el) => {
|
||||
new ProtectedBranchEdit({
|
||||
$wrap: $(el)
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
class ProtectedBranchSelect {
|
||||
class ProtectedBranchDropdown {
|
||||
constructor(options) {
|
||||
this.onSelect = options.onSelect;
|
||||
this.$dropdown = options.$dropdown;
|
||||
|
@ -74,12 +74,12 @@ class ProtectedBranchSelect {
|
|||
}
|
||||
}
|
||||
|
||||
class ProtectedBranchSelects {
|
||||
class ProtectedBranchDropdowns {
|
||||
constructor(options) {
|
||||
const { $dropdowns, onSelect } = options;
|
||||
|
||||
$dropdowns.each((i, el) => {
|
||||
new ProtectedBranchSelect({
|
||||
new ProtectedBranchDropdown({
|
||||
$dropdown: $(el),
|
||||
onSelect: onSelect
|
||||
});
|
||||
|
|
|
@ -675,7 +675,14 @@ pre.light-well {
|
|||
}
|
||||
}
|
||||
|
||||
&.table-bordered {
|
||||
.settings-message {
|
||||
margin: 0;
|
||||
border-radius: 0 0 1px 1px;
|
||||
padding: 20px 0;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.table-bordered {
|
||||
border-radius: 1px;
|
||||
|
||||
th:not(:last-child), td:not(:last-child) {
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
.panel.panel-default
|
||||
.panel.panel-default.protected-branches-list
|
||||
- if @protected_branches.empty?
|
||||
.panel-heading
|
||||
%b Protected branch (#{@protected_branches.size})
|
||||
%p.settings-message.text-center
|
||||
No branches are protected, protect a branch with the form above.
|
||||
There are currently no protected braches, protect a branch with the form above.
|
||||
- else
|
||||
- can_admin_project = can?(current_user, :admin_project, @project)
|
||||
|
||||
%table.table.protected-branches-list.table-bordered
|
||||
%table.table.table-bordered
|
||||
%colgroup
|
||||
%col{ width: "20%" }
|
||||
%col{ width: "25%" }
|
||||
%col{ width: "30%" }
|
||||
%col{ width: "25%" }
|
||||
%col{ width: "25%" }
|
||||
%col{ width: "20%" }
|
||||
%thead
|
||||
%tr
|
||||
%th Protected branch (#{@protected_branches.size})
|
||||
|
|
Loading…
Reference in New Issue