@@ -11,6 +11,8 @@ import {
11
11
GlTooltipDirective ,
12
12
} from ' @gitlab/ui' ;
13
13
import CustomMetricsFormFields from ' ~/custom_metrics/components/custom_metrics_form_fields.vue' ;
14
+ import glFeatureFlagsMixin from ' ~/vue_shared/mixins/gl_feature_flags_mixin' ;
15
+ import { PANEL_NEW_PAGE } from ' ../router/constants' ;
14
16
import DuplicateDashboardModal from ' ./duplicate_dashboard_modal.vue' ;
15
17
import CreateDashboardModal from ' ./create_dashboard_modal.vue' ;
16
18
import { s__ } from ' ~/locale' ;
@@ -36,6 +38,7 @@ export default {
36
38
GlTooltip: GlTooltipDirective,
37
39
TrackEvent: TrackEventDirective,
38
40
},
41
+ mixins: [glFeatureFlagsMixin ()],
39
42
props: {
40
43
addingMetricsAvailable: {
41
44
type: Boolean ,
@@ -56,6 +59,10 @@ export default {
56
59
type: String ,
57
60
required: true ,
58
61
},
62
+ isOotbDashboard: {
63
+ type: Boolean ,
64
+ required: true ,
65
+ },
59
66
},
60
67
data () {
61
68
return { customMetricsFormIsValid: null };
@@ -72,15 +79,22 @@ export default {
72
79
},
73
80
isMenuItemEnabled () {
74
81
return {
82
+ addPanel: ! this .isOotbDashboard ,
75
83
createDashboard: Boolean (this .projectPath ),
76
84
editDashboard: this .selectedDashboard ? .can_edit ,
77
85
};
78
86
},
79
87
isMenuItemShown () {
80
88
return {
89
+ addPanel: this .glFeatures .metricsDashboardNewPanelPage ,
81
90
duplicateDashboard: this .isOutOfTheBoxDashboard ,
82
91
};
83
92
},
93
+ newPanelPageLocation () {
94
+ // Retains params/query if any
95
+ const { params , query } = this .$route ?? {};
96
+ return { name: PANEL_NEW_PAGE , params, query };
97
+ },
84
98
},
85
99
methods: {
86
100
... mapActions (' monitoringDashboard' , [' toggleStarredValue' ]),
@@ -117,7 +131,9 @@ export default {
117
131
starDashboard: s__ (' Metrics|Star dashboard' ),
118
132
unstarDashboard: s__ (' Metrics|Unstar dashboard' ),
119
133
addMetric: s__ (' Metrics|Add metric' ),
120
- editDashboardInfo: s__ (' Metrics|Duplicate this dashboard to edit dashboard YAML' ),
134
+ addPanel: s__ (' Metrics|Add panel' ),
135
+ addPanelInfo: s__ (' Metrics|Duplicate this dashboard to add panel or edit dashboard YAML.' ),
136
+ editDashboardInfo: s__ (' Metrics|Duplicate this dashboard to add panel or edit dashboard YAML.' ),
121
137
editDashboard: s__ (' Metrics|Edit dashboard YAML' ),
122
138
createDashboard: s__ (' Metrics|Create new dashboard' ),
123
139
},
@@ -176,6 +192,32 @@ export default {
176
192
< / gl- modal>
177
193
< / template>
178
194
195
+ < template v- if = " isMenuItemShown.addPanel" >
196
+ < gl- new - dropdown- item
197
+ v- if = " isMenuItemEnabled.addPanel"
198
+ data- testid= " add-panel-item-enabled"
199
+ : to= " newPanelPageLocation"
200
+ >
201
+ {{ $options .i18n .addPanel }}
202
+ < / gl- new - dropdown- item>
203
+
204
+ <!--
205
+ wrapper for tooltip as button can be ` disabled`
206
+ https: // bootstrap-vue.org/docs/components/tooltip#disabled-elements
207
+ -->
208
+ < div v- else v- gl- tooltip : title= " $options.i18n.addPanelInfo" >
209
+ < gl- new - dropdown- item
210
+ : alt= " $options.i18n.addPanelInfo"
211
+ : to= " newPanelPageLocation"
212
+ data- testid= " add-panel-item-disabled"
213
+ disabled
214
+ class = " gl-cursor-not-allowed"
215
+ >
216
+ < span class = " gl-text-gray-400" > {{ $options .i18n .addPanel }}< / span>
217
+ < / gl- new - dropdown- item>
218
+ < / div>
219
+ < / template>
220
+
179
221
< gl- new - dropdown- item
180
222
v- if = " isMenuItemEnabled.editDashboard"
181
223
: href= " selectedDashboard ? selectedDashboard.project_blob_path : null"
0 commit comments