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 {
|
class ProtectedBranchCreate {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.$wrap = this.$form = $('#new_protected_branch');
|
this.$wrap = this.$form = $('#new_protected_branch');
|
||||||
|
@ -59,12 +12,12 @@ class ProtectedBranchCreate {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Allowed to Push dropdowns
|
// Allowed to Push dropdowns
|
||||||
new AllowedToPushSelects({
|
new AllowedToPushDropdowns({
|
||||||
$dropdowns: this.$wrap.find('.js-allowed-to-push'),
|
$dropdowns: this.$wrap.find('.js-allowed-to-push'),
|
||||||
onSelect: this.onSelect.bind(this)
|
onSelect: this.onSelect.bind(this)
|
||||||
});
|
});
|
||||||
|
|
||||||
new ProtectedBranchSelects({
|
new ProtectedBranchDropdowns({
|
||||||
$dropdowns: this.$wrap.find('.js-protected-branch-select'),
|
$dropdowns: this.$wrap.find('.js-protected-branch-select'),
|
||||||
onSelect: this.onSelect.bind(this)
|
onSelect: this.onSelect.bind(this)
|
||||||
});
|
});
|
|
@ -10,14 +10,14 @@ class ProtectedBranchEdit {
|
||||||
buildDropdowns() {
|
buildDropdowns() {
|
||||||
|
|
||||||
// Allowed to merge dropdown
|
// Allowed to merge dropdown
|
||||||
new ProtectedBranchesAccessDropdown({
|
new ProtectedBranchAccessDropdown({
|
||||||
$dropdown: this.$allowedToMergeDropdown,
|
$dropdown: this.$allowedToMergeDropdown,
|
||||||
data: gon.merge_access_levels,
|
data: gon.merge_access_levels,
|
||||||
onSelect: this.onSelect.bind(this)
|
onSelect: this.onSelect.bind(this)
|
||||||
});
|
});
|
||||||
|
|
||||||
// Allowed to push dropdown
|
// Allowed to push dropdown
|
||||||
new ProtectedBranchesAccessDropdown({
|
new ProtectedBranchAccessDropdown({
|
||||||
$dropdown: this.$allowedToPushDropdown,
|
$dropdown: this.$allowedToPushDropdown,
|
||||||
data: gon.push_access_levels,
|
data: gon.push_access_levels,
|
||||||
onSelect: this.onSelect.bind(this)
|
onSelect: this.onSelect.bind(this)
|
||||||
|
@ -47,23 +47,10 @@ class ProtectedBranchEdit {
|
||||||
success: () => {
|
success: () => {
|
||||||
this.$wrap.effect('highlight');
|
this.$wrap.effect('highlight');
|
||||||
},
|
},
|
||||||
error: function() {
|
error() {
|
||||||
$.scrollTo(0);
|
$.scrollTo(0);
|
||||||
new Flash('Failed to update branch!');
|
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) {
|
constructor(options) {
|
||||||
this.onSelect = options.onSelect;
|
this.onSelect = options.onSelect;
|
||||||
this.$dropdown = options.$dropdown;
|
this.$dropdown = options.$dropdown;
|
||||||
|
@ -74,12 +74,12 @@ class ProtectedBranchSelect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProtectedBranchSelects {
|
class ProtectedBranchDropdowns {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
const { $dropdowns, onSelect } = options;
|
const { $dropdowns, onSelect } = options;
|
||||||
|
|
||||||
$dropdowns.each((i, el) => {
|
$dropdowns.each((i, el) => {
|
||||||
new ProtectedBranchSelect({
|
new ProtectedBranchDropdown({
|
||||||
$dropdown: $(el),
|
$dropdown: $(el),
|
||||||
onSelect: onSelect
|
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;
|
border-radius: 1px;
|
||||||
|
|
||||||
th:not(:last-child), td:not(:last-child) {
|
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?
|
- if @protected_branches.empty?
|
||||||
|
.panel-heading
|
||||||
|
%b Protected branch (#{@protected_branches.size})
|
||||||
%p.settings-message.text-center
|
%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
|
- else
|
||||||
- can_admin_project = can?(current_user, :admin_project, @project)
|
- can_admin_project = can?(current_user, :admin_project, @project)
|
||||||
|
|
||||||
%table.table.protected-branches-list.table-bordered
|
%table.table.table-bordered
|
||||||
%colgroup
|
%colgroup
|
||||||
%col{ width: "20%" }
|
%col{ width: "25%" }
|
||||||
%col{ width: "30%" }
|
%col{ width: "30%" }
|
||||||
%col{ width: "25%" }
|
%col{ width: "25%" }
|
||||||
%col{ width: "25%" }
|
%col{ width: "20%" }
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
%th Protected branch (#{@protected_branches.size})
|
%th Protected branch (#{@protected_branches.size})
|
||||||
|
|
Loading…
Reference in New Issue