Skip to content

Commit f821a53

Browse files
committed
Merge branch '55945-suggested-change-preview-highlight' into 'master'
Add syntax highlighting to suggestion preview Closes #55945 See merge request gitlab-org/gitlab-ce!24358
2 parents cbad001 + f3b9eda commit f821a53

File tree

10 files changed

+28
-6
lines changed

10 files changed

+28
-6
lines changed

app/assets/javascripts/diffs/components/diff_line_note_form.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export default {
2828
type: Object,
2929
required: true,
3030
},
31+
helpPagePath: {
32+
type: String,
33+
required: false,
34+
default: '',
35+
},
3136
},
3237
computed: {
3338
...mapState({
@@ -95,6 +100,7 @@ export default {
95100
:is-editing="true"
96101
:line-code="line.line_code"
97102
:line="line"
103+
:help-page-path="helpPagePath"
98104
save-button-title="Comment"
99105
class="diff-comment-form"
100106
@cancelForm="handleCancelCommentForm"

app/assets/javascripts/diffs/components/inline_diff_comment_row.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export default {
5454
:diff-file-hash="diffFileHash"
5555
:line="line"
5656
:note-target-line="line"
57+
:help-page-path="helpPagePath"
5758
/>
5859
</div>
5960
</td>

app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export default {
101101
:diff-file-hash="diffFileHash"
102102
:line="line.left"
103103
:note-target-line="line.left"
104+
:help-page-path="helpPagePath"
104105
line-position="left"
105106
/>
106107
</td>

app/assets/javascripts/vue_shared/components/markdown/field.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ export default {
182182
this.hasSuggestion = data.references.suggestions && data.references.suggestions.length;
183183
}
184184
185-
this.$nextTick(() => {
186-
$(this.$refs['markdown-preview']).renderGFM();
187-
});
185+
this.$nextTick()
186+
.then(() => $(this.$refs['markdown-preview']).renderGFM())
187+
.catch(() => new Flash(__('Error rendering markdown preview')));
188188
},
189189
190190
versionedPreviewPath() {

app/assets/javascripts/vue_shared/components/markdown/suggestion_diff_header.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default {
4242
<div class="md-suggestion-header border-bottom-0 mt-2">
4343
<div class="qa-suggestion-diff-header font-weight-bold">
4444
{{ __('Suggested change') }}
45-
<a v-if="helpPagePath" :href="helpPagePath" :aria-label="__('Help')">
45+
<a v-if="helpPagePath" :href="helpPagePath" :aria-label="__('Help')" class="js-help-btn">
4646
<icon name="question-o" css-classes="link-highlight" />
4747
</a>
4848
</div>

app/assets/stylesheets/framework/markdown_area.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
max-height: calc(100vh - 100px);
159159
}
160160

161-
table {
161+
table:not(.js-syntax-highlight) {
162162
@include markdown-table;
163163
}
164164
}

app/assets/stylesheets/framework/typography.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
margin: 0 0 16px;
144144
}
145145

146-
table {
146+
table:not(.js-syntax-highlight) {
147147
@extend .table;
148148
@extend .table-bordered;
149149
margin: 16px 0;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: Fix syntax highlighting for suggested changes preview
3+
merge_request: 24358
4+
author:
5+
type: fixed

locale/gitlab.pot

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2956,6 +2956,9 @@ msgstr ""
29562956
msgid "Error occurred when toggling the notification subscription"
29572957
msgstr ""
29582958

2959+
msgid "Error rendering markdown preview"
2960+
msgstr ""
2961+
29592962
msgid "Error saving label update."
29602963
msgstr ""
29612964

spec/javascripts/vue_shared/components/markdown/suggestion_diff_header_spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ describe('Suggestion Diff component', () => {
3131
expect(header.innerHTML.includes('Suggested change')).toBe(true);
3232
});
3333

34+
it('renders a help button', () => {
35+
const helpBtn = vm.$el.querySelector('.js-help-btn');
36+
37+
expect(helpBtn).not.toBeNull();
38+
});
39+
3440
it('renders an apply button', () => {
3541
const applyBtn = vm.$el.querySelector('.qa-apply-btn');
3642

0 commit comments

Comments
 (0)