Skip to content

Commit b24a43d

Browse files
ziomeckaKatarzyna Ziomek-Zdanowicz
authored andcommitted
8963 Remove edit icons in dashboard row (#71)
Co-authored-by: Katarzyna Ziomek-Zdanowicz <[email protected]>
1 parent 781e41e commit b24a43d

File tree

1 file changed

+20
-87
lines changed

1 file changed

+20
-87
lines changed

public/app/features/dashboard/components/DashboardRow/DashboardRow.tsx

+20-87
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { css, cx } from '@emotion/css';
22
import { indexOf } from 'lodash';
3-
import { Component } from 'react';
3+
import React, { Component } from 'react';
44
import { Unsubscribable } from 'rxjs';
5+
import {connect} from "react-redux"
56

67
import { GrafanaTheme2 } from '@grafana/data';
78
import { selectors } from '@grafana/e2e-selectors';
@@ -14,13 +15,15 @@ import { ShowConfirmModalEvent } from '../../../../types/events';
1415
import { DashboardModel } from '../../state/DashboardModel';
1516
import { PanelModel } from '../../state/PanelModel';
1617
import { RowOptionsButton } from '../RowOptions/RowOptionsButton';
18+
import { StoreState } from 'app/types';
1719

1820
export interface DashboardRowProps extends Themeable2 {
1921
panel: PanelModel;
2022
dashboard: DashboardModel;
23+
isFnDashboard: boolean
2124
}
2225

23-
export class UnthemedDashboardRow extends Component<DashboardRowProps> {
26+
class Component extends React.Component<DashboardRowProps> {
2427
sub?: Unsubscribable;
2528

2629
componentDidMount() {
@@ -94,12 +97,18 @@ export class UnthemedDashboardRow extends Component<DashboardRowProps> {
9497
};
9598

9699
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+
97107
const title = getTemplateSrv().replace(this.props.panel.title, this.props.panel.scopedVars, 'text');
98108
const count = this.props.panel.panels ? this.props.panel.panels.length : 0;
99109
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+
103112

104113
return (
105114
<div
@@ -164,88 +173,12 @@ export class UnthemedDashboardRow extends Component<DashboardRowProps> {
164173
}
165174
}
166175

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
187180
});
181+
}
188182

189-
return {
190-
dashboardRow: css({
191-
display: 'flex',
192-
alignItems: 'center',
193-
height: '100%',
194183

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

Comments
 (0)