New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug 1804638: add tooltip to devconsole monitoring graph #4363
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,64 @@ | ||
import * as React from 'react'; | ||
import { QueryBrowser } from '@console/internal/components/monitoring/query-browser'; | ||
import { connect } from 'react-redux'; | ||
import { QueryBrowser, QueryObj } from '@console/internal/components/monitoring/query-browser'; | ||
import { Humanize } from '@console/internal/components/utils'; | ||
import { ByteDataTypes } from '@console/shared/src/graph-helper/data-utils'; | ||
import { PrometheusGraphLink } from '@console/internal/components/graphs/prometheus-graph'; | ||
import { queryBrowserPatchQuery } from '@console/internal/actions/ui'; | ||
import './MonitoringDashboardGraph.scss'; | ||
|
||
export enum GraphTypes { | ||
area = 'Area', | ||
line = 'Line', | ||
} | ||
|
||
interface MonitoringDashboardGraphProps { | ||
type DispatchProps = { | ||
patchQuery: (patch: QueryObj) => void; | ||
}; | ||
|
||
type OwnProps = { | ||
title: string; | ||
query: string; | ||
namespace: string; | ||
graphType?: GraphTypes; | ||
humanize: Humanize; | ||
byteDataType: ByteDataTypes; | ||
} | ||
}; | ||
|
||
type MonitoringDashboardGraphProps = OwnProps & DispatchProps; | ||
|
||
const defaultTimespan = 30 * 60 * 1000; | ||
|
||
const MonitoringDashboardGraph: React.FC<MonitoringDashboardGraphProps> = ({ | ||
export const MonitoringDashboardGraph: React.FC<MonitoringDashboardGraphProps> = ({ | ||
query, | ||
namespace, | ||
title, | ||
patchQuery, | ||
graphType = GraphTypes.area, | ||
}) => { | ||
return ( | ||
<div className="odc-monitoring-dashboard-graph"> | ||
<h5>{title}</h5> | ||
<PrometheusGraphLink query={query}> | ||
<QueryBrowser | ||
hideControls | ||
defaultTimespan={defaultTimespan} | ||
namespace={namespace} | ||
queries={[query]} | ||
isStack={graphType === GraphTypes.area} | ||
/> | ||
<div onMouseEnter={() => patchQuery({ query })}> | ||
<QueryBrowser | ||
hideControls | ||
defaultTimespan={defaultTimespan} | ||
namespace={namespace} | ||
queries={[query]} | ||
isStack={graphType === GraphTypes.area} | ||
/> | ||
</div> | ||
</PrometheusGraphLink> | ||
</div> | ||
); | ||
}; | ||
|
||
export default MonitoringDashboardGraph; | ||
const mapDispatchToProps = (dispatch): DispatchProps => ({ | ||
patchQuery: (v: QueryObj) => dispatch(queryBrowserPatchQuery(0, v)), | ||
}); | ||
|
||
export default connect<{}, DispatchProps, OwnProps>( | ||
null, | ||
mapDispatchToProps, | ||
)(MonitoringDashboardGraph); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import * as React from 'react'; | |
import * as _ from 'lodash'; | ||
import { requirePrometheus } from '@console/internal/components/graphs'; | ||
import { topWorkloadMetricsQueries } from '../queries'; | ||
import MonitoringDashboardGraph from '../dashboard/MonitoringDashboardGraph'; | ||
import ConnectedMonitoringDashboardGraph from '../dashboard/MonitoringDashboardGraph'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no need to change all these from I suggest changing all these import name changes back to simply There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok so you'll need to change the name because of the eslint rule for using the same name as an exported value. |
||
|
||
const WorkloadGraphs = requirePrometheus(({ resource }) => { | ||
const namespace = resource?.metadata?.namespace; | ||
|
@@ -12,7 +12,7 @@ const WorkloadGraphs = requirePrometheus(({ resource }) => { | |
return ( | ||
<> | ||
{_.map(topWorkloadMetricsQueries, (q) => ( | ||
<MonitoringDashboardGraph | ||
<ConnectedMonitoringDashboardGraph | ||
key={q.title} | ||
title={q.title} | ||
namespace={namespace} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems very odd to me that every graph is using the same index.
@kyoto can you please provide insight into the proper usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always using the index
0
looks wrong to me, so I'm not sure why this appears to be working.For the admin perspective, I used
onMouseEnter
as a workaround for the problem (see #4060).The root problem is that the tooltips assume the query is in Redux, which is actually only true for the Metrics page. Longer term, we should aim to fix that in the tooltips and remove these workarounds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @kyoto
Longer term we will move to share more of the dashboards.