Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

KIALI-2129 UXD: Move the grafana link to the topbar #876

Merged
merged 4 commits into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/components/Metrics/Metrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ class Metrics extends React.Component<MetricsProps, MetricsState> {
onLabelsFiltersChanged={this.onLabelsFiltersChanged}
direction={this.props.direction}
labelValues={this.state.labelValues}
grafanaLink={this.getGrafanaLink()}
/>
{expandedChart ? this.renderExpandedChart(expandedChart) : this.renderMetrics()}
</div>
Expand All @@ -254,13 +255,6 @@ class Metrics extends React.Component<MetricsProps, MetricsState> {
<div className="card-pf-body">{Object.keys(charts).map(key => this.renderChart(key, charts[key]))}</div>
</div>
</div>
{this.props.grafanaInfo && (
<span id="grafana-link">
<a href={this.getGrafanaLink()} target="_blank">
View in Grafana
</a>
</span>
)}
</div>
</div>
);
Expand Down
30 changes: 19 additions & 11 deletions src/components/MetricsOptions/MetricsOptionsBar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { Toolbar, ToolbarRightContent, FormGroup } from 'patternfly-react';
import { Toolbar, ToolbarRightContent, FormGroup, Icon } from 'patternfly-react';
import isEqual from 'lodash/fp/isEqual';

import RefreshContainer from '../../containers/RefreshContainer';
Expand All @@ -18,6 +18,7 @@ export interface MetricsOptionsBarProps {
onLabelsFiltersChanged: (label: L.LabelName, value: string, checked: boolean) => void;
direction: Direction;
labelValues: Map<L.LabelName, L.LabelValues>;
grafanaLink: string;
}

export class MetricsOptionsBar extends React.Component<MetricsOptionsBarProps> {
Expand Down Expand Up @@ -161,17 +162,24 @@ export class MetricsOptionsBar extends React.Component<MetricsOptionsBarProps> {
options={MetricsOptionsBar.ReporterOptions}
/>
</FormGroup>
<ToolbarDropdown
id={'metrics_filter_interval_duration'}
disabled={false}
handleSelect={this.onDurationChanged}
nameDropdown={'Displaying'}
initialValue={this.duration}
initialLabel={String(MetricsOptionsBar.Durations[this.duration])}
options={MetricsOptionsBar.Durations}
/>
{this.props.grafanaLink && (
<FormGroup style={{ borderRight: 'none' }}>
<a id={'grafana_link'} href={this.props.grafanaLink} target="_blank">
View in Grafana <Icon type={'fa'} name={'external-link'} />
</a>
</FormGroup>
)}
<ToolbarRightContent>
<RefreshContainer id="metrics-refresh" handleRefresh={this.props.onRefresh} />
<ToolbarDropdown
id={'metrics_filter_interval_duration'}
disabled={false}
handleSelect={this.onDurationChanged}
nameDropdown={'Fetching'}
initialValue={this.duration}
initialLabel={String(MetricsOptionsBar.Durations[this.duration])}
options={MetricsOptionsBar.Durations}
/>
<RefreshContainer id="metrics-refresh" handleRefresh={this.props.onRefresh} hideLabel={true} />
</ToolbarRightContent>
</Toolbar>
);
Expand Down
18 changes: 18 additions & 0 deletions src/components/MetricsOptions/__tests__/MetricsOptionsBar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('MetricsOptionsBar', () => {
onLabelsFiltersChanged={jest.fn()}
direction={'inbound'}
labelValues={new Map()}
grafanaLink={'http://grafana-istio-system.127.0.0.1.nip.io/d/UbsSZTDik/istio-workload-dashboard'}
/>
</Provider>
);
Expand All @@ -31,6 +32,7 @@ describe('MetricsOptionsBar', () => {
onLabelsFiltersChanged={jest.fn()}
direction={'inbound'}
labelValues={new Map()}
grafanaLink={''}
/>
</Provider>
);
Expand All @@ -44,4 +46,20 @@ describe('MetricsOptionsBar', () => {
wrapper.setProps({}); // Force re-render
expect(optionsChanged).toHaveBeenCalledTimes(2);
});

it('Has a Grafana link', () => {
let wrapper = mount(
<Provider store={store}>
<MetricsOptionsBar
onOptionsChanged={jest.fn()}
onRefresh={jest.fn()}
onLabelsFiltersChanged={jest.fn()}
direction={'inbound'}
labelValues={new Map()}
grafanaLink={'http://grafana-istio-system.127.0.0.1.nip.io/d/UbsSZTDik/istio-workload-dashboard'}
/>
</Provider>
);
expect(wrapper.find('#grafana_link')).toHaveLength(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ShallowWrapper {
>
<MetricsOptionsBar
direction="inbound"
grafanaLink="http://grafana-istio-system.127.0.0.1.nip.io/d/UbsSZTDik/istio-workload-dashboard"
labelValues={Map {}}
onLabelsFiltersChanged={[MockFunction]}
onOptionsChanged={[MockFunction]}
Expand All @@ -37,6 +38,7 @@ ShallowWrapper {
"nodeType": "class",
"props": Object {
"direction": "inbound",
"grafanaLink": "http://grafana-istio-system.127.0.0.1.nip.io/d/UbsSZTDik/istio-workload-dashboard",
"labelValues": Map {},
"onLabelsFiltersChanged": [MockFunction],
"onOptionsChanged": [MockFunction],
Expand All @@ -53,6 +55,7 @@ ShallowWrapper {
"nodeType": "class",
"props": Object {
"direction": "inbound",
"grafanaLink": "http://grafana-istio-system.127.0.0.1.nip.io/d/UbsSZTDik/istio-workload-dashboard",
"labelValues": Map {},
"onLabelsFiltersChanged": [MockFunction],
"onOptionsChanged": [MockFunction],
Expand Down
4 changes: 3 additions & 1 deletion src/components/Refresh/Refresh.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { PollIntervalInMs } from '../../types/Common';
type ComponentProps = {
id: string;
handleRefresh: () => void;
hideLabel?: boolean;
};

type ReduxProps = {
Expand Down Expand Up @@ -54,9 +55,10 @@ class Refresh extends React.Component<Props, State> {

render() {
if (this.props.refreshInterval !== undefined) {
const { hideLabel } = this.props;
return (
<>
<label style={{ paddingRight: '0.5em', marginLeft: '1.5em' }}>Refreshing</label>
{!hideLabel && <label style={{ paddingRight: '0.5em', marginLeft: '1.5em' }}>Refreshing</label>}
<DropdownButton id={this.props.id} title={POLL_INTERVALS[this.props.refreshInterval]}>
{Object.keys(POLL_INTERVALS).map(strKey => {
const key = Number(strKey);
Expand Down
3 changes: 2 additions & 1 deletion src/containers/WorkloadMetricsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { RouteComponentProps, withRouter } from 'react-router';
import Metrics, { MetricsProps } from '../components/Metrics/Metrics';

const mapStateToProps = (state: KialiAppState) => ({
isPageVisible: state.globalState.isPageVisible
isPageVisible: state.globalState.isPageVisible,
grafanaInfo: state.grafanaInfo
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added here the link for workloads @jotak


const WorkloadMetricsConnected = withRouter<RouteComponentProps<{}> & MetricsProps>(connect(mapStateToProps)(Metrics));
Expand Down