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
Boxiang Sun
gitlab-ce
Commits
433e4a80
Commit
433e4a80
authored
Nov 14, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix code duplication in NotificationsHelper
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
cd513034
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
25 deletions
+13
-25
app/helpers/notifications_helper.rb
app/helpers/notifications_helper.rb
+13
-25
No files found.
app/helpers/notifications_helper.rb
View file @
433e4a80
...
@@ -16,40 +16,28 @@ module NotificationsHelper
...
@@ -16,40 +16,28 @@ module NotificationsHelper
def
notification_list_item
(
notification_level
,
user_membership
)
def
notification_list_item
(
notification_level
,
user_membership
)
case
notification_level
case
notification_level
when
Notification
::
N_DISABLED
when
Notification
::
N_DISABLED
content_tag
(
:li
,
class:
active_level_for
(
user_membership
,
Notification
::
N_DISABLED
))
do
update_notification_link
(
Notification
::
N_DISABLED
,
user_membership
,
'Disabled'
,
'microphone-slash'
)
link_to
'#'
,
class:
'update-notification'
,
data:
{
notification_level:
Notification
::
N_DISABLED
}
do
icon
(
'microphone-slash fw'
,
text:
'Disabled'
)
end
end
when
Notification
::
N_PARTICIPATING
when
Notification
::
N_PARTICIPATING
content_tag
(
:li
,
class:
active_level_for
(
user_membership
,
Notification
::
N_PARTICIPATING
))
do
update_notification_link
(
Notification
::
N_PARTICIPATING
,
user_membership
,
'Participate'
,
'volume-up'
)
link_to
'#'
,
class:
'update-notification'
,
data:
{
notification_level:
Notification
::
N_PARTICIPATING
}
do
icon
(
'volume-up fw'
,
text:
'Participate'
)
end
end
when
Notification
::
N_WATCH
when
Notification
::
N_WATCH
content_tag
(
:li
,
class:
active_level_for
(
user_membership
,
Notification
::
N_WATCH
))
do
update_notification_link
(
Notification
::
N_WATCH
,
user_membership
,
'Watch'
,
'eye'
)
link_to
'#'
,
class:
'update-notification'
,
data:
{
notification_level:
Notification
::
N_WATCH
}
do
icon
(
'eye fw'
,
text:
'Watch'
)
end
end
when
Notification
::
N_MENTION
when
Notification
::
N_MENTION
content_tag
(
:li
,
class:
active_level_for
(
user_membership
,
Notification
::
N_MENTION
))
do
update_notification_link
(
Notification
::
N_MENTION
,
user_membership
,
'On mention'
,
'at'
)
link_to
'#'
,
class:
'update-notification'
,
data:
{
notification_level:
Notification
::
N_MENTION
}
do
icon
(
'at fw'
,
text:
'On mention'
)
end
end
when
Notification
::
N_GLOBAL
when
Notification
::
N_GLOBAL
content_tag
(
:li
,
class:
active_level_for
(
user_membership
,
Notification
::
N_GLOBAL
))
do
update_notification_link
(
Notification
::
N_GLOBAL
,
user_membership
,
'Global'
,
'globe'
)
link_to
'#'
,
class:
'update-notification'
,
data:
{
notification_level:
Notification
::
N_GLOBAL
}
do
icon
(
'globe fw'
,
text:
'Global'
)
end
end
else
else
# do nothing
# do nothing
end
end
end
end
def
update_notification_link
(
notification_label
,
user_membership
,
title
,
icon
)
content_tag
(
:li
,
class:
active_level_for
(
user_membership
,
notification_level
))
do
link_to
'#'
,
class:
'update-notification'
,
data:
{
notification_level:
notification_label
}
do
icon
(
"
#{
icon
}
fw"
,
text:
title
)
end
end
end
def
notification_label
(
user_membership
)
def
notification_label
(
user_membership
)
Notification
.
new
(
user_membership
).
to_s
Notification
.
new
(
user_membership
).
to_s
end
end
...
...
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