-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f4c24a4
Add breadcrumb navigation at the top of linkerd dashboard
b0f7570
add color to breadcrumb header
1f53019
fix breadcrumb when using linkerd dashboard command
06aa0a6
address PR feedback
bb8d03b
fix overview title not being capitalized
7cf3245
fix import formatting
7cfbe7a
refactor breadcrumb rendering to be much simpler
5995ef0
change color scheme to new material design
cd632af
small tweaks and code cleanup
cc9d6a4
address PR feedback
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@import 'styles.css'; | ||
|
||
.ant-layout-header { | ||
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,9 +12,9 @@ | |
--coldgrey: #c9c9c9; | ||
--neutralgrey: #828282; | ||
--silver: #BDBDBD; | ||
--green: #27AE60; | ||
--siennared: #EB5757; | ||
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. can we change the name of |
||
--orange: #FF8C00; | ||
--green: #26E99D; | ||
--red: #FF4D2B; | ||
--orange: #ffae4b; | ||
--latency-p99: var(--royalblue); | ||
--latency-p95: var(--curiousblue); | ||
--latency-p50: var(--pictonblue); | ||
|
@@ -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); | ||
|
@@ -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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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).