-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Logs + Metrics UI] Remove eslint exceptions #50979
[Logs + Metrics UI] Remove eslint exceptions #50979
Conversation
Pinging @elastic/logs-metrics-ui (Team:logs-metrics-ui) |
💔 Build Failed
|
Instead of requiring separate `useEffect` usages to populate the URL with the initial state, enhance `useUrlState` with the ability to write back the default state to the URL if the `writeDefaultState` option is true.
7daf5b4
to
c366a36
Compare
💔 Build Failed |
@@ -40,12 +40,9 @@ export const useLogAnalysisResultsUrlState = () => { | |||
pipe(urlTimeRangeRT.decode(value), fold(constant(undefined), identity)), | |||
encodeUrlState: urlTimeRangeRT.encode, | |||
urlStateKey: TIME_RANGE_URL_STATE_KEY, | |||
writeDefaultState: true, |
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.
ℹ️ The initialization is now handled by the useUrlState
hook itself.
@@ -23,29 +23,25 @@ export const SubSection: FunctionComponent<SubSectionProps> = ({ | |||
isLiveStreaming, | |||
stopLiveStreaming, | |||
}) => { | |||
if (!children || !metrics) { |
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.
ℹ️ This condition violated the hook call order invariant so it was moved further down below the hook calls.
} | ||
return null; | ||
}), | ||
[children, metric, id, onChangeRangeTime, isLiveStreaming, stopLiveStreaming] |
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.
ℹ️ Memoizing on children
had no effect in this case because the parent always supplies a new list of React elements.
@@ -42,19 +42,15 @@ export const useMetricsTime = () => { | |||
interval: '>=1m', | |||
}); | |||
|
|||
const parsedFrom = dateMath.parse(timeRange.from); | |||
const parsedTo = dateMath.parse(timeRange.to, { roundUp: true }); |
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.
ℹ️ This always produced a new Moment
and thereby caused the memoization below to have no effect. It was therefore moved into the memoization function's body so the original value could be used as the memoization key.
} | ||
}, [inputRef]); | ||
// the EuiCombobox forwards the ref to an input element | ||
const handleInputRef = useCallback( |
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.
ℹ️ Since the stored Ref
was not used anywhere the imperative action can just be performed in the already imperative ref callback.
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.
I would rename it then to something on the line of focusInput()
💚 Build Succeeded |
I would appreciate a look at the metric explorer fixes by someone more familiar with the intended semantics. Some of the required fixes were a bit more extensive, especially those were the calls were conditionally called. |
addNavItem(item: NavItem): void; | ||
setRefreshInterval(refreshInterval: number): void; | ||
setAutoReload(isAutoReloading: boolean): void; | ||
triggerRefresh(): void; | ||
setTimeRange(timeRange: MetricsTimeInput): void; | ||
} | ||
export const NodeDetailsPage = (props: Props) => { | ||
if (!props.metadata) { |
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.
ℹ️ This condition broke the hook call order invariant so it was moved to the parent component.
triggerRefresh={triggerRefresh} | ||
setTimeRange={setTimeRange} | ||
/> | ||
{metadata ? ( |
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.
ℹ️ This was moved up from the NodeDetailsPage
component to fix the conditional hook usage. There's probably a better way of handling this than not rendering anything, but that's what the component itself did (@simianhacker @phillipb).
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.
Logs
changes LGTM
} | ||
}, [inputRef]); | ||
// the EuiCombobox forwards the ref to an input element | ||
const handleInputRef = useCallback( |
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.
I would rename it then to something on the line of focusInput()
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.
This all looks really good. Not totally sure how I feel about useEffect
needing to specify all of its deps, but it appears there's already a rich thread of folks talking through this facebook/create-react-app#6880. It'll probably just take me a bit to wrap my head around it.
if (!metric) { | ||
if (!id) { | ||
return null; | ||
} else if (!metric) { |
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.
🤦♂looks right to me
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
…le-sql-highlighting * 'master' of github.com:elastic/kibana: (56 commits) Migrate url shortener service (elastic#50896) Re-enable datemath in from/to canvas timelion args (elastic#52159) [Logs + Metrics UI] Remove eslint exceptions (elastic#50979) [Logs + Metrics UI] Add missing headers in Logs & metrics (elastic#52405) [ML] API integration tests - initial tests for bucket span estimator (elastic#52636) [Watcher] New Platform (NP) Migration (elastic#50908) Decouple Authorization subsystem from Legacy API. (elastic#52638) [APM] Fix some warnings logged in APM tests (elastic#52487) [ui/public/utils] Delete unused base_object & find_by_param (elastic#52500) [ui/public/utils] Move items into ui/vis (elastic#52615) fix newlines in kbn-analytics build script Add top level examples folder and command to run, `--run-examples`. (elastic#52027) feat(NA): add trap for SIGINT in the git precommit hook (elastic#52662) [DOCS] Updtes description of elasticsearch.requestHeadersWhitelist (elastic#52675) [Telemetry/Pulse] Updates advanced settings text for usage data (elastic#52657) [SIEM][Detection Engine] Adds the default name space to the end of the signals index [Logs UI] Generalize ML module management (elastic#50662) Removing stateful saved object finder (elastic#52166) Shim oss telemetry (elastic#51168) [Reporting/Screenshots] Do not fail the report if request is aborted (elastic#52344) ... # Conflicts: # src/legacy/core_plugins/console/public/legacy.ts # src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/mode/elasticsearch_sql_highlight_rules.ts # src/legacy/core_plugins/console/public/np_ready/lib/autocomplete/components/full_request_component.ts # src/legacy/core_plugins/console/public/quarantined/src/sense_editor/row_parser.js
|
This removes the two eslint exceptions specific to the `infra` plugin introduced in elastic#49244. fixes elastic#49563
Summary
This removes the two eslint exceptions specific to the
infra
plugin introduced in #49244.fixes #49563
Notes
The changes fall into one of several categories:
useEffect
s and might have changed the semantics.Checklist
This was checked for cross-browser compatibility, including a check against IE11Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n supportDocumentation was added for features that require explanation or tutorialsUnit or functional tests were updated or added to match the most common scenariosThis was checked for keyboard-only and screenreader accessibility