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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
ebc32465
Commit
ebc32465
authored
Feb 01, 2018
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moves more mr widget components into vue files
parent
402f3dfc
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
136 additions
and
137 deletions
+136
-137
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_author.js
...s/vue_merge_request_widget/components/mr_widget_author.js
+0
-28
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_author.vue
.../vue_merge_request_widget/components/mr_widget_author.vue
+33
-0
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_author_time.js
..._merge_request_widget/components/mr_widget_author_time.js
+0
-27
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_author_time.vue
...merge_request_widget/components/mr_widget_author_time.vue
+42
-0
app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_closed.vue
...rge_request_widget/components/states/mr_widget_closed.vue
+1
-1
app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_merge_when_pipeline_succeeds.vue
...ponents/states/mr_widget_merge_when_pipeline_succeeds.vue
+1
-1
app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_merged.vue
...rge_request_widget/components/states/mr_widget_merged.vue
+1
-1
spec/javascripts/vue_mr_widget/components/mr_widget_author_spec.js
...scripts/vue_mr_widget/components/mr_widget_author_spec.js
+29
-29
spec/javascripts/vue_mr_widget/components/mr_widget_author_time_spec.js
...ts/vue_mr_widget/components/mr_widget_author_time_spec.js
+29
-50
No files found.
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_author.js
deleted
100644 → 0
View file @
402f3dfc
import
tooltip
from
'
../../vue_shared/directives/tooltip
'
;
export
default
{
name
:
'
MRWidgetAuthor
'
,
props
:
{
author
:
{
type
:
Object
,
required
:
true
},
showAuthorName
:
{
type
:
Boolean
,
required
:
false
,
default
:
true
},
showAuthorTooltip
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
},
},
directives
:
{
tooltip
,
},
template
:
`
<a
:href="author.webUrl || author.web_url"
class="author-link inline"
:v-tooltip="showAuthorTooltip"
:title="author.name">
<img
:src="author.avatarUrl || author.avatar_url"
class="avatar avatar-inline s16" />
<span
v-if="showAuthorName"
class="author">{{author.name}}
</span>
</a>
`
,
};
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_author.vue
0 → 100644
View file @
ebc32465
<
script
>
export
default
{
name
:
'
MRWidgetAuthor
'
,
props
:
{
author
:
{
type
:
Object
,
required
:
true
,
},
},
computed
:
{
authorUrl
()
{
return
this
.
author
.
webUrl
||
this
.
author
.
web_url
;
},
avatarUrl
()
{
return
this
.
author
.
avatarUrl
||
this
.
author
.
avatar_url
;
},
},
};
</
script
>
<
template
>
<a
:href=
"authorUrl"
class=
"author-link inline"
>
<img
:src=
"avatarUrl"
class=
"avatar avatar-inline s16"
/>
<span
class=
"author"
>
{{
author
.
name
}}
</span>
</a>
</
template
>
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_author_time.js
deleted
100644 → 0
View file @
402f3dfc
import
MRWidgetAuthor
from
'
./mr_widget_author
'
;
export
default
{
name
:
'
MRWidgetAuthorTime
'
,
props
:
{
actionText
:
{
type
:
String
,
required
:
true
},
author
:
{
type
:
Object
,
required
:
true
},
dateTitle
:
{
type
:
String
,
required
:
true
},
dateReadable
:
{
type
:
String
,
required
:
true
},
},
components
:
{
'
mr-widget-author
'
:
MRWidgetAuthor
,
},
template
:
`
<h4 class="js-mr-widget-author">
{{actionText}}
<mr-widget-author :author="author" />
<time
:title="dateTitle"
data-toggle="tooltip"
data-placement="top"
data-container="body">
{{dateReadable}}
</time>
</h4>
`
,
};
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_author_time.vue
0 → 100644
View file @
ebc32465
<
script
>
import
mrWidgetAuthor
from
'
./mr_widget_author.vue
'
;
export
default
{
name
:
'
MRWidgetAuthorTime
'
,
components
:
{
mrWidgetAuthor
,
},
props
:
{
actionText
:
{
type
:
String
,
required
:
true
,
},
author
:
{
type
:
Object
,
required
:
true
,
},
dateTitle
:
{
type
:
String
,
required
:
true
,
},
dateReadable
:
{
type
:
String
,
required
:
true
,
},
},
};
</
script
>
<
template
>
<h4
class=
"js-mr-widget-author"
>
{{
actionText
}}
<mr-widget-author
:author=
"author"
/>
<time
:title=
"dateTitle"
data-toggle=
"tooltip"
data-placement=
"top"
data-container=
"body"
>
{{
dateReadable
}}
</time>
</h4>
</
template
>
app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_closed.vue
View file @
ebc32465
<
script
>
<
script
>
import
mrWidgetAuthorTime
from
'
../../components/mr_widget_author_time
'
;
import
mrWidgetAuthorTime
from
'
../../components/mr_widget_author_time
.vue
'
;
import
statusIcon
from
'
../mr_widget_status_icon.vue
'
;
import
statusIcon
from
'
../mr_widget_status_icon.vue
'
;
export
default
{
export
default
{
...
...
app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_merge_when_pipeline_succeeds.vue
View file @
ebc32465
<
script
>
<
script
>
import
Flash
from
'
../../../flash
'
;
import
Flash
from
'
../../../flash
'
;
import
statusIcon
from
'
../mr_widget_status_icon.vue
'
;
import
statusIcon
from
'
../mr_widget_status_icon.vue
'
;
import
mrWidgetAuthor
from
'
../../components/mr_widget_author
'
;
import
mrWidgetAuthor
from
'
../../components/mr_widget_author
.vue
'
;
import
eventHub
from
'
../../event_hub
'
;
import
eventHub
from
'
../../event_hub
'
;
export
default
{
export
default
{
...
...
app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_merged.vue
View file @
ebc32465
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
import
tooltip
from
'
~/vue_shared/directives/tooltip
'
;
import
tooltip
from
'
~/vue_shared/directives/tooltip
'
;
import
loadingIcon
from
'
~/vue_shared/components/loading_icon.vue
'
;
import
loadingIcon
from
'
~/vue_shared/components/loading_icon.vue
'
;
import
{
s__
,
__
}
from
'
~/locale
'
;
import
{
s__
,
__
}
from
'
~/locale
'
;
import
mrWidgetAuthorTime
from
'
../../components/mr_widget_author_time
'
;
import
mrWidgetAuthorTime
from
'
../../components/mr_widget_author_time
.vue
'
;
import
statusIcon
from
'
../mr_widget_status_icon.vue
'
;
import
statusIcon
from
'
../mr_widget_status_icon.vue
'
;
import
eventHub
from
'
../../event_hub
'
;
import
eventHub
from
'
../../event_hub
'
;
...
...
spec/javascripts/vue_mr_widget/components/mr_widget_author_spec.js
View file @
ebc32465
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
authorComponent
from
'
~/vue_merge_request_widget/components/mr_widget_author
'
;
import
authorComponent
from
'
~/vue_merge_request_widget/components/mr_widget_author.vue
'
;
import
mountComponent
from
'
../../helpers/vue_mount_component_helper
'
;
const
author
=
{
webUrl
:
'
http://foo.bar
'
,
avatarUrl
:
'
http://gravatar.com/foo
'
,
name
:
'
fatihacet
'
,
};
const
createComponent
=
()
=>
{
const
Component
=
Vue
.
extend
(
authorComponent
);
return
new
Component
({
el
:
document
.
createElement
(
'
div
'
),
propsData
:
{
author
},
});
};
describe
(
'
MRWidgetAuthor
'
,
()
=>
{
describe
(
'
MRWidgetAuthor
'
,
()
=>
{
describe
(
'
props
'
,
()
=>
{
let
vm
;
it
(
'
should have props
'
,
()
=>
{
const
authorProp
=
authorComponent
.
props
.
author
;
beforeEach
(()
=>
{
const
Component
=
Vue
.
extend
(
authorComponent
);
vm
=
mountComponent
(
Component
,
{
author
:
{
name
:
'
Administrator
'
,
username
:
'
root
'
,
webUrl
:
'
http://localhost:3000/root
'
,
avatarUrl
:
'
http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon
'
,
},
expect
(
authorProp
).
toBeDefined
();
expect
(
authorProp
.
type
instanceof
Object
).
toBeTruthy
();
expect
(
authorProp
.
required
).
toBeTruthy
();
});
});
});
});
describe
(
'
template
'
,
()
=>
{
afterEach
(
()
=>
{
it
(
'
should have correct elements
'
,
()
=>
{
vm
.
$destroy
();
const
el
=
createComponent
().
$el
;
})
;
expect
(
el
.
tagName
).
toEqual
(
'
A
'
);
it
(
'
renders link with the author web url
'
,
()
=>
{
expect
(
el
.
getAttribute
(
'
href
'
)).
toEqual
(
author
.
webUrl
);
expect
(
vm
.
$el
.
getAttribute
(
'
href
'
)).
toEqual
(
'
http://localhost:3000/root
'
);
expect
(
el
.
querySelector
(
'
img
'
).
getAttribute
(
'
src
'
)).
toEqual
(
author
.
avatarUrl
);
});
expect
(
el
.
querySelector
(
'
.author
'
).
innerText
.
trim
()).
toEqual
(
author
.
name
);
});
it
(
'
renders image with avatar url
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
img
'
).
getAttribute
(
'
src
'
),
).
toEqual
(
'
http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon
'
);
});
it
(
'
renders author name
'
,
()
=>
{
expect
(
vm
.
$el
.
textContent
.
trim
()).
toEqual
(
'
Administrator
'
);
});
});
});
});
spec/javascripts/vue_mr_widget/components/mr_widget_author_time_spec.js
View file @
ebc32465
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
authorTimeComponent
from
'
~/vue_merge_request_widget/components/mr_widget_author_time
'
;
import
authorTimeComponent
from
'
~/vue_merge_request_widget/components/mr_widget_author_time.vue
'
;
import
mountComponent
from
'
../../helpers/vue_mount_component_helper
'
;
const
props
=
{
actionText
:
'
Merged by
'
,
author
:
{
webUrl
:
'
http://foo.bar
'
,
avatarUrl
:
'
http://gravatar.com/foo
'
,
name
:
'
fatihacet
'
,
},
dateTitle
:
'
2017-03-23T23:02:00.807Z
'
,
dateReadable
:
'
12 hours ago
'
,
};
const
createComponent
=
()
=>
{
const
Component
=
Vue
.
extend
(
authorTimeComponent
);
return
new
Component
({
el
:
document
.
createElement
(
'
div
'
),
propsData
:
props
,
});
};
describe
(
'
MRWidgetAuthorTime
'
,
()
=>
{
describe
(
'
MRWidgetAuthorTime
'
,
()
=>
{
describe
(
'
props
'
,
()
=>
{
let
vm
;
it
(
'
should have props
'
,
()
=>
{
const
{
actionText
,
author
,
dateTitle
,
dateReadable
}
=
authorTimeComponent
.
props
;
beforeEach
(()
=>
{
const
ActionTextClass
=
actionText
.
type
;
const
Component
=
Vue
.
extend
(
authorTimeComponent
);
const
DateTitleClass
=
dateTitle
.
type
;
const
DateReadableClass
=
dateReadable
.
type
;
vm
=
mountComponent
(
Component
,
{
actionText
:
'
Merged by
'
,
expect
(
new
ActionTextClass
()
instanceof
String
).
toBeTruthy
();
author
:
{
expect
(
actionText
.
required
).
toBeTruthy
();
name
:
'
Administrator
'
,
username
:
'
root
'
,
expect
(
author
.
type
instanceof
Object
).
toBeTruthy
();
webUrl
:
'
http://localhost:3000/root
'
,
expect
(
author
.
required
).
toBeTruthy
();
avatarUrl
:
'
http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon
'
,
},
expect
(
new
DateTitleClass
()
instanceof
String
).
toBeTruthy
();
dateTitle
:
'
2017-03-23T23:02:00.807Z
'
,
expect
(
dateTitle
.
required
).
toBeTruthy
();
dateReadable
:
'
12 hours ago
'
,
expect
(
new
DateReadableClass
()
instanceof
String
).
toBeTruthy
();
expect
(
dateReadable
.
required
).
toBeTruthy
();
});
});
});
});
describe
(
'
components
'
,
()
=>
{
afterEach
(()
=>
{
it
(
'
should have components
'
,
()
=>
{
vm
.
$destroy
();
expect
(
authorTimeComponent
.
components
[
'
mr-widget-author
'
]).
toBeDefined
();
});
});
it
(
'
renders provided action text
'
,
()
=>
{
expect
(
vm
.
$el
.
textContent
).
toContain
(
'
Merged by
'
);
});
});
describe
(
'
template
'
,
()
=>
{
it
(
'
renders author
'
,
()
=>
{
it
(
'
should have correct elements
'
,
()
=>
{
expect
(
vm
.
$el
.
textContent
).
toContain
(
'
Administrator
'
);
const
el
=
createComponent
().
$el
;
})
;
expect
(
el
.
tagName
).
toEqual
(
'
H4
'
);
it
(
'
renders provided time
'
,
()
=>
{
expect
(
el
.
querySelector
(
'
a
'
).
getAttribute
(
'
href
'
)).
toEqual
(
props
.
author
.
webUrl
);
expect
(
vm
.
$el
.
querySelector
(
'
time
'
).
getAttribute
(
'
title
'
)).
toEqual
(
'
2017-03-23T23:02:00.807Z
'
);
expect
(
el
.
querySelector
(
'
time
'
).
innerText
).
toContain
(
props
.
dateReadable
);
expect
(
vm
.
$el
.
querySelector
(
'
time
'
).
textContent
.
trim
()).
toEqual
(
'
12 hours ago
'
);
expect
(
el
.
querySelector
(
'
time
'
).
getAttribute
(
'
title
'
)).
toEqual
(
props
.
dateTitle
);
});
});
});
});
});
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