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
139ce1c4
Unverified
Commit
139ce1c4
authored
Dec 07, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Export date utility functions as ES6 modules
parent
f1a98477
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
256 additions
and
237 deletions
+256
-237
activities.js
app/assets/javascripts/activities.js
+2
-1
commits.js
app/assets/javascripts/commits.js
+2
-1
compare.js
app/assets/javascripts/compare.js
+2
-1
key.vue
app/assets/javascripts/deploy_keys/components/key.vue
+2
-1
discussion.js
app/assets/javascripts/diff_notes/models/discussion.js
+2
-1
job.js
app/assets/javascripts/job.js
+2
-1
cache.js
app/assets/javascripts/lib/utils/cache.js
+1
-3
constants.js
app/assets/javascripts/lib/utils/constants.js
+0
-1
datetime_utility.js
app/assets/javascripts/lib/utils/datetime_utility.js
+114
-106
main.js
app/assets/javascripts/main.js
+4
-4
merge_request_tabs.js
app/assets/javascripts/merge_request_tabs.js
+6
-3
milestone_select.js
app/assets/javascripts/milestone_select.js
+2
-1
notes.js
app/assets/javascripts/notes.js
+3
-2
activity_calendar.js
app/assets/javascripts/users/activity_calendar.js
+3
-2
user_tabs.js
app/assets/javascripts/users/user_tabs.js
+2
-1
mr_widget_deployment.js
...e_merge_request_widget/components/mr_widget_deployment.js
+2
-2
mr_widget_store.js
...cripts/vue_merge_request_widget/stores/mr_widget_store.js
+2
-1
memory_graph.js
app/assets/javascripts/vue_shared/components/memory_graph.js
+3
-1
timeago.js
app/assets/javascripts/vue_shared/mixins/timeago.js
+3
-3
datetime_utility_spec.js
spec/javascripts/datetime_utility_spec.js
+92
-94
key_spec.js
spec/javascripts/deploy_keys/components/key_spec.js
+2
-1
notes_spec.js
spec/javascripts/notes_spec.js
+0
-2
mr_widget_deployment_spec.js
...pts/vue_mr_widget/components/mr_widget_deployment_spec.js
+2
-1
time_ago_tooltip_spec.js
...avascripts/vue_shared/components/time_ago_tooltip_spec.js
+3
-3
No files found.
app/assets/javascripts/activities.js
View file @
139ce1c4
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
/* global Pager */
/* global Pager */
import
Cookies
from
'js-cookie'
;
import
Cookies
from
'js-cookie'
;
import
{
localTimeAgo
}
from
'./lib/utils/datetime_utility'
;
class
Activities
{
class
Activities
{
constructor
()
{
constructor
()
{
...
@@ -15,7 +16,7 @@ class Activities {
...
@@ -15,7 +16,7 @@ class Activities {
}
}
updateTooltips
()
{
updateTooltips
()
{
gl
.
utils
.
localTimeAgo
(
$
(
'.js-timeago'
,
'.content_list'
));
localTimeAgo
(
$
(
'.js-timeago'
,
'.content_list'
));
}
}
reloadActivities
()
{
reloadActivities
()
{
...
...
app/assets/javascripts/commits.js
View file @
139ce1c4
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
/* global Pager */
/* global Pager */
import
{
pluralize
}
from
'./lib/utils/text_utility'
;
import
{
pluralize
}
from
'./lib/utils/text_utility'
;
import
{
localTimeAgo
}
from
'./lib/utils/datetime_utility'
;
export
default
(
function
()
{
export
default
(
function
()
{
const
CommitsList
=
{};
const
CommitsList
=
{};
...
@@ -91,7 +92,7 @@ export default (function () {
...
@@ -91,7 +92,7 @@ export default (function () {
$commitsHeadersLast
.
find
(
'span.commits-count'
).
text
(
`
${
commitsCount
}
${
pluralize
(
'commit'
,
commitsCount
)}
`
);
$commitsHeadersLast
.
find
(
'span.commits-count'
).
text
(
`
${
commitsCount
}
${
pluralize
(
'commit'
,
commitsCount
)}
`
);
}
}
gl
.
utils
.
localTimeAgo
(
$processedData
.
find
(
'.js-timeago'
));
localTimeAgo
(
$processedData
.
find
(
'.js-timeago'
));
return
processedData
;
return
processedData
;
};
};
...
...
app/assets/javascripts/compare.js
View file @
139ce1c4
/* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, no-var, object-shorthand, consistent-return, no-unused-vars, comma-dangle, vars-on-top, prefer-template, max-len */
/* eslint-disable func-names, space-before-function-paren, wrap-iife, quotes, no-var, object-shorthand, consistent-return, no-unused-vars, comma-dangle, vars-on-top, prefer-template, max-len */
import
{
localTimeAgo
}
from
'./lib/utils/datetime_utility'
;
window
.
Compare
=
(
function
()
{
window
.
Compare
=
(
function
()
{
function
Compare
(
opts
)
{
function
Compare
(
opts
)
{
...
@@ -81,7 +82,7 @@ window.Compare = (function() {
...
@@ -81,7 +82,7 @@ window.Compare = (function() {
loading
.
hide
();
loading
.
hide
();
$target
.
html
(
html
);
$target
.
html
(
html
);
var
className
=
'.'
+
$target
[
0
].
className
.
replace
(
' '
,
'.'
);
var
className
=
'.'
+
$target
[
0
].
className
.
replace
(
' '
,
'.'
);
gl
.
utils
.
localTimeAgo
(
$
(
'.js-timeago'
,
className
));
localTimeAgo
(
$
(
'.js-timeago'
,
className
));
}
}
});
});
};
};
...
...
app/assets/javascripts/deploy_keys/components/key.vue
View file @
139ce1c4
<
script
>
<
script
>
import
actionBtn
from
'./action_btn.vue'
;
import
actionBtn
from
'./action_btn.vue'
;
import
{
getTimeago
}
from
'../../lib/utils/datetime_utility'
;
export
default
{
export
default
{
props
:
{
props
:
{
...
@@ -21,7 +22,7 @@
...
@@ -21,7 +22,7 @@
},
},
computed
:
{
computed
:
{
timeagoDate
()
{
timeagoDate
()
{
return
g
l
.
utils
.
g
etTimeago
().
format
(
this
.
deployKey
.
created_at
);
return
getTimeago
().
format
(
this
.
deployKey
.
created_at
);
},
},
editDeployKeyPath
()
{
editDeployKeyPath
()
{
return
`
${
this
.
endpoint
}
/
${
this
.
deployKey
.
id
}
/edit`
;
return
`
${
this
.
endpoint
}
/
${
this
.
deployKey
.
id
}
/edit`
;
...
...
app/assets/javascripts/diff_notes/models/discussion.js
View file @
139ce1c4
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
/* global NoteModel */
/* global NoteModel */
import
Vue
from
'vue'
;
import
Vue
from
'vue'
;
import
{
localTimeAgo
}
from
'../../lib/utils/datetime_utility'
;
class
DiscussionModel
{
class
DiscussionModel
{
constructor
(
discussionId
)
{
constructor
(
discussionId
)
{
...
@@ -71,7 +72,7 @@ class DiscussionModel {
...
@@ -71,7 +72,7 @@ class DiscussionModel {
$
(
`
${
discussionSelector
}
.discussion-header`
).
append
(
data
.
discussion_headline_html
);
$
(
`
${
discussionSelector
}
.discussion-header`
).
append
(
data
.
discussion_headline_html
);
}
}
gl
.
utils
.
localTimeAgo
(
$
(
'.js-timeago'
,
`
${
discussionSelector
}
`
));
localTimeAgo
(
$
(
'.js-timeago'
,
`
${
discussionSelector
}
`
));
}
else
{
}
else
{
$discussionHeadline
.
remove
();
$discussionHeadline
.
remove
();
}
}
...
...
app/assets/javascripts/job.js
View file @
139ce1c4
...
@@ -2,6 +2,7 @@ import _ from 'underscore';
...
@@ -2,6 +2,7 @@ import _ from 'underscore';
import
bp
from
'./breakpoints'
;
import
bp
from
'./breakpoints'
;
import
{
bytesToKiB
}
from
'./lib/utils/number_utils'
;
import
{
bytesToKiB
}
from
'./lib/utils/number_utils'
;
import
{
setCiStatusFavicon
}
from
'./lib/utils/common_utils'
;
import
{
setCiStatusFavicon
}
from
'./lib/utils/common_utils'
;
import
{
timeFor
}
from
'./lib/utils/datetime_utility'
;
export
default
class
Job
{
export
default
class
Job
{
constructor
(
options
)
{
constructor
(
options
)
{
...
@@ -260,7 +261,7 @@ export default class Job {
...
@@ -260,7 +261,7 @@ export default class Job {
if
(
$date
.
length
)
{
if
(
$date
.
length
)
{
const
date
=
$date
.
text
();
const
date
=
$date
.
text
();
return
$date
.
text
(
return
$date
.
text
(
gl
.
utils
.
timeFor
(
new
Date
(
date
.
replace
(
/
([
0-9
]
+
)
-
([
0-9
]
+
)
-
([
0-9
]
+
)
/g
,
'$1/$2/$3'
)),
' '
),
timeFor
(
new
Date
(
date
.
replace
(
/
([
0-9
]
+
)
-
([
0-9
]
+
)
-
([
0-9
]
+
)
/g
,
'$1/$2/$3'
))
),
);
);
}
}
}
}
...
...
app/assets/javascripts/lib/utils/cache.js
View file @
139ce1c4
class
Cache
{
export
default
class
Cache
{
constructor
()
{
constructor
()
{
this
.
internalStorage
=
{
};
this
.
internalStorage
=
{
};
}
}
...
@@ -15,5 +15,3 @@ class Cache {
...
@@ -15,5 +15,3 @@ class Cache {
delete
this
.
internalStorage
[
key
];
delete
this
.
internalStorage
[
key
];
}
}
}
}
export
default
Cache
;
app/assets/javascripts/lib/utils/constants.js
View file @
139ce1c4
/* eslint-disable import/prefer-default-export */
export
const
BYTES_IN_KIB
=
1024
;
export
const
BYTES_IN_KIB
=
1024
;
export
const
HIDDEN_CLASS
=
'hidden'
;
export
const
HIDDEN_CLASS
=
'hidden'
;
app/assets/javascripts/lib/utils/datetime_utility.js
View file @
139ce1c4
This diff is collapsed.
Click to expand it.
app/assets/javascripts/main.js
View file @
139ce1c4
...
@@ -28,7 +28,7 @@ import './commit/image_file';
...
@@ -28,7 +28,7 @@ import './commit/image_file';
// lib/utils
// lib/utils
import
{
handleLocationHash
}
from
'./lib/utils/common_utils'
;
import
{
handleLocationHash
}
from
'./lib/utils/common_utils'
;
import
'./lib/utils/datetime_utility'
;
import
{
localTimeAgo
,
renderTimeago
,
getLocationHash
}
from
'./lib/utils/datetime_utility'
;
import
'./lib/utils/url_utility'
;
import
'./lib/utils/url_utility'
;
// behaviors
// behaviors
...
@@ -122,7 +122,7 @@ $(function () {
...
@@ -122,7 +122,7 @@ $(function () {
// `hashchange` is not triggered when link target is already in window.location
// `hashchange` is not triggered when link target is already in window.location
$body
.
on
(
'click'
,
'a[href^="#"]'
,
function
()
{
$body
.
on
(
'click'
,
'a[href^="#"]'
,
function
()
{
var
href
=
this
.
getAttribute
(
'href'
);
var
href
=
this
.
getAttribute
(
'href'
);
if
(
href
.
substr
(
1
)
===
g
l
.
utils
.
g
etLocationHash
())
{
if
(
href
.
substr
(
1
)
===
getLocationHash
())
{
setTimeout
(
handleLocationHash
,
1
);
setTimeout
(
handleLocationHash
,
1
);
}
}
});
});
...
@@ -194,7 +194,7 @@ $(function () {
...
@@ -194,7 +194,7 @@ $(function () {
return
$
(
this
).
parents
(
'form'
).
submit
();
return
$
(
this
).
parents
(
'form'
).
submit
();
// Form submitter
// Form submitter
});
});
gl
.
utils
.
localTimeAgo
(
$
(
'abbr.timeago, .js-timeago'
),
true
);
localTimeAgo
(
$
(
'abbr.timeago, .js-timeago'
),
true
);
// Disable form buttons while a form is submitting
// Disable form buttons while a form is submitting
$body
.
on
(
'ajax:complete, ajax:beforeSend, submit'
,
'form'
,
function
(
e
)
{
$body
.
on
(
'ajax:complete, ajax:beforeSend, submit'
,
'form'
,
function
(
e
)
{
var
buttons
;
var
buttons
;
...
@@ -283,7 +283,7 @@ $(function () {
...
@@ -283,7 +283,7 @@ $(function () {
loadAwardsHandler
();
loadAwardsHandler
();
new
Aside
();
new
Aside
();
gl
.
utils
.
renderTimeago
();
renderTimeago
();
$
(
document
).
trigger
(
'init.scrolling-tabs'
);
$
(
document
).
trigger
(
'init.scrolling-tabs'
);
...
...
app/assets/javascripts/merge_request_tabs.js
View file @
139ce1c4
...
@@ -13,6 +13,9 @@ import {
...
@@ -13,6 +13,9 @@ import {
}
from
'./lib/utils/common_utils'
;
}
from
'./lib/utils/common_utils'
;
import
initDiscussionTab
from
'./image_diff/init_discussion_tab'
;
import
initDiscussionTab
from
'./image_diff/init_discussion_tab'
;
import
Diff
from
'./diff'
;
import
Diff
from
'./diff'
;
import
{
localTimeAgo
,
}
from
'./lib/utils/datetime_utility'
;
/* eslint-disable max-len */
/* eslint-disable max-len */
// MergeRequestTabs
// MergeRequestTabs
...
@@ -246,7 +249,7 @@ import Diff from './diff';
...
@@ -246,7 +249,7 @@ import Diff from './diff';
url
:
`
${
source
}
.json`
,
url
:
`
${
source
}
.json`
,
success
:
(
data
)
=>
{
success
:
(
data
)
=>
{
document
.
querySelector
(
'div#commits'
).
innerHTML
=
data
.
html
;
document
.
querySelector
(
'div#commits'
).
innerHTML
=
data
.
html
;
gl
.
utils
.
localTimeAgo
(
$
(
'.js-timeago'
,
'div#commits'
));
localTimeAgo
(
$
(
'.js-timeago'
,
'div#commits'
));
this
.
commitsLoaded
=
true
;
this
.
commitsLoaded
=
true
;
this
.
scrollToElement
(
'#commits'
);
this
.
scrollToElement
(
'#commits'
);
},
},
...
@@ -293,7 +296,7 @@ import Diff from './diff';
...
@@ -293,7 +296,7 @@ import Diff from './diff';
gl
.
diffNotesCompileComponents
();
gl
.
diffNotesCompileComponents
();
}
}
gl
.
utils
.
localTimeAgo
(
$
(
'.js-timeago'
,
'div#diffs'
));
localTimeAgo
(
$
(
'.js-timeago'
,
'div#diffs'
));
$
(
'#diffs .js-syntax-highlight'
).
syntaxHighlight
();
$
(
'#diffs .js-syntax-highlight'
).
syntaxHighlight
();
if
(
this
.
diffViewType
()
===
'parallel'
&&
this
.
isDiffAction
(
this
.
currentAction
))
{
if
(
this
.
diffViewType
()
===
'parallel'
&&
this
.
isDiffAction
(
this
.
currentAction
))
{
...
@@ -317,7 +320,7 @@ import Diff from './diff';
...
@@ -317,7 +320,7 @@ import Diff from './diff';
// Scroll any linked note into view
// Scroll any linked note into view
// Similar to `toggler_behavior` in the discussion tab
// Similar to `toggler_behavior` in the discussion tab
const
hash
=
window
.
gl
.
utils
.
getLocationHash
();
const
hash
=
gl
.
utils
.
getLocationHash
();
const
anchor
=
hash
&&
$container
.
find
(
`.note[id="
${
hash
}
"]`
);
const
anchor
=
hash
&&
$container
.
find
(
`.note[id="
${
hash
}
"]`
);
if
(
anchor
&&
anchor
.
length
>
0
)
{
if
(
anchor
&&
anchor
.
length
>
0
)
{
const
notesContent
=
anchor
.
closest
(
'.notes_content'
);
const
notesContent
=
anchor
.
closest
(
'.notes_content'
);
...
...
app/assets/javascripts/milestone_select.js
View file @
139ce1c4
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
/* global Issuable */
/* global Issuable */
/* global ListMilestone */
/* global ListMilestone */
import
_
from
'underscore'
;
import
_
from
'underscore'
;
import
{
timeFor
}
from
'./lib/utils/datetime_utility'
;
(
function
()
{
(
function
()
{
this
.
MilestoneSelect
=
(
function
()
{
this
.
MilestoneSelect
=
(
function
()
{
...
@@ -216,7 +217,7 @@ import _ from 'underscore';
...
@@ -216,7 +217,7 @@ import _ from 'underscore';
$value
.
css
(
'display'
,
''
);
$value
.
css
(
'display'
,
''
);
if
(
data
.
milestone
!=
null
)
{
if
(
data
.
milestone
!=
null
)
{
data
.
milestone
.
full_path
=
_this
.
currentProject
.
full_path
;
data
.
milestone
.
full_path
=
_this
.
currentProject
.
full_path
;
data
.
milestone
.
remaining
=
gl
.
utils
.
timeFor
(
data
.
milestone
.
due_date
);
data
.
milestone
.
remaining
=
timeFor
(
data
.
milestone
.
due_date
);
data
.
milestone
.
name
=
data
.
milestone
.
title
;
data
.
milestone
.
name
=
data
.
milestone
.
title
;
$value
.
html
(
milestoneLinkTemplate
(
data
.
milestone
));
$value
.
html
(
milestoneLinkTemplate
(
data
.
milestone
));
return
$sidebarCollapsedValue
.
find
(
'span'
).
html
(
collapsedSidebarLabelTemplate
(
data
.
milestone
));
return
$sidebarCollapsedValue
.
find
(
'span'
).
html
(
collapsedSidebarLabelTemplate
(
data
.
milestone
));
...
...
app/assets/javascripts/notes.js
View file @
139ce1c4
...
@@ -24,6 +24,7 @@ import Autosave from './autosave';
...
@@ -24,6 +24,7 @@ import Autosave from './autosave';
import
TaskList
from
'./task_list'
;
import
TaskList
from
'./task_list'
;
import
{
ajaxPost
,
isInViewport
,
getPagePath
,
scrollToElement
,
isMetaKey
}
from
'./lib/utils/common_utils'
;
import
{
ajaxPost
,
isInViewport
,
getPagePath
,
scrollToElement
,
isMetaKey
}
from
'./lib/utils/common_utils'
;
import
imageDiffHelper
from
'./image_diff/helpers/index'
;
import
imageDiffHelper
from
'./image_diff/helpers/index'
;
import
{
localTimeAgo
}
from
'./lib/utils/datetime_utility'
;
window
.
autosize
=
Autosize
;
window
.
autosize
=
Autosize
;
...
@@ -310,7 +311,7 @@ export default class Notes {
...
@@ -310,7 +311,7 @@ export default class Notes {
setupNewNote
(
$note
)
{
setupNewNote
(
$note
)
{
// Update datetime format on the recent note
// Update datetime format on the recent note
gl
.
utils
.
localTimeAgo
(
$note
.
find
(
'.js-timeago'
),
false
);
localTimeAgo
(
$note
.
find
(
'.js-timeago'
),
false
);
this
.
collapseLongCommitList
();
this
.
collapseLongCommitList
();
this
.
taskList
.
init
();
this
.
taskList
.
init
();
...
@@ -462,7 +463,7 @@ export default class Notes {
...
@@ -462,7 +463,7 @@ export default class Notes {
this
.
renderDiscussionAvatar
(
diffAvatarContainer
,
noteEntity
);
this
.
renderDiscussionAvatar
(
diffAvatarContainer
,
noteEntity
);
}
}
gl
.
utils
.
localTimeAgo
(
$
(
'.js-timeago'
),
false
);
localTimeAgo
(
$
(
'.js-timeago'
),
false
);
Notes
.
checkMergeRequestStatus
();
Notes
.
checkMergeRequestStatus
();
return
this
.
updateNotesCount
(
1
);
return
this
.
updateNotesCount
(
1
);
}
}
...
...
app/assets/javascripts/users/activity_calendar.js
View file @
139ce1c4
import
_
from
'underscore'
;
import
_
from
'underscore'
;
import
d3
from
'd3'
;
import
d3
from
'd3'
;
import
{
getDayName
,
getDayDifference
}
from
'../lib/utils/datetime_utility'
;
const
LOADING_HTML
=
`
const
LOADING_HTML
=
`
<div class="text-center">
<div class="text-center">
...
@@ -17,7 +18,7 @@ function getSystemDate(systemUtcOffsetSeconds) {
...
@@ -17,7 +18,7 @@ function getSystemDate(systemUtcOffsetSeconds) {
function
formatTooltipText
({
date
,
count
})
{
function
formatTooltipText
({
date
,
count
})
{
const
dateObject
=
new
Date
(
date
);
const
dateObject
=
new
Date
(
date
);
const
dateDayName
=
g
l
.
utils
.
g
etDayName
(
dateObject
);
const
dateDayName
=
getDayName
(
dateObject
);
const
dateText
=
dateObject
.
format
(
'mmm d, yyyy'
);
const
dateText
=
dateObject
.
format
(
'mmm d, yyyy'
);
let
contribText
=
'No contributions'
;
let
contribText
=
'No contributions'
;
...
@@ -51,7 +52,7 @@ export default class ActivityCalendar {
...
@@ -51,7 +52,7 @@ export default class ActivityCalendar {
const
oneYearAgo
=
new
Date
(
today
);
const
oneYearAgo
=
new
Date
(
today
);
oneYearAgo
.
setFullYear
(
today
.
getFullYear
()
-
1
);
oneYearAgo
.
setFullYear
(
today
.
getFullYear
()
-
1
);
const
days
=
g
l
.
utils
.
g
etDayDifference
(
oneYearAgo
,
today
);
const
days
=
getDayDifference
(
oneYearAgo
,
today
);
for
(
let
i
=
0
;
i
<=
days
;
i
+=
1
)
{
for
(
let
i
=
0
;
i
<=
days
;
i
+=
1
)
{
const
date
=
new
Date
(
oneYearAgo
);
const
date
=
new
Date
(
oneYearAgo
);
...
...
app/assets/javascripts/users/user_tabs.js
View file @
139ce1c4
import
ActivityCalendar
from
'./activity_calendar'
;
import
ActivityCalendar
from
'./activity_calendar'
;
import
{
localTimeAgo
}
from
'../lib/utils/datetime_utility'
;
/**
/**
* UserTabs
* UserTabs
...
@@ -138,7 +139,7 @@ export default class UserTabs {
...
@@ -138,7 +139,7 @@ export default class UserTabs {
const
tabSelector
=
`div#
${
action
}
`
;
const
tabSelector
=
`div#
${
action
}
`
;
this
.
$parentEl
.
find
(
tabSelector
).
html
(
data
.
html
);
this
.
$parentEl
.
find
(
tabSelector
).
html
(
data
.
html
);
this
.
loaded
[
action
]
=
true
;
this
.
loaded
[
action
]
=
true
;
gl
.
utils
.
localTimeAgo
(
$
(
'.js-timeago'
,
tabSelector
));
localTimeAgo
(
$
(
'.js-timeago'
,
tabSelector
));
},
},
});
});
}
}
...
...
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_deployment.js
View file @
139ce1c4
import
'~/lib/utils/datetime_utility'
;
import
{
getTimeago
}
from
'~/lib/utils/datetime_utility'
;
import
Flash
from
'../../flash'
;
import
Flash
from
'../../flash'
;
import
MemoryUsage
from
'./mr_widget_memory_usage'
;
import
MemoryUsage
from
'./mr_widget_memory_usage'
;
import
StatusIcon
from
'./mr_widget_status_icon'
;
import
StatusIcon
from
'./mr_widget_status_icon'
;
...
@@ -16,7 +16,7 @@ export default {
...
@@ -16,7 +16,7 @@ export default {
},
},
methods
:
{
methods
:
{
formatDate
(
date
)
{
formatDate
(
date
)
{
return
g
l
.
utils
.
g
etTimeago
().
format
(
date
);
return
getTimeago
().
format
(
date
);
},
},
hasExternalUrls
(
deployment
=
{})
{
hasExternalUrls
(
deployment
=
{})
{
return
deployment
.
external_url
&&
deployment
.
external_url_formatted
;
return
deployment
.
external_url
&&
deployment
.
external_url_formatted
;
...
...
app/assets/javascripts/vue_merge_request_widget/stores/mr_widget_store.js
View file @
139ce1c4
import
Timeago
from
'timeago.js'
;
import
Timeago
from
'timeago.js'
;
import
{
getStateKey
}
from
'../dependencies'
;
import
{
getStateKey
}
from
'../dependencies'
;
import
{
formatDate
}
from
'../../lib/utils/datetime_utility'
;
export
default
class
MergeRequestStore
{
export
default
class
MergeRequestStore
{
...
@@ -122,7 +123,7 @@ export default class MergeRequestStore {
...
@@ -122,7 +123,7 @@ export default class MergeRequestStore {
static
getEventObject
(
event
)
{
static
getEventObject
(
event
)
{
return
{
return
{
author
:
MergeRequestStore
.
getAuthorObject
(
event
),
author
:
MergeRequestStore
.
getAuthorObject
(
event
),
updatedAt
:
gl
.
utils
.
formatDate
(
MergeRequestStore
.
getEventUpdatedAtDate
(
event
)),
updatedAt
:
formatDate
(
MergeRequestStore
.
getEventUpdatedAtDate
(
event
)),
formattedUpdatedAt
:
MergeRequestStore
.
getEventDate
(
event
),
formattedUpdatedAt
:
MergeRequestStore
.
getEventDate
(
event
),
};
};
}
}
...
...
app/assets/javascripts/vue_shared/components/memory_graph.js
View file @
139ce1c4
import
{
getTimeago
}
from
'../../lib/utils/datetime_utility'
;
export
default
{
export
default
{
name
:
'MemoryGraph'
,
name
:
'MemoryGraph'
,
props
:
{
props
:
{
...
@@ -16,7 +18,7 @@ export default {
...
@@ -16,7 +18,7 @@ export default {
},
},
computed
:
{
computed
:
{
getFormattedMedian
()
{
getFormattedMedian
()
{
const
deployedSince
=
g
l
.
utils
.
g
etTimeago
().
format
(
this
.
deploymentTime
*
1000
);
const
deployedSince
=
getTimeago
().
format
(
this
.
deploymentTime
*
1000
);
return
`Deployed
${
deployedSince
}
`
;
return
`Deployed
${
deployedSince
}
`
;
},
},
},
},
...
...
app/assets/javascripts/vue_shared/mixins/timeago.js
View file @
139ce1c4
import
'../../lib/utils/datetime_utility'
;
import
{
formatDate
,
getTimeago
}
from
'../../lib/utils/datetime_utility'
;
/**
/**
* Mixin with time ago methods used in some vue components
* Mixin with time ago methods used in some vue components
...
@@ -6,13 +6,13 @@ import '../../lib/utils/datetime_utility';
...
@@ -6,13 +6,13 @@ import '../../lib/utils/datetime_utility';
export
default
{
export
default
{
methods
:
{
methods
:
{
timeFormated
(
time
)
{
timeFormated
(
time
)
{
const
timeago
=
g
l
.
utils
.
g
etTimeago
();
const
timeago
=
getTimeago
();
return
timeago
.
format
(
time
);
return
timeago
.
format
(
time
);
},
},
tooltipTitle
(
time
)
{
tooltipTitle
(
time
)
{
return
gl
.
utils
.
formatDate
(
time
);
return
formatDate
(
time
);
},
},
},
},
};
};
spec/javascripts/datetime_utility_spec.js
View file @
139ce1c4
import
*
as
datetimeUtility
from
'~/lib/utils/datetime_utility'
;
import
*
as
datetimeUtility
from
'~/lib/utils/datetime_utility'
;
(()
=>
{
describe
(
'Date time utils'
,
()
=>
{
describe
(
'Date time utils'
,
()
=>
{
describe
(
'timeFor'
,
()
=>
{
describe
(
'timeFor'
,
()
=>
{
it
(
'returns `past due` when in past'
,
()
=>
{
it
(
'returns `past due` when in past'
,
()
=>
{
const
date
=
new
Date
();
const
date
=
new
Date
();
date
.
setFullYear
(
date
.
getFullYear
()
-
1
);
date
.
setFullYear
(
date
.
getFullYear
()
-
1
);
expect
(
expect
(
datetimeUtility
.
timeFor
(
date
),
gl
.
utils
.
timeFor
(
date
),
).
toBe
(
'Past due'
);
).
toBe
(
'Past due'
);
});
it
(
'returns remaining time when in the future'
,
()
=>
{
const
date
=
new
Date
();
date
.
setFullYear
(
date
.
getFullYear
()
+
1
);
// Add a day to prevent a transient error. If date is even 1 second
// short of a full year, timeFor will return '11 months remaining'
date
.
setDate
(
date
.
getDate
()
+
1
);
expect
(
gl
.
utils
.
timeFor
(
date
),
).
toBe
(
'1 year remaining'
);
});
});
});
describe
(
'get day name'
,
()
=>
{
it
(
'returns remaining time when in the future'
,
()
=>
{
it
(
'should return Sunday'
,
()
=>
{
const
date
=
new
Date
();
const
day
=
gl
.
utils
.
getDayName
(
new
Date
(
'07/17/2016'
));
date
.
setFullYear
(
date
.
getFullYear
()
+
1
);
expect
(
day
).
toBe
(
'Sunday'
);
});
// Add a day to prevent a transient error. If date is even 1 second
// short of a full year, timeFor will return '11 months remaining'
it
(
'should return Monday'
,
()
=>
{
date
.
setDate
(
date
.
getDate
()
+
1
);
const
day
=
gl
.
utils
.
getDayName
(
new
Date
(
'07/18/2016'
));
expect
(
day
).
toBe
(
'Monday'
);
});
it
(
'should return Tuesday'
,
()
=>
{
const
day
=
gl
.
utils
.
getDayName
(
new
Date
(
'07/19/2016'
));
expect
(
day
).
toBe
(
'Tuesday'
);
});
it
(
'should return Wednesday'
,
()
=>
{
const
day
=
gl
.
utils
.
getDayName
(
new
Date
(
'07/20/2016'
));
expect
(
day
).
toBe
(
'Wednesday'
);
});
it
(
'should return Thursday'
,
()
=>
{
const
day
=
gl
.
utils
.
getDayName
(
new
Date
(
'07/21/2016'
));
expect
(
day
).
toBe
(
'Thursday'
);
});
it
(
'should return Friday'
,
()
=>
{
const
day
=
gl
.
utils
.
getDayName
(
new
Date
(
'07/22/2016'
));
expect
(
day
).
toBe
(
'Friday'
);
});
it
(
'should return Saturday'
,
()
=>
{
const
day
=
gl
.
utils
.
getDayName
(
new
Date
(
'07/23/2016'
));
expect
(
day
).
toBe
(
'Saturday'
);
});
});
describe
(
'get day difference'
,
()
=>
{
expect
(
it
(
'should return 7'
,
()
=>
{
datetimeUtility
.
timeFor
(
date
),
const
firstDay
=
new
Date
(
'07/01/2016'
);
).
toBe
(
'1 year remaining'
);
const
secondDay
=
new
Date
(
'07/08/2016'
);
const
difference
=
gl
.
utils
.
getDayDifference
(
firstDay
,
secondDay
);
expect
(
difference
).
toBe
(
7
);
});
it
(
'should return 31'
,
()
=>
{
const
firstDay
=
new
Date
(
'07/01/2016'
);
const
secondDay
=
new
Date
(
'08/01/2016'
);
const
difference
=
gl
.
utils
.
getDayDifference
(
firstDay
,
secondDay
);
expect
(
difference
).
toBe
(
31
);
});
it
(
'should return 365'
,
()
=>
{
const
firstDay
=
new
Date
(
'07/02/2015'
);
const
secondDay
=
new
Date
(
'07/01/2016'
);
const
difference
=
gl
.
utils
.
getDayDifference
(
firstDay
,
secondDay
);
expect
(
difference
).
toBe
(
365
);
});
});
});
});
});
describe
(
'timeIntervalInWords'
,
()
=>
{
describe
(
'get day name'
,
()
=>
{
it
(
'should return string with number of minutes and seconds'
,
()
=>
{
it
(
'should return Sunday'
,
()
=>
{
expect
(
datetimeUtility
.
timeIntervalInWords
(
9.54
)).
toEqual
(
'9 seconds'
);
const
day
=
datetimeUtility
.
getDayName
(
new
Date
(
'07/17/2016'
));
expect
(
datetimeUtility
.
timeIntervalInWords
(
1
)).
toEqual
(
'1 second'
);
expect
(
day
).
toBe
(
'Sunday'
);
expect
(
datetimeUtility
.
timeIntervalInWords
(
200
)).
toEqual
(
'3 minutes 20 seconds'
);
});
expect
(
datetimeUtility
.
timeIntervalInWords
(
6008
)).
toEqual
(
'100 minutes 8 seconds'
);
it
(
'should return Monday'
,
()
=>
{
const
day
=
datetimeUtility
.
getDayName
(
new
Date
(
'07/18/2016'
));
expect
(
day
).
toBe
(
'Monday'
);
});
it
(
'should return Tuesday'
,
()
=>
{
const
day
=
datetimeUtility
.
getDayName
(
new
Date
(
'07/19/2016'
));
expect
(
day
).
toBe
(
'Tuesday'
);
});
it
(
'should return Wednesday'
,
()
=>
{
const
day
=
datetimeUtility
.
getDayName
(
new
Date
(
'07/20/2016'
));
expect
(
day
).
toBe
(
'Wednesday'
);
});
it
(
'should return Thursday'
,
()
=>
{
const
day
=
datetimeUtility
.
getDayName
(
new
Date
(
'07/21/2016'
));
expect
(
day
).
toBe
(
'Thursday'
);
});
it
(
'should return Friday'
,
()
=>
{
const
day
=
datetimeUtility
.
getDayName
(
new
Date
(
'07/22/2016'
));
expect
(
day
).
toBe
(
'Friday'
);
});
it
(
'should return Saturday'
,
()
=>
{
const
day
=
datetimeUtility
.
getDayName
(
new
Date
(
'07/23/2016'
));
expect
(
day
).
toBe
(
'Saturday'
);
});
});
});
});
describe
(
'dateInWords'
,
()
=>
{
describe
(
'get day difference'
,
()
=>
{
const
date
=
new
Date
(
'07/01/2016'
);
it
(
'should return 7'
,
()
=>
{
const
firstDay
=
new
Date
(
'07/01/2016'
);
const
secondDay
=
new
Date
(
'07/08/2016'
);
const
difference
=
datetimeUtility
.
getDayDifference
(
firstDay
,
secondDay
);
expect
(
difference
).
toBe
(
7
);
});
it
(
'should return date in words'
,
()
=>
{
it
(
'should return 31'
,
()
=>
{
expect
(
datetimeUtility
.
dateInWords
(
date
)).
toEqual
(
'July 1, 2016'
);
const
firstDay
=
new
Date
(
'07/01/2016'
);
const
secondDay
=
new
Date
(
'08/01/2016'
);
const
difference
=
datetimeUtility
.
getDayDifference
(
firstDay
,
secondDay
);
expect
(
difference
).
toBe
(
31
);
});
});
it
(
'should return abbreviated month name'
,
()
=>
{
it
(
'should return 365'
,
()
=>
{
expect
(
datetimeUtility
.
dateInWords
(
date
,
true
)).
toEqual
(
'Jul 1, 2016'
);
const
firstDay
=
new
Date
(
'07/02/2015'
);
const
secondDay
=
new
Date
(
'07/01/2016'
);
const
difference
=
datetimeUtility
.
getDayDifference
(
firstDay
,
secondDay
);
expect
(
difference
).
toBe
(
365
);
});
});
});
});
})();
});
describe
(
'timeIntervalInWords'
,
()
=>
{
it
(
'should return string with number of minutes and seconds'
,
()
=>
{
expect
(
datetimeUtility
.
timeIntervalInWords
(
9.54
)).
toEqual
(
'9 seconds'
);
expect
(
datetimeUtility
.
timeIntervalInWords
(
1
)).
toEqual
(
'1 second'
);
expect
(
datetimeUtility
.
timeIntervalInWords
(
200
)).
toEqual
(
'3 minutes 20 seconds'
);
expect
(
datetimeUtility
.
timeIntervalInWords
(
6008
)).
toEqual
(
'100 minutes 8 seconds'
);
});
});
describe
(
'dateInWords'
,
()
=>
{
const
date
=
new
Date
(
'07/01/2016'
);
it
(
'should return date in words'
,
()
=>
{
expect
(
datetimeUtility
.
dateInWords
(
date
)).
toEqual
(
'July 1, 2016'
);
});
it
(
'should return abbreviated month name'
,
()
=>
{
expect
(
datetimeUtility
.
dateInWords
(
date
,
true
)).
toEqual
(
'Jul 1, 2016'
);
});
});
spec/javascripts/deploy_keys/components/key_spec.js
View file @
139ce1c4
import
Vue
from
'vue'
;
import
Vue
from
'vue'
;
import
DeployKeysStore
from
'~/deploy_keys/store'
;
import
DeployKeysStore
from
'~/deploy_keys/store'
;
import
key
from
'~/deploy_keys/components/key.vue'
;
import
key
from
'~/deploy_keys/components/key.vue'
;
import
{
getTimeago
}
from
'~/lib/utils/datetime_utility'
;
describe
(
'Deploy keys key'
,
()
=>
{
describe
(
'Deploy keys key'
,
()
=>
{
let
vm
;
let
vm
;
...
@@ -37,7 +38,7 @@ describe('Deploy keys key', () => {
...
@@ -37,7 +38,7 @@ describe('Deploy keys key', () => {
it
(
'renders human friendly formatted created date'
,
()
=>
{
it
(
'renders human friendly formatted created date'
,
()
=>
{
expect
(
expect
(
vm
.
$el
.
querySelector
(
'.key-created-at'
).
textContent
.
trim
(),
vm
.
$el
.
querySelector
(
'.key-created-at'
).
textContent
.
trim
(),
).
toBe
(
`created
${
g
l
.
utils
.
g
etTimeago
().
format
(
deployKey
.
created_at
)}
`
);
).
toBe
(
`created
${
getTimeago
().
format
(
deployKey
.
created_at
)}
`
);
});
});
it
(
'shows edit button'
,
()
=>
{
it
(
'shows edit button'
,
()
=>
{
...
...
spec/javascripts/notes_spec.js
View file @
139ce1c4
...
@@ -224,7 +224,6 @@ import '~/notes';
...
@@ -224,7 +224,6 @@ import '~/notes';
notes
.
note_ids
=
[];
notes
.
note_ids
=
[];
notes
.
updatedNotesTrackingMap
=
{};
notes
.
updatedNotesTrackingMap
=
{};
spyOn
(
gl
.
utils
,
'localTimeAgo'
);
spyOn
(
Notes
,
'isNewNote'
).
and
.
callThrough
();
spyOn
(
Notes
,
'isNewNote'
).
and
.
callThrough
();
spyOn
(
Notes
,
'isUpdatedNote'
).
and
.
callThrough
();
spyOn
(
Notes
,
'isUpdatedNote'
).
and
.
callThrough
();
spyOn
(
Notes
,
'animateAppendNote'
).
and
.
callThrough
();
spyOn
(
Notes
,
'animateAppendNote'
).
and
.
callThrough
();
...
@@ -351,7 +350,6 @@ import '~/notes';
...
@@ -351,7 +350,6 @@ import '~/notes';
]);
]);
notes
.
note_ids
=
[];
notes
.
note_ids
=
[];
spyOn
(
gl
.
utils
,
'localTimeAgo'
);
spyOn
(
Notes
,
'isNewNote'
);
spyOn
(
Notes
,
'isNewNote'
);
spyOn
(
Notes
,
'animateAppendNote'
);
spyOn
(
Notes
,
'animateAppendNote'
);
Notes
.
isNewNote
.
and
.
returnValue
(
true
);
Notes
.
isNewNote
.
and
.
returnValue
(
true
);
...
...
spec/javascripts/vue_mr_widget/components/mr_widget_deployment_spec.js
View file @
139ce1c4
import
Vue
from
'vue'
;
import
Vue
from
'vue'
;
import
deploymentComponent
from
'~/vue_merge_request_widget/components/mr_widget_deployment'
;
import
deploymentComponent
from
'~/vue_merge_request_widget/components/mr_widget_deployment'
;
import
MRWidgetService
from
'~/vue_merge_request_widget/services/mr_widget_service'
;
import
MRWidgetService
from
'~/vue_merge_request_widget/services/mr_widget_service'
;
import
{
getTimeago
}
from
'~/lib/utils/datetime_utility'
;
const
deploymentMockData
=
[
const
deploymentMockData
=
[
{
{
...
@@ -48,7 +49,7 @@ describe('MRWidgetDeployment', () => {
...
@@ -48,7 +49,7 @@ describe('MRWidgetDeployment', () => {
describe
(
'formatDate'
,
()
=>
{
describe
(
'formatDate'
,
()
=>
{
it
(
'should work'
,
()
=>
{
it
(
'should work'
,
()
=>
{
const
readable
=
g
l
.
utils
.
g
etTimeago
().
format
(
deployment
.
deployed_at
);
const
readable
=
getTimeago
().
format
(
deployment
.
deployed_at
);
expect
(
vm
.
formatDate
(
deployment
.
deployed_at
)).
toEqual
(
readable
);
expect
(
vm
.
formatDate
(
deployment
.
deployed_at
)).
toEqual
(
readable
);
});
});
});
});
...
...
spec/javascripts/vue_shared/components/time_ago_tooltip_spec.js
View file @
139ce1c4
import
Vue
from
'vue'
;
import
Vue
from
'vue'
;
import
timeagoTooltip
from
'~/vue_shared/components/time_ago_tooltip.vue'
;
import
timeagoTooltip
from
'~/vue_shared/components/time_ago_tooltip.vue'
;
import
'~/lib/utils/datetime_utility'
;
import
{
formatDate
,
getTimeago
}
from
'~/lib/utils/datetime_utility'
;
describe
(
'Time ago with tooltip component'
,
()
=>
{
describe
(
'Time ago with tooltip component'
,
()
=>
{
let
TimeagoTooltip
;
let
TimeagoTooltip
;
...
@@ -24,10 +24,10 @@ describe('Time ago with tooltip component', () => {
...
@@ -24,10 +24,10 @@ describe('Time ago with tooltip component', () => {
expect
(
vm
.
$el
.
tagName
).
toEqual
(
'TIME'
);
expect
(
vm
.
$el
.
tagName
).
toEqual
(
'TIME'
);
expect
(
expect
(
vm
.
$el
.
getAttribute
(
'data-original-title'
),
vm
.
$el
.
getAttribute
(
'data-original-title'
),
).
toEqual
(
gl
.
utils
.
formatDate
(
'2017-05-08T14:57:39.781Z'
));
).
toEqual
(
formatDate
(
'2017-05-08T14:57:39.781Z'
));
expect
(
vm
.
$el
.
getAttribute
(
'data-placement'
)).
toEqual
(
'top'
);
expect
(
vm
.
$el
.
getAttribute
(
'data-placement'
)).
toEqual
(
'top'
);
const
timeago
=
g
l
.
utils
.
g
etTimeago
();
const
timeago
=
getTimeago
();
expect
(
vm
.
$el
.
textContent
.
trim
()).
toEqual
(
timeago
.
format
(
'2017-05-08T14:57:39.781Z'
));
expect
(
vm
.
$el
.
textContent
.
trim
()).
toEqual
(
timeago
.
format
(
'2017-05-08T14:57:39.781Z'
));
});
});
...
...
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