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
18e2388d
Commit
18e2388d
authored
Apr 07, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue button state bug
parent
2f22890d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
121 additions
and
80 deletions
+121
-80
app/assets/javascripts/comment_type_toggle.js
app/assets/javascripts/comment_type_toggle.js
+42
-27
app/assets/javascripts/notes.js
app/assets/javascripts/notes.js
+21
-12
app/assets/stylesheets/pages/note_form.scss
app/assets/stylesheets/pages/note_form.scss
+0
-1
app/views/projects/notes/_comment_button.html.haml
app/views/projects/notes/_comment_button.html.haml
+2
-3
spec/javascripts/comment_type_toggle_spec.js
spec/javascripts/comment_type_toggle_spec.js
+56
-37
No files found.
app/assets/javascripts/comment_type_toggle.js
View file @
18e2388d
...
@@ -2,39 +2,54 @@ import DropLab from '~/droplab/drop_lab';
...
@@ -2,39 +2,54 @@ import DropLab from '~/droplab/drop_lab';
import
InputSetter
from
'
~/droplab/plugins/input_setter
'
;
import
InputSetter
from
'
~/droplab/plugins/input_setter
'
;
class
CommentTypeToggle
{
class
CommentTypeToggle
{
constructor
(
dropdownTrigger
,
dropdownList
,
noteTypeInput
,
submitButton
,
closeButton
)
{
constructor
(
opts
=
{})
{
this
.
dropdownTrigger
=
dropdownTrigger
;
this
.
dropdownTrigger
=
opts
.
dropdownTrigger
;
this
.
dropdownList
=
dropdownList
;
this
.
dropdownList
=
opts
.
dropdownList
;
this
.
noteTypeInput
=
noteTypeInput
;
this
.
noteTypeInput
=
opts
.
noteTypeInput
;
this
.
submitButton
=
submitButton
;
this
.
submitButton
=
opts
.
submitButton
;
this
.
closeButton
=
closeButton
;
this
.
closeButton
=
opts
.
closeButton
;
this
.
reopenButton
=
opts
.
reopenButton
;
}
}
initDroplab
()
{
initDroplab
()
{
this
.
droplab
=
new
DropLab
();
this
.
droplab
=
new
DropLab
();
const
inputSetterConfig
=
[{
const
config
=
this
.
setConfig
();
input
:
this
.
noteTypeInput
,
valueAttribute
:
'
data-value
'
,
this
.
droplab
.
init
(
this
.
dropdownTrigger
,
this
.
dropdownList
,
[
InputSetter
],
config
);
},
}
{
input
:
this
.
submitButton
,
setConfig
()
{
valueAttribute
:
'
data-button-text
'
,
const
config
=
{
}];
InputSetter
:
[{
if
(
this
.
closeButton
)
{
input
:
this
.
noteTypeInput
,
inputSetterConfig
.
push
({
valueAttribute
:
'
data-value
'
,
input
:
this
.
closeButton
,
},
valueAttribute
:
'
data-secondary-button-text
'
,
{
},
{
input
:
this
.
submitButton
,
input
:
this
.
closeButton
,
valueAttribute
:
'
data-submit-text
'
,
valueAttribute
:
'
data-secondary-button-text
'
,
}],
inputAttribute
:
'
data-alternative-text
'
,
};
});
}
if
(
!
this
.
closeButton
||
!
this
.
reopenButton
)
return
config
;
this
.
droplab
.
init
(
this
.
dropdownTrigger
,
this
.
dropdownList
,
[
InputSetter
],
{
config
.
InputSetter
.
push
({
InputSetter
:
inputSetterConfig
,
input
:
this
.
closeButton
,
valueAttribute
:
'
data-close-text
'
,
},
{
input
:
this
.
closeButton
,
valueAttribute
:
'
data-close-text
'
,
inputAttribute
:
'
data-alternative-text
'
,
},
{
input
:
this
.
reopenButton
,
valueAttribute
:
'
data-reopen-text
'
,
},
{
input
:
this
.
reopenButton
,
valueAttribute
:
'
data-reopen-text
'
,
inputAttribute
:
'
data-alternative-text
'
,
});
});
return
config
;
}
}
}
}
...
...
app/assets/javascripts/notes.js
View file @
18e2388d
...
@@ -137,16 +137,24 @@ require('./task_list');
...
@@ -137,16 +137,24 @@ require('./task_list');
$
(
document
).
off
(
"
click
"
,
'
.system-note-commit-list-toggler
'
);
$
(
document
).
off
(
"
click
"
,
'
.system-note-commit-list-toggler
'
);
};
};
Notes
.
prototype
.
initCommentTypeToggle
=
function
(
form
)
{
Notes
.
initCommentTypeToggle
=
function
(
form
)
{
this
.
commentTypeToggle
=
new
CommentTypeToggle
(
const
dropdownTrigger
=
form
.
querySelector
(
'
.js-comment-type-dropdown .dropdown-toggle
'
);
form
.
querySelector
(
'
.js-comment-type-dropdown .dropdown-toggle
'
),
const
dropdownList
=
form
.
querySelector
(
'
.js-comment-type-dropdown .dropdown-menu
'
);
form
.
querySelector
(
'
.js-comment-type-dropdown .dropdown-menu
'
),
const
noteTypeInput
=
form
.
querySelector
(
'
#note_type
'
);
form
.
querySelector
(
'
#note_type
'
),
const
submitButton
=
form
.
querySelector
(
'
.js-comment-type-dropdown .js-comment-submit-button
'
);
form
.
querySelector
(
'
.js-comment-type-dropdown .js-comment-submit-button
'
),
const
closeButton
=
form
.
querySelector
(
'
.js-note-target-close
'
);
form
.
querySelector
(
'
.js-note-target-close:not(.hidden)
'
)
||
form
.
querySelector
(
'
.js-note-target-reopen
'
),
const
reopenButton
=
form
.
querySelector
(
'
.js-note-target-reopen
'
);
);
const
commentTypeToggle
=
new
CommentTypeToggle
({
this
.
commentTypeToggle
.
initDroplab
();
dropdownTrigger
,
dropdownList
,
noteTypeInput
,
submitButton
,
closeButton
,
reopenButton
,
});
commentTypeToggle
.
initDroplab
();
};
};
Notes
.
prototype
.
keydownNoteText
=
function
(
e
)
{
Notes
.
prototype
.
keydownNoteText
=
function
(
e
)
{
...
@@ -470,7 +478,7 @@ require('./task_list');
...
@@ -470,7 +478,7 @@ require('./task_list');
this
.
parentTimeline
=
form
.
parents
(
'
.timeline
'
);
this
.
parentTimeline
=
form
.
parents
(
'
.timeline
'
);
if
(
form
.
length
)
{
if
(
form
.
length
)
{
thi
s
.
initCommentTypeToggle
(
form
.
get
(
0
));
Note
s
.
initCommentTypeToggle
(
form
.
get
(
0
));
}
}
};
};
...
@@ -939,8 +947,9 @@ require('./task_list');
...
@@ -939,8 +947,9 @@ require('./task_list');
reopenbtn
=
form
.
find
(
'
.js-note-target-reopen
'
);
reopenbtn
=
form
.
find
(
'
.js-note-target-reopen
'
);
closebtn
=
form
.
find
(
'
.js-note-target-close
'
);
closebtn
=
form
.
find
(
'
.js-note-target-close
'
);
discardbtn
=
form
.
find
(
'
.js-note-discard
'
);
discardbtn
=
form
.
find
(
'
.js-note-discard
'
);
if
(
textarea
.
val
().
trim
().
length
>
0
)
{
if
(
textarea
.
val
().
trim
().
length
>
0
)
{
reopentext
=
reopenbtn
.
data
(
'
alternative-text
'
);
reopentext
=
reopenbtn
.
attr
(
'
data-
alternative-text
'
);
closetext
=
closebtn
.
attr
(
'
data-alternative-text
'
);
closetext
=
closebtn
.
attr
(
'
data-alternative-text
'
);
if
(
reopenbtn
.
text
()
!==
reopentext
)
{
if
(
reopenbtn
.
text
()
!==
reopentext
)
{
reopenbtn
.
text
(
reopentext
);
reopenbtn
.
text
(
reopentext
);
...
...
app/assets/stylesheets/pages/note_form.scss
View file @
18e2388d
...
@@ -334,7 +334,6 @@
...
@@ -334,7 +334,6 @@
li
{
li
{
white-space
:
nowrap
;
white-space
:
nowrap
;
border-radius
:
0
;
cursor
:
pointer
;
cursor
:
pointer
;
padding-top
:
6px
;
padding-top
:
6px
;
...
...
app/views/projects/notes/_comment_button.html.haml
View file @
18e2388d
-
noteable_name
=
@note
.
noteable
.
human_class_name
-
noteable_name
=
@note
.
noteable
.
human_class_name
-
noteable_state_action
=
noteable_name
=~
/(merge request|issue)/
&&
@note
.
noteable
[
'state'
]
==
'closed'
?
'reopen'
:
'close'
.pull-left.btn-group.append-right-10.comment-type-dropdown.js-comment-type-dropdown
.pull-left.btn-group.append-right-10.comment-type-dropdown.js-comment-type-dropdown
%input
.btn.btn-nr.btn-create.comment-btn.js-comment-button.js-comment-submit-button
{
type:
'submit'
,
value:
'Comment'
}
%input
.btn.btn-nr.btn-create.comment-btn.js-comment-button.js-comment-submit-button
{
type:
'submit'
,
value:
'Comment'
}
...
@@ -9,7 +8,7 @@
...
@@ -9,7 +8,7 @@
=
icon
(
'caret-down'
)
=
icon
(
'caret-down'
)
%ul
#resolvable-comment-menu
.dropdown-menu
{
data:
{
dropdown:
true
}
}
%ul
#resolvable-comment-menu
.dropdown-menu
{
data:
{
dropdown:
true
}
}
%li
#comment
.droplab-item-selected
{
data:
{
value:
''
,
'
button-text'
=>
'Comment'
,
'secondary-button-text'
=>
"Comment & #{noteable_state_action}
#{noteable_name}"
}
}
%li
#comment
.droplab-item-selected
{
data:
{
value:
''
,
'
submit-text'
=>
'Comment'
,
'close-text'
=>
"Comment & close #{noteable_name}"
,
'reopen-text'
=>
"Comment & reopen
#{noteable_name}"
}
}
=
icon
(
'check'
)
=
icon
(
'check'
)
.description
.description
%strong
Comment
%strong
Comment
...
@@ -18,7 +17,7 @@
...
@@ -18,7 +17,7 @@
%li
.divider
%li
.divider
%li
#discussion
{
data:
{
value:
'DiscussionNote'
,
'
button-text'
=>
'Start discussion'
,
'secondary-button-text'
=>
"Start discussion & #{noteable_state_action}
#{noteable_name}"
}
}
%li
#discussion
{
data:
{
value:
'DiscussionNote'
,
'
submit-text'
=>
'Start discussion'
,
'close-text'
=>
"Start discussion & close #{noteable_name}"
,
'reopen-text'
=>
"Start discussion & reopen
#{noteable_name}"
}
}
=
icon
(
'check'
)
=
icon
(
'check'
)
.description
.description
%strong
Start discussion
%strong
Start discussion
...
...
spec/javascripts/comment_type_toggle_spec.js
View file @
18e2388d
...
@@ -11,13 +11,13 @@ describe('CommentTypeToggle', function () {
...
@@ -11,13 +11,13 @@ describe('CommentTypeToggle', function () {
this
.
submitButton
=
{};
this
.
submitButton
=
{};
this
.
closeButton
=
{};
this
.
closeButton
=
{};
this
.
commentTypeToggle
=
new
CommentTypeToggle
(
this
.
commentTypeToggle
=
new
CommentTypeToggle
(
{
this
.
dropdownTrigger
,
dropdownTrigger
:
this
.
dropdownTrigger
,
this
.
dropdownList
,
dropdownList
:
this
.
dropdownList
,
this
.
noteTypeInput
,
noteTypeInput
:
this
.
noteTypeInput
,
this
.
submitButton
,
submitButton
:
this
.
submitButton
,
this
.
closeButton
,
closeButton
:
this
.
closeButton
,
);
}
);
});
});
it
(
'
should set .dropdownTrigger
'
,
function
()
{
it
(
'
should set .dropdownTrigger
'
,
function
()
{
...
@@ -39,6 +39,10 @@ describe('CommentTypeToggle', function () {
...
@@ -39,6 +39,10 @@ describe('CommentTypeToggle', function () {
it
(
'
should set .closeButton
'
,
function
()
{
it
(
'
should set .closeButton
'
,
function
()
{
expect
(
this
.
commentTypeToggle
.
closeButton
).
toBe
(
this
.
closeButton
);
expect
(
this
.
commentTypeToggle
.
closeButton
).
toBe
(
this
.
closeButton
);
});
});
it
(
'
should set .reopenButton
'
,
function
()
{
expect
(
this
.
commentTypeToggle
.
reopenButton
).
toBe
(
this
.
reopenButton
);
});
});
});
describe
(
'
initDroplab
'
,
function
()
{
describe
(
'
initDroplab
'
,
function
()
{
...
@@ -49,13 +53,16 @@ describe('CommentTypeToggle', function () {
...
@@ -49,13 +53,16 @@ describe('CommentTypeToggle', function () {
noteTypeInput
:
{},
noteTypeInput
:
{},
submitButton
:
{},
submitButton
:
{},
closeButton
:
{},
closeButton
:
{},
setConfig
:
()
=>
{},
};
};
this
.
config
=
{};
this
.
droplab
=
jasmine
.
createSpyObj
(
'
droplab
'
,
[
'
init
'
]);
this
.
droplab
=
jasmine
.
createSpyObj
(
'
droplab
'
,
[
'
init
'
]);
spyOn
(
dropLabSrc
,
'
default
'
).
and
.
returnValue
(
this
.
droplab
);
spyOn
(
dropLabSrc
,
'
default
'
).
and
.
returnValue
(
this
.
droplab
);
spyOn
(
this
.
commentTypeToggle
,
'
setConfig
'
).
and
.
returnValue
(
this
.
config
);
this
.
initDroplab
=
CommentTypeToggle
.
prototype
.
initDroplab
.
call
(
this
.
commentTypeToggle
);
CommentTypeToggle
.
prototype
.
initDroplab
.
call
(
this
.
commentTypeToggle
);
});
});
it
(
'
should instantiate a DropLab instance
'
,
function
()
{
it
(
'
should instantiate a DropLab instance
'
,
function
()
{
...
@@ -66,58 +73,70 @@ describe('CommentTypeToggle', function () {
...
@@ -66,58 +73,70 @@ describe('CommentTypeToggle', function () {
expect
(
this
.
commentTypeToggle
.
droplab
).
toBe
(
this
.
droplab
);
expect
(
this
.
commentTypeToggle
.
droplab
).
toBe
(
this
.
droplab
);
});
});
it
(
'
should call .setConfig
'
,
function
()
{
expect
(
this
.
commentTypeToggle
.
setConfig
).
toHaveBeenCalled
();
});
it
(
'
should call DropLab.prototype.init
'
,
function
()
{
it
(
'
should call DropLab.prototype.init
'
,
function
()
{
expect
(
this
.
droplab
.
init
).
toHaveBeenCalledWith
(
expect
(
this
.
droplab
.
init
).
toHaveBeenCalledWith
(
this
.
commentTypeToggle
.
dropdownTrigger
,
this
.
commentTypeToggle
.
dropdownTrigger
,
this
.
commentTypeToggle
.
dropdownList
,
this
.
commentTypeToggle
.
dropdownList
,
[
InputSetter
],
[
InputSetter
],
{
this
.
config
,
);
});
});
describe
(
'
setConfig
'
,
function
()
{
describe
(
'
if no .closeButton is provided
'
,
function
()
{
beforeEach
(
function
()
{
this
.
commentTypeToggle
=
{
dropdownTrigger
:
{},
dropdownList
:
{},
noteTypeInput
:
{},
submitButton
:
{},
reopenButton
:
{},
};
this
.
setConfig
=
CommentTypeToggle
.
prototype
.
setConfig
.
call
(
this
.
commentTypeToggle
);
});
it
(
'
should not add .closeButton or .reopenButton related InputSetter config
'
,
function
()
{
expect
(
this
.
setConfig
).
toEqual
({
InputSetter
:
[{
InputSetter
:
[{
input
:
this
.
commentTypeToggle
.
noteTypeInput
,
input
:
this
.
commentTypeToggle
.
noteTypeInput
,
valueAttribute
:
'
data-value
'
,
valueAttribute
:
'
data-value
'
,
},
{
},
{
input
:
this
.
commentTypeToggle
.
submitButton
,
input
:
this
.
commentTypeToggle
.
submitButton
,
valueAttribute
:
'
data-button-text
'
,
valueAttribute
:
'
data-submit-text
'
,
},
{
input
:
this
.
commentTypeToggle
.
closeButton
,
valueAttribute
:
'
data-secondary-button-text
'
,
},
{
input
:
this
.
commentTypeToggle
.
closeButton
,
valueAttribute
:
'
data-secondary-button-text
'
,
inputAttribute
:
'
data-alternative-text
'
,
}],
}],
}
,
}
);
);
}
);
});
});
describe
(
'
if no .
close
Button is provided
'
,
function
()
{
describe
(
'
if no .
reopen
Button is provided
'
,
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
this
.
commentTypeToggle
=
{
this
.
commentTypeToggle
=
{
dropdownTrigger
:
{},
dropdownTrigger
:
{},
dropdownList
:
{},
dropdownList
:
{},
noteTypeInput
:
{},
noteTypeInput
:
{},
submitButton
:
{},
submitButton
:
{},
closeButton
:
{},
};
};
this
.
initDroplab
=
CommentTypeToggle
.
prototype
.
initDroplab
.
call
(
this
.
commentTypeToggle
);
this
.
setConfig
=
CommentTypeToggle
.
prototype
.
setConfig
.
call
(
this
.
commentTypeToggle
);
});
});
it
(
'
should not add .closeButton related InputSetter config
'
,
function
()
{
it
(
'
should not add .closeButton or .reopenButton related InputSetter config
'
,
function
()
{
expect
(
this
.
droplab
.
init
).
toHaveBeenCalledWith
(
expect
(
this
.
setConfig
).
toEqual
({
this
.
commentTypeToggle
.
dropdownTrigger
,
InputSetter
:
[{
this
.
commentTypeToggle
.
dropdownList
,
input
:
this
.
commentTypeToggle
.
noteTypeInput
,
[
InputSetter
],
valueAttribute
:
'
data-value
'
,
{
},
{
InputSetter
:
[{
input
:
this
.
commentTypeToggle
.
submitButton
,
input
:
this
.
commentTypeToggle
.
noteTypeInput
,
valueAttribute
:
'
data-submit-text
'
,
valueAttribute
:
'
data-value
'
,
}],
},
{
});
input
:
this
.
commentTypeToggle
.
submitButton
,
valueAttribute
:
'
data-button-text
'
,
}],
},
);
});
});
});
});
});
});
...
...
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