Commit e4e6401b authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/202305/commitGravatar' into 'master'

Get commit authors gravatar for last commit widget

Closes #202305

See merge request gitlab-org/gitlab!24604
parents 38e8ead9 5dce2e76
......@@ -108,7 +108,12 @@ export default {
class="avatar-cell"
/>
<span v-else class="avatar-cell user-avatar-link">
<img :src="$options.defaultAvatarUrl" width="40" height="40" class="avatar s40" />
<img
:src="commit.authorGravatar || $options.defaultAvatarUrl"
width="40"
height="40"
class="avatar s40"
/>
</span>
<div class="commit-detail flex-list">
<div class="commit-content qa-commit-content">
......
......@@ -10,6 +10,7 @@ query pathLastCommit($projectPath: ID!, $path: String, $ref: String!) {
webUrl
authoredDate
authorName
authorGravatar
author {
name
avatarUrl
......
......@@ -26,6 +26,11 @@ module Types
description: 'Rendered HTML of the commit signature'
field :author_name, type: GraphQL::STRING_TYPE, null: true,
description: 'Commit authors name'
field :author_gravatar, type: GraphQL::STRING_TYPE, null: true,
description: 'Commit authors gravatar',
resolve: -> (commit, args, context) do
GravatarService.new.execute(commit.author_email, 40)
end
# models/commit lazy loads the author by email
field :author, type: Types::UserType, null: true,
......
......@@ -165,6 +165,11 @@ type Commit {
"""
author: User
"""
Commit authors gravatar
"""
authorGravatar: String
"""
Commit authors name
"""
......
......@@ -13259,6 +13259,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "authorGravatar",
"description": "Commit authors gravatar",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "authorName",
"description": "Commit authors name",
......
......@@ -54,6 +54,7 @@ An emoji awarded by a user.
| Name | Type | Description |
| --- | ---- | ---------- |
| `author` | User | Author of the commit |
| `authorGravatar` | String | Commit authors gravatar |
| `authorName` | String | Commit authors name |
| `authoredDate` | Time | Timestamp of when the commit was authored |
| `description` | String | Description of the commit message |
......
......@@ -10,7 +10,8 @@ describe GitlabSchema.types['Commit'] do
it 'contains attributes related to commit' do
expect(described_class).to have_graphql_fields(
:id, :sha, :title, :description, :message, :authored_date,
:author_name, :author, :web_url, :latest_pipeline, :pipelines, :signature_html
:author_name, :author_gravatar, :author, :web_url, :latest_pipeline,
:pipelines, :signature_html
)
end
end
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