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
abc2b648
Commit
abc2b648
authored
May 14, 2020
by
Ezekiel Kigbo
Committed by
Natalia Tepluhina
May 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added unit prop to shared metric card
Updates specs for the metric card and the time metrics card components
parent
c3e79104
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
8 deletions
+79
-8
ee/app/assets/javascripts/analytics/cycle_analytics/components/time_metrics_card.vue
...nalytics/cycle_analytics/components/time_metrics_card.vue
+47
-0
ee/app/assets/javascripts/analytics/shared/components/metric_card.vue
...s/javascripts/analytics/shared/components/metric_card.vue
+8
-6
ee/spec/frontend/analytics/cycle_analytics/mock_data.js
ee/spec/frontend/analytics/cycle_analytics/mock_data.js
+4
-0
ee/spec/frontend/analytics/shared/components/metric_card_spec.js
.../frontend/analytics/shared/components/metric_card_spec.js
+20
-2
No files found.
ee/app/assets/javascripts/analytics/cycle_analytics/components/time_metrics_card.vue
0 → 100644
View file @
abc2b648
<
script
>
import
MetricCard
from
'
../../shared/components/metric_card.vue
'
;
import
{
timeMetricsData
as
mockTimeMetricsData
}
from
'
../../../../../../spec/frontend/analytics/cycle_analytics/mock_data
'
;
export
default
{
name
:
'
TimeMetricsCard
'
,
components
:
{
MetricCard
,
},
props
:
{
groupPath
:
{
type
:
String
,
required
:
true
,
},
additionalParams
:
{
type
:
Object
,
required
:
false
,
default
:
null
,
},
},
data
()
{
return
{
data
:
[],
loading
:
false
,
};
},
watch
:
{
additionalParams
()
{
this
.
fetchData
();
},
},
mounted
()
{
this
.
fetchData
();
},
methods
:
{
fetchData
()
{
this
.
data
=
mockTimeMetricsData
;
},
},
render
()
{
return
this
.
$scopedSlots
.
default
({
metrics
:
this
.
data
,
loading
:
this
.
loading
,
});
},
};
</
script
>
ee/app/assets/javascripts/analytics/shared/components/metric_card.vue
View file @
abc2b648
...
...
@@ -22,6 +22,13 @@ export default {
default
:
false
,
},
},
methods
:
{
valueText
(
metric
)
{
const
{
value
=
null
,
unit
=
null
}
=
metric
;
if
(
!
value
)
return
'
-
'
;
return
unit
?
`
${
value
}
${
unit
}
`
:
value
;
},
},
};
</
script
>
...
...
@@ -39,12 +46,7 @@ export default {
ref=
"metricItem"
class=
"js-metric-card-item flex-grow text-center"
>
<h3
class=
"my-2"
>
<template
v-if=
"metric.value === null"
>
-
</
template
>
<
template
v-else
>
{{
metric
.
value
}}
</
template
>
</h3>
<h3
class=
"my-2"
>
{{
valueText
(
metric
)
}}
</h3>
<p
class=
"text-secondary gl-font-sm mb-2"
>
{{
metric
.
label
}}
</p>
</div>
</div>
...
...
ee/spec/frontend/analytics/cycle_analytics/mock_data.js
View file @
abc2b648
...
...
@@ -53,6 +53,10 @@ const getStageByTitle = (stages, title) =>
stages
.
find
(
stage
=>
stage
.
title
&&
stage
.
title
.
toLowerCase
().
trim
()
===
title
)
||
{};
export
const
recentActivityData
=
getJSONFixture
(
fixtureEndpoints
.
recentActivityData
);
export
const
timeMetricsData
=
[
{
label
:
'
Lead time
'
,
value
:
'
2
'
,
unit
:
'
days
'
},
{
label
:
'
Cycle time
'
,
value
:
'
1.5
'
,
unit
:
'
days
'
},
];
export
const
customizableStagesAndEvents
=
getJSONFixture
(
fixtureEndpoints
.
customizableCycleAnalyticsStagesAndEvents
,
...
...
ee/spec/frontend/analytics/shared/components/metric_card_spec.js
View file @
abc2b648
...
...
@@ -5,9 +5,9 @@ import MetricCard from 'ee/analytics/shared/components/metric_card.vue';
const
defaultProps
=
{
title
:
'
My fancy title
'
,
metrics
:
[
{
key
:
'
first_metric
'
,
value
:
10
,
label
:
'
First metric
'
},
{
key
:
'
first_metric
'
,
value
:
10
,
label
:
'
First metric
'
,
unit
:
'
days
'
},
{
key
:
'
second_metric
'
,
value
:
20
,
label
:
'
Yet another metric
'
},
{
key
:
'
third_metric
'
,
value
:
null
,
label
:
'
Metric without value
'
},
{
key
:
'
third_metric
'
,
value
:
null
,
label
:
'
Metric without value
'
,
unit
:
'
parsecs
'
},
],
isLoading
:
false
,
};
...
...
@@ -93,6 +93,24 @@ describe('MetricCard', () => {
).
toContain
(
value
);
});
});
describe
(
'
units
'
,
()
=>
{
it
(
`renders when there is a value`
,
()
=>
{
expect
(
findMetricItem
()
.
at
(
0
)
.
text
(),
).
toContain
(
'
10 days
'
);
});
it
(
`does not render without a value`
,
()
=>
{
expect
(
findMetricItem
()
.
at
(
2
)
.
text
(),
).
toContain
(
'
-
'
);
});
});
});
});
});
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