Skip to content

Commit

Permalink
fix: avoid error on typing colon (#6056)
Browse files Browse the repository at this point in the history
* fix: avoid error on typing colon
* Fix eslint errors
* Update CHANGELOG.md
* fix eslint error
* Requested changes from review
  • Loading branch information
R290 authored Sep 13, 2023
1 parent 5b27f15 commit ff78803
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Bug Fixes

1. [#6056](https://github.com/influxdata/chronograf/pull/6056): Fix error on typing colon

## v1.10.1

### Features
Expand Down
1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"@types/react-dnd": "^2.0.36",
"@types/react-dnd-html5-backend": "^2.1.9",
"@types/react-dom": "^16.8.4",
"@types/react-onclickoutside": "^6.7.4",
"@types/react-router": "^3.0.15",
"@types/react-router-redux": "4",
"@types/react-virtualized": "^9.18.3",
Expand Down
58 changes: 35 additions & 23 deletions ui/src/shared/components/TemplateDrawer.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,52 @@
import React, {FunctionComponent, MouseEvent} from 'react'
import React, {Component, MouseEvent} from 'react'
import OnClickOutside from 'react-onclickoutside'
import classnames from 'classnames'

import {Template} from 'src/types'

interface TempVar {
tempVar: string
}

interface Props {
templates: Template[]
selected: Template
selected: TempVar
onMouseOverTempVar: (
template: Template
) => (e: MouseEvent<HTMLDivElement>) => void
onClickTempVar: (
template: Template
) => (e: MouseEvent<HTMLDivElement>) => void
}
const TemplateDrawer: FunctionComponent<Props> = ({
templates,
selected,
onMouseOverTempVar,
onClickTempVar,
}) => (
<div className="template-drawer">
{templates.map(t => (
<div
className={classnames('template-drawer--item', {
'template-drawer--selected': t.tempVar === selected.tempVar,
})}
onMouseOver={onMouseOverTempVar(t)}
onMouseDown={onClickTempVar(t)}
key={t.tempVar}
>
{' '}
{t.tempVar}{' '}

// TemplateDrawer must be a class component,
// functional components are not supported by react-onclickoutside
class TemplateDrawer extends Component<Props> {
constructor(props: Props | Readonly<Props>) {
super(props)
}

public render(): React.ReactNode {
const {templates, selected, onMouseOverTempVar, onClickTempVar} = this.props

return (
<div className="template-drawer">
{templates.map(t => (
<div
className={classnames('template-drawer--item', {
'template-drawer--selected': t.tempVar === selected.tempVar,
})}
onMouseOver={onMouseOverTempVar(t)}
onMouseDown={onClickTempVar(t)}
key={t.tempVar}
>
{' '}
{t.tempVar}{' '}
</div>
))}
</div>
))}
</div>
)
)
}
}

export default OnClickOutside(TemplateDrawer)
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2663,6 +2663,13 @@
dependencies:
"@types/react" "^16"

"@types/react-onclickoutside@^6.7.4":
version "6.7.4"
resolved "https://registry.yarnpkg.com/@types/react-onclickoutside/-/react-onclickoutside-6.7.4.tgz#05b1ec0d31a85999873c51e166f57aefa3f037a4"
integrity sha512-N7EnMhxqb+TaUOGJQUV8YJeL3n5qP5+cXwtWRS/FYW+DSEAb8T3xwNsgZ6wEJMHP4/QpfVHcBaFopFjJ9XBuOg==
dependencies:
"@types/react" "*"

"@types/react-redux@^7.1.20":
version "7.1.23"
resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-7.1.23.tgz#3c2bb1bcc698ae69d70735f33c5a8e95f41ac528"
Expand Down

0 comments on commit ff78803

Please sign in to comment.