BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
d7f68bcf
Commit
d7f68bcf
authored
Apr 23, 2018
by
Tim Zallmann
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fl-prettify-2' into 'master'
Runs prettier on some vue shared components See merge request gitlab-org/gitlab-ce!18487
parents
14981d51
d7642137
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
261 additions
and
269 deletions
+261
-269
commit.vue
app/assets/javascripts/vue_shared/components/commit.vue
+103
-112
expand_button.vue
...ssets/javascripts/vue_shared/components/expand_button.vue
+27
-27
header_ci_component.vue
...javascripts/vue_shared/components/header_ci_component.vue
+66
-66
icon.vue
app/assets/javascripts/vue_shared/components/icon.vue
+59
-59
commit_spec.js
spec/javascripts/vue_shared/components/commit_spec.js
+4
-3
expand_button_spec.js
spec/javascripts/vue_shared/components/expand_button_spec.js
+2
-2
No files found.
app/assets/javascripts/vue_shared/components/commit.vue
View file @
d7f68bcf
<
script
>
import
commitIconSvg
from
'icons/_icon_commit.svg'
;
import
userAvatarLink
from
'./user_avatar/user_avatar_link.vue'
;
import
tooltip
from
'../directives/tooltip'
;
import
icon
from
'../../vue_shared/components/icon.vue'
;
import
UserAvatarLink
from
'./user_avatar/user_avatar_link.vue'
;
import
tooltip
from
'../directives/tooltip'
;
import
Icon
from
'../../vue_shared/components/icon.vue'
;
export
default
{
directives
:
{
tooltip
,
export
default
{
directives
:
{
tooltip
,
},
components
:
{
UserAvatarLink
,
Icon
,
},
props
:
{
/**
* Indicates the existance of a tag.
* Used to render the correct icon, if true will render `fa-tag` icon,
* if false will render a svg sprite fork icon
*/
tag
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
components
:
{
userAvatarLink
,
icon
,
/**
* If provided is used to render the branch name and url.
* Should contain the following properties:
* name
* ref_url
*/
commitRef
:
{
type
:
Object
,
required
:
false
,
default
:
()
=>
({}),
},
/**
* Used to link to the commit sha.
*/
commitUrl
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
props
:
{
/**
* Indicates the existance of a tag.
* Used to render the correct icon, if true will render `fa-tag` icon,
* if false will render a svg sprite fork icon
*/
tag
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
/**
* If provided is used to render the branch name and url.
* Should contain the following properties:
* name
* ref_url
*/
commitRef
:
{
type
:
Object
,
required
:
false
,
default
:
()
=>
({}),
},
/**
* Used to link to the commit sha.
*/
commitUrl
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
/**
* Used to show the commit short sha that links to the commit url.
*/
shortSha
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
/**
* If provided shows the commit tile.
*/
title
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
/**
* If provided renders information about the author of the commit.
* When provided should include:
* `avatar_url` to render the avatar icon
* `web_url` to link to user profile
* `username` to render alt and title tags
*/
author
:
{
type
:
Object
,
required
:
false
,
default
:
()
=>
({}),
},
showBranch
:
{
type
:
Boolean
,
required
:
false
,
default
:
true
,
},
/**
* Used to show the commit short sha that links to the commit url.
*/
shortSha
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
/**
* If provided shows the commit tile.
*/
title
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
/**
* If provided renders information about the author of the commit.
* When provided should include:
* `avatar_url` to render the avatar icon
* `web_url` to link to user profile
* `username` to render alt and title tags
*/
author
:
{
type
:
Object
,
required
:
false
,
default
:
()
=>
({}),
},
showBranch
:
{
type
:
Boolean
,
required
:
false
,
default
:
true
,
},
computed
:
{
/**
* Used to verify if all the properties needed to render the commit
* ref section were provided.
*
* @returns {Boolean}
*/
hasCommitRef
()
{
return
this
.
commitRef
&&
this
.
commitRef
.
name
&&
this
.
commitRef
.
ref_url
;
},
/**
* Used to verify if all the properties needed to render the commit
* author section were provided.
*
* @returns {Boolean}
*/
hasAuthor
()
{
return
this
.
author
&&
this
.
author
.
avatar_url
&&
this
.
author
.
path
&&
this
.
author
.
username
;
},
/**
* If information about the author is provided will return a string
* to be rendered as the alt attribute of the img tag.
*
* @returns {String}
*/
userImageAltDescription
()
{
return
this
.
author
&&
this
.
author
.
username
?
`
${
this
.
author
.
username
}
's avatar`
:
null
;
},
},
computed
:
{
/**
* Used to verify if all the properties needed to render the commit
* ref section were provided.
*
* @returns {Boolean}
*/
hasCommitRef
()
{
return
this
.
commitRef
&&
this
.
commitRef
.
name
&&
this
.
commitRef
.
ref_url
;
},
created
()
{
this
.
commitIconSvg
=
commitIconSvg
;
/**
* Used to verify if all the properties needed to render the commit
* author section were provided.
*
* @returns {Boolean}
*/
hasAuthor
()
{
return
this
.
author
&&
this
.
author
.
avatar_url
&&
this
.
author
.
path
&&
this
.
author
.
username
;
},
};
/**
* If information about the author is provided will return a string
* to be rendered as the alt attribute of the img tag.
*
* @returns {String}
*/
userImageAltDescription
()
{
return
this
.
author
&&
this
.
author
.
username
?
`
${
this
.
author
.
username
}
's avatar`
:
null
;
},
},
};
</
script
>
<
template
>
<div
class=
"branch-commit"
>
...
...
@@ -141,11 +133,10 @@
{{
commitRef
.
name
}}
</a>
</
template
>
<
div
v-html=
"commitIconSvg
"
<
icon
name=
"commit
"
class=
"commit-icon js-commit-icon"
>
</div>
/>
<a
class=
"commit-sha"
...
...
app/assets/javascripts/vue_shared/components/expand_button.vue
View file @
d7f68bcf
<
script
>
import
{
__
}
from
'~/locale'
;
/**
* Port of detail_behavior expand button.
*
* @example
* <expand-button>
* <template slot="expanded">
* Text goes here.
* </template>
* </expand-button>
*/
export
default
{
name
:
'ExpandButton'
,
data
()
{
return
{
isCollapsed
:
true
,
};
import
{
__
}
from
'~/locale'
;
/**
* Port of detail_behavior expand button.
*
* @example
* <expand-button>
* <template slot="expanded">
* Text goes here.
* </template>
* </expand-button>
*/
export
default
{
name
:
'ExpandButton'
,
data
()
{
return
{
isCollapsed
:
true
,
};
},
computed
:
{
ariaLabel
()
{
return
__
(
'Click to expand text'
);
},
computed
:
{
ariaLabel
()
{
return
__
(
'Click to expand text'
);
},
},
methods
:
{
onClick
()
{
this
.
isCollapsed
=
!
this
.
isCollapsed
;
},
methods
:
{
onClick
()
{
this
.
isCollapsed
=
!
this
.
isCollapsed
;
},
},
};
},
};
</
script
>
<
template
>
<span>
...
...
app/assets/javascripts/vue_shared/components/header_ci_component.vue
View file @
d7f68bcf
<
script
>
import
c
iIconBadge
from
'./ci_badge_link.vue'
;
import
l
oadingIcon
from
'./loading_icon.vue'
;
import
t
imeagoTooltip
from
'./time_ago_tooltip.vue'
;
import
tooltip
from
'../directives/tooltip'
;
import
u
serAvatarImage
from
'./user_avatar/user_avatar_image.vue'
;
import
C
iIconBadge
from
'./ci_badge_link.vue'
;
import
L
oadingIcon
from
'./loading_icon.vue'
;
import
T
imeagoTooltip
from
'./time_ago_tooltip.vue'
;
import
tooltip
from
'../directives/tooltip'
;
import
U
serAvatarImage
from
'./user_avatar/user_avatar_image.vue'
;
/**
* Renders header component for job and pipeline page based on UI mockups
*
* Used in:
* - job show page
* - pipeline show page
*/
export
default
{
components
:
{
ciIconBadge
,
loadingIcon
,
timeagoTooltip
,
userAvatarImage
,
/**
* Renders header component for job and pipeline page based on UI mockups
*
* Used in:
* - job show page
* - pipeline show page
*/
export
default
{
components
:
{
CiIconBadge
,
LoadingIcon
,
TimeagoTooltip
,
UserAvatarImage
,
},
directives
:
{
tooltip
,
},
props
:
{
status
:
{
type
:
Object
,
required
:
true
,
},
directives
:
{
tooltip
,
itemName
:
{
type
:
String
,
required
:
true
,
},
props
:
{
status
:
{
type
:
Object
,
required
:
true
,
},
itemName
:
{
type
:
String
,
required
:
true
,
},
itemId
:
{
type
:
Number
,
required
:
true
,
},
time
:
{
type
:
String
,
required
:
true
,
},
user
:
{
type
:
Object
,
required
:
false
,
default
:
()
=>
({}),
},
actions
:
{
type
:
Array
,
required
:
false
,
default
:
()
=>
[],
},
hasSidebarButton
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
shouldRenderTriggeredLabel
:
{
type
:
Boolean
,
required
:
false
,
default
:
true
,
},
itemId
:
{
type
:
Number
,
required
:
true
,
},
time
:
{
type
:
String
,
required
:
true
,
},
user
:
{
type
:
Object
,
required
:
false
,
default
:
()
=>
({}),
},
actions
:
{
type
:
Array
,
required
:
false
,
default
:
()
=>
[],
},
hasSidebarButton
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
shouldRenderTriggeredLabel
:
{
type
:
Boolean
,
required
:
false
,
default
:
true
,
},
},
computed
:
{
userAvatarAltText
()
{
return
`
${
this
.
user
.
name
}
's avatar`
;
},
computed
:
{
userAvatarAltText
()
{
return
`
${
this
.
user
.
name
}
's avatar`
;
},
},
methods
:
{
onClickAction
(
action
)
{
this
.
$emit
(
'actionClicked'
,
action
);
},
methods
:
{
onClickAction
(
action
)
{
this
.
$emit
(
'actionClicked'
,
action
);
},
};
},
};
</
script
>
<
template
>
...
...
app/assets/javascripts/vue_shared/components/icon.vue
View file @
d7f68bcf
<
script
>
/* This is a re-usable vue component for rendering a svg sprite
icon
/* This is a re-usable vue component for rendering a svg sprite
icon
Sample configuration:
Sample configuration:
<icon
name="retry"
:size="32"
css-classes="top"
/>
<icon
name="retry"
:size="32"
css-classes="top"
/>
*/
// only allow classes in images.scss e.g. s12
const
validSizes
=
[
8
,
12
,
16
,
18
,
24
,
32
,
48
,
72
];
*/
// only allow classes in images.scss e.g. s12
const
validSizes
=
[
8
,
12
,
16
,
18
,
24
,
32
,
48
,
72
];
export
default
{
props
:
{
name
:
{
type
:
String
,
required
:
true
,
},
export
default
{
props
:
{
name
:
{
type
:
String
,
required
:
true
,
},
size
:
{
type
:
Number
,
required
:
false
,
default
:
16
,
validator
(
value
)
{
return
validSizes
.
includes
(
value
);
},
size
:
{
type
:
Number
,
required
:
false
,
default
:
16
,
validator
(
value
)
{
return
validSizes
.
includes
(
value
);
},
},
cssClasses
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
cssClasses
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
width
:
{
type
:
Number
,
required
:
false
,
default
:
null
,
},
width
:
{
type
:
Number
,
required
:
false
,
default
:
null
,
},
height
:
{
type
:
Number
,
required
:
false
,
default
:
null
,
},
height
:
{
type
:
Number
,
required
:
false
,
default
:
null
,
},
y
:
{
type
:
Number
,
required
:
false
,
default
:
null
,
},
y
:
{
type
:
Number
,
required
:
false
,
default
:
null
,
},
x
:
{
type
:
Number
,
required
:
false
,
default
:
null
,
},
x
:
{
type
:
Number
,
required
:
false
,
default
:
null
,
},
},
computed
:
{
spriteHref
()
{
return
`
${
gon
.
sprite_icons
}
#
${
this
.
name
}
`
;
},
iconSizeClass
()
{
return
this
.
size
?
`s
${
this
.
size
}
`
:
''
;
},
computed
:
{
spriteHref
()
{
return
`
${
gon
.
sprite_icons
}
#
${
this
.
name
}
`
;
},
iconSizeClass
()
{
return
this
.
size
?
`s
${
this
.
size
}
`
:
''
;
},
};
},
};
</
script
>
<
template
>
...
...
@@ -79,7 +78,8 @@
:width=
"width"
:height=
"height"
:x=
"x"
:y=
"y"
>
:y=
"y"
>
<use
v-bind=
"
{ 'xlink:href':spriteHref }" />
</svg>
</
template
>
spec/javascripts/vue_shared/components/commit_spec.js
View file @
d7f68bcf
...
...
@@ -55,7 +55,6 @@ describe('Commit component', () => {
path
:
'/jschatz1'
,
username
:
'jschatz1'
,
},
commitIconSvg
:
'<svg></svg>'
,
};
component
=
mountComponent
(
CommitComponent
,
props
);
...
...
@@ -82,8 +81,10 @@ describe('Commit component', () => {
expect
(
component
.
$el
.
querySelector
(
'.commit-sha'
).
textContent
).
toContain
(
props
.
shortSha
);
});
it
(
'should render the given commitIconSvg'
,
()
=>
{
expect
(
component
.
$el
.
querySelector
(
'.js-commit-icon'
).
children
).
toContain
(
'svg'
);
it
(
'should render icon for commit'
,
()
=>
{
expect
(
component
.
$el
.
querySelector
(
'.js-commit-icon use'
).
getAttribute
(
'xlink:href'
),
).
toContain
(
'commit'
);
});
describe
(
'Given commit title and author props'
,
()
=>
{
...
...
spec/javascripts/vue_shared/components/expand_button_spec.js
View file @
d7f68bcf
...
...
@@ -3,10 +3,10 @@ import expandButton from '~/vue_shared/components/expand_button.vue';
import
mountComponent
from
'spec/helpers/vue_mount_component_helper'
;
describe
(
'expand button'
,
()
=>
{
const
Component
=
Vue
.
extend
(
expandButton
);
let
vm
;
beforeEach
(()
=>
{
const
Component
=
Vue
.
extend
(
expandButton
);
vm
=
mountComponent
(
Component
,
{
slots
:
{
expanded
:
'<p>Expanded!</p>'
,
...
...
@@ -22,7 +22,7 @@ describe('expand button', () => {
expect
(
vm
.
$el
.
textContent
.
trim
()).
toEqual
(
'...'
);
});
it
(
'hides expander on click'
,
(
done
)
=>
{
it
(
'hides expander on click'
,
done
=>
{
vm
.
$el
.
querySelector
(
'button'
).
click
();
vm
.
$nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'button'
).
getAttribute
(
'style'
)).
toEqual
(
'display: none;'
);
...
...
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