Commit a6f9f79b authored by Jose Vargas's avatar Jose Vargas

Changed the feature flag usage

In order for the dashboard component not to fail, the feature flag
is now required by default
parent 217e9e4d
...@@ -89,6 +89,10 @@ export default { ...@@ -89,6 +89,10 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
showTimeWindowDropdown: {
type: Boolean,
required: true,
},
}, },
data() { data() {
return { return {
...@@ -99,11 +103,6 @@ export default { ...@@ -99,11 +103,6 @@ export default {
selectedTimeWindow: '', selectedTimeWindow: '',
}; };
}, },
computed: {
showTimeWindowDropdown() {
return gon.features.metricsTimeWindow;
},
},
created() { created() {
this.service = new MonitoringService({ this.service = new MonitoringService({
metricsEndpoint: this.metricsEndpoint, metricsEndpoint: this.metricsEndpoint,
......
...@@ -14,6 +14,7 @@ export default () => { ...@@ -14,6 +14,7 @@ export default () => {
props: { props: {
...el.dataset, ...el.dataset,
hasMetrics: parseBoolean(el.dataset.hasMetrics), hasMetrics: parseBoolean(el.dataset.hasMetrics),
showTimeWindowDropdown: gon.features.metricsTimeWindow,
}, },
}); });
}, },
......
...@@ -33,13 +33,7 @@ export default class MonitoringService { ...@@ -33,13 +33,7 @@ export default class MonitoringService {
} }
getGraphsData(params = {}) { getGraphsData(params = {}) {
return backOffRequest(() => return backOffRequest(() => axios.get(this.metricsEndpoint, { params }))
axios.get(this.metricsEndpoint, {
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, msPerMinute } from './constants'; import { timeWindows, msPerMinute } from './constants';
export const getTimeDifferenceMinutes = timeWindow => { const getTimeDifferenceMinutes = timeWindow => {
switch (timeWindow) { switch (timeWindow) {
case timeWindows.thirtyMinutes: case timeWindows.thirtyMinutes:
return 30; return 30;
case timeWindows.threeHours: case timeWindows.threeHours:
return 60 * 3; return 60 * 3;
case timeWindows.eightHours:
return 60 * 8;
case timeWindows.oneDay: case timeWindows.oneDay:
return 60 * 24 * 1; return 60 * 24 * 1;
case timeWindows.threeDays: case timeWindows.threeDays:
......
...@@ -39,17 +39,11 @@ describe('Dashboard', () => { ...@@ -39,17 +39,11 @@ 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();
}); });
...@@ -57,7 +51,7 @@ describe('Dashboard', () => { ...@@ -57,7 +51,7 @@ describe('Dashboard', () => {
it('shows a getting started empty state when no metrics are present', () => { it('shows a getting started empty state when no metrics are present', () => {
const component = new DashboardComponent({ const component = new DashboardComponent({
el: document.querySelector('.prometheus-graphs'), el: document.querySelector('.prometheus-graphs'),
propsData, propsData: { ...propsData, showTimeWindowDropdown: false },
}); });
expect(component.$el.querySelector('.prometheus-graphs')).toBe(null); expect(component.$el.querySelector('.prometheus-graphs')).toBe(null);
...@@ -73,7 +67,7 @@ describe('Dashboard', () => { ...@@ -73,7 +67,7 @@ describe('Dashboard', () => {
it('shows up a loading state', done => { it('shows up a loading state', done => {
const component = new DashboardComponent({ const component = new DashboardComponent({
el: document.querySelector('.prometheus-graphs'), el: document.querySelector('.prometheus-graphs'),
propsData: { ...propsData, hasMetrics: true }, propsData: { ...propsData, hasMetrics: true, showTimeWindowDropdown: false },
}); });
Vue.nextTick(() => { Vue.nextTick(() => {
...@@ -85,7 +79,12 @@ describe('Dashboard', () => { ...@@ -85,7 +79,12 @@ describe('Dashboard', () => {
it('hides the legend when showLegend is false', done => { it('hides the legend when showLegend is false', done => {
const component = new DashboardComponent({ const component = new DashboardComponent({
el: document.querySelector('.prometheus-graphs'), el: document.querySelector('.prometheus-graphs'),
propsData: { ...propsData, hasMetrics: true, showLegend: false }, propsData: {
...propsData,
hasMetrics: true,
showLegend: false,
showTimeWindowDropdown: false,
},
}); });
setTimeout(() => { setTimeout(() => {
...@@ -99,7 +98,12 @@ describe('Dashboard', () => { ...@@ -99,7 +98,12 @@ describe('Dashboard', () => {
it('hides the group panels when showPanels is false', done => { it('hides the group panels when showPanels is false', done => {
const component = new DashboardComponent({ const component = new DashboardComponent({
el: document.querySelector('.prometheus-graphs'), el: document.querySelector('.prometheus-graphs'),
propsData: { ...propsData, hasMetrics: true, showPanels: false }, propsData: {
...propsData,
hasMetrics: true,
showPanels: false,
showTimeWindowDropdown: false,
},
}); });
setTimeout(() => { setTimeout(() => {
...@@ -113,7 +117,12 @@ describe('Dashboard', () => { ...@@ -113,7 +117,12 @@ describe('Dashboard', () => {
it('renders the environments dropdown with a number of environments', done => { it('renders the environments dropdown with a number of environments', done => {
const component = new DashboardComponent({ const component = new DashboardComponent({
el: document.querySelector('.prometheus-graphs'), el: document.querySelector('.prometheus-graphs'),
propsData: { ...propsData, hasMetrics: true, showPanels: false }, propsData: {
...propsData,
hasMetrics: true,
showPanels: false,
showTimeWindowDropdown: false,
},
}); });
component.store.storeEnvironmentsData(environmentData); component.store.storeEnvironmentsData(environmentData);
...@@ -131,7 +140,12 @@ describe('Dashboard', () => { ...@@ -131,7 +140,12 @@ describe('Dashboard', () => {
it('hides the environments dropdown list when there is no environments', done => { it('hides the environments dropdown list when there is no environments', done => {
const component = new DashboardComponent({ const component = new DashboardComponent({
el: document.querySelector('.prometheus-graphs'), el: document.querySelector('.prometheus-graphs'),
propsData: { ...propsData, hasMetrics: true, showPanels: false }, propsData: {
...propsData,
hasMetrics: true,
showPanels: false,
showTimeWindowDropdown: false,
},
}); });
component.store.storeEnvironmentsData([]); component.store.storeEnvironmentsData([]);
...@@ -149,7 +163,12 @@ describe('Dashboard', () => { ...@@ -149,7 +163,12 @@ describe('Dashboard', () => {
it('renders the environments dropdown with a single is-active element', done => { it('renders the environments dropdown with a single is-active element', done => {
const component = new DashboardComponent({ const component = new DashboardComponent({
el: document.querySelector('.prometheus-graphs'), el: document.querySelector('.prometheus-graphs'),
propsData: { ...propsData, hasMetrics: true, showPanels: false }, propsData: {
...propsData,
hasMetrics: true,
showPanels: false,
showTimeWindowDropdown: false,
},
}); });
component.store.storeEnvironmentsData(environmentData); component.store.storeEnvironmentsData(environmentData);
...@@ -173,6 +192,7 @@ describe('Dashboard', () => { ...@@ -173,6 +192,7 @@ describe('Dashboard', () => {
hasMetrics: true, hasMetrics: true,
showPanels: false, showPanels: false,
environmentsEndpoint: '', environmentsEndpoint: '',
showTimeWindowDropdown: false,
}, },
}); });
...@@ -184,11 +204,15 @@ describe('Dashboard', () => { ...@@ -184,11 +204,15 @@ describe('Dashboard', () => {
}); });
}); });
it('renders the time window dropdown with a set of options', done => { it('does not show the time window dropdown when the feature flag is not set', done => {
gon.features.metricsTimeWindow = false;
const component = new DashboardComponent({ const component = new DashboardComponent({
el: document.querySelector('.prometheus-graphs'), el: document.querySelector('.prometheus-graphs'),
propsData: { ...propsData, hasMetrics: true, showPanels: false }, propsData: {
...propsData,
hasMetrics: true,
showPanels: false,
showTimeWindowDropdown: false,
},
}); });
setTimeout(() => { setTimeout(() => {
...@@ -200,10 +224,15 @@ describe('Dashboard', () => { ...@@ -200,10 +224,15 @@ describe('Dashboard', () => {
}); });
}); });
it('does not show the time window dropdown when the feature flag is not set', done => { it('rewnders the time window dropdown with a set of options', done => {
const component = new DashboardComponent({ const component = new DashboardComponent({
el: document.querySelector('.prometheus-graphs'), el: document.querySelector('.prometheus-graphs'),
propsData: { ...propsData, hasMetrics: true, showPanels: false }, propsData: {
...propsData,
hasMetrics: true,
showPanels: false,
showTimeWindowDropdown: true,
},
}); });
const numberOfTimeWindows = Object.keys(timeWindows).length; const numberOfTimeWindows = Object.keys(timeWindows).length;
...@@ -234,7 +263,12 @@ describe('Dashboard', () => { ...@@ -234,7 +263,12 @@ describe('Dashboard', () => {
it('sets elWidth to page width when the sidebar is resized', done => { it('sets elWidth to page width when the sidebar is resized', done => {
const component = new DashboardComponent({ const component = new DashboardComponent({
el: document.querySelector('.prometheus-graphs'), el: document.querySelector('.prometheus-graphs'),
propsData: { ...propsData, hasMetrics: true, showPanels: false }, propsData: {
...propsData,
hasMetrics: true,
showPanels: false,
showTimeWindowDropdown: false,
},
}); });
expect(component.elWidth).toEqual(0); expect(component.elWidth).toEqual(0);
......
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