Commit 4ac53a1a authored by Mike Greiling's avatar Mike Greiling

coerce hasMetrics to a boolean value before instantiating the Vue component

parent e761e6e1
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
import EmptyState from './empty_state.vue'; import EmptyState from './empty_state.vue';
import MonitoringStore from '../stores/monitoring_store'; import MonitoringStore from '../stores/monitoring_store';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import { convertPermissionToBoolean } from '../../lib/utils/common_utils';
export default { export default {
components: { components: {
...@@ -18,8 +17,9 @@ ...@@ -18,8 +17,9 @@
props: { props: {
hasMetrics: { hasMetrics: {
type: String, type: Boolean,
required: true, required: false,
default: true,
}, },
showLegend: { showLegend: {
type: Boolean, type: Boolean,
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
mounted() { mounted() {
this.resizeThrottled = _.throttle(this.resize, 600); this.resizeThrottled = _.throttle(this.resize, 600);
if (!convertPermissionToBoolean(this.hasMetrics)) { if (!this.hasMetrics) {
this.state = 'gettingStarted'; this.state = 'gettingStarted';
} else { } else {
this.getGraphsData(); this.getGraphsData();
......
import Vue from 'vue'; import Vue from 'vue';
import { convertPermissionToBoolean } from '~/lib/utils/common_utils';
import Dashboard from './components/dashboard.vue'; import Dashboard from './components/dashboard.vue';
export default () => { export default () => {
...@@ -10,7 +11,10 @@ export default () => { ...@@ -10,7 +11,10 @@ export default () => {
el, el,
render(createElement) { render(createElement) {
return createElement(Dashboard, { return createElement(Dashboard, {
props: el.dataset, props: {
...el.dataset,
hasMetrics: convertPermissionToBoolean(el.dataset.hasMetrics),
},
}); });
}, },
}); });
......
...@@ -11,8 +11,7 @@ ...@@ -11,8 +11,7 @@
"empty-unable-to-connect-svg-path": image_path('illustrations/monitoring/unable_to_connect.svg'), "empty-unable-to-connect-svg-path": image_path('illustrations/monitoring/unable_to_connect.svg'),
"metrics-endpoint": metrics_namespace_project_cluster_path( format: :json ), "metrics-endpoint": metrics_namespace_project_cluster_path( format: :json ),
"project-path": project_path(@project), "project-path": project_path(@project),
"tags-path": project_tags_path(@project), "tags-path": project_tags_path(@project) } }
"has-metrics": "true" } }
- else - else
.settings-content .settings-content
......
...@@ -9,7 +9,7 @@ describe('Dashboard', () => { ...@@ -9,7 +9,7 @@ describe('Dashboard', () => {
let DashboardComponent; let DashboardComponent;
let component; let component;
const propsData = { const propsData = {
hasMetrics: 'false', hasMetrics: false,
documentationPath: '/path/to/docs', documentationPath: '/path/to/docs',
settingsPath: '/path/to/settings', settingsPath: '/path/to/settings',
clustersPath: '/path/to/clusters', clustersPath: '/path/to/clusters',
...@@ -58,7 +58,7 @@ describe('Dashboard', () => { ...@@ -58,7 +58,7 @@ describe('Dashboard', () => {
it('shows up a loading state', (done) => { it('shows up a loading state', (done) => {
component = new DashboardComponent({ component = new DashboardComponent({
el: document.querySelector('#prometheus-graphs'), el: document.querySelector('#prometheus-graphs'),
propsData: { ...propsData, hasMetrics: 'true' }, propsData: { ...propsData, hasMetrics: true },
}); });
component.$mount(); component.$mount();
Vue.nextTick(() => { Vue.nextTick(() => {
......
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