-
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
Fix Data Streams and Rollups Jobs deep-link bugs #70903
Changes from all commits
8692515
c3c471d
cfe0b7a
74bd3aa
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { parse, ParsedQuery } from 'query-string'; | ||
|
||
export function extractQueryParams(queryString: string = ''): ParsedQuery<string> { | ||
const hrefSplit = queryString.split('?'); | ||
if (!hrefSplit.length) { | ||
return {}; | ||
} | ||
|
||
return parse(hrefSplit[1], { sort: false }); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export { extractQueryParams } from './extract_query_params'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ import { i18n } from '@kbn/i18n'; | |
import { EuiTitle, EuiText, EuiSpacer, EuiEmptyPrompt, EuiLink } from '@elastic/eui'; | ||
import { ScopedHistory } from 'kibana/public'; | ||
|
||
import { reactRouterNavigate } from '../../../../shared_imports'; | ||
import { reactRouterNavigate, extractQueryParams } from '../../../../shared_imports'; | ||
import { useAppContext } from '../../../app_context'; | ||
import { SectionError, SectionLoading, Error } from '../../../components'; | ||
import { useLoadDataStreams } from '../../../services/api'; | ||
|
@@ -28,8 +28,11 @@ export const DataStreamList: React.FunctionComponent<RouteComponentProps<MatchPa | |
match: { | ||
params: { dataStreamName }, | ||
}, | ||
location: { search }, | ||
history, | ||
}) => { | ||
const { isDeepLink } = extractQueryParams(search); | ||
|
||
const { | ||
core: { getUrlForApp }, | ||
plugins: { ingestManager }, | ||
|
@@ -144,7 +147,9 @@ export const DataStreamList: React.FunctionComponent<RouteComponentProps<MatchPa | |
|
||
<DataStreamTable | ||
filters={ | ||
dataStreamName !== undefined ? `name=${decodePathFromReactRouter(dataStreamName)}` : '' | ||
isDeepLink && dataStreamName !== undefined | ||
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. Suggestion: I see the No need to change if we have 100% confidence that 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. Good point, JL! Yes, I think we can be 100% confident it will always be either a string or undefined. It's provided by react router and is extracted from the path, so I'm not seeing any opportunities for it to be null, a number, or an object. I think we can leave as-is. |
||
? `name=${decodePathFromReactRouter(dataStreamName)}` | ||
: '' | ||
} | ||
dataStreams={dataStreams} | ||
reload={reload} | ||
|
This file was deleted.
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.
@cjcenizal @jloleysens I think we need to write some guidelines for our team about how to export from "es_ui_shared". I thought that we were aligned but I see we are not, and that's probably my mistake of not spreading the word.
The guidelines to follow, like we can see on L71, is to export namespace packages from the es_ui_shared folder. This implies to group items by "domain". Here I would have suggested having a "Routing" domain.
Each domain represents a top-level folder that lives inside the "packages_do_not_import" folder.
My main concerns are:
name collision. I don't want to have to tweak my interface names to not collide with other interfaces from other existing domains. If
UpdateHandler
makes sense in my context, I want to be able to use it, even if another domain is using it in a different context.Pollute the public
index.ts
with all the interfaces, constants, functions from all the packages. This file will keep growing with time and it's much better to export "packages" like we do withIf we need to know what a package contains, we then go and look at its barrel file inside its folder.
Until the guidelines are written I think it is important to keep an eye on that during code reviews. WDYT?
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.
@sebelga , I do agree with this overall. I think it is best in as far as possible to follow the convention you've outlined (which is why I created #72034 in response to your comment :) ).
In this case naming of the function seemed so specific that I was not worried collision protection. That being said it would probably have been best if I'd also called it out here.
The other aspect of putting something that is fairly uniquely named inside of a module like
Routing.extractQueryParams
is the added step of unwrapping it later or updating all uses to have the module name prefix. On my initial review I just thought it might be overkill.But again, in retrospect, I think it should have been called it attention here.
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 was not pointing you directly about the review 😊 Just sharing thoughts/concerns. Thanks for creating #72034 !
The thing about thinking "naming of the function seemed so specific that I was not worried collision protection" is that it is subject to interpretation so I think it is better to follow a pattern and stick to it.
For the extra unwrapping, yes there is an extra step but I think it is worth in the long run. True that we might need to update the code in a few places but I didn't find it too complex to do when I worked with Forms
IMO it makes it very clear what reusable package(s) a file uses and we can understand the context of a specific handler/interface.