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
62be748e
Commit
62be748e
authored
Aug 25, 2017
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dynamically disable/enable visibility options when changing namespaces in new project form
parent
77a5d9db
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
1 deletion
+40
-1
app/assets/javascripts/dispatcher.js
app/assets/javascripts/dispatcher.js
+2
-0
app/assets/javascripts/project_visibility.js
app/assets/javascripts/project_visibility.js
+37
-0
app/helpers/namespaces_helper.rb
app/helpers/namespaces_helper.rb
+1
-1
No files found.
app/assets/javascripts/dispatcher.js
View file @
62be748e
...
...
@@ -74,6 +74,7 @@ import PerformanceBar from './performance_bar';
import
initNotes
from
'
./init_notes
'
;
import
initLegacyFilters
from
'
./init_legacy_filters
'
;
import
initIssuableSidebar
from
'
./init_issuable_sidebar
'
;
import
initProjectVisibilitySelector
from
'
./project_visibility
'
;
import
GpgBadges
from
'
./gpg_badges
'
;
import
UserFeatureHelper
from
'
./helpers/user_feature_helper
'
;
import
initChangesDropdown
from
'
./init_changes_dropdown
'
;
...
...
@@ -575,6 +576,7 @@ import initChangesDropdown from './init_changes_dropdown';
break
;
case
'
new
'
:
new
ProjectNew
();
initProjectVisibilitySelector
();
break
;
case
'
show
'
:
new
Star
();
...
...
app/assets/javascripts/project_visibility.js
0 → 100644
View file @
62be748e
function
setVisibilityOptions
(
namespaceSelector
)
{
if
(
!
namespaceSelector
||
!
(
'
selectedIndex
'
in
namespaceSelector
))
{
return
;
}
const
selectedNamespace
=
namespaceSelector
.
options
[
namespaceSelector
.
selectedIndex
];
const
{
name
,
visibility
,
visibilityLevel
}
=
selectedNamespace
.
dataset
;
document
.
querySelectorAll
(
'
.visibility-level-setting .radio
'
).
forEach
((
option
)
=>
{
const
optionInput
=
option
.
querySelector
(
'
input[type=radio]
'
);
const
optionValue
=
optionInput
?
optionInput
.
value
:
0
;
const
optionTitle
=
option
.
querySelector
(
'
.option-title
'
);
const
optionName
=
optionTitle
?
optionTitle
.
innerText
.
toLowerCase
()
:
''
;
// don't change anything if the option is restricted by admin
if
(
!
option
.
classList
.
contains
(
'
restricted
'
))
{
if
(
visibilityLevel
<
optionValue
)
{
option
.
classList
.
add
(
'
disabled
'
);
optionInput
.
disabled
=
true
;
const
reason
=
option
.
querySelector
(
'
.option-disabled-reason
'
);
if
(
reason
)
{
reason
.
innerText
=
`This project cannot be
${
optionName
}
because the visibility of
${
name
}
is
${
visibility
}
.`
;
}
}
else
{
option
.
classList
.
remove
(
'
disabled
'
);
optionInput
.
disabled
=
false
;
}
}
});
}
export
default
function
initProjectVisibilitySelector
()
{
const
namespaceSelector
=
document
.
querySelector
(
'
select.js-select-namespace
'
);
if
(
namespaceSelector
)
{
$
(
'
.select2.js-select-namespace
'
).
on
(
'
change
'
,
()
=>
setVisibilityOptions
(
namespaceSelector
));
setVisibilityOptions
(
namespaceSelector
);
}
}
app/helpers/namespaces_helper.rb
View file @
62be748e
...
...
@@ -41,7 +41,7 @@ module NamespacesHelper
elements
=
namespaces
.
sort_by
(
&
:human_name
).
map!
do
|
n
|
[
display_path
?
n
.
full_path
:
n
.
human_name
,
n
.
id
,
data:
{
options_parent:
type
,
visibility_level:
n
.
visibility_level_value
,
name:
n
.
human_
name
}]
data:
{
options_parent:
type
,
visibility_level:
n
.
visibility_level_value
,
visibility:
n
.
visibility
,
name:
n
.
name
}]
end
[
type
.
camelize
,
elements
]
...
...
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