Commit 15920ee0 authored by Miguel Rincon's avatar Miguel Rincon Committed by Clement Ho

Allow refresh rate feature to be disabled

We should allow refresh rate feature to be disabled via feature flag.

Enabling refresh rate for all user might have impact in performance if
too many of them enable it. We want to release this feature and monitor
it's behavior.
parent a43489c1
...@@ -10,6 +10,7 @@ import { ...@@ -10,6 +10,7 @@ import {
GlNewDropdownDivider, GlNewDropdownDivider,
GlTooltipDirective, GlTooltipDirective,
} from '@gitlab/ui'; } from '@gitlab/ui';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
const makeInterval = (length = 0, unit = 's') => { const makeInterval = (length = 0, unit = 's') => {
const shortLabel = `${length}${unit}`; const shortLabel = `${length}${unit}`;
...@@ -53,6 +54,7 @@ export default { ...@@ -53,6 +54,7 @@ export default {
directives: { directives: {
GlTooltip: GlTooltipDirective, GlTooltip: GlTooltipDirective,
}, },
mixins: [glFeatureFlagsMixin()],
data() { data() {
return { return {
refreshInterval: null, refreshInterval: null,
...@@ -60,6 +62,12 @@ export default { ...@@ -60,6 +62,12 @@ export default {
}; };
}, },
computed: { computed: {
disableMetricDashboardRefreshRate() {
// Can refresh rates impact performance?
// Add "negative" feature flag called `disable_metric_dashboard_refresh_rate`
// See more at: https://gitlab.com/gitlab-org/gitlab/-/issues/229831
return this.glFeatures.disableMetricDashboardRefreshRate;
},
dropdownText() { dropdownText() {
return this.refreshInterval?.shortLabel ?? __('Off'); return this.refreshInterval?.shortLabel ?? __('Off');
}, },
...@@ -142,7 +150,12 @@ export default { ...@@ -142,7 +150,12 @@ export default {
icon="retry" icon="retry"
@click="refresh" @click="refresh"
/> />
<gl-new-dropdown v-gl-tooltip :title="s__('Metrics|Set refresh rate')" :text="dropdownText"> <gl-new-dropdown
v-if="!disableMetricDashboardRefreshRate"
v-gl-tooltip
:title="s__('Metrics|Set refresh rate')"
:text="dropdownText"
>
<gl-new-dropdown-item <gl-new-dropdown-item
:is-check-item="true" :is-check-item="true"
:is-checked="refreshInterval === null" :is-checked="refreshInterval === null"
......
...@@ -13,6 +13,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController ...@@ -13,6 +13,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
authorize_metrics_dashboard! authorize_metrics_dashboard!
push_frontend_feature_flag(:prometheus_computed_alerts) push_frontend_feature_flag(:prometheus_computed_alerts)
push_frontend_feature_flag(:disable_metric_dashboard_refresh_rate)
end end
before_action :authorize_read_environment!, except: [:metrics, :additional_metrics, :metrics_dashboard, :metrics_redirect] before_action :authorize_read_environment!, except: [:metrics, :additional_metrics, :metrics_dashboard, :metrics_redirect]
before_action :authorize_create_environment!, only: [:new, :create] before_action :authorize_create_environment!, only: [:new, :create]
......
...@@ -9,6 +9,7 @@ module Projects ...@@ -9,6 +9,7 @@ module Projects
before_action :authorize_metrics_dashboard! before_action :authorize_metrics_dashboard!
before_action do before_action do
push_frontend_feature_flag(:prometheus_computed_alerts) push_frontend_feature_flag(:prometheus_computed_alerts)
push_frontend_feature_flag(:disable_metric_dashboard_refresh_rate)
end end
def show def show
......
...@@ -10,8 +10,8 @@ describe('RefreshButton', () => { ...@@ -10,8 +10,8 @@ describe('RefreshButton', () => {
let dispatch; let dispatch;
let documentHidden; let documentHidden;
const createWrapper = () => { const createWrapper = (options = {}) => {
wrapper = shallowMount(RefreshButton, { store }); wrapper = shallowMount(RefreshButton, { store, ...options });
}; };
const findRefreshBtn = () => wrapper.find(GlButton); const findRefreshBtn = () => wrapper.find(GlButton);
...@@ -57,6 +57,20 @@ describe('RefreshButton', () => { ...@@ -57,6 +57,20 @@ describe('RefreshButton', () => {
expect(findDropdown().props('text')).toBe('Off'); expect(findDropdown().props('text')).toBe('Off');
}); });
describe('when feature flag disable_metric_dashboard_refresh_rate is on', () => {
beforeEach(() => {
createWrapper({
provide: {
glFeatures: { disableMetricDashboardRefreshRate: true },
},
});
});
it('refresh rate is not available', () => {
expect(findDropdown().exists()).toBe(false);
});
});
describe('refresh rate options', () => { describe('refresh rate options', () => {
it('presents multiple options', () => { it('presents multiple options', () => {
expect(findOptions().length).toBeGreaterThan(1); expect(findOptions().length).toBeGreaterThan(1);
......
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