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
733fbebe
Commit
733fbebe
authored
Nov 15, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use button instead of an icon to subscribe/unsubscribe to labels
parent
e43f572f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
14 deletions
+49
-14
app/assets/javascripts/label_subscription.js.es6
app/assets/javascripts/label_subscription.js.es6
+42
-0
app/assets/stylesheets/pages/labels.scss
app/assets/stylesheets/pages/labels.scss
+1
-1
app/helpers/labels_helper.rb
app/helpers/labels_helper.rb
+0
-6
app/views/shared/_label.html.haml
app/views/shared/_label.html.haml
+6
-7
No files found.
app/assets/javascripts/label_subscription.js.es6
0 → 100644
View file @
733fbebe
/* eslint-disable */
(function(global) {
class LabelSubscription {
constructor(container) {
$(container).on('click', '.js-subscribe-button', this.toggleSubscription);
}
toggleSubscription(event) {
event.preventDefault();
const $btn = $(event.currentTarget);
const $span = $btn.find('span');
const url = $btn.attr('data-url');
const status = $btn.attr('data-status');
$btn.addClass('disabled');
$span.toggleClass('hidden');
$.ajax({
type: 'POST',
url: url
}).done(() => {
let newStatus, newAction;
if (status === 'subscribed') {
[newStatus, newAction] = ['unsubscribed', 'Subscribe'];
} else {
[newStatus, newAction] = ['subscribed', 'Unsubscribe'];
}
$span.text(newAction);
$span.toggleClass('hidden');
$btn.removeClass('disabled');
$btn.tooltip('hide').attr('data-original-title', newAction).tooltip('fixTitle');
$btn.attr('data-status', newStatus);
});
}
}
global.LabelSubscription = LabelSubscription;
})(window.gl || (window.gl = {}));
app/assets/stylesheets/pages/labels.scss
View file @
733fbebe
...
...
@@ -90,7 +90,7 @@
@media
(
min-width
:
$screen-sm-min
)
{
display
:
inline-block
;
width
:
40
%
;
width
:
35
%
;
margin-left
:
10px
;
margin-bottom
:
0
;
vertical-align
:
middle
;
...
...
app/helpers/labels_helper.rb
View file @
733fbebe
...
...
@@ -68,12 +68,6 @@ module LabelsHelper
end
end
def
toggle_subscription_data
(
label
,
project
)
{
url:
toggle_subscription_namespace_project_label_path
(
project
.
namespace
,
project
,
label
)
}
end
def
render_colored_label
(
label
,
label_suffix
=
''
,
tooltip:
true
)
label_color
=
label
.
color
||
Label
::
DEFAULT_COLOR
text_color
=
text_color_for_bg
(
label_color
)
...
...
app/views/shared/_label.html.haml
View file @
733fbebe
...
...
@@ -19,8 +19,8 @@
=
link_to_label
(
label
,
subject:
subject
)
do
=
pluralize
open_issues_count
,
'open issue'
-
if
current_user
&&
defined?
(
@project
)
%li
.label-subscription
{
data:
toggle_subscription_data
(
label
,
@project
)
}
%a
.js-subscribe-button.label-subscribe-button.subscription-status
{
role:
"button"
,
href:
"#"
,
data:
{
toggle:
"tooltip"
,
status:
label_subscription_status
(
label
,
@project
)
}
}
%li
.label-subscription
%a
.js-subscribe-button.label-subscribe-button.subscription-status
{
role:
"button"
,
href:
"#"
,
data:
{
toggle:
"tooltip"
,
status:
label_subscription_status
(
label
,
@project
)
,
url:
toggle_subscription_namespace_project_label_path
(
@project
.
namespace
,
@project
,
label
)
}
}
%span
=
label_subscription_toggle_button_text
(
label
,
@project
)
-
if
can?
(
current_user
,
:admin_label
,
label
)
%li
...
...
@@ -35,10 +35,9 @@
=
pluralize
open_issues_count
,
'open issue'
-
if
current_user
&&
defined?
(
@project
)
.label-subscription.inline
{
data:
toggle_subscription_data
(
label
,
@project
)
}
%button
.js-subscribe-button.label-subscribe-button.btn.btn-transparent.btn-action.subscription-status
{
type:
"button"
,
title:
label_subscription_toggle_button_text
(
label
,
@project
),
data:
{
toggle:
"tooltip"
,
status:
label_subscription_status
(
label
,
@project
)
}
}
%span
.sr-only
=
label_subscription_toggle_button_text
(
label
,
@project
)
=
icon
(
'eye'
,
class:
'label-subscribe-button-icon'
)
.label-subscription.inline
%button
.js-subscribe-button.label-subscribe-button.btn.btn-default.btn-action.subscription-status
{
type:
"button"
,
title:
label_subscription_toggle_button_text
(
label
,
@project
),
data:
{
toggle:
"tooltip"
,
status:
label_subscription_status
(
label
,
@project
),
url:
toggle_subscription_namespace_project_label_path
(
@project
.
namespace
,
@project
,
label
)
}
}
%span
=
label_subscription_toggle_button_text
(
label
,
@project
)
=
icon
(
'spinner spin'
,
class:
'label-subscribe-button-loading'
)
-
if
can?
(
current_user
,
:admin_label
,
label
)
...
...
@@ -51,4 +50,4 @@
-
if
current_user
&&
defined?
(
@project
)
:javascript
new
Subscription
(
'
##{dom_id(label)} .label-subscription
'
);
new
gl
.
Label
Subscription
(
'
##{dom_id(label)} .label-subscription
'
);
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