-
Notifications
You must be signed in to change notification settings - Fork 626
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
feat(webapp): Annotations flot plugin #1605
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
757cbb3
feat: Annotations flot plugin
pavelpashkovsky 7d4e421
Merge branch 'main' into flot-annotations
pavelpashkovsky 2e7a811
chore: adjust annotations marks appearance
pavelpashkovsky 880cc71
fix: test w/o icons
pavelpashkovsky d6887fa
fix: reverse prev commit
pavelpashkovsky 02b70da
chore: updating types for annotations plugin
pavelpashkovsky f2088cd
refactor: annotations icons
pavelpashkovsky d888f8c
refactor: annotation marks positioning & icons
pavelpashkovsky 7942e4f
refactor: extractRange fn
pavelpashkovsky 4eac5cf
refactor: remove triggering hovering events
pavelpashkovsky a2ae0ed
refactor: rename WRAPPER_ID
pavelpashkovsky bdb8876
refactor: remove shouldStartAnnotationsFunctionality
pavelpashkovsky fc39986
refactor: refactor plugin hooks
pavelpashkovsky 110c234
refactor: use fns instead of arrow fns
pavelpashkovsky d46bfca
Merge branch 'main' into flot-annotations
pavelpashkovsky 9f0c11f
refactor: ContextMenu.plugin
pavelpashkovsky d592291
refactor: composeAnnotationsList
pavelpashkovsky 0df0419
chore: adjust annotation data modal input
pavelpashkovsky 03ef37f
chore: tests (v2)
pavelpashkovsky cfbc3d0
remove cache
eh-am abbe15b
chore: adjust timeline title appearance for single view
pavelpashkovsky 0d220b8
feat: add annotation mark visual feedback on hover
pavelpashkovsky 34d31f0
chore: resolving issues from comments
pavelpashkovsky ec8f5b7
Merge branch 'main' into flot-annotations
pavelpashkovsky 5f9bde6
fix: test raw
pavelpashkovsky bdb2397
refactor: cy test
pavelpashkovsky c02c12b
refactor: annotation mark appearance
pavelpashkovsky 528e96d
refactor: assigning styles
pavelpashkovsky 3df0a6b
fix: added extra nwline for svg icon
pavelpashkovsky 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
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,51 @@ | ||
describe('Annotations', () => { | ||
it('add annotation flow works as expected', () => { | ||
const basePath = Cypress.env('basePath') || ''; | ||
cy.intercept(`${basePath}**/labels*`).as('labels'); | ||
cy.intercept(`${basePath}**/label-values*`, { | ||
fixture: 'appNames.json', | ||
}).as('labelValues'); | ||
cy.intercept('**/render*', { | ||
fixture: 'render.json', | ||
}).as('render'); | ||
|
||
cy.visit('/'); | ||
|
||
cy.wait('@labels'); | ||
cy.wait('@labelValues'); | ||
cy.wait('@render'); | ||
|
||
cy.get('canvas.flot-overlay').click(); | ||
|
||
cy.get('li[role=menuitem]').contains('Add annotation').click(); | ||
|
||
const content = 'test'; | ||
let time; | ||
|
||
cy.get('form#annotation-form') | ||
.findByTestId('annotation_timestamp_input') | ||
.invoke('val') | ||
.then((sometext) => (time = sometext)); | ||
|
||
cy.get('form#annotation-form') | ||
.findByTestId('annotation_content_input') | ||
.type(content); | ||
|
||
cy.get('button[form=annotation-form]').click(); | ||
|
||
cy.get('div[data-testid="annotation_mark_wrapper"]').click(); | ||
|
||
cy.get('form#annotation-form') | ||
.findByTestId('annotation_content_input') | ||
.should('have.value', content); | ||
|
||
cy.get('form#annotation-form') | ||
.findByTestId('annotation_timestamp_input') | ||
.invoke('val') | ||
.then((sometext2) => assert.isTrue(sometext2 === time)); | ||
|
||
cy.get('button[form=annotation-form]').contains('Close').click(); | ||
|
||
cy.get('form#annotation-form').should('not.exist'); | ||
}); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 0 additions & 15 deletions
15
webapp/javascript/components/TimelineChart/Annotation.module.scss
This file was deleted.
Oops, something went wrong.
107 changes: 0 additions & 107 deletions
107
webapp/javascript/components/TimelineChart/Annotation.spec.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
74 changes: 74 additions & 0 deletions
74
webapp/javascript/components/TimelineChart/AnnotationMark/index.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,74 @@ | ||
/* eslint-disable default-case, consistent-return */ | ||
import Color from 'color'; | ||
import React, { useState } from 'react'; | ||
import classNames from 'classnames/bind'; | ||
import AnnotationInfo from '@webapp/pages/continuous/contextMenu/AnnotationInfo'; | ||
import useTimeZone from '@webapp/hooks/timeZone.hook'; | ||
|
||
import styles from './styles.module.scss'; | ||
|
||
const cx = classNames.bind(styles); | ||
|
||
interface IAnnotationMarkProps { | ||
type: 'message'; | ||
color: Color; | ||
value: { | ||
content: string; | ||
timestamp: number; | ||
}; | ||
} | ||
|
||
const getIcon = (type: IAnnotationMarkProps['type']) => { | ||
switch (type) { | ||
case 'message': | ||
return styles.message; | ||
} | ||
}; | ||
|
||
const AnnotationMark = ({ type, color, value }: IAnnotationMarkProps) => { | ||
const { offset } = useTimeZone(); | ||
const [visible, setVisible] = useState(false); | ||
const [target, setTarget] = useState<Element>(); | ||
const [hovered, setHovered] = useState(false); | ||
|
||
const onClick = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => { | ||
e.stopPropagation(); | ||
setTarget(e.target as Element); | ||
setVisible(true); | ||
}; | ||
|
||
const annotationInfoPopover = target ? ( | ||
<AnnotationInfo | ||
popoverAnchorPoint={{ x: 0, y: 27 }} | ||
container={target} | ||
value={value} | ||
timezone={offset === 0 ? 'utc' : 'browser'} | ||
timestamp={value.timestamp} | ||
isOpen={visible} | ||
onClose={() => setVisible(false)} | ||
popoverClassname={styles.form} | ||
/> | ||
) : null; | ||
|
||
const onHoverStyle = { | ||
backgroundColor: hovered ? color.darken(0.2).hex() : color.hex(), | ||
zIndex: hovered ? 2 : 1, | ||
}; | ||
|
||
return ( | ||
<> | ||
<div | ||
data-testid="annotation_mark_wrapper" | ||
onClick={onClick} | ||
style={onHoverStyle} | ||
className={cx(styles.wrapper, getIcon(type))} | ||
role="none" | ||
onMouseEnter={() => setHovered(true)} | ||
onMouseLeave={() => setHovered(false)} | ||
/> | ||
{annotationInfoPopover} | ||
</> | ||
); | ||
}; | ||
|
||
export default AnnotationMark; |
23 changes: 23 additions & 0 deletions
23
webapp/javascript/components/TimelineChart/AnnotationMark/styles.module.scss
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,23 @@ | ||
.wrapper { | ||
position: relative; | ||
width: 18px; | ||
height: 18px; | ||
left: -9px; | ||
top: -7px; | ||
border-radius: 4px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
cursor: pointer; | ||
background-size: 14px; | ||
background-position: center; | ||
background-repeat: no-repeat; | ||
} | ||
|
||
.message { | ||
background-image: url('../../../../images/comment.svg'); | ||
} | ||
|
||
.form { | ||
width: 180px; | ||
} |
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.
Pretty sure color can be inferred from the
type
(which we currently only havemessage
). Each type is gonna be an item/bg color, which is static. We won't allow people to mix and match these. At least not in the foreseeable future.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.
can you please explain more what you want to see here