mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
* [Discover] Fix context page with special char in data view (#133222)
* [Discover] fix context page with special char in data view
* [Discover] fix linting
* [Discover] add test
* [Discover] apply suggestions
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 96f31938fa
)
# Conflicts:
# src/plugins/discover/public/application/apps/context/context_app_route.tsx
# test/functional/apps/discover/_context_encoded_url_params.ts
# test/functional/apps/discover/index.ts
# test/functional/page_objects/settings_page.ts
* [Discover] fix prettier
This commit is contained in:
parent
753f389b0e
commit
a85cd9b176
5 changed files with 34 additions and 14 deletions
|
@ -34,6 +34,7 @@ export function ContextAppRoute(props: ContextAppProps) {
|
|||
|
||||
const { indexPatternId, id } = useParams<ContextUrlParams>();
|
||||
const anchorId = decodeURIComponent(id);
|
||||
const dataViewId = decodeURIComponent(indexPatternId);
|
||||
|
||||
useEffect(() => {
|
||||
chrome.setBreadcrumbs([
|
||||
|
@ -46,7 +47,7 @@ export function ContextAppRoute(props: ContextAppProps) {
|
|||
]);
|
||||
}, [chrome]);
|
||||
|
||||
const { indexPattern, error } = useIndexPattern(services.indexPatterns, indexPatternId);
|
||||
const { indexPattern, error } = useIndexPattern(services.indexPatterns, dataViewId);
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
|
@ -55,15 +56,15 @@ export function ContextAppRoute(props: ContextAppProps) {
|
|||
iconColor="danger"
|
||||
title={
|
||||
<FormattedMessage
|
||||
id="discover.singleDocRoute.errorTitle"
|
||||
defaultMessage="An error occured"
|
||||
id="discover.contextViewRoute.errorTitle"
|
||||
defaultMessage="An error occurred"
|
||||
/>
|
||||
}
|
||||
body={
|
||||
<FormattedMessage
|
||||
id="discover.singleDocRoute.errorMessage"
|
||||
defaultMessage="No matching index pattern for id {indexPatternId}"
|
||||
values={{ indexPatternId }}
|
||||
id="discover.contextViewRoute.errorMessage"
|
||||
defaultMessage="No matching data view for id {dataViewId}"
|
||||
values={{ dataViewId }}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
|
|
@ -64,13 +64,13 @@ export function SingleDocRoute(props: SingleDocRouteProps) {
|
|||
title={
|
||||
<FormattedMessage
|
||||
id="discover.singleDocRoute.errorTitle"
|
||||
defaultMessage="An error occured"
|
||||
defaultMessage="An error occurred"
|
||||
/>
|
||||
}
|
||||
body={
|
||||
<FormattedMessage
|
||||
id="discover.singleDocRoute.errorMessage"
|
||||
defaultMessage="No matching index pattern for id {indexPatternId}"
|
||||
defaultMessage="No matching data view for id {indexPatternId}"
|
||||
values={{ indexPatternId }}
|
||||
/>
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
import expect from '@kbn/expect';
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
|
||||
const customDataViewIdParam = 'context-enc:oded-param';
|
||||
const customDocIdParam = '1+1=2';
|
||||
|
||||
export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||
const dataGrid = getService('dataGrid');
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
|
@ -22,21 +25,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
await security.testUser.setRoles(['kibana_admin', 'context_encoded_param']);
|
||||
await PageObjects.common.navigateToApp('settings');
|
||||
await es.transport.request({
|
||||
path: '/context-encoded-param/_doc/1+1=2',
|
||||
path: `/context-encoded-param/_doc/${customDocIdParam}`,
|
||||
method: 'PUT',
|
||||
body: {
|
||||
username: 'Dmitry',
|
||||
'@timestamp': '2015-09-21T09:30:23',
|
||||
},
|
||||
});
|
||||
await PageObjects.settings.createIndexPattern('context-encoded-param');
|
||||
|
||||
await kibanaServer.uiSettings.update({ 'doc_table:legacy': false });
|
||||
await PageObjects.settings.createIndexPattern(
|
||||
'context-encoded-param',
|
||||
'@timestamp',
|
||||
true,
|
||||
customDataViewIdParam
|
||||
);
|
||||
await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings();
|
||||
await PageObjects.common.navigateToApp('discover');
|
||||
});
|
||||
|
||||
it('should navigate correctly', async () => {
|
||||
it('should navigate correctly when ', async () => {
|
||||
await PageObjects.discover.selectIndexPattern('context-encoded-param');
|
||||
await PageObjects.header.waitUntilLoadingHasFinished();
|
||||
|
|
@ -53,6 +53,6 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
|
|||
loadTestFile(require.resolve('./_date_nested'));
|
||||
loadTestFile(require.resolve('./_search_on_page_load'));
|
||||
loadTestFile(require.resolve('./_chart_hidden'));
|
||||
loadTestFile(require.resolve('./_context_encoded_url_param'));
|
||||
loadTestFile(require.resolve('./_context_encoded_url_params'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -343,11 +343,20 @@ export class SettingsPageObject extends FtrService {
|
|||
}
|
||||
}
|
||||
|
||||
async addCustomDataViewId(value: string) {
|
||||
await this.testSubjects.click('toggleAdvancedSetting');
|
||||
const customDataViewIdInput = await (
|
||||
await this.testSubjects.find('savedObjectIdField')
|
||||
).findByTagName('input');
|
||||
await customDataViewIdInput.type(value);
|
||||
}
|
||||
|
||||
async createIndexPattern(
|
||||
indexPatternName: string,
|
||||
// null to bypass default value
|
||||
timefield: string | null = '@timestamp',
|
||||
isStandardIndexPattern = true
|
||||
isStandardIndexPattern = true,
|
||||
customDataViewId?: string
|
||||
) {
|
||||
await this.retry.try(async () => {
|
||||
await this.header.waitUntilLoadingHasFinished();
|
||||
|
@ -378,6 +387,9 @@ export class SettingsPageObject extends FtrService {
|
|||
if (timefield) {
|
||||
await this.selectTimeFieldOption(timefield);
|
||||
}
|
||||
if (customDataViewId) {
|
||||
await this.addCustomDataViewId(customDataViewId);
|
||||
}
|
||||
await (await this.getSaveIndexPatternButton()).click();
|
||||
});
|
||||
await this.header.waitUntilLoadingHasFinished();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue