-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support trace-scoped external links similar to tag links
Signed-off-by: Ruben Vargas <[email protected]>
- Loading branch information
1 parent
7580270
commit 0f27f9a
Showing
3 changed files
with
125 additions
and
1 deletion.
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
62 changes: 62 additions & 0 deletions
62
packages/jaeger-ui/src/components/common/ExternalLinks.tsx
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,62 @@ | ||
// Copyright (c) 2019 Uber Technologies, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import { Dropdown, Icon, Menu } from 'antd'; | ||
import * as React from 'react'; | ||
import { Link } from '../../types/trace'; | ||
|
||
type ExternalLinksProps = { | ||
links: Link[]; | ||
children?: React.ReactNode; | ||
}; | ||
|
||
const LinkValue = (props: { href: string; title?: string; children: React.ReactNode }) => ( | ||
<a href={props.href} title={props.title} target="_blank" rel="noopener noreferrer"> | ||
{props.children} <Icon className="KeyValueTable--linkIcon" type="export" /> | ||
</a> | ||
); | ||
|
||
const linkValueList = (links: Link[]) => ( | ||
<Menu> | ||
{links.map(({ text, url }, index) => ( | ||
// `index` is necessary in the key because url can repeat | ||
// eslint-disable-next-line react/no-array-index-key | ||
<Menu.Item key={`${url}-${index}`}> | ||
<LinkValue href={url}>{text}</LinkValue> | ||
</Menu.Item> | ||
))} | ||
</Menu> | ||
); | ||
|
||
export default function ExternalLinks(props: ExternalLinksProps) { | ||
const { links } = props; | ||
if (links.length === 1) { | ||
return ( | ||
<div> | ||
<LinkValue href={links[0].url} title={links[0].text}> | ||
{props.children} | ||
</LinkValue> | ||
</div> | ||
); | ||
} | ||
return ( | ||
<div> | ||
<Dropdown overlay={linkValueList(links)} placement="bottomRight" trigger={['click']}> | ||
<a> | ||
{props.children} <Icon className="KeyValueTable--linkIcon is-large" type="profile" /> | ||
</a> | ||
</Dropdown> | ||
</div> | ||
); | ||
} |
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