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
1056b8e7
Commit
1056b8e7
authored
Apr 19, 2022
by
Tom Quirk
Committed by
Miguel Rincon
Apr 19, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use GlAvatar in environments dashboard
Changelog: changed
parent
60afa0a4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
36 deletions
+85
-36
app/assets/javascripts/environments/components/environment_item.vue
.../javascripts/environments/components/environment_item.vue
+43
-25
spec/frontend/environments/environment_item_spec.js
spec/frontend/environments/environment_item_spec.js
+42
-11
No files found.
app/assets/javascripts/environments/components/environment_item.vue
View file @
1056b8e7
<
script
>
<
script
>
import
{
GlDropdown
,
GlTooltipDirective
,
GlIcon
,
GlLink
,
GlSprintf
,
GlBadge
}
from
'
@gitlab/ui
'
;
import
{
GlDropdown
,
GlTooltipDirective
,
GlIcon
,
GlLink
,
GlSprintf
,
GlBadge
,
GlAvatar
,
GlAvatarLink
,
}
from
'
@gitlab/ui
'
;
import
{
isEmpty
}
from
'
lodash
'
;
import
{
isEmpty
}
from
'
lodash
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
{
__
,
s__
,
sprintf
}
from
'
~/locale
'
;
import
{
__
,
s__
,
sprintf
}
from
'
~/locale
'
;
import
CiIcon
from
'
~/vue_shared/components/ci_icon.vue
'
;
import
CiIcon
from
'
~/vue_shared/components/ci_icon.vue
'
;
import
CommitComponent
from
'
~/vue_shared/components/commit.vue
'
;
import
CommitComponent
from
'
~/vue_shared/components/commit.vue
'
;
import
TooltipOnTruncate
from
'
~/vue_shared/components/tooltip_on_truncate/tooltip_on_truncate.vue
'
;
import
TooltipOnTruncate
from
'
~/vue_shared/components/tooltip_on_truncate/tooltip_on_truncate.vue
'
;
import
UserAvatarLink
from
'
~/vue_shared/components/user_avatar/user_avatar_link.vue
'
;
import
timeagoMixin
from
'
~/vue_shared/mixins/timeago
'
;
import
timeagoMixin
from
'
~/vue_shared/mixins/timeago
'
;
import
eventHub
from
'
../event_hub
'
;
import
eventHub
from
'
../event_hub
'
;
import
ActionsComponent
from
'
./environment_actions.vue
'
;
import
ActionsComponent
from
'
./environment_actions.vue
'
;
...
@@ -41,7 +49,8 @@ export default {
...
@@ -41,7 +49,8 @@ export default {
StopComponent
,
StopComponent
,
TerminalButtonComponent
,
TerminalButtonComponent
,
TooltipOnTruncate
,
TooltipOnTruncate
,
UserAvatarLink
,
GlAvatar
,
GlAvatarLink
,
CiIcon
,
CiIcon
,
},
},
directives
:
{
directives
:
{
...
@@ -649,22 +658,27 @@ export default {
...
@@ -649,22 +658,27 @@ export default {
class=
"table-section deployment-column d-none d-md-block"
class=
"table-section deployment-column d-none d-md-block"
:class=
"tableData.deploy.spacing"
:class=
"tableData.deploy.spacing"
role=
"gridcell"
role=
"gridcell"
data-testid=
"envi
or
nment-deployment-id-cell"
data-testid=
"envi
ro
nment-deployment-id-cell"
>
>
<span
v-if=
"shouldRenderDeploymentID"
class=
"text-break-word"
>
<span
v-if=
"shouldRenderDeploymentID"
class=
"text-break-word"
>
{{
deploymentInternalId
}}
{{
deploymentInternalId
}}
</span>
</span>
<span
v-if=
"!isFolder && deploymentHasUser"
class=
"text-break-word"
>
<span
v-if=
"!isFolder && deploymentHasUser"
class=
"text-break-word gl-display-inline-flex gl-align-items-center"
>
<gl-sprintf
:message=
"s__('Environments|by %
{avatar}')">
<gl-sprintf
:message=
"s__('Environments|by %
{avatar}')">
<template
#avatar
>
<template
#avatar
>
<user-avatar-link
<gl-avatar-link
:href=
"deploymentUser.web_url"
class=
"gl-ml-2"
>
:link-href=
"deploymentUser.web_url"
<gl-avatar
:img-src=
"deploymentUser.avatar_url"
:src=
"deploymentUser.avatar_url"
:img-alt=
"userImageAltDescription"
:entity-name=
"deploymentUser.username"
:tooltip-text=
"deploymentUser.username"
:title=
"deploymentUser.username"
class=
"js-deploy-user-container float-none"
:alt=
"userImageAltDescription"
/>
:size=
"24"
/>
</gl-avatar-link>
</
template
>
</
template
>
</gl-sprintf>
</gl-sprintf>
</span>
</span>
...
@@ -753,20 +767,24 @@ export default {
...
@@ -753,20 +767,24 @@ export default {
<ci-icon
class=
"gl-mr-2"
:status=
"upcomingDeployment.deployable.status"
/>
<ci-icon
class=
"gl-mr-2"
:status=
"upcomingDeployment.deployable.status"
/>
</gl-link>
</gl-link>
</div>
</div>
<div
class=
"gl-display-flex"
>
<span
<span
v-if=
"upcomingDeployment.user"
class=
"text-break-word"
>
v-if=
"upcomingDeployment.user"
<gl-sprintf
:message=
"s__('Environments|by %{avatar}')"
>
class=
"text-break-word gl-display-inline-flex gl-align-items-center gl-mt-2"
<
template
#avatar
>
>
<user-avatar-link
<gl-sprintf
:message=
"s__('Environments|by %{avatar}')"
>
:link-href=
"upcomingDeployment.user.web_url"
<
template
#avatar
>
:img-src=
"upcomingDeployment.user.avatar_url"
<gl-avatar-link
:href=
"upcomingDeployment.user.web_url"
class=
"gl-ml-2"
>
:img-alt=
"upcomingDeploymentUserImageAltDescription"
<gl-avatar
:tooltip-text=
"upcomingDeployment.user.username"
:src=
"upcomingDeployment.user.avatar_url"
:alt=
"upcomingDeploymentUserImageAltDescription"
:entity-name=
"upcomingDeployment.user.username"
:title=
"upcomingDeployment.user.username"
:size=
"24"
/>
/>
</
template
>
</
gl-avatar-link
>
</
gl-sprintf
>
</
template
>
</
span
>
</
gl-sprintf
>
</
div
>
</
span
>
</div>
</div>
</div>
</div>
...
...
spec/frontend/environments/environment_item_spec.js
View file @
1056b8e7
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
GlAvatarLink
,
GlAvatar
}
from
'
@gitlab/ui
'
;
import
{
cloneDeep
}
from
'
lodash
'
;
import
{
cloneDeep
}
from
'
lodash
'
;
import
{
format
}
from
'
timeago.js
'
;
import
{
format
}
from
'
timeago.js
'
;
import
{
mockTracking
,
unmockTracking
,
triggerEvent
}
from
'
helpers/tracking_helper
'
;
import
{
mockTracking
,
unmockTracking
,
triggerEvent
}
from
'
helpers/tracking_helper
'
;
...
@@ -44,10 +45,16 @@ describe('Environment item', () => {
...
@@ -44,10 +45,16 @@ describe('Environment item', () => {
const
findAutoStop
=
()
=>
wrapper
.
find
(
'
.js-auto-stop
'
);
const
findAutoStop
=
()
=>
wrapper
.
find
(
'
.js-auto-stop
'
);
const
findUpcomingDeployment
=
()
=>
wrapper
.
find
(
'
[data-testid="upcoming-deployment"]
'
);
const
findUpcomingDeployment
=
()
=>
wrapper
.
find
(
'
[data-testid="upcoming-deployment"]
'
);
const
findLastDeployment
=
()
=>
wrapper
.
find
(
'
[data-testid="environment-deployment-id-cell"]
'
);
const
findUpcomingDeploymentContent
=
()
=>
const
findUpcomingDeploymentContent
=
()
=>
wrapper
.
find
(
'
[data-testid="upcoming-deployment-content"]
'
);
wrapper
.
find
(
'
[data-testid="upcoming-deployment-content"]
'
);
const
findUpcomingDeploymentStatusLink
=
()
=>
const
findUpcomingDeploymentStatusLink
=
()
=>
wrapper
.
find
(
'
[data-testid="upcoming-deployment-status-link"]
'
);
wrapper
.
find
(
'
[data-testid="upcoming-deployment-status-link"]
'
);
const
findLastDeploymentAvatarLink
=
()
=>
findLastDeployment
().
findComponent
(
GlAvatarLink
);
const
findLastDeploymentAvatar
=
()
=>
findLastDeployment
().
findComponent
(
GlAvatar
);
const
findUpcomingDeploymentAvatarLink
=
()
=>
findUpcomingDeployment
().
findComponent
(
GlAvatarLink
);
const
findUpcomingDeploymentAvatar
=
()
=>
findUpcomingDeployment
().
findComponent
(
GlAvatar
);
afterEach
(()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
.
destroy
();
...
@@ -79,9 +86,19 @@ describe('Environment item', () => {
...
@@ -79,9 +86,19 @@ describe('Environment item', () => {
describe
(
'
With user information
'
,
()
=>
{
describe
(
'
With user information
'
,
()
=>
{
it
(
'
should render user avatar with link to profile
'
,
()
=>
{
it
(
'
should render user avatar with link to profile
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-deploy-user-container
'
).
props
(
'
linkHref
'
)).
toEqual
(
const
avatarLink
=
findLastDeploymentAvatarLink
();
environment
.
last_deployment
.
user
.
web_url
,
const
avatar
=
findLastDeploymentAvatar
();
);
const
{
username
,
avatar_url
,
web_url
}
=
environment
.
last_deployment
.
user
;
expect
(
avatarLink
.
attributes
(
'
href
'
)).
toBe
(
web_url
);
expect
(
avatar
.
props
()).
toMatchObject
({
src
:
avatar_url
,
entityName
:
username
,
});
expect
(
avatar
.
attributes
()).
toMatchObject
({
title
:
username
,
alt
:
`
${
username
}
's avatar`
,
});
});
});
});
});
...
@@ -108,9 +125,16 @@ describe('Environment item', () => {
...
@@ -108,9 +125,16 @@ describe('Environment item', () => {
describe
(
'
When the envionment has an upcoming deployment
'
,
()
=>
{
describe
(
'
When the envionment has an upcoming deployment
'
,
()
=>
{
describe
(
'
When the upcoming deployment has a deployable
'
,
()
=>
{
describe
(
'
When the upcoming deployment has a deployable
'
,
()
=>
{
it
(
'
should render the build ID and user
'
,
()
=>
{
it
(
'
should render the build ID and user
'
,
()
=>
{
expect
(
findUpcomingDeploymentContent
().
text
()).
toMatchInterpolatedText
(
const
avatarLink
=
findUpcomingDeploymentAvatarLink
();
'
#27 by upcoming-username
'
,
const
avatar
=
findUpcomingDeploymentAvatar
();
);
const
{
username
,
avatar_url
,
web_url
}
=
environment
.
upcoming_deployment
.
user
;
expect
(
findUpcomingDeploymentContent
().
text
()).
toMatchInterpolatedText
(
'
#27 by
'
);
expect
(
avatarLink
.
attributes
(
'
href
'
)).
toBe
(
web_url
);
expect
(
avatar
.
props
()).
toMatchObject
({
src
:
avatar_url
,
entityName
:
username
,
});
});
});
it
(
'
should render a status icon with a link and tooltip
'
,
()
=>
{
it
(
'
should render a status icon with a link and tooltip
'
,
()
=>
{
...
@@ -139,10 +163,17 @@ describe('Environment item', () => {
...
@@ -139,10 +163,17 @@ describe('Environment item', () => {
});
});
});
});
it
(
'
should still renders the build ID and user
'
,
()
=>
{
it
(
'
should still render the build ID and user avatar
'
,
()
=>
{
expect
(
findUpcomingDeploymentContent
().
text
()).
toMatchInterpolatedText
(
const
avatarLink
=
findUpcomingDeploymentAvatarLink
();
'
#27 by upcoming-username
'
,
const
avatar
=
findUpcomingDeploymentAvatar
();
);
const
{
username
,
avatar_url
,
web_url
}
=
environment
.
upcoming_deployment
.
user
;
expect
(
findUpcomingDeploymentContent
().
text
()).
toMatchInterpolatedText
(
'
#27 by
'
);
expect
(
avatarLink
.
attributes
(
'
href
'
)).
toBe
(
web_url
);
expect
(
avatar
.
props
()).
toMatchObject
({
src
:
avatar_url
,
entityName
:
username
,
});
});
});
it
(
'
should not render the status icon
'
,
()
=>
{
it
(
'
should not render the status icon
'
,
()
=>
{
...
@@ -383,7 +414,7 @@ describe('Environment item', () => {
...
@@ -383,7 +414,7 @@ describe('Environment item', () => {
});
});
it
(
'
should hide non-folder properties
'
,
()
=>
{
it
(
'
should hide non-folder properties
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
[data-testid="environment-deployment-id-cell"]
'
).
exists
()).
toBe
(
false
);
expect
(
findLastDeployment
(
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
'
[data-testid="environment-build-cell"]
'
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
'
[data-testid="environment-build-cell"]
'
).
exists
()).
toBe
(
false
);
});
});
});
});
...
...
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