-
Notifications
You must be signed in to change notification settings - Fork 487
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
Color log markers by user-specified log fields #2369
Draft
SOF3
wants to merge
1
commit into
jaegertracing:main
Choose a base branch
from
SOF3:colored-log-marker
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
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
25 changes: 25 additions & 0 deletions
25
packages/jaeger-ui/src/components/TracePage/TracePageHeader/TracePageSettings.css
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,25 @@ | ||
/* | ||
Copyright (c) 2024 The Jaeger Authors. | ||
|
||
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. | ||
*/ | ||
|
||
.TracePageSettings--cta { | ||
font-size: 1.2rem; | ||
margin: -3px -7px; | ||
} | ||
|
||
.TracePageSettings-emptyColorKey, | ||
.TracePageSettings--noColorKey { | ||
font-style: italic; | ||
} |
150 changes: 150 additions & 0 deletions
150
packages/jaeger-ui/src/components/TracePage/TracePageHeader/TracePageSettings.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,150 @@ | ||
// Copyright (c) 2024 The Jaeger Authors. | ||
// | ||
// 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 * as React from 'react'; | ||
import { Button, Dropdown, Form, Modal, Space, Tag } from 'antd'; | ||
import { IoAdd, IoCheckmark, IoChevronDown, IoClose, IoSettings } from 'react-icons/io5'; | ||
|
||
import keyboardMappings from '../keyboard-mappings'; | ||
import track from './KeyboardShortcutsHelp.track'; | ||
|
||
import './KeyboardShortcutsHelp.css'; | ||
|
||
type Props = { | ||
availableTagKeys: string[]; | ||
selectedMarkerColorKey: string[]; | ||
onMarkerColorKeyChange: (tagKey: string[]) => void; | ||
className: string; | ||
}; | ||
|
||
type State = { | ||
visible: boolean; | ||
}; | ||
|
||
type DataRecord = { | ||
key: string; | ||
kbds: React.JSX.Element; | ||
description: string; | ||
}; | ||
|
||
function renderTagKey(tag: string) { | ||
if (tag === '') { | ||
return <span className="TracePageSettings-emptyMarkerColorKey">(Empty string)</span>; | ||
} | ||
|
||
return <span>{tag}</span>; | ||
} | ||
|
||
function getMarkerColorKeyFormItem(props: Props) { | ||
const items = []; | ||
const callbacks: { [key: string]: boolean } = {}; // whether the key should be added or removed | ||
|
||
for (const key of props.selectedMarkerColorKey) { | ||
callbacks[key] = false; | ||
items.push({ | ||
key: key, | ||
label: ( | ||
<span> | ||
{renderTagKey(key)} | ||
<IoCheckmark /> | ||
</span> | ||
), | ||
}); | ||
} | ||
|
||
for (const key of props.availableTagKeys) { | ||
if (callbacks.hasOwnProperty(key)) { | ||
continue; | ||
} | ||
|
||
callbacks[key] = true; | ||
items.push({ | ||
key: key, | ||
label: renderTagKey(key), | ||
}); | ||
} | ||
|
||
const toggle = key => { | ||
console.log(callbacks); | ||
console.log(key, callbacks[key]); | ||
let newList: string[]; | ||
if (callbacks[key]) { | ||
newList = props.selectedMarkerColorKey.concat([key]); | ||
newList.sort(); | ||
} else { | ||
newList = props.selectedMarkerColorKey.filter(item => item != key); | ||
} | ||
console.log(newList); | ||
props.onMarkerColorKeyChange(newList); | ||
}; | ||
|
||
return ( | ||
<Form.Item label="Color log ticks by log field:"> | ||
<> | ||
{props.selectedMarkerColorKey.map(key => ( | ||
<Tag | ||
closeIcon={<IoClose />} | ||
onClose={e => { | ||
e.preventDefault(); | ||
toggle(key); | ||
}} | ||
> | ||
{renderTagKey(key)} | ||
</Tag> | ||
))} | ||
</> | ||
<Dropdown menu={{ items, onClick: ({ key }) => toggle(key) }}> | ||
<Tag> | ||
<IoAdd /> | ||
</Tag> | ||
</Dropdown> | ||
</Form.Item> | ||
); | ||
} | ||
|
||
export default class TracePageSettings extends React.PureComponent<Props, State> { | ||
state = { | ||
visible: false, | ||
}; | ||
|
||
onCtaClicked = () => { | ||
track(); | ||
this.setState({ visible: true }); | ||
}; | ||
|
||
onCloserClicked = () => this.setState({ visible: false }); | ||
|
||
render() { | ||
const { className } = this.props; | ||
return ( | ||
<React.Fragment> | ||
<Button className={className} htmlType="button" onClick={this.onCtaClicked}> | ||
<span className="TracePageSettings--cta"> | ||
<IoSettings /> | ||
</span> | ||
</Button> | ||
<Modal | ||
title="Page settings" | ||
open={this.state.visible} | ||
onOk={this.onCloserClicked} | ||
onCancel={this.onCloserClicked} | ||
cancelButtonProps={{ style: { display: 'none' } }} | ||
bodyStyle={{ padding: 0 }} | ||
> | ||
<Form>{getMarkerColorKeyFormItem(this.props)}</Form> | ||
</Modal> | ||
</React.Fragment> | ||
); | ||
} | ||
} |
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.
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.
These don't seem relevant in any way to the "page header" type. Is it possible to use the Context API to keep the knowledge of the settings only to the components that actually need this knowledge, such as the Settings popup and the SpanBar that renders the ticks?