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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
68787297
Commit
68787297
authored
Dec 09, 2016
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement snippets_scope_menu partial to reduce code duplication
parent
adbc3780
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
53 deletions
+45
-53
app/helpers/snippets_helper.rb
app/helpers/snippets_helper.rb
+11
-0
app/views/dashboard/snippets/index.html.haml
app/views/dashboard/snippets/index.html.haml
+1
-25
app/views/projects/snippets/index.html.haml
app/views/projects/snippets/index.html.haml
+2
-28
app/views/snippets/_snippets_scope_menu.html.haml
app/views/snippets/_snippets_scope_menu.html.haml
+31
-0
No files found.
app/helpers/snippets_helper.rb
View file @
68787297
...
...
@@ -8,6 +8,17 @@ module SnippetsHelper
end
end
# Return the path of a snippets index for a user or for a project
#
# @returns String, path to snippet index
def
snippets_path
(
subject
=
nil
,
opts
=
nil
)
if
subject
.
is_a?
(
Project
)
namespace_project_snippets_path
(
subject
.
namespace
,
subject
,
opts
)
else
# assume subject === User
dashboard_snippets_path
(
opts
)
end
end
# Get an array of line numbers surrounding a matching
# line, bounded by min/max.
#
...
...
app/views/dashboard/snippets/index.html.haml
View file @
68787297
...
...
@@ -2,31 +2,7 @@
-
header_title
"Snippets"
,
dashboard_snippets_path
=
render
'dashboard/snippets_head'
.nav-links.snippet-scope-menu
%li
{
class:
(
"active"
unless
params
[
:scope
])
}
=
link_to
dashboard_snippets_path
do
All
%span
.badge
=
current_user
.
snippets
.
count
%li
{
class:
(
"active"
if
params
[
:scope
]
==
"are_private"
)
}
=
link_to
dashboard_snippets_path
(
scope:
'are_private'
)
do
Private
%span
.badge
=
current_user
.
snippets
.
are_private
.
count
%li
{
class:
(
"active"
if
params
[
:scope
]
==
"are_internal"
)
}
=
link_to
dashboard_snippets_path
(
scope:
'are_internal'
)
do
Internal
%span
.badge
=
current_user
.
snippets
.
are_internal
.
count
%li
{
class:
(
"active"
if
params
[
:scope
]
==
"are_public"
)
}
=
link_to
dashboard_snippets_path
(
scope:
'are_public'
)
do
Public
%span
.badge
=
current_user
.
snippets
.
are_public
.
count
=
render
partial:
'snippets/snippets_scope_menu'
,
locals:
{
include_private:
true
}
.visible-xs
...
...
app/views/projects/snippets/index.html.haml
View file @
68787297
...
...
@@ -2,34 +2,8 @@
-
if
current_user
.top-area
.nav-links.snippet-scope-menu
%li
{
class:
(
"active"
unless
params
[
:scope
])
}
=
link_to
namespace_project_snippets_path
(
@project
.
namespace
,
@project
)
do
All
%span
.badge
-
if
@project
.
team
.
member?
(
current_user
)
||
current_user
.
admin?
=
@project
.
snippets
.
count
-
else
=
@project
.
snippets
.
public_and_internal
.
count
-
if
@project
.
team
.
member?
(
current_user
)
||
current_user
.
admin?
%li
{
class:
(
"active"
if
params
[
:scope
]
==
"are_private"
)
}
=
link_to
namespace_project_snippets_path
(
@project
.
namespace
,
@project
,
scope:
'are_private'
)
do
Private
%span
.badge
=
@project
.
snippets
.
are_private
.
count
%li
{
class:
(
"active"
if
params
[
:scope
]
==
"are_internal"
)
}
=
link_to
namespace_project_snippets_path
(
@project
.
namespace
,
@project
,
scope:
'are_internal'
)
do
Internal
%span
.badge
=
@project
.
snippets
.
are_internal
.
count
%li
{
class:
(
"active"
if
params
[
:scope
]
==
"are_public"
)
}
=
link_to
namespace_project_snippets_path
(
@project
.
namespace
,
@project
,
scope:
'are_public'
)
do
Public
%span
.badge
=
@project
.
snippets
.
are_public
.
count
-
include_private
=
@project
.
team
.
member?
(
current_user
)
||
current_user
.
admin?
=
render
partial:
'snippets/snippets_scope_menu'
,
locals:
{
subject:
@project
,
include_private:
include_private
}
.nav-controls.hidden-xs
-
if
can?
(
current_user
,
:create_project_snippet
,
@project
)
...
...
app/views/snippets/_snippets_scope_menu.html.haml
0 → 100644
View file @
68787297
-
subject
=
local_assigns
.
fetch
(
:subject
,
current_user
)
-
include_private
=
local_assigns
.
fetch
(
:include_private
,
false
)
.nav-links.snippet-scope-menu
%li
{
class:
(
"active"
unless
params
[
:scope
])
}
=
link_to
snippets_path
(
subject
)
do
All
%span
.badge
-
if
include_private
=
subject
.
snippets
.
count
-
else
=
subject
.
snippets
.
public_and_internal
.
count
-
if
include_private
%li
{
class:
(
"active"
if
params
[
:scope
]
==
"are_private"
)
}
=
link_to
snippets_path
(
subject
,
scope:
'are_private'
)
do
Private
%span
.badge
=
subject
.
snippets
.
are_private
.
count
%li
{
class:
(
"active"
if
params
[
:scope
]
==
"are_internal"
)
}
=
link_to
snippets_path
(
subject
,
scope:
'are_internal'
)
do
Internal
%span
.badge
=
subject
.
snippets
.
are_internal
.
count
%li
{
class:
(
"active"
if
params
[
:scope
]
==
"are_public"
)
}
=
link_to
snippets_path
(
subject
,
scope:
'are_public'
)
do
Public
%span
.badge
=
subject
.
snippets
.
are_public
.
count
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