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
Jérome Perrin
gitlab-ce
Commits
3d2917bf
Commit
3d2917bf
authored
Aug 31, 2017
by
Jarka Kadlecova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the possibility to lock issuables from the frontend
parent
073ba05d
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
1 deletion
+74
-1
app/assets/javascripts/discussion_lock.js
app/assets/javascripts/discussion_lock.js
+46
-0
app/assets/javascripts/init_issuable_sidebar.js
app/assets/javascripts/init_issuable_sidebar.js
+1
-0
app/assets/javascripts/main.js
app/assets/javascripts/main.js
+1
-0
app/assets/stylesheets/pages/notes.scss
app/assets/stylesheets/pages/notes.scss
+6
-0
app/views/shared/issuable/_sidebar.html.haml
app/views/shared/issuable/_sidebar.html.haml
+11
-0
app/views/shared/notes/_notes_with_form.html.haml
app/views/shared/notes/_notes_with_form.html.haml
+9
-1
No files found.
app/assets/javascripts/discussion_lock.js
0 → 100644
View file @
3d2917bf
class
DiscussionLock
{
constructor
(
containerElm
)
{
this
.
containerElm
=
containerElm
;
const
lockButton
=
containerElm
.
querySelector
(
'
.js-discussion-lock-button
'
);
console
.
log
(
lockButton
);
if
(
lockButton
)
{
// remove class so we don't bind twice
lockButton
.
classList
.
remove
(
'
js-discussion-lock-button
'
);
console
.
log
(
lockButton
);
lockButton
.
addEventListener
(
'
click
'
,
this
.
toggleDiscussionLock
.
bind
(
this
));
}
}
toggleDiscussionLock
(
event
)
{
const
button
=
event
.
currentTarget
;
const
buttonSpan
=
button
.
querySelector
(
'
span
'
);
if
(
!
buttonSpan
||
button
.
classList
.
contains
(
'
disabled
'
))
{
return
;
}
button
.
classList
.
add
(
'
disabled
'
);
const
url
=
this
.
containerElm
.
dataset
.
url
;
const
lock
=
this
.
containerElm
.
dataset
.
lock
;
const
issuableType
=
this
.
containerElm
.
dataset
.
issuableType
;
const
data
=
{}
data
[
issuableType
]
=
{}
data
[
issuableType
].
discussion_locked
=
lock
$
.
ajax
({
url
,
data
:
data
,
type
:
'
PUT
'
}).
done
((
data
)
=>
{
button
.
classList
.
remove
(
'
disabled
'
);
});
}
static
bindAll
(
selector
)
{
[].
forEach
.
call
(
document
.
querySelectorAll
(
selector
),
elm
=>
new
DiscussionLock
(
elm
));
}
}
window
.
gl
=
window
.
gl
||
{};
window
.
gl
.
DiscussionLock
=
DiscussionLock
;
app/assets/javascripts/init_issuable_sidebar.js
View file @
3d2917bf
...
...
@@ -13,6 +13,7 @@ export default () => {
new
LabelsSelect
();
new
IssuableContext
(
sidebarOptions
.
currentUser
);
gl
.
Subscription
.
bindAll
(
'
.subscription
'
);
gl
.
DiscussionLock
.
bindAll
(
'
.discussion-lock
'
);
new
gl
.
DueDateSelectors
();
window
.
sidebar
=
new
Sidebar
();
};
app/assets/javascripts/main.js
View file @
3d2917bf
...
...
@@ -80,6 +80,7 @@ import './copy_as_gfm';
import
'
./copy_to_clipboard
'
;
import
'
./create_label
'
;
import
'
./diff
'
;
import
'
./discussion_lock
'
;
import
'
./dropzone_input
'
;
import
'
./due_date_select
'
;
import
'
./files_comment_button
'
;
...
...
app/assets/stylesheets/pages/notes.scss
View file @
3d2917bf
...
...
@@ -703,6 +703,12 @@ ul.notes {
color
:
$note-disabled-comment-color
;
padding
:
90px
0
;
&
.discussion-locked
{
border
:
none
;
background-color
:
$white-light
;
}
a
{
color
:
$gl-link-color
;
}
...
...
app/views/shared/issuable/_sidebar.html.haml
View file @
3d2917bf
...
...
@@ -131,6 +131,17 @@
%button
.btn.btn-default.pull-right.js-subscribe-button.issuable-subscribe-button.hide-collapsed
{
type:
"button"
}
%span
=
subscribed
?
'Unsubscribe'
:
'Subscribe'
-
if
can_edit_issuable
-
locked
=
issuable
.
discussion_locked?
.block.light.discussion-lock
{
data:
{
lock:
(
!
locked
).
to_s
,
url:
"#{issuable_json_path(issuable)}?basic=true"
,
issuable_type:
issuable
.
class
.
to_s
.
underscore
}
}
.sidebar-collapsed-icon
=
icon
(
'rss'
,
'aria-hidden'
:
'true'
)
%span
.issuable-header-text.hide-collapsed.pull-left
Discussion Lock
-
subscribtion_status
=
locked
?
'locked'
:
'not locked'
%button
.btn.btn-default.pull-right.js-discussion-lock-button.issuable-discussion-lock-button.hide-collapsed
{
type:
"button"
}
%span
=
locked
?
'Unlock'
:
'Lock'
-
project_ref
=
cross_project_reference
(
@project
,
issuable
)
.block.project-reference
.sidebar-collapsed-icon.dont-change-state
...
...
app/views/shared/notes/_notes_with_form.html.haml
View file @
3d2917bf
-
issuable
=
@issue
||
@merge_request
-
discussion_locked
=
issuable
&
.
discussion_locked?
%ul
#notes-list
.notes.main-notes-list.timeline
=
render
"shared/notes/notes"
...
...
@@ -21,5 +24,10 @@
or
=
link_to
"sign in"
,
new_session_path
(
:user
,
redirect_to_referer:
'yes'
),
class:
'js-sign-in-link'
to comment
-
elsif
discussion_locked
.discussion_locked
%span
This
=
issuable
.
class
.
to_s
has been locked. Posting comments has been restricted to project members.
%script
.js-notes-data
{
type:
"application/json"
}=
initial_notes_data
(
autocomplete
).
to_json
.
html_safe
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