From be1dd672df90a217b4bd3d7ffed3a7d3b8e32dde Mon Sep 17 00:00:00 2001 From: Rares Mardare Date: Fri, 26 Jul 2024 12:16:09 +0300 Subject: [PATCH] Prevent AG call refresh if a timeout is already pending + few tweaks to the AG table sizing (#4744) # What this PR does - Checks for AG timeout before setting a new one - Changed table column sizing on a few columns within AG --- grafana-plugin/src/assets/style/utils.css | 11 ++-- .../src/pages/incidents/Incidents.tsx | 61 ++++++++++--------- 2 files changed, 39 insertions(+), 33 deletions(-) diff --git a/grafana-plugin/src/assets/style/utils.css b/grafana-plugin/src/assets/style/utils.css index 38795f9a..76d404c0 100644 --- a/grafana-plugin/src/assets/style/utils.css +++ b/grafana-plugin/src/assets/style/utils.css @@ -156,22 +156,25 @@ text-overflow: ellipsis; display: -webkit-box; white-space: initial; + line-clamp: 2; -webkit-line-clamp: 2; -webkit-box-orient: vertical; } .overflow-child--line-1 { + line-clamp: 1; -webkit-line-clamp: 1; } +.line-clamp-3 { + line-clamp: 3; + -webkit-line-clamp: 3; +} + .break-word { word-break: break-all; } -.line-clamp-3 { - -webkit-line-clamp: 3; -} - /* ----- * CSSTransitionGroup fading */ diff --git a/grafana-plugin/src/pages/incidents/Incidents.tsx b/grafana-plugin/src/pages/incidents/Incidents.tsx index 4b873b3c..a48ca8eb 100644 --- a/grafana-plugin/src/pages/incidents/Incidents.tsx +++ b/grafana-plugin/src/pages/incidents/Incidents.tsx @@ -18,7 +18,7 @@ import { observer } from 'mobx-react'; import moment from 'moment-timezone'; import Emoji from 'react-emoji-render'; import { RouteComponentProps, withRouter } from 'react-router-dom'; -import { getUtilStyles } from 'styles/utils.styles'; +import { bem, getUtilStyles } from 'styles/utils.styles'; import { CardButton } from 'components/CardButton/CardButton'; import { CursorPagination } from 'components/CursorPagination/CursorPagination'; @@ -55,7 +55,7 @@ import { PageProps, WithStoreProps } from 'state/types'; import { withMobXProviderContext } from 'state/withStore'; import { LocationHelper } from 'utils/LocationHelper'; import { UserActions } from 'utils/authorization/authorization'; -import { INCIDENT_HORIZONTAL_SCROLLING_STORAGE, PAGE, PLUGIN_ROOT, TEXT_ELLIPSIS_CLASS } from 'utils/consts'; +import { INCIDENT_HORIZONTAL_SCROLLING_STORAGE, PAGE, PLUGIN_ROOT } from 'utils/consts'; import { getItem, setItem } from 'utils/localStorage'; import { TableColumn } from 'utils/types'; @@ -561,7 +561,7 @@ class _IncidentsPage extends React.Component { const { selectedIncidentIds, pagination, isHorizontalScrolling } = this.state; const { alertGroupStore, filtersStore, loaderStore } = this.props.store; const { theme } = this.props; @@ -626,7 +626,7 @@ class _IncidentsPage extends React.Component ); - } + }; renderId = (record: ApiSchemas['AlertGroup']) => { const styles = getUtilStyles(this.props.theme); @@ -640,9 +640,10 @@ class _IncidentsPage extends React.Component { - const { store, query } = this.props; + const { store, query, theme } = this.props; const { start } = this.state.pagination || {}; const { incidentsCursor } = store.alertGroupStore; + const utilStyles = getUtilStyles(theme); return (
@@ -658,7 +659,7 @@ class _IncidentsPage extends React.Component - {record.render_for_web.title} + {record.render_for_web.title} @@ -667,9 +668,15 @@ class _IncidentsPage extends React.Component{record.alerts_count}; - } + renderAlertsCounter = (record: ApiSchemas['AlertGroup']) => { + const { theme } = this.props; + const utilStyles = getUtilStyles(theme); + return ( + + {record.alerts_count} + + ); + }; renderSource = (record: ApiSchemas['AlertGroup']) => { const { @@ -690,7 +697,7 @@ class _IncidentsPage extends React.Component @@ -771,13 +778,16 @@ class _IncidentsPage extends React.Component { + const { theme } = this.props; + const styles = getUtilStyles(theme); + return ( - + ); - } + }; getApplyLabelFilterClickHandler = (label: ApiSchemas['LabelPair']) => { const { @@ -803,11 +813,13 @@ class _IncidentsPage extends React.Component { + const { theme } = this.props; const matchingLabel = alert.labels?.find((label) => label.key.name === column.name)?.value.name; + const utilStyles = getUtilStyles(theme); return ( - + {matchingLabel} @@ -837,19 +849,19 @@ class _IncidentsPage extends React.Component ( ), - grow: 1.5, + grow: 2, }, }; @@ -1006,7 +1018,7 @@ class _IncidentsPage extends React.Component { - if (!this.state.refreshInterval) { + if (!this.state.refreshInterval || this.pollingIntervalId) { return; } @@ -1031,6 +1043,7 @@ class _IncidentsPage extends React.Component { gap: 8px; `, - bau: css` - ${[1, 2, 3].map( - (num) => ` - $--line-${num} { - -webkit-line-clamp: ${num} - } - ` - )} - `, - actionButtons: css` width: 100%; justify-content: flex-end;