Commit 481d25bf authored by Jose Vargas's avatar Jose Vargas

Add feature flag

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