1
1
import { css , cx } from '@emotion/css' ;
2
2
import { indexOf } from 'lodash' ;
3
- import { Component } from 'react' ;
3
+ import React , { Component } from 'react' ;
4
4
import { Unsubscribable } from 'rxjs' ;
5
+ import { connect } from "react-redux"
5
6
6
7
import { GrafanaTheme2 } from '@grafana/data' ;
7
8
import { selectors } from '@grafana/e2e-selectors' ;
@@ -14,13 +15,15 @@ import { ShowConfirmModalEvent } from '../../../../types/events';
14
15
import { DashboardModel } from '../../state/DashboardModel' ;
15
16
import { PanelModel } from '../../state/PanelModel' ;
16
17
import { RowOptionsButton } from '../RowOptions/RowOptionsButton' ;
18
+ import { StoreState } from 'app/types' ;
17
19
18
20
export interface DashboardRowProps extends Themeable2 {
19
21
panel : PanelModel ;
20
22
dashboard : DashboardModel ;
23
+ isFnDashboard : boolean
21
24
}
22
25
23
- export class UnthemedDashboardRow extends Component < DashboardRowProps > {
26
+ class Component extends React . Component < DashboardRowProps > {
24
27
sub ?: Unsubscribable ;
25
28
26
29
componentDidMount ( ) {
@@ -94,12 +97,18 @@ export class UnthemedDashboardRow extends Component<DashboardRowProps> {
94
97
} ;
95
98
96
99
render ( ) {
100
+ const classes = classNames ( {
101
+ 'dashboard-row' : true ,
102
+ 'dashboard-row--collapsed' : this . props . panel . collapsed ,
103
+ } ) ;
104
+
105
+ const { isFnDashboard} = this . props
106
+
97
107
const title = getTemplateSrv ( ) . replace ( this . props . panel . title , this . props . panel . scopedVars , 'text' ) ;
98
108
const count = this . props . panel . panels ? this . props . panel . panels . length : 0 ;
99
109
const panels = count === 1 ? 'panel' : 'panels' ;
100
- const canEdit = this . props . dashboard . meta . canEdit === true ;
101
- const collapsed = this . props . panel . collapsed ;
102
- const styles = getStyles ( this . props . theme ) ;
110
+ const canEdit = this . props . dashboard . meta . canEdit === true && ! isFnDashboard ;
111
+
103
112
104
113
return (
105
114
< div
@@ -164,88 +173,12 @@ export class UnthemedDashboardRow extends Component<DashboardRowProps> {
164
173
}
165
174
}
166
175
167
- export const DashboardRow = withTheme2 ( UnthemedDashboardRow ) ;
168
-
169
- const getStyles = ( theme : GrafanaTheme2 ) => {
170
- const actions = css ( {
171
- color : theme . colors . text . secondary ,
172
- opacity : 0 ,
173
- [ theme . transitions . handleMotion ( 'no-preference' , 'reduce' ) ] : {
174
- transition : '200ms opacity ease-in 200ms' ,
175
- } ,
176
-
177
- button : {
178
- color : theme . colors . text . secondary ,
179
- paddingLeft : theme . spacing ( 2 ) ,
180
- background : 'transparent' ,
181
- border : 'none' ,
182
-
183
- '&:hover' : {
184
- color : theme . colors . text . maxContrast ,
185
- } ,
186
- } ,
176
+
177
+ function mapStateToProps ( ) {
178
+ return ( state : StoreState ) => ( {
179
+ isFnDashboard : state . fnGlobalState . FNDashboard
187
180
} ) ;
181
+ }
188
182
189
- return {
190
- dashboardRow : css ( {
191
- display : 'flex' ,
192
- alignItems : 'center' ,
193
- height : '100%' ,
194
183
195
- '&:hover, &:focus-within' : {
196
- [ `.${ actions } ` ] : {
197
- opacity : 1 ,
198
- } ,
199
- } ,
200
- } ) ,
201
- dashboardRowCollapsed : css ( {
202
- background : theme . components . panel . background ,
203
- } ) ,
204
- toggleTargetCollapsed : css ( {
205
- flex : 1 ,
206
- cursor : 'pointer' ,
207
- marginRight : '15px' ,
208
- } ) ,
209
- title : css ( {
210
- flexGrow : 0 ,
211
- fontSize : theme . typography . h5 . fontSize ,
212
- fontWeight : theme . typography . fontWeightMedium ,
213
- color : theme . colors . text . primary ,
214
- background : 'transparent' ,
215
- border : 'none' ,
216
-
217
- '.fa' : {
218
- color : theme . colors . text . secondary ,
219
- fontSize : theme . typography . size . xs ,
220
- padding : theme . spacing ( 0 , 1 ) ,
221
- } ,
222
- } ) ,
223
- actions,
224
- count : css ( {
225
- paddingLeft : theme . spacing ( 2 ) ,
226
- color : theme . colors . text . secondary ,
227
- fontStyle : 'italic' ,
228
- fontSize : theme . typography . size . sm ,
229
- fontWeight : 'normal' ,
230
- display : 'none' ,
231
- } ) ,
232
- countCollapsed : css ( {
233
- display : 'inline-block' ,
234
- } ) ,
235
- dragHandle : css ( {
236
- cursor : 'move' ,
237
- width : '16px' ,
238
- height : '100%' ,
239
- background : 'url("public/img/grab_dark.svg") no-repeat 50% 50%' ,
240
- backgroundSize : '8px' ,
241
- visibility : 'hidden' ,
242
- position : 'absolute' ,
243
- top : 0 ,
244
- right : 0 ,
245
- } ) ,
246
- dragHandleCollapsed : css ( {
247
- visibility : 'visible' ,
248
- opacity : 1 ,
249
- } ) ,
250
- } ;
251
- } ;
184
+ export const DashboardRow = connect ( mapStateToProps ) ( Component ) ;
0 commit comments