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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
b43b0cdf
Commit
b43b0cdf
authored
Jan 15, 2021
by
Kev
Committed by
Stan Hu
Jan 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show status of snippet author in header
parent
1cc51c95
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
6 deletions
+50
-6
app/assets/javascripts/snippets/components/snippet_header.vue
...assets/javascripts/snippets/components/snippet_header.vue
+7
-0
app/graphql/queries/snippet/snippet.query.graphql
app/graphql/queries/snippet/snippet.query.graphql
+5
-0
changelogs/unreleased/262394-show-status-of-snippet-author.yml
...elogs/unreleased/262394-show-status-of-snippet-author.yml
+5
-0
spec/frontend/snippets/components/snippet_header_spec.js
spec/frontend/snippets/components/snippet_header_spec.js
+33
-6
No files found.
app/assets/javascripts/snippets/components/snippet_header.vue
View file @
b43b0cdf
...
...
@@ -200,6 +200,13 @@ export default {
<
gl
-
avatar
:
size
=
"
24
"
:
src
=
"
snippet.author.avatarUrl
"
/>
<
span
class
=
"
bold
"
>
{{
snippet
.
author
.
name
}}
<
/span
>
<
/a
>
<
gl
-
emoji
v
-
if
=
"
snippet.author.status
"
v
-
gl
-
tooltip
class
=
"
gl-vertical-align-baseline font-size-inherit gl-mr-1
"
:
title
=
"
snippet.author.status.message
"
:
data
-
name
=
"
snippet.author.status.emoji
"
/>
<
/template
>
<
/gl-sprintf
>
<
/div
>
...
...
app/graphql/queries/snippet/snippet.query.graphql
View file @
b43b0cdf
...
...
@@ -59,6 +59,11 @@ query GetSnippetQuery($ids: [SnippetID!]) {
name
username
webUrl
status
{
__typename
emoji
message
}
}
}
}
...
...
changelogs/unreleased/262394-show-status-of-snippet-author.yml
0 → 100644
View file @
b43b0cdf
---
title
:
Show status of snippet author in header
merge_request
:
51030
author
:
Kev @KevSlashNull
type
:
fixed
spec/frontend/snippets/components/snippet_header_spec.js
View file @
b43b0cdf
...
...
@@ -17,6 +17,8 @@ describe('Snippet header component', () => {
let
err
;
const
originalRelativeUrlRoot
=
gon
.
relative_url_root
;
const
GlEmoji
=
{
template
:
'
<img/>
'
};
function
createComponent
({
loading
=
false
,
permissions
=
{},
...
...
@@ -47,10 +49,15 @@ describe('Snippet header component', () => {
},
stubs
:
{
ApolloMutation
,
GlEmoji
,
},
});
}
const
findAuthorEmoji
=
()
=>
wrapper
.
find
(
GlEmoji
);
const
findAuthoredMessage
=
()
=>
wrapper
.
find
(
'
[data-testid="authored-message"]
'
).
text
();
const
buttonCount
=
()
=>
wrapper
.
findAll
(
GlButton
).
length
;
beforeEach
(()
=>
{
gon
.
relative_url_root
=
'
/foo/
'
;
snippet
=
{
...
...
@@ -66,6 +73,7 @@ describe('Snippet header component', () => {
project
:
null
,
author
:
{
name
:
'
Thor Odinson
'
,
status
:
null
,
},
blobs
:
[
Blob
],
createdAt
:
new
Date
(
differenceInMilliseconds
(
32
*
24
*
3600
*
1000
)).
toISOString
(),
...
...
@@ -100,17 +108,36 @@ describe('Snippet header component', () => {
it
(
'
renders a message showing snippet creation date and author
'
,
()
=>
{
createComponent
();
const
text
=
wrapper
.
find
(
'
[data-testid="authored-message"]
'
).
text
();
const
text
=
findAuthoredMessage
();
expect
(
text
).
toContain
(
'
Authored 1 month ago by
'
);
expect
(
text
).
toContain
(
'
Thor Odinson
'
);
});
describe
(
'
author status
'
,
()
=>
{
it
(
'
is rendered when it is set
'
,
()
=>
{
snippet
.
author
.
status
=
{
message
:
'
At work
'
,
emoji
:
'
hammer
'
,
};
createComponent
();
expect
(
findAuthorEmoji
().
attributes
(
'
title
'
)).
toBe
(
snippet
.
author
.
status
.
message
);
expect
(
findAuthorEmoji
().
attributes
(
'
data-name
'
)).
toBe
(
snippet
.
author
.
status
.
emoji
);
});
it
(
'
is not rendered when the user has no status
'
,
()
=>
{
createComponent
();
expect
(
findAuthorEmoji
().
exists
()).
toBe
(
false
);
});
});
it
(
'
renders a message showing only snippet creation date if author is null
'
,
()
=>
{
snippet
.
author
=
null
;
createComponent
();
const
text
=
wrapper
.
find
(
'
[data-testid="authored-message"]
'
).
text
();
const
text
=
findAuthoredMessage
();
expect
(
text
).
toBe
(
'
Authored 1 month ago
'
);
});
...
...
@@ -121,7 +148,7 @@ describe('Snippet header component', () => {
updateSnippet
:
false
,
},
});
expect
(
wrapper
.
findAll
(
GlButton
).
length
).
toEqual
(
0
);
expect
(
buttonCount
()
).
toEqual
(
0
);
createComponent
({
permissions
:
{
...
...
@@ -129,7 +156,7 @@ describe('Snippet header component', () => {
updateSnippet
:
false
,
},
});
expect
(
wrapper
.
findAll
(
GlButton
).
length
).
toEqual
(
1
);
expect
(
buttonCount
()
).
toEqual
(
1
);
createComponent
({
permissions
:
{
...
...
@@ -137,7 +164,7 @@ describe('Snippet header component', () => {
updateSnippet
:
true
,
},
});
expect
(
wrapper
.
findAll
(
GlButton
).
length
).
toEqual
(
2
);
expect
(
buttonCount
()
).
toEqual
(
2
);
createComponent
({
permissions
:
{
...
...
@@ -149,7 +176,7 @@ describe('Snippet header component', () => {
canCreateSnippet
:
true
,
});
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
expect
(
wrapper
.
findAll
(
GlButton
).
length
).
toEqual
(
3
);
expect
(
buttonCount
()
).
toEqual
(
3
);
});
});
...
...
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