提交 481d25bf 编写于 作者: J Jose Vargas

Add feature flag

Also added relevant tests that make use of a stubbed feature flag,
prettified files
上级 268b727a
......@@ -99,6 +99,11 @@ export default {
selectedTimeWindow: '',
};
},
computed: {
getTimeWindowFlagStatus() {
return gon.features.metricsTimeWindow;
},
},
created() {
this.service = new MonitoringService({
metricsEndpoint: this.metricsEndpoint,
......@@ -201,7 +206,10 @@ export default {
<template>
<div v-if="!showEmptyState" class="prometheus-graphs prepend-top-default">
<div v-if="environmentsEndpoint" class="environments d-flex align-items-center">
<div
v-if="environmentsEndpoint"
class="dropdowns d-flex align-items-center justify-content-between"
>
<div class="d-flex align-items-center">
<strong>{{ s__('Metrics|Environment') }}</strong>
<gl-dropdown
......@@ -219,11 +227,10 @@ export default {
>
</gl-dropdown>
</div>
<div class="d-flex align-items-center">
<div v-if="getTimeWindowFlagStatus" class="d-flex align-items-center float-right">
<span class="font-weight-bold">{{ s__('Metrics|Show Last') }}</span>
<gl-dropdown
id="time-window-dropdown"
class="prepend-left-10"
class="prepend-left-10 js-time-window-dropdown"
toggle-class="dropdown-menu-toggle"
:text="selectedTimeWindow"
>
......
......@@ -33,11 +33,13 @@ export default class MonitoringService {
}
getGraphsData(params = {}) {
return backOffRequest(() => axios.get(this.metricsEndpoint, {
params: {
...params
}
}))
return backOffRequest(() =>
axios.get(this.metricsEndpoint, {
params: {
...params,
},
}),
)
.then(resp => resp.data)
.then(response => {
if (!response || !response.data || !response.success) {
......
import { timeWindows } from './constants'
import { timeWindows } from './constants';
export const getTimeDifferenceMinutes = (timeWindow) => {
export const getTimeDifferenceMinutes = timeWindow => {
let timeDifferenceMinutes;
switch(timeWindow) {
switch (timeWindow) {
case timeWindows.thirtyMinutes:
timeDifferenceMinutes = 30;
break;
......
......@@ -39,11 +39,17 @@ describe('Dashboard', () => {
ee: false,
};
gon.features = {
metricsTimeWindow: true,
};
mock = new MockAdapter(axios);
DashboardComponent = Vue.extend(Dashboard);
});
afterEach(() => {
gon.features = {};
mock.restore();
});
......@@ -186,9 +192,9 @@ describe('Dashboard', () => {
const numberOfTimeWindows = Object.keys(timeWindows).length;
setTimeout(() => {
const timeWindowDropdown = component.$el.querySelector('#time-window-dropdown');
const timeWindowDropdown = component.$el.querySelector('.js-time-window-dropdown');
const timeWindowDropdownEls = component.$el.querySelectorAll(
'#time-window-dropdown .dropdown-item',
'.js-time-window-dropdown .dropdown-item',
);
expect(timeWindowDropdown).not.toBeNull();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册