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
Boxiang Sun
gitlab-ce
Commits
fc8d4c70
Commit
fc8d4c70
authored
Oct 01, 2018
by
Winnie Hellmann
Committed by
Alessio Caiazza
Oct 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add scheduled job dropdown to pipelines list
parent
786ae683
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
10 deletions
+59
-10
app/assets/javascripts/lib/utils/datetime_utility.js
app/assets/javascripts/lib/utils/datetime_utility.js
+20
-0
app/assets/javascripts/pipelines/components/pipelines_actions.vue
...ts/javascripts/pipelines/components/pipelines_actions.vue
+15
-2
app/assets/javascripts/pipelines/components/pipelines_table_row.vue
.../javascripts/pipelines/components/pipelines_table_row.vue
+5
-2
spec/javascripts/datetime_utility_spec.js
spec/javascripts/datetime_utility_spec.js
+19
-6
No files found.
app/assets/javascripts/lib/utils/datetime_utility.js
View file @
fc8d4c70
...
...
@@ -370,3 +370,23 @@ window.gl.utils = {
getTimeago
,
localTimeAgo
,
};
/**
* Formats milliseconds as timestamp (e.g. 01:02:03).
*
* @param milliseconds
* @returns {string}
*/
export
const
formatTime
=
milliseconds
=>
{
const
remainingSeconds
=
Math
.
floor
(
milliseconds
/
1000
)
%
60
;
const
remainingMinutes
=
Math
.
floor
(
milliseconds
/
1000
/
60
)
%
60
;
const
remainingHours
=
Math
.
floor
(
milliseconds
/
1000
/
60
/
60
);
let
formattedTime
=
''
;
if
(
remainingHours
<
10
)
formattedTime
+=
'
0
'
;
formattedTime
+=
`
${
remainingHours
}
:`
;
if
(
remainingMinutes
<
10
)
formattedTime
+=
'
0
'
;
formattedTime
+=
`
${
remainingMinutes
}
:`
;
if
(
remainingSeconds
<
10
)
formattedTime
+=
'
0
'
;
formattedTime
+=
remainingSeconds
;
return
formattedTime
;
};
app/assets/javascripts/pipelines/components/pipelines_actions.vue
View file @
fc8d4c70
<
script
>
import
{
formatTime
}
from
'
~/lib/utils/datetime_utility
'
;
import
eventHub
from
'
../event_hub
'
;
import
icon
from
'
../../vue_shared/components/icon.vue
'
;
import
tooltip
from
'
../../vue_shared/directives/tooltip
'
;
...
...
@@ -35,6 +36,11 @@ export default {
return
!
action
.
playable
;
},
remainingTime
(
action
)
{
const
remainingMilliseconds
=
new
Date
(
action
.
scheduled_at
).
getTime
()
-
Date
.
now
();
return
formatTime
(
remainingMilliseconds
);
},
},
};
</
script
>
...
...
@@ -63,8 +69,8 @@ export default {
<ul
class=
"dropdown-menu dropdown-menu-right"
>
<li
v-for=
"
(action, i)
in actions"
:key=
"
i
"
v-for=
"
action
in actions"
:key=
"
action.path
"
>
<button
:class=
"
{ disabled: isActionDisabled(action) }"
...
...
@@ -74,6 +80,13 @@ export default {
@click="onClickAction(action.path)"
>
{{
action
.
name
}}
<span
v-if=
"action.scheduled_at"
class=
"pull-right"
>
<icon
name=
"clock"
/>
{{
remainingTime
(
action
)
}}
</span>
</button>
</li>
</ul>
...
...
app/assets/javascripts/pipelines/components/pipelines_table_row.vue
View file @
fc8d4c70
...
...
@@ -59,6 +59,9 @@ export default {
};
},
computed
:
{
actions
()
{
return
[...
this
.
pipeline
.
details
.
manual_actions
,
...
this
.
pipeline
.
details
.
scheduled_actions
];
},
/**
* If provided, returns the commit tag.
* Needed to render the commit component column.
...
...
@@ -321,8 +324,8 @@ export default {
>
<div
class=
"btn-group table-action-buttons"
>
<pipelines-actions-component
v-if=
"
pipeline.details.manual_actions.length
"
:actions=
"
pipeline.details.manual_
actions"
v-if=
"
actions.length > 0
"
:actions=
"actions"
/>
<pipelines-artifacts-component
...
...
spec/javascripts/datetime_utility_spec.js
View file @
fc8d4c70
...
...
@@ -6,9 +6,7 @@ describe('Date time utils', () => {
const
date
=
new
Date
();
date
.
setFullYear
(
date
.
getFullYear
()
-
1
);
expect
(
datetimeUtility
.
timeFor
(
date
),
).
toBe
(
'
Past due
'
);
expect
(
datetimeUtility
.
timeFor
(
date
)).
toBe
(
'
Past due
'
);
});
it
(
'
returns remaining time when in the future
'
,
()
=>
{
...
...
@@ -19,9 +17,7 @@ describe('Date time utils', () => {
// short of a full year, timeFor will return '11 months remaining'
date
.
setDate
(
date
.
getDate
()
+
1
);
expect
(
datetimeUtility
.
timeFor
(
date
),
).
toBe
(
'
1 year remaining
'
);
expect
(
datetimeUtility
.
timeFor
(
date
)).
toBe
(
'
1 year remaining
'
);
});
});
...
...
@@ -168,3 +164,20 @@ describe('getTimeframeWindowFrom', () => {
});
});
});
describe
(
'
formatTime
'
,
()
=>
{
const
expectedTimestamps
=
[
[
0
,
'
00:00:00
'
],
[
1000
,
'
00:00:01
'
],
[
42000
,
'
00:00:42
'
],
[
121000
,
'
00:02:01
'
],
[
10921000
,
'
03:02:01
'
],
[
108000000
,
'
30:00:00
'
],
];
expectedTimestamps
.
forEach
(([
milliseconds
,
expectedTimestamp
])
=>
{
it
(
`formats
${
milliseconds
}
ms as
${
expectedTimestamp
}
`
,
()
=>
{
expect
(
datetimeUtility
.
formatTime
(
milliseconds
)).
toBe
(
expectedTimestamp
);
});
});
});
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