diff --git a/app/assets/javascripts/comment_type_toggle.js b/app/assets/javascripts/comment_type_toggle.js index 75b6f60cabb..df337441a40 100644 --- a/app/assets/javascripts/comment_type_toggle.js +++ b/app/assets/javascripts/comment_type_toggle.js @@ -12,19 +12,24 @@ class CommentTypeToggle { initDroplab() { this.droplab = new DropLab(); - this.droplab.init(this.trigger, this.list, [InputSetter], { - InputSetter: [{ - input: this.input, - valueAttribute: 'data-value', - }, - { - input: this.button, - valueAttribute: 'data-button-text', - }, - { + + const inputSetterConfig = [{ + input: this.input, + valueAttribute: 'data-value', + }, + { + input: this.button, + valueAttribute: 'data-button-text', + }]; + if (this.secondaryButton) { + inputSetterConfig.push({ input: this.secondaryButton, valueAttribute: 'data-secondary-button-text', - }], + }); + } + + this.droplab.init(this.trigger, this.list, [InputSetter], { + InputSetter: inputSetterConfig }); } } diff --git a/app/views/projects/notes/_comment_type_button.html.haml b/app/views/projects/notes/_comment_type_button.html.haml index c690aa2a30d..e3bb15e1d15 100644 --- a/app/views/projects/notes/_comment_type_button.html.haml +++ b/app/views/projects/notes/_comment_type_button.html.haml @@ -1,4 +1,5 @@ - noteable_type = @note.noteable_type + .btn-group.append-right-10.comment-type-dropdown.js-comment-type-dropdown %button.btn.btn-nr.btn-create.comment-btn.js-comment-button.js-comment-submit-button Comment @@ -12,8 +13,17 @@ %strong Comment %p= "Add a general comment to this #{noteable_type.titleize.downcase}." %li.divider - %li#discussion{ data: { value: 'DiscussionNote', 'button-text' => 'Start discussion', 'secondary-button-text' => 'Start discussion & close merge request' } } - = icon('check') - .description - %strong Start discussion - %p= "Discuss a specific suggestion or question#{@note.can_be_resolvable? ? ' that needs to be resolved' : ''}." + - if @note.can_be_resolvable? + %li#discussion{ data: { value: 'DiscussionNote', 'button-text' => 'Start discussion', 'secondary-button-text' => "Start discussion & close #{noteable_type.titleize.downcase}" } } + = icon('check') + .description + %strong Start discussion + %p + Discuss a specific suggestion or question that needs to be resolved. + - else + %li#discussion{ data: { value: 'DiscussionNote', 'button-text' => 'Start discussion', 'secondary-button-text' => "Start discussion & close #{noteable_type.titleize.downcase}"} } + = icon('check') + .description + %strong Start discussion + %p + Discuss a specific suggestion or question.