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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
fc95395c
Commit
fc95395c
authored
Aug 25, 2017
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display specific reasons when visibility options are disabled
parent
8cf504a7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
2 deletions
+52
-2
app/helpers/visibility_level_helper.rb
app/helpers/visibility_level_helper.rb
+50
-0
app/views/shared/_visibility_radios.html.haml
app/views/shared/_visibility_radios.html.haml
+2
-2
No files found.
app/helpers/visibility_level_helper.rb
View file @
fc95395c
...
...
@@ -63,6 +63,56 @@ module VisibilityLevelHelper
end
end
def
restricted_visibility_level_description
(
level
)
level_name
=
Gitlab
::
VisibilityLevel
.
level_name
(
level
)
"
#{
level_name
.
capitalize
}
visibilitiy has been restricted by the administrator."
end
def
disallowed_visibility_level_description
(
level
,
form_model
)
case
form_model
when
Project
disallowed_project_visibility_level_description
(
level
,
form_model
)
when
Group
disallowed_group_visibility_level_description
(
level
,
form_model
)
end
end
def
disallowed_project_visibility_level_description
(
level
,
project
)
level_name
=
Gitlab
::
VisibilityLevel
.
level_name
(
level
).
downcase
reasons
=
[]
unless
project
.
visibility_level_allowed_as_fork?
(
level
)
reasons
<<
"the fork source project has lower visibility"
end
unless
project
.
visibility_level_allowed_by_group?
(
level
)
reasons
<<
"the visibility of
#{
project
.
group
.
name
}
is
#{
project
.
group
.
visibility
}
"
end
reasons
=
reasons
.
any?
?
' because '
+
reasons
.
to_sentence
:
''
"This project cannot be
#{
level_name
}#{
reasons
}
."
end
def
disallowed_group_visibility_level_description
(
level
,
group
)
level_name
=
Gitlab
::
VisibilityLevel
.
level_name
(
level
).
downcase
reasons
=
[]
unless
group
.
visibility_level_allowed_by_projects?
(
level
)
reasons
<<
"it contains projects with higher visibility"
end
unless
group
.
visibility_level_allowed_by_sub_groups?
(
level
)
reasons
<<
"it contains sub-groups with higher visibility"
end
unless
group
.
visibility_level_allowed_by_parent?
(
level
)
reasons
<<
"the visibility of its parent group is
#{
group
.
parent
.
visibility
}
"
end
reasons
=
reasons
.
any?
?
' because '
+
reasons
.
to_sentence
:
''
"This group cannot be
#{
level_name
}#{
reasons
}
."
end
def
visibility_icon_description
(
form_model
)
case
form_model
when
Project
...
...
app/views/shared/_visibility_radios.html.haml
View file @
fc95395c
...
...
@@ -12,6 +12,6 @@
=
visibility_level_description
(
level
,
form_model
)
.option-disabled-reason
-
if
restricted
This visibility level has been restricted by the administrator.
=
restricted_visibility_level_description
(
level
)
-
elsif
disallowed
This option is not available the visibility of parent or child items prevents it.
=
disallowed_visibility_level_description
(
level
,
form_model
)
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