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
e0e5ea0e
Commit
e0e5ea0e
authored
Nov 17, 2016
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rewrite subscription javascript to accomodate new design
parent
d795a70d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
59 deletions
+60
-59
app/assets/javascripts/boards/components/board_sidebar.js.es6
...assets/javascripts/boards/components/board_sidebar.js.es6
+1
-1
app/assets/javascripts/subscription.js.es6
app/assets/javascripts/subscription.js.es6
+52
-46
app/assets/stylesheets/pages/boards.scss
app/assets/stylesheets/pages/boards.scss
+0
-1
app/views/projects/boards/components/sidebar/_notifications.html.haml
...ojects/boards/components/sidebar/_notifications.html.haml
+4
-8
app/views/shared/issuable/_sidebar.html.haml
app/views/shared/issuable/_sidebar.html.haml
+1
-1
spec/features/boards/sidebar_spec.rb
spec/features/boards/sidebar_spec.rb
+2
-2
No files found.
app/assets/javascripts/boards/components/board_sidebar.js.es6
View file @
e0e5ea0e
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
new gl.DueDateSelectors();
new gl.DueDateSelectors();
new LabelsSelect();
new LabelsSelect();
new Sidebar();
new Sidebar();
new Subscription
('.subscription');
gl.Subscription.bindAll
('.subscription');
}
}
});
});
})();
})();
app/assets/javascripts/subscription.js.es6
View file @
e0e5ea0e
/* eslint-disable func-names, space-before-function-paren, no-var, space-before-blocks, prefer-rest-params, wrap-iife, vars-on-top, no-unused-vars, one-var, one-var-declaration-per-line, camelcase, consistent-return, no-undef, padded-blocks, max-len */
/* global Vue */
(function() {
var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
((global) => {
class Subscription {
this.Subscription = (function() {
constructor(containerSelector) {
function Subscription(container) {
this.containerElm = (typeof containerSelector === 'string')
this.toggleSubscription = bind(this.toggleSubscription, this);
? document.querySelector(containerSelector)
var $container;
: containerSelector;
this.$container = $(container);
this.url = this.$container.attr('data-url');
const subscribeButton = this.containerElm.querySelector('.js-subscribe-button');
this.subscribe_button = this.$container.find('.js-subscribe-button');
if (subscribeButton) {
this.subscription_status = this.$container.find('.subscription-status');
// remove class so we don't bind twice
this.subscribe_button.unbind('click').click(this.toggleSubscription);
subscribeButton.classList.remove('js-subscribe-button');
subscribeButton.addEventListener('click', this.toggleSubscription.bind(this));
}
}
}
Subscription.prototype.toggleSubscription = function(event) {
toggleSubscription(event) {
var action, btn, current_status;
const button = event.currentTarget;
btn = $(event.currentTarget);
const buttonSpan = button.querySelector('span');
action = btn.find('span').text();
if (!buttonSpan || button.classList.contains('disabled')) {
current_status = this.subscription_status.attr('data-status');
return;
btn.addClass('disabled');
if ($('html').hasClass('issue-boards-page')) {
this.url = this.$container.attr('data-url');
}
}
button.classList.add('disabled');
return $.post(this.url, (function(_this) {
return function() {
const isSubscribed = buttonSpan.innerHTML.trim() !== 'Subscribe';
var status;
const toggleActionUrl = this.containerElm.getAttribute('data-url');
btn.removeClass('disabled');
$.post(toggleActionUrl, () => {
if ($('html').hasClass('issue-boards-page')) {
button.classList.remove('disabled');
Vue.set(gl.issueBoards.BoardsStore.detail.issue, 'subscribed', !gl.issueBoards.BoardsStore.detail.issue.subscribed);
} else {
// hack to allow this to work with the issue boards Vue object
status = current_status === 'subscribed' ? 'unsubscribed' : 'subscribed';
if (document.querySelector('html').classList.contains('issue-boards-page')) {
_this.subscription_status.attr('data-status', status);
Vue.set(
action = status === 'subscribed' ? 'Unsubscribe' : 'Subscribe';
gl.issueBoards.BoardsStore.detail.issue,
btn.find('span').text(action);
'subscribed',
_this.subscription_status.find('>div').toggleClass('hidden');
!gl.issueBoards.BoardsStore.detail.issue.subscribed
if (btn.attr('data-original-title')) {
);
return btn.tooltip('hide').attr('data-original-title', action).tooltip('fixTitle');
} else {
}
const newToggleText = isSubscribed ? 'Subscribe' : 'Unsubscribe';
buttonSpan.innerHTML = newToggleText;
if (button.getAttribute('data-original-title')) {
button.setAttribute('data-original-title', newToggleText);
$(button).tooltip('hide').tooltip('fixTitle');
}
}
};
}
})(this));
});
};
}
return Subscription;
})();
static bindAll(selector) {
[].forEach.call(document.querySelectorAll(selector), elm => new Subscription(elm));
}
}
}).call(this);
// eslint-disable-next-line no-param-reassign
global.Subscription = Subscription;
})(window.gl || (window.gl = {}));
app/assets/stylesheets/pages/boards.scss
View file @
e0e5ea0e
...
@@ -325,7 +325,6 @@
...
@@ -325,7 +325,6 @@
}
}
.issuable-header-text
{
.issuable-header-text
{
width
:
100%
;
padding-right
:
35px
;
padding-right
:
35px
;
>
strong
{
>
strong
{
...
...
app/views/projects/boards/components/sidebar/_notifications.html.haml
View file @
e0e5ea0e
-
if
current_user
-
if
current_user
.block.light.subscription
{
":data-url"
=>
"'#{namespace_project_issues_path(@project.namespace, @project)}/' + issue.id + '/toggle_subscription'"
}
.block.light.subscription
{
":data-url"
=>
"'#{namespace_project_issues_path(@project.namespace, @project)}/' + issue.id + '/toggle_subscription'"
}
.title
%span
.issuable-header-text.hide-collapsed.pull-left
Notifications
Notifications
%button
.btn.btn-block.btn-default.js-subscribe-button.issuable-subscribe-button.hide-collapsed
{
type:
"button"
}
%button
.btn.btn-default.pull-right.js-subscribe-button.issuable-subscribe-button.hide-collapsed
{
type:
"button"
}
{{ issue.subscribed ? 'Unsubscribe' : 'Subscribe' }}
%span
.subscription-status
{
":data-status"
=>
"issue.subscribed ? 'subscribed' : 'unsubscribed'"
}
{{issue.subscribed ? 'Unsubscribe' : 'Subscribe'}}
.unsubscribed
{
"v-show"
=>
"!issue.subscribed"
}
You're not receiving notifications from this thread.
.subscribed
{
"v-show"
=>
"issue.subscribed"
}
You're receiving notifications because you're subscribed to this thread.
app/views/shared/issuable/_sidebar.html.haml
View file @
e0e5ea0e
...
@@ -165,6 +165,6 @@
...
@@ -165,6 +165,6 @@
new
MilestoneSelect
(
'
{"namespace":"
#{
@project
.
namespace
.
path
}
","path":"
#{
@project
.
path
}
"}
'
);
new
MilestoneSelect
(
'
{"namespace":"
#{
@project
.
namespace
.
path
}
","path":"
#{
@project
.
path
}
"}
'
);
new
LabelsSelect
();
new
LabelsSelect
();
new
IssuableContext
(
'
#{
escape_javascript
(
current_user
.
to_json
(
only:
[
:username
,
:id
,
:name
]))
}
'
);
new
IssuableContext
(
'
#{
escape_javascript
(
current_user
.
to_json
(
only:
[
:username
,
:id
,
:name
]))
}
'
);
new
Subscription
(
'
.subscription
'
)
gl
.
Subscription
.
bindAll
(
'
.subscription
'
);
new
gl
.
DueDateSelectors
();
new
gl
.
DueDateSelectors
();
sidebar
=
new
Sidebar
();
sidebar
=
new
Sidebar
();
spec/features/boards/sidebar_spec.rb
View file @
e0e5ea0e
...
@@ -304,8 +304,8 @@ describe 'Issue Boards', feature: true, js: true do
...
@@ -304,8 +304,8 @@ describe 'Issue Boards', feature: true, js: true do
page
.
within
(
'.subscription'
)
do
page
.
within
(
'.subscription'
)
do
click_button
'Subscribe'
click_button
'Subscribe'
wait_for_ajax
expect
(
page
).
to
have_content
(
"
You're receiving notifications because you're subscribed to this thread.
"
)
expect
(
page
).
to
have_content
(
"
Unsubscribe
"
)
end
end
end
end
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