BigW Consortium Gitlab

Created shared/visibility_select and merged with feature permissions ui

Fixed up nested padding and added dynamic text js Added padding and tests
parent 3f768f9a
......@@ -262,6 +262,7 @@
case 'edit':
shortcut_handler = new ShortcutsNavigation();
new ProjectNew();
new gl.VisibilitySelect();
break;
case 'new':
new ProjectNew();
......
(() => {
const global = window.gl || (window.gl = {});
const VISIBILITY_DESCRIPTIONS = {
0: 'Project access must be granted explicitly to each user.',
10: 'Project access must be granted explicitly to each user.',
20: 'The project can be cloned without any authentication.',
};
class VisibilitySelect {
constructor() {
this.visibilitySelect = document.querySelector('.js-visibility-select');
this.helpBlock = this.visibilitySelect.querySelector('.help-block');
this.select = this.visibilitySelect.querySelector('select');
if (this.select) {
this.visibilityChanged();
this.select.addEventListener('change', this.visibilityChanged.bind(this));
} else {
this.helpBlock.textContent = this.visibilitySelect.querySelector('.js-locked').dataset.helpBlock;
}
}
visibilityChanged() {
this.helpBlock.innerText = VISIBILITY_DESCRIPTIONS[this.select.value];
}
}
global.VisibilitySelect = VisibilitySelect;
})();
......@@ -15,10 +15,22 @@
.new_project,
.edit-project {
.visibility-select-container {
padding-left: 26px;
@media(max-width: $screen-md-min) {
padding-left: 15px;
}
}
fieldset {
&.features {
.header {
padding-top: $gl-vert-padding;
}
.label-light {
margin-bottom: 0;
}
......
......@@ -21,76 +21,69 @@
.form-group
= f.label :default_branch, "Default Branch", class: 'label-light'
= f.select(:default_branch, @project.repository.branch_names, {}, {class: 'select2 select-wide'})
.form-group.project-visibility-level-holder
= f.label :visibility_level, class: 'label-light' do
Visibility Level
= link_to "(?)", help_page_path("public_access/public_access")
- if can_change_visibility_level?(@project, current_user)
= render('shared/visibility_radios', model_method: :visibility_level, form: f, selected_level: @project.visibility_level, form_model: @project)
- else
.info
= visibility_level_icon(@project.visibility_level)
%strong
= visibility_level_label(@project.visibility_level)
.light= visibility_level_description(@project.visibility_level, @project)
.form-group
= render 'shared/allow_request_access', form: f
.form-group
= f.label :tag_list, "Tags", class: 'label-light'
= f.text_field :tag_list, value: @project.tag_list.to_s, maxlength: 2000, class: "form-control"
%p.help-block Separate tags with commas.
%hr
%fieldset.features.append-bottom-0
%fieldset.append-bottom-0
%h5.prepend-top-0
Feature Visibility
= f.fields_for :project_feature do |feature_fields|
Sharing & Permissions
.form_group.prepend-top-20
.row
.row.js-visibility-select
.col-md-9
%label.label-light
= label_tag :project_visibility, 'Project Visibility', class: 'label-light'
= link_to "(?)", help_page_path("public_access/public_access")
%span.help-block
.col-md-3.visibility-select-container
= render('shared/visibility_select', model_method: :visibility_level, form: f, selected_level: @project.visibility_level)
= f.fields_for :project_feature do |feature_fields|
%fieldset.features
.row.project-feature-nested
.col-md-9.header
= feature_fields.label :repository_access_level, "Repository", class: 'label-light'
%span.help-block Push files to be stored in this project
.col-md-3.js-repo-access-level
= project_feature_access_select(:repository_access_level)
.col-sm-12
.row
.col-md-9.project-feature-nested
.row.project-feature-nested
.col-md-9.header
= feature_fields.label :merge_requests_access_level, "Merge requests", class: 'label-light'
%span.help-block Submit changes to be merged upstream
.col-md-3
= project_feature_access_select(:merge_requests_access_level)
.row
.col-md-9.project-feature-nested
.row.project-feature-nested
.col-md-9.header
= feature_fields.label :builds_access_level, "Builds", class: 'label-light'
%span.help-block Submit, test and deploy your changes before merge
.col-md-3
.col-md-3.double-nested
= project_feature_access_select(:builds_access_level)
.row
.col-md-9
.col-md-9.header
= feature_fields.label :snippets_access_level, "Snippets", class: 'label-light'
%span.help-block Share code pastes with others out of Git repository
.col-md-3
= project_feature_access_select(:snippets_access_level)
.row
.col-md-9
.col-md-9.header
= feature_fields.label :issues_access_level, "Issues", class: 'label-light'
%span.help-block Lightweight issue tracking system for this project
.col-md-3
= project_feature_access_select(:issues_access_level)
.row
.col-md-9
.col-md-9.header
= feature_fields.label :wiki_access_level, "Wiki", class: 'label-light'
%span.help-block Pages for project documentation
.col-md-3
= project_feature_access_select(:wiki_access_level)
.form-group
= render 'shared/allow_request_access', form: f
- if Gitlab.config.lfs.enabled && current_user.admin?
.row
.col-md-9
......
- if can_change_visibility_level?(@project, current_user)
- levels_options_hash = {}
- Gitlab::VisibilityLevel.values.each do |level|
- levels_options_hash[visibility_level_label(level)] = level
- options = options_for_select(levels_options_hash, selected_level)
= form.select(model_method, options, {}, class: 'form-control visibility-select')
- else
.info.js-locked{ data: { help_block: visibility_level_description(@project.visibility_level, @project)}}
= visibility_level_icon(@project.visibility_level)
%strong
= visibility_level_label(@project.visibility_level)
---
title: Updated project visibility settings UX
merge_request: 7645
author:
require 'spec_helper'
require 'byebug'
feature 'Visibility settings', feature: true, js: true do
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace, visibility_level: 20) }
context 'as owner' do
before do
login_as(user)
visit edit_namespace_project_path(project.namespace, project)
end
scenario 'project visibility select is available' do
visibility_select_container = find('.js-visibility-select')
expect(visibility_select_container.find('.visibility-select').value).to eq project.visibility_level.to_s
expect(visibility_select_container).to have_content 'The project can be cloned without any authentication.'
end
scenario 'project visibility description updates on change' do
visibility_select_container = find('.js-visibility-select')
visibility_select = visibility_select_container.find('.visibility-select')
visibility_select.select('Private')
expect(visibility_select.value).to eq '0'
expect(visibility_select_container).to have_content 'Project access must be granted explicitly to each user.'
end
end
context 'as master' do
let(:master_user) { create(:user) }
before do
project.team << [master_user, :master]
login_as(master_user)
visit edit_namespace_project_path(project.namespace, project)
end
scenario 'project visibility is locked' do
visibility_select_container = find('.js-visibility-select')
expect(visibility_select_container).not_to have_select '.visibility-select'
expect(visibility_select_container).to have_content 'Public'
expect(visibility_select_container).to have_content 'The project can be cloned without any authentication.'
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment