Commit cd1994c1 authored by Phil Hughes's avatar Phil Hughes Committed by Igor Drozdov

Fixes emojis not rendering in the Vue file list

Adds the rendered markdown HTML to the GraphQL endpoint.
Also adds the rendered markdown HTML to the logs endpoint.

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/212669
parent 26e53150
...@@ -121,9 +121,8 @@ export default { ...@@ -121,9 +121,8 @@ export default {
:href="commit.webUrl" :href="commit.webUrl"
:class="{ 'font-italic': !commit.message }" :class="{ 'font-italic': !commit.message }"
class="commit-row-message item-title" class="commit-row-message item-title"
> v-html="commit.titleHtml"
{{ commit.title }} />
</gl-link>
<gl-deprecated-button <gl-deprecated-button
v-if="commit.description" v-if="commit.description"
:class="{ open: showDescription }" :class="{ open: showDescription }"
......
...@@ -167,9 +167,8 @@ export default { ...@@ -167,9 +167,8 @@ export default {
:href="commit.commitPath" :href="commit.commitPath"
:title="commit.message" :title="commit.message"
class="str-truncated-100 tree-commit-link" class="str-truncated-100 tree-commit-link"
> v-html="commit.titleHtml"
{{ commit.message }} />
</gl-link>
<gl-skeleton-loading v-else :lines="1" class="h-auto" /> <gl-skeleton-loading v-else :lines="1" class="h-auto" />
</td> </td>
<td class="tree-time-ago text-right cursor-default"> <td class="tree-time-ago text-right cursor-default">
......
fragment TreeEntryCommit on LogTreeCommit { fragment TreeEntryCommit on LogTreeCommit {
sha sha
message message
titleHtml
committedDate committedDate
commitPath commitPath
fileName fileName
......
...@@ -5,6 +5,7 @@ query pathLastCommit($projectPath: ID!, $path: String, $ref: String!) { ...@@ -5,6 +5,7 @@ query pathLastCommit($projectPath: ID!, $path: String, $ref: String!) {
lastCommit { lastCommit {
sha sha
title title
titleHtml
description description
message message
webUrl webUrl
......
...@@ -3,6 +3,7 @@ export function normalizeData(data, path, extra = () => {}) { ...@@ -3,6 +3,7 @@ export function normalizeData(data, path, extra = () => {}) {
return data.map(d => ({ return data.map(d => ({
sha: d.commit.id, sha: d.commit.id,
message: d.commit.message, message: d.commit.message,
titleHtml: d.commit_title_html,
committedDate: d.commit.committed_date, committedDate: d.commit.committed_date,
commitPath: d.commit_path, commitPath: d.commit_path,
fileName: d.file_name, fileName: d.file_name,
......
...@@ -14,6 +14,7 @@ module Types ...@@ -14,6 +14,7 @@ module Types
description: 'SHA1 ID of the commit' description: 'SHA1 ID of the commit'
field :title, type: GraphQL::STRING_TYPE, null: true, calls_gitaly: true, field :title, type: GraphQL::STRING_TYPE, null: true, calls_gitaly: true,
description: 'Title of the commit message' description: 'Title of the commit message'
markdown_field :title_html, null: true
field :description, type: GraphQL::STRING_TYPE, null: true, field :description, type: GraphQL::STRING_TYPE, null: true,
description: 'Description of the commit message' description: 'Description of the commit message'
field :message, type: GraphQL::STRING_TYPE, null: true, field :message, type: GraphQL::STRING_TYPE, null: true,
......
---
title: Fixes commit message emojis not rendering in Vue file list
merge_request:
author:
type: fixed
...@@ -889,6 +889,11 @@ type Commit { ...@@ -889,6 +889,11 @@ type Commit {
""" """
title: String title: String
"""
The GitLab Flavored Markdown rendering of `title`
"""
titleHtml: String
""" """
Web URL of the commit Web URL of the commit
""" """
......
...@@ -2378,6 +2378,20 @@ ...@@ -2378,6 +2378,20 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "titleHtml",
"description": "The GitLab Flavored Markdown rendering of `title`",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "webUrl", "name": "webUrl",
"description": "Web URL of the commit", "description": "Web URL of the commit",
......
...@@ -161,6 +161,7 @@ Autogenerated return type of BoardListUpdateLimitMetrics ...@@ -161,6 +161,7 @@ Autogenerated return type of BoardListUpdateLimitMetrics
| `sha` | String! | SHA1 ID of the commit | | `sha` | String! | SHA1 ID of the commit |
| `signatureHtml` | String | Rendered HTML of the commit signature | | `signatureHtml` | String | Rendered HTML of the commit signature |
| `title` | String | Title of the commit message | | `title` | String | Title of the commit message |
| `titleHtml` | String | The GitLab Flavored Markdown rendering of `title` |
| `webUrl` | String! | Web URL of the commit | | `webUrl` | String! | Web URL of the commit |
## CreateBranchPayload ## CreateBranchPayload
......
fragment TreeEntryCommit on LogTreeCommit { fragment TreeEntryCommit on LogTreeCommit {
sha sha
message message
titleHtml
committedDate committedDate
commitPath commitPath
fileName fileName
......
...@@ -8,6 +8,7 @@ const mockData = [ ...@@ -8,6 +8,7 @@ const mockData = [
committed_date: '2019-01-01', committed_date: '2019-01-01',
}, },
commit_path: `https://test.com`, commit_path: `https://test.com`,
commit_title_html: 'testing message',
file_name: 'index.js', file_name: 'index.js',
type: 'blob', type: 'blob',
lock_label: 'Locked', lock_label: 'Locked',
...@@ -26,6 +27,7 @@ describe('normalizeData', () => { ...@@ -26,6 +27,7 @@ describe('normalizeData', () => {
filePath: '/index.js', filePath: '/index.js',
type: 'blob', type: 'blob',
lockLabel: 'Locked', lockLabel: 'Locked',
titleHtml: 'testing message',
__typename: 'LogTreeCommit', __typename: 'LogTreeCommit',
}, },
]); ]);
...@@ -45,6 +47,7 @@ describe('normalizeData', () => { ...@@ -45,6 +47,7 @@ describe('normalizeData', () => {
filePath: '/index.js', filePath: '/index.js',
type: 'blob', type: 'blob',
lockLabel: false, lockLabel: false,
titleHtml: 'testing message',
__typename: 'LogTreeCommit', __typename: 'LogTreeCommit',
}, },
]); ]);
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
module Gitlab module Gitlab
class TreeSummary class TreeSummary
include ::Gitlab::Utils::StrongMemoize include ::Gitlab::Utils::StrongMemoize
include ::MarkupHelper
CACHE_EXPIRE_IN = 1.hour CACHE_EXPIRE_IN = 1.hour
MAX_OFFSET = 2**31 MAX_OFFSET = 2**31
...@@ -104,6 +105,7 @@ module Gitlab ...@@ -104,6 +105,7 @@ module Gitlab
if commit if commit
entry[:commit] = commit entry[:commit] = commit
entry[:commit_path] = commit_path(commit) entry[:commit_path] = commit_path(commit)
entry[:commit_title_html] = markdown_field(commit, :title)
end end
end end
end end
......
...@@ -171,6 +171,18 @@ describe "User browses files" do ...@@ -171,6 +171,18 @@ describe "User browses files" do
end end
end end
context 'when commit message has markdown', :js do
before do
project.repository.create_file(user, 'index', 'test', message: ':star: testing', branch_name: 'master')
visit(project_tree_path(project, "master"))
end
it 'renders emojis' do
expect(page).to have_selector('gl-emoji', count: 2)
end
end
context "when browsing a `improve/awesome` branch", :js do context "when browsing a `improve/awesome` branch", :js do
before do before do
visit(project_tree_path(project, "improve/awesome")) visit(project_tree_path(project, "improve/awesome"))
......
...@@ -26,9 +26,7 @@ exports[`Repository last commit component renders commit widget 1`] = ` ...@@ -26,9 +26,7 @@ exports[`Repository last commit component renders commit widget 1`] = `
class="commit-row-message item-title" class="commit-row-message item-title"
href="https://test.com/commit/123" href="https://test.com/commit/123"
> >
Commit title
Commit title
</gl-link-stub> </gl-link-stub>
<!----> <!---->
...@@ -128,9 +126,7 @@ exports[`Repository last commit component renders the signature HTML as returned ...@@ -128,9 +126,7 @@ exports[`Repository last commit component renders the signature HTML as returned
class="commit-row-message item-title" class="commit-row-message item-title"
href="https://test.com/commit/123" href="https://test.com/commit/123"
> >
Commit title
Commit title
</gl-link-stub> </gl-link-stub>
<!----> <!---->
......
...@@ -9,6 +9,7 @@ function createCommitData(data = {}) { ...@@ -9,6 +9,7 @@ function createCommitData(data = {}) {
const defaultData = { const defaultData = {
sha: '123456789', sha: '123456789',
title: 'Commit title', title: 'Commit title',
titleHtml: 'Commit title',
message: 'Commit message', message: 'Commit message',
webUrl: 'https://test.com/commit/123', webUrl: 'https://test.com/commit/123',
authoredDate: '2019-01-01', authoredDate: '2019-01-01',
......
...@@ -8,6 +8,7 @@ const mockData = [ ...@@ -8,6 +8,7 @@ const mockData = [
committed_date: '2019-01-01', committed_date: '2019-01-01',
}, },
commit_path: `https://test.com`, commit_path: `https://test.com`,
commit_title_html: 'testing message',
file_name: 'index.js', file_name: 'index.js',
type: 'blob', type: 'blob',
}, },
...@@ -24,6 +25,7 @@ describe('normalizeData', () => { ...@@ -24,6 +25,7 @@ describe('normalizeData', () => {
fileName: 'index.js', fileName: 'index.js',
filePath: '/index.js', filePath: '/index.js',
type: 'blob', type: 'blob',
titleHtml: 'testing message',
__typename: 'LogTreeCommit', __typename: 'LogTreeCommit',
}, },
]); ]);
......
...@@ -9,7 +9,7 @@ describe GitlabSchema.types['Commit'] do ...@@ -9,7 +9,7 @@ describe GitlabSchema.types['Commit'] do
it 'contains attributes related to commit' do it 'contains attributes related to commit' do
expect(described_class).to have_graphql_fields( expect(described_class).to have_graphql_fields(
:id, :sha, :title, :description, :message, :authored_date, :id, :sha, :title, :description, :message, :title_html, :authored_date,
:author_name, :author_gravatar, :author, :web_url, :latest_pipeline, :author_name, :author_gravatar, :author, :web_url, :latest_pipeline,
:pipelines, :signature_html :pipelines, :signature_html
) )
......
...@@ -72,7 +72,8 @@ describe Gitlab::TreeSummary do ...@@ -72,7 +72,8 @@ describe Gitlab::TreeSummary do
expected_commit_path = Gitlab::Routing.url_helpers.project_commit_path(project, commit) expected_commit_path = Gitlab::Routing.url_helpers.project_commit_path(project, commit)
expect(entry[:commit]).to be_a(::Commit) expect(entry[:commit]).to be_a(::Commit)
expect(entry[:commit_path]).to eq expected_commit_path expect(entry[:commit_path]).to eq(expected_commit_path)
expect(entry[:commit_title_html]).to eq(commit.message)
end end
context 'in a good subdirectory' do context 'in a good subdirectory' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment