-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[App Search] Minor var names follow-up #87258
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,31 +69,30 @@ export const EngineRouter: React.FC = () => { | |
}, | ||
} = useValues(AppLogic); | ||
|
||
const { engineName: engineNameFromUrl } = useParams() as { engineName: string }; | ||
const { engineName, dataLoading, engineNotFound } = useValues(EngineLogic); | ||
const { setEngineName, initializeEngine, clearEngine } = useActions(EngineLogic); | ||
|
||
const { engineName: engineNameParam } = useParams() as { engineName: string }; | ||
const engineBreadcrumb = [ENGINES_TITLE, engineNameParam]; | ||
|
||
const isEngineInStateStale = () => engineName !== engineNameParam; | ||
|
||
useEffect(() => { | ||
setEngineName(engineNameParam); | ||
setEngineName(engineNameFromUrl); | ||
initializeEngine(); | ||
return clearEngine; | ||
}, [engineNameParam]); | ||
}, [engineNameFromUrl]); | ||
|
||
if (engineNotFound) { | ||
setQueuedErrorMessage( | ||
i18n.translate('xpack.enterpriseSearch.appSearch.engine.notFound', { | ||
defaultMessage: "No engine with name '{engineNameParam}' could be found.", | ||
values: { engineNameParam }, | ||
defaultMessage: "No engine with name '{engineName}' could be found.", | ||
values: { engineName }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There isn't really a realistic scenario where |
||
}) | ||
); | ||
return <Redirect to={ENGINES_PATH} />; | ||
} | ||
|
||
if (isEngineInStateStale() || dataLoading) return <Loading />; | ||
const isLoadingNewEngine = engineName !== engineNameFromUrl; | ||
if (isLoadingNewEngine || dataLoading) return <Loading />; | ||
|
||
const engineBreadcrumb = [ENGINES_TITLE, engineName]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, I wanted to simplify |
||
|
||
return ( | ||
<Switch> | ||
|
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.
Feel free to push back if you disagree, but I was thinking
FromUrl
flowed a little better reading-wise and also made it a little clearer where we're setting engineName from. I also played withengineNameFromParam
but ended up likeingFromUrl
a little better