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
c45a93a7
Commit
c45a93a7
authored
Mar 02, 2022
by
Parkour Karthik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the month view on CI usage by minutes bar chart
Changelog: fixed
parent
124f7b9d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
28 deletions
+19
-28
ee/app/assets/javascripts/ci_minutes_usage/components/minutes_usage_project_chart.vue
..._minutes_usage/components/minutes_usage_project_chart.vue
+17
-12
ee/app/assets/javascripts/ci_minutes_usage/constants.js
ee/app/assets/javascripts/ci_minutes_usage/constants.js
+0
-15
ee/spec/frontend/ci_minutes_usage/components/minutes_usage_project_chart_spec.js
...utes_usage/components/minutes_usage_project_chart_spec.js
+2
-1
No files found.
ee/app/assets/javascripts/ci_minutes_usage/components/minutes_usage_project_chart.vue
View file @
c45a93a7
...
...
@@ -2,13 +2,13 @@
import
{
GlAlert
,
GlDropdown
,
GlDropdownItem
}
from
'
@gitlab/ui
'
;
import
{
GlColumnChart
}
from
'
@gitlab/ui/dist/charts
'
;
import
{
keyBy
}
from
'
lodash
'
;
import
{
formatDate
}
from
'
~/lib/utils/datetime_utility
'
;
import
{
USAGE_BY_PROJECT
,
X_AXIS_PROJECT_LABEL
,
X_AXIS_CATEGORY
,
Y_AXIS_LABEL
,
NO_CI_MINUTES_MSG
,
MONTHS
,
}
from
'
../constants
'
;
export
default
{
...
...
@@ -43,7 +43,7 @@ export default {
];
},
usageDataByMonth
()
{
return
keyBy
(
this
.
minutesUsageData
,
'
month
'
);
return
keyBy
(
this
.
minutesUsageData
,
'
month
Iso8601
'
);
},
getUsageDataSelectedMonth
()
{
return
this
.
usageDataByMonth
[
this
.
selectedMonth
]?.
projects
?.
nodes
.
map
((
cur
)
=>
[
...
...
@@ -52,7 +52,7 @@ export default {
]);
},
months
()
{
return
this
.
minutesUsageData
.
filter
((
cur
)
=>
cur
.
minutes
>
0
).
map
((
cur
)
=>
cur
.
month
);
return
this
.
minutesUsageData
.
filter
((
cur
)
=>
cur
.
minutes
>
0
).
map
((
cur
)
=>
cur
.
month
Iso8601
);
},
isDataEmpty
()
{
return
this
.
minutesUsageData
.
length
===
0
&&
!
this
.
selectedMonth
;
...
...
@@ -69,14 +69,14 @@ export default {
}
},
methods
:
{
changeSelectedMonth
(
month
)
{
this
.
selectedMonth
=
month
;
changeSelectedMonth
(
month
Iso8601
)
{
this
.
selectedMonth
=
month
Iso8601
;
},
setFirstMonthDropdown
()
{
[
this
.
selectedMonth
]
=
this
.
months
;
},
get
TranslatedMonthName
(
month
)
{
return
MONTHS
[
month
.
toLowerCase
()]
??
month
;
get
FormattedMonthYear
(
monthIso8601
)
{
return
formatDate
(
monthIso8601
,
'
mmm yyyy
'
)
;
},
},
};
...
...
@@ -86,16 +86,21 @@ export default {
<div
class=
"gl-display-flex gl-mt-7"
:class=
"
{ 'gl-mb-3': !isDataEmpty }">
<h5
class=
"gl-flex-grow-1"
>
{{
$options
.
USAGE_BY_PROJECT
}}
</h5>
<gl-dropdown
v-if=
"!isDataEmpty"
:text=
"selectedMonth"
data-testid=
"project-month-dropdown"
>
<gl-dropdown
v-if=
"!isDataEmpty"
:text=
"getFormattedMonthYear(selectedMonth)"
data-testid=
"project-month-dropdown"
right
>
<gl-dropdown-item
v-for=
"(month
Name
, index) in months"
v-for=
"(month
Iso8601
, index) in months"
:key=
"index"
:is-checked=
"selectedMonth === month
Name
"
:is-checked=
"selectedMonth === month
Iso8601
"
is-check-item
data-testid=
"month-dropdown-item"
@
click=
"changeSelectedMonth(month
Name
)"
@
click=
"changeSelectedMonth(month
Iso8601
)"
>
{{
get
TranslatedMonthName
(
monthName
)
}}
{{
get
FormattedMonthYear
(
monthIso8601
)
}}
</gl-dropdown-item>
</gl-dropdown>
</div>
...
...
ee/app/assets/javascripts/ci_minutes_usage/constants.js
View file @
c45a93a7
...
...
@@ -9,18 +9,3 @@ export const Y_AXIS_LABEL = __('Minutes');
export
const
NO_CI_MINUTES_MSG
=
s__
(
'
UsageQuota|No CI minutes usage data available.
'
);
export
const
X_AXIS_CATEGORY
=
'
category
'
;
export
const
MONTHS
=
{
january
:
__
(
'
January
'
),
february
:
__
(
'
February
'
),
march
:
__
(
'
March
'
),
april
:
__
(
'
April
'
),
may
:
__
(
'
May
'
),
june
:
__
(
'
June
'
),
july
:
__
(
'
July
'
),
august
:
__
(
'
August
'
),
september
:
__
(
'
September
'
),
october
:
__
(
'
October
'
),
november
:
__
(
'
November
'
),
december
:
__
(
'
December
'
),
};
ee/spec/frontend/ci_minutes_usage/components/minutes_usage_project_chart_spec.js
View file @
c45a93a7
...
...
@@ -2,6 +2,7 @@ import { GlAlert, GlDropdown, GlDropdownItem } from '@gitlab/ui';
import
{
GlColumnChart
}
from
'
@gitlab/ui/dist/charts
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
MinutesUsageProjectChart
from
'
ee/ci_minutes_usage/components/minutes_usage_project_chart.vue
'
;
import
{
formatDate
}
from
'
~/lib/utils/datetime_utility
'
;
import
{
ciMinutesUsageMockData
}
from
'
../mock_data
'
;
const
defaultProps
=
{
minutesUsageData
:
ciMinutesUsageMockData
.
data
.
ciMinutesUsage
.
nodes
};
...
...
@@ -42,7 +43,7 @@ describe('Minutes usage by project chart component', () => {
it
(
'
renders a dropdown component
'
,
()
=>
{
expect
(
findDropdown
().
exists
()).
toBe
(
true
);
expect
(
findDropdown
().
props
(
'
text
'
)).
toBe
(
ciMinutesUsageMockData
.
data
.
ciMinutesUsage
.
nodes
[
0
].
month
,
formatDate
(
ciMinutesUsageMockData
.
data
.
ciMinutesUsage
.
nodes
[
0
].
monthIso8601
,
'
mmm yyyy
'
)
,
);
expect
(
findAlert
().
exists
()).
toBe
(
false
);
});
...
...
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