From 164d1696ba8a583e7c5d4ad7bada48c9708bd2ae Mon Sep 17 00:00:00 2001 From: Pavel Zavora Date: Mon, 20 Jun 2022 13:51:07 +0200 Subject: [PATCH] fix(ui): use stable react component keys --- ui/src/admin/components/chronograf/AllUsersTable.js | 6 ++---- ui/src/admin/components/chronograf/OrganizationsTable.js | 3 +-- ui/src/admin/components/chronograf/ProvidersTable.js | 5 ++--- ui/src/admin/components/chronograf/UsersTable.js | 3 +-- ui/src/alerts/components/AlertsTable.tsx | 5 ++--- ui/src/dashboards/components/GaugeOptions.tsx | 2 +- ui/src/kapacitor/components/HandlerTabs.tsx | 5 ++--- ui/src/logs/components/SeverityOptions.tsx | 5 ++--- ui/src/shared/components/DygraphLegend.tsx | 5 ++--- ui/src/shared/components/SourceIndicator.tsx | 7 ++----- ui/src/shared/components/SubSections.tsx | 5 ++--- ui/src/shared/components/Tags.tsx | 7 +++---- ui/src/shared/components/TagsAddButton.tsx | 5 ++--- ui/src/shared/components/ThresholdsList.tsx | 5 ++--- ui/src/shared/components/threesizer/DivisionMenu.tsx | 5 ++--- ui/src/tempVars/components/TemplatePreviewList.tsx | 5 ++--- 16 files changed, 30 insertions(+), 48 deletions(-) diff --git a/ui/src/admin/components/chronograf/AllUsersTable.js b/ui/src/admin/components/chronograf/AllUsersTable.js index d2ddfa9a7..b12b44aa8 100644 --- a/ui/src/admin/components/chronograf/AllUsersTable.js +++ b/ui/src/admin/components/chronograf/AllUsersTable.js @@ -1,8 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import uuid from 'uuid' - import AllUsersTableHeader from 'src/admin/components/chronograf/AllUsersTableHeader' import AllUsersTableRowNew from 'src/admin/components/chronograf/AllUsersTableRowNew' import AllUsersTableRow from 'src/admin/components/chronograf/AllUsersTableRow' @@ -138,10 +136,10 @@ class AllUsersTable extends Component { {users.length ? ( - users.map(user => ( + users.map((user,i) => ( (
- {mappings.map((mapping, i) => ( + {mappings.map((mapping) => ( ( { ( -
+ items={alerts.map((alert, i) => ( +
))} diff --git a/ui/src/dashboards/components/GaugeOptions.tsx b/ui/src/dashboards/components/GaugeOptions.tsx index 26e9cfba2..3c370ec38 100644 --- a/ui/src/dashboards/components/GaugeOptions.tsx +++ b/ui/src/dashboards/components/GaugeOptions.tsx @@ -56,7 +56,7 @@ class GaugeOptions extends PureComponent { isMax={index === gaugeColors.length - 1} visualizationType="gauge" threshold={color} - key={uuid.v4()} + key={index} disableMaxColor={this.disableMaxColor} onChooseColor={this.handleChooseColor} onValidateColorValue={this.handleValidateColorValue} diff --git a/ui/src/kapacitor/components/HandlerTabs.tsx b/ui/src/kapacitor/components/HandlerTabs.tsx index 6c7137cdc..d000a6374 100644 --- a/ui/src/kapacitor/components/HandlerTabs.tsx +++ b/ui/src/kapacitor/components/HandlerTabs.tsx @@ -1,6 +1,5 @@ import React, {FunctionComponent, MouseEvent} from 'react' import classnames from 'classnames' -import uuid from 'uuid' import {Handler} from 'src/types/kapacitor' @@ -27,10 +26,10 @@ const HandlerTabs: FunctionComponent = ({ }) => handlersOnThisAlert.length ? (
    - {handlersOnThisAlert.map(endpoint => { + {handlersOnThisAlert.map((endpoint, i) => { return (
  • = ({ <>
    - {severityLevelColors.map(lc => { + {severityLevelColors.map((lc, i) => { const color = {name: lc.color, hex: SeverityColorValues[lc.color]} return ( -
    +
    {lc.level}
    diff --git a/ui/src/shared/components/DygraphLegend.tsx b/ui/src/shared/components/DygraphLegend.tsx index 216108f94..115acdd17 100644 --- a/ui/src/shared/components/DygraphLegend.tsx +++ b/ui/src/shared/components/DygraphLegend.tsx @@ -3,7 +3,6 @@ import React, {PureComponent, ChangeEvent} from 'react' import {connect} from 'react-redux' import _ from 'lodash' import classnames from 'classnames' -import uuid from 'uuid' // Components import DygraphLegendSort from 'src/shared/components/DygraphLegendSort' @@ -139,12 +138,12 @@ class DygraphLegend extends PureComponent { /> )}
    - {this.filtered.map(({label, color, yHTML, isHighlighted}) => { + {this.filtered.map(({label, color, yHTML, isHighlighted}, i) => { const seriesClass = isHighlighted ? 'dygraph-legend--row highlight' : 'dygraph-legend--row' return ( -
    +
    {label}
    {yHTML || 'no value'}
    diff --git a/ui/src/shared/components/SourceIndicator.tsx b/ui/src/shared/components/SourceIndicator.tsx index 0020885fa..7eb36e57e 100644 --- a/ui/src/shared/components/SourceIndicator.tsx +++ b/ui/src/shared/components/SourceIndicator.tsx @@ -1,6 +1,5 @@ import React, {FunctionComponent} from 'react' import _ from 'lodash' -import uuid from 'uuid' import ReactTooltip from 'react-tooltip' import {SourceContext} from 'src/CheckSources' @@ -19,19 +18,17 @@ const getTooltipText = (source: Source, sourceOverride: Source): string => { } const SourceIndicator: FunctionComponent = ({sourceOverride}) => { - const uuidTooltip: string = uuid.v4() - return ( {(source: Source) => (
    {
    {sections.map( - section => + (section, i) => section.enabled && ( = ({ }) => { return (
    - {tags.map(item => { + {tags.map((item, i) => { return ( { public render() { const {item, confirmText} = this.props return ( - + {item.text || item.name || item} {
    - {items.map(item => ( + {items.map((item, i) => (
    diff --git a/ui/src/shared/components/ThresholdsList.tsx b/ui/src/shared/components/ThresholdsList.tsx index 7c0ad57ff..212b771e0 100644 --- a/ui/src/shared/components/ThresholdsList.tsx +++ b/ui/src/shared/components/ThresholdsList.tsx @@ -60,9 +60,9 @@ class ThresholdsList extends PureComponent { > Add Threshold - {this.sortedColors.map(color => + {this.sortedColors.map((color, i) => color.id === THRESHOLD_TYPE_BASE ? ( -
    +
    Base Color
    { { const {menuItems} = this.props return (
      - {menuItems.map(item => ( + {menuItems.map((item, i) => (
    • diff --git a/ui/src/tempVars/components/TemplatePreviewList.tsx b/ui/src/tempVars/components/TemplatePreviewList.tsx index 52b5352c6..9947f11bf 100644 --- a/ui/src/tempVars/components/TemplatePreviewList.tsx +++ b/ui/src/tempVars/components/TemplatePreviewList.tsx @@ -1,5 +1,4 @@ import React, {PureComponent} from 'react' -import uuid from 'uuid' import {ErrorHandling} from 'src/shared/decorators/errors' import FancyScrollbar from 'src/shared/components/FancyScrollbar' @@ -27,9 +26,9 @@ class TemplatePreviewList extends PureComponent { autoHeight={true} maxHeight={this.resultsListHeight} > - {items.map(item => ( + {items.map((item, i) => (