Skip to content
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

Add breadcrumb navigation at the top of linkerd dashboard #1613

Merged
merged 10 commits into from
Sep 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 20 additions & 0 deletions web/app/css/breadcrumb-header.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@import 'styles.css';

.ant-layout-header {
Copy link

Choose a reason for hiding this comment

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

some visual feedback:
I think this would look more like a part of the header if it were 84px tall ( same height as the linkerd logo container).

background-color: var(--green);
height: 60px;
z-index: 100;
position: fixed;
width: 100vw;
padding:16px 40px;

& span.ant-breadcrumb-link, & span.ant-breadcrumb-separator, & :first-child {
color: #404544;
font-size: 22px;
font-weight: 500;
}
}

.ant-layout-header:last-child {
color: var(--white);
}
4 changes: 2 additions & 2 deletions web/app/css/octopus.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
stroke: var(--orange)
}
& .status-poor .ant-progress-circle-path {
stroke: var(--siennared);
stroke: var(--red);
}
}

Expand All @@ -54,7 +54,7 @@
color: var(--green);
}
&.status-poor {
color: var(--siennared);
color: var(--red);
}
&.status-neutral {
color: #E0E0E0;
Expand Down
6 changes: 3 additions & 3 deletions web/app/css/service-mesh.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
background-color: rgb(130,130,130, 0.8);;
}
&.poor{
background-color: rgb(235, 87, 87, 0.8);
background-color: rgba(255, 77, 43, 0.8);
}
&.good{
background-color: rgb(39, 174, 96, 0.8);
background-color: rgba(38, 233, 157, 0.8);
}
}
}
Expand All @@ -82,7 +82,7 @@ td div.status-dot {
.controller-error-icon {
cursor: pointer;
margin-left: 5px;
color: var(--siennared);
color: var(--red);
}

.controller-pod-error {
Expand Down
14 changes: 11 additions & 3 deletions web/app/css/sidebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ul.ant-menu.ant-menu-sub {
}

& .update {
color: var(--siennared);
color: var(--red);
}

& .ant-select-selection {
Expand Down Expand Up @@ -89,8 +89,8 @@ ul.ant-menu.ant-menu-sub {
}

& .sidebar-menu-header {
height: 80px;
padding: calc(var(--base-width)*2) 14px;
height: 60px;
padding: calc(var(--base-width)) 14px;

&.collapsed {
text-align: center;
Expand All @@ -104,6 +104,14 @@ ul.ant-menu.ant-menu-sub {
line-height: 2;
min-height: 56px;
}

& .ant-badge-status-success {
background-color: var(--green);
}

& .ant-badge-status-error {
background-color: var(--red);
}
}

.ant-layout-sider {
Expand Down
10 changes: 5 additions & 5 deletions web/app/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
--coldgrey: #c9c9c9;
--neutralgrey: #828282;
--silver: #BDBDBD;
--green: #27AE60;
--siennared: #EB5757;
Copy link

Choose a reason for hiding this comment

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

can we change the name of siennared to red? While it is a rather arbitrary name, I doubt it matches the original sianna red now anyway :)

--orange: #FF8C00;
--green: #26E99D;
--red: #FF4D2B;
--orange: #ffae4b;
--latency-p99: var(--royalblue);
--latency-p95: var(--curiousblue);
--latency-p50: var(--pictonblue);
Expand Down Expand Up @@ -154,7 +154,7 @@ h2, h3, h4, h5, h6 {
padding: var(--base-width);
margin-bottom: calc(3 * var(--base-width));
border-radius: 5px;
background: var(--siennared);
background: var(--red);
color: white;
font-size: 12px;
font-weight: var(--font-weight-bold);
Expand Down Expand Up @@ -256,7 +256,7 @@ div.status-dot {
background-color: var(--green);
}
&.status-dot-poor {
background-color: var(--siennared);
background-color: var(--red);
}
&.status-dot-neutral {
background-color: #E0E0E0;
Expand Down
4 changes: 2 additions & 2 deletions web/app/css/tap.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
border-color: var(--green);
}
&.tap-stop {
background-color: var(--siennared);
border-color: var(--siennared);
background-color: var(--red);
border-color: var(--red);
}
}

Expand Down
131 changes: 131 additions & 0 deletions web/app/js/components/BreadcrumbHeader.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import _ from 'lodash';
import PropTypes from "prop-types";
import React from 'react';
import ReactRouterPropTypes from 'react-router-prop-types';
import { withContext } from './util/AppContext.jsx';
import { Breadcrumb, Layout } from 'antd';
import { friendlyTitle, isResource, singularResource } from "./util/Utils.js";
import './../../css/breadcrumb-header.css';


const routeToCrumbTitle = {
"servicemesh": "Service Mesh",
"overview": "Overview",
"tap": "Tap",
"top": "Top"
};

class BreadcrumbHeader extends React.Component {

static propTypes = {
api: PropTypes.shape({
PrefixedLink: PropTypes.func.isRequired,
}).isRequired,
location: ReactRouterPropTypes.location.isRequired,
pathPrefix: PropTypes.string.isRequired
}

constructor(props) {
super(props);
this.api = this.props.api;
}

processResourceDetailURL(segments) {
if (segments.length === 4) {
let splitSegments = _.chunk(segments, 2);
let resourceNameSegment = splitSegments[1];
resourceNameSegment[0] = singularResource(resourceNameSegment[0]);
return _.concat(splitSegments[0], resourceNameSegment.join('/'));
} else {
return segments;
}
}

convertURLToBreadcrumbs(location) {
if (location.length === 0) {
return [];
} else {
let segments = location.split('/').slice(1);
let finalSegments = this.processResourceDetailURL(segments);

return _.map(finalSegments, segment => {
let partialUrl = _.takeWhile(segments, s => {
return s !== segment;
});

if (partialUrl.length !== segments.length) {
partialUrl.push(segment);
}

return {
link: `/${partialUrl.join("/")}`,
segment: segment
};
});
}
}

segmentToFriendlyTitle(segment, isResourceType) {
if (isResourceType) {
return routeToCrumbTitle[segment] || friendlyTitle(segment).plural;
} else {
return routeToCrumbTitle[segment] || segment;
}
}

renderBreadcrumbSegment(segment, index) {
let isMeshResource = isResource(segment);

if (isMeshResource) {
if (index === 0) {
return friendlyTitle(segment).singular;
}
return this.segmentToFriendlyTitle(segment, true);
}
return this.segmentToFriendlyTitle(segment, false);
}

renderBreadcrumbs(breadcrumbs) {
let PrefixedLink = this.api.PrefixedLink;

if (breadcrumbs.length === 1) {
// Check for a single segment so that we can pluralize it.
let singleBreadcrumb = breadcrumbs[0];

return (
<Breadcrumb.Item key={singleBreadcrumb.segment}>
<PrefixedLink
to={singleBreadcrumb.link}>
{this.renderBreadcrumbSegment(singleBreadcrumb.segment)}
</PrefixedLink>
</Breadcrumb.Item>
);
} else {
return _.map(breadcrumbs, (pathSegment, index) => {
return (
<Breadcrumb.Item key={pathSegment.segment}>
<PrefixedLink
to={pathSegment.link}>
{this.renderBreadcrumbSegment(pathSegment.segment, index)}
</PrefixedLink>
</Breadcrumb.Item>
);
});
}
}

render() {
let prefix = this.props.pathPrefix;
let breadcrumbs = this.convertURLToBreadcrumbs(this.props.location.pathname.replace(prefix, ""));

return (
<Layout.Header>
<Breadcrumb separator=">">
{ this.renderBreadcrumbs(breadcrumbs) }
</Breadcrumb>
</Layout.Header>
);
}
}

export default withContext(BreadcrumbHeader);
2 changes: 0 additions & 2 deletions web/app/js/components/Namespace.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import ErrorBanner from './ErrorBanner.jsx';
import { friendlyTitle } from './util/Utils.js';
import MetricsTable from './MetricsTable.jsx';
import NetworkGraph from './NetworkGraph.jsx';
import PageHeader from './PageHeader.jsx';
import { processMultiResourceRollup } from './util/MetricUtils.js';
import PropTypes from 'prop-types';
import React from 'react';
Expand Down Expand Up @@ -130,7 +129,6 @@ class Namespaces extends React.Component {
{ !this.state.error ? null : <ErrorBanner message={this.state.error} /> }
{ !this.state.loaded ? <Spin size="large" /> : (
<div>
<PageHeader header={`Namespace: ${this.state.ns}`} />
{ noMetrics ? <div>No resources detected.</div> : null}
{
_.isEmpty(deploymentsWithMetrics) ? null :
Expand Down
10 changes: 0 additions & 10 deletions web/app/js/components/ResourceDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import AddResources from './AddResources.jsx';
import ErrorBanner from './ErrorBanner.jsx';
import MetricsTable from './MetricsTable.jsx';
import Octopus from './Octopus.jsx';
import PageHeader from './PageHeader.jsx';
import { processNeighborData } from './util/TapUtils.jsx';
import { processSingleResourceRollup } from './util/MetricUtils.js';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -260,20 +259,11 @@ export class ResourceDetailBase extends React.Component {
}

render() {
let resourceBreadcrumb = (
<React.Fragment>
<this.api.PrefixedLink to={"/namespaces/" + this.state.namespace}>
{this.state.namespace}
</this.api.PrefixedLink> &gt; {`${this.state.resource.type}/${this.state.resource.name}`}
</React.Fragment>
);

return (
<div className="page-content">
<div>
{this.banner()}
{resourceBreadcrumb}
<PageHeader header={`${this.state.resource.type}/${this.state.resource.name}`} />
{this.content()}
</div>
</div>
Expand Down
4 changes: 0 additions & 4 deletions web/app/js/components/ResourceList.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import _ from 'lodash';
import { apiErrorPropType } from './util/ApiHelpers.jsx';
import ErrorBanner from './ErrorBanner.jsx';
import { friendlyTitle } from './util/Utils.js';
import MetricsTable from './MetricsTable.jsx';
import PageHeader from './PageHeader.jsx';
import PropTypes from 'prop-types';
import React from 'react';
import { Spin } from 'antd';
Expand Down Expand Up @@ -53,13 +51,11 @@ export class ResourceListBase extends React.Component {
}

render() {
const {loading, resource} = this.props;

return (
<div className="page-content">
<div>
{this.banner()}
{loading ? null : <PageHeader header={friendlyTitle(resource).plural} />}
{this.content()}
</div>
</div>
Expand Down
5 changes: 0 additions & 5 deletions web/app/js/components/ServiceMesh.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { incompleteMeshMessage } from './util/CopyUtils.jsx';
import Metric from './Metric.jsx';
import moment from 'moment';
import { numericSort } from './util/Utils.js';
import PageHeader from './PageHeader.jsx';
import Percentage from './util/Percentage.js';
import PropTypes from 'prop-types';
import React from 'react';
Expand Down Expand Up @@ -357,10 +356,6 @@ class ServiceMesh extends React.Component {
{ !this.state.error ? null : <ErrorBanner message={this.state.error} /> }
{ !this.state.loaded ? <Spin size="large" /> : (
<div>
<PageHeader
header="Service mesh overview"
hideButtons={this.proxyCount() === 0} />

{this.proxyCount() === 0 ?
<CallToAction
numResources={_.size(this.state.nsStatuses)}
Expand Down
10 changes: 5 additions & 5 deletions web/app/js/components/Sidebar.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import _ from 'lodash';
import {friendlyTitle} from './util/Utils.js';
import {Link} from 'react-router-dom';
import { friendlyTitle } from './util/Utils.js';
import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
import React from 'react';
import ReactRouterPropTypes from 'react-router-prop-types';
import Version from './Version.jsx';
import {withContext} from './util/AppContext.jsx';
import {Badge, Form, Icon, Layout, Menu, Select} from 'antd';
import { withContext } from './util/AppContext.jsx';
import { Badge, Form, Icon, Layout, Menu, Select } from 'antd';
import {
excludeResourcesFromRollup,
getSuccessRateClassification,
Expand Down Expand Up @@ -237,7 +237,7 @@ class Sidebar extends React.Component {
<Form layout="inline">
<Form.Item>
<Select
defaultValue="All Namespaces"
defaultValue={this.state.namespaceFilter || "All Namespaces"}
rmars marked this conversation as resolved.
Show resolved Hide resolved
dropdownMatchSelectWidth={true}
onChange={this.handleNamespaceSelector}>
{
Expand Down
2 changes: 0 additions & 2 deletions web/app/js/components/Tap.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import _ from 'lodash';
import ErrorBanner from './ErrorBanner.jsx';
import PageHeader from './PageHeader.jsx';
import PropTypes from 'prop-types';
import React from 'react';
import TapEventTable from './TapEventTable.jsx';
Expand Down Expand Up @@ -346,7 +345,6 @@ class Tap extends React.Component {
{!this.state.error ? null :
<ErrorBanner message={this.state.error} onHideMessage={() => this.setState({ error: null })} />}

<PageHeader header="Tap" />
<TapQueryForm
tapRequestInProgress={this.state.tapRequestInProgress}
handleTapStart={this.handleTapStart}
Expand Down
Loading