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
db2c78a9
Commit
db2c78a9
authored
Jul 07, 2021
by
Tom Quirk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create new project_avatar component
Adds a new project_avatar component, based on GitLab-ui GlAvatar
parent
9df6fc5f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
113 additions
and
0 deletions
+113
-0
app/assets/javascripts/vue_shared/components/project_avatar.stories.js
...vascripts/vue_shared/components/project_avatar.stories.js
+24
-0
app/assets/javascripts/vue_shared/components/project_avatar.vue
...sets/javascripts/vue_shared/components/project_avatar.vue
+35
-0
spec/frontend/vue_shared/components/project_avatar_spec.js
spec/frontend/vue_shared/components/project_avatar_spec.js
+54
-0
No files found.
app/assets/javascripts/vue_shared/components/project_avatar.stories.js
0 → 100644
View file @
db2c78a9
import
ProjectAvatar
from
'
./project_avatar.vue
'
;
export
default
{
component
:
ProjectAvatar
,
title
:
'
vue_shared/components/project_avatar
'
,
};
const
Template
=
(
args
,
{
argTypes
})
=>
({
components
:
{
ProjectAvatar
},
props
:
Object
.
keys
(
argTypes
),
template
:
'
<project-avatar v-bind="$props" v-on="$props" />
'
,
});
export
const
Default
=
Template
.
bind
({});
Default
.
args
=
{
projectAvatarUrl
:
'
https://gitlab.com/uploads/-/system/project/avatar/278964/logo-extra-whitespace.png?width=64
'
,
projectName
:
'
GitLab
'
,
};
export
const
FallbackAvatar
=
Template
.
bind
({});
FallbackAvatar
.
args
=
{
projectName
:
'
GitLab
'
,
};
app/assets/javascripts/vue_shared/components/project_avatar.vue
0 → 100644
View file @
db2c78a9
<
script
>
import
{
GlAvatar
}
from
'
@gitlab/ui
'
;
export
default
{
components
:
{
GlAvatar
,
},
props
:
{
projectName
:
{
type
:
String
,
required
:
true
,
},
projectAvatarUrl
:
{
type
:
String
,
required
:
false
,
default
:
undefined
,
},
size
:
{
type
:
Number
,
default
:
32
,
required
:
false
,
},
},
};
</
script
>
<
template
>
<gl-avatar
shape=
"rect"
:entity-name=
"projectName"
:src=
"projectAvatarUrl"
:alt=
"projectName"
:size=
"size"
/>
</
template
>
spec/frontend/vue_shared/components/project_avatar_spec.js
0 → 100644
View file @
db2c78a9
import
{
GlAvatar
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
ProjectAvatar
from
'
~/vue_shared/components/project_avatar.vue
'
;
const
defaultProps
=
{
projectName
:
'
GitLab
'
,
};
describe
(
'
ProjectAvatar
'
,
()
=>
{
let
wrapper
;
const
findGlAvatar
=
()
=>
wrapper
.
findComponent
(
GlAvatar
);
const
createComponent
=
({
props
}
=
{})
=>
{
wrapper
=
shallowMount
(
ProjectAvatar
,
{
propsData
:
{
...
defaultProps
,
...
props
}
});
};
afterEach
(()
=>
{
wrapper
.
destroy
();
});
it
(
'
renders GlAvatar with correct props
'
,
()
=>
{
createComponent
();
const
avatar
=
findGlAvatar
();
expect
(
avatar
.
exists
()).
toBe
(
true
);
expect
(
avatar
.
props
()).
toMatchObject
({
alt
:
defaultProps
.
projectName
,
entityName
:
defaultProps
.
projectName
,
size
:
32
,
src
:
''
,
});
});
describe
(
'
with `size` prop
'
,
()
=>
{
it
(
'
renders GlAvatar with specified `size` prop
'
,
()
=>
{
const
mockSize
=
48
;
createComponent
({
props
:
{
size
:
mockSize
}
});
const
avatar
=
findGlAvatar
();
expect
(
avatar
.
props
(
'
size
'
)).
toBe
(
mockSize
);
});
});
describe
(
'
with `projectAvatarUrl` prop
'
,
()
=>
{
it
(
'
renders GlAvatar with specified `src` prop
'
,
()
=>
{
const
mockProjectAvatarUrl
=
'
https://gitlab.com
'
;
createComponent
({
props
:
{
projectAvatarUrl
:
mockProjectAvatarUrl
}
});
const
avatar
=
findGlAvatar
();
expect
(
avatar
.
props
(
'
src
'
)).
toBe
(
mockProjectAvatarUrl
);
});
});
});
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