-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ES|QL] Bypass no data views screen (#174316)
> Derived from #173068 > Further addresses #169873 ## Summary - We're adding a link to the No Data Prompt to send a person to explore their data using ES|QL if there exists any ingested data but no data view. - This PR populates the query bar with the first available index (some special handling for logs index. 2a9edec) - All consumers of the prompt/no data view are updated in this PR. - [x] ~There's an issue where, if you're in Discover, clicking the link won't refresh the page. .~ This is fixed on Discover side by reinitializing the state container when user clicks the "try es|ql" link and URL state updates. - [x] ~There is an issue that you can save the es|ql chart from Discover, but Dashboard's empty screen blocks the navigation because data views don't exist #174316 (comment). This is fixed by allowing the dashboard to work without the default data view. Hopefully, this won't lead to major issues - [x] ~ES|QL panels can't be created without the default data views~ this is fixed by trying to fallback to an ad-hoc dataview, plan to move that code to the utils introduced here #174736 - [x] fix circular deps - [x] Add functional tests ## Visuals https://github.com/elastic/kibana/assets/7784120/af3592c1-f4c8-43bb-a128-3268b7761367 ### Storybook Stories #### Can access ES|QL ![Screenshot 2024-01-31 at 17 05 47](https://github.com/elastic/kibana/assets/7784120/370d0351-198e-4dc3-b22e-86f497ad4df5) #### Cannot access (e.g. preview is unavailable - _not implemented_) ![Screenshot 2024-01-31 at 17 05 59](https://github.com/elastic/kibana/assets/7784120/c2bf52ab-9fa8-4f25-9e5d-512d4f4342fa) --------- Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co> Co-authored-by: Rachel Shen <rshen@elastic.co> Co-authored-by: Anton Dosov <anton.dosov@elastic.co>
- Loading branch information
1 parent
6fc6950
commit 450f9f6
Showing
52 changed files
with
553 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
packages/shared-ux/prompt/no_data_views/impl/src/actions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { EuiButton, EuiLink, EuiSpacer, EuiText } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import React from 'react'; | ||
|
||
interface NoDataButtonProps { | ||
onClickCreate: (() => void) | undefined; | ||
canCreateNewDataView: boolean; | ||
onTryESQL?: () => void; | ||
esqlDocLink?: string; | ||
} | ||
|
||
const createDataViewText = i18n.translate('sharedUXPackages.noDataViewsPrompt.addDataViewText', { | ||
defaultMessage: 'Create data view', | ||
}); | ||
|
||
export const NoDataButtonLink = ({ | ||
onClickCreate, | ||
canCreateNewDataView, | ||
onTryESQL, | ||
esqlDocLink, | ||
}: NoDataButtonProps) => { | ||
if (!onTryESQL && !canCreateNewDataView) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
{canCreateNewDataView && ( | ||
<EuiButton | ||
onClick={onClickCreate} | ||
iconType="plusInCircle" | ||
fill={true} | ||
data-test-subj="createDataViewButton" | ||
> | ||
{createDataViewText} | ||
</EuiButton> | ||
)} | ||
{canCreateNewDataView && onTryESQL && <EuiSpacer />} | ||
{onTryESQL && ( | ||
<EuiText size="xs" color={'subdued'}> | ||
<FormattedMessage | ||
id="sharedUXPackages.no_data_views.esqlMessage" | ||
defaultMessage="Alternatively, you can query your data directly using ES|QL (technical preview). {docsLink}" | ||
values={{ | ||
docsLink: esqlDocLink && ( | ||
<EuiLink href={esqlDocLink} target="_blank"> | ||
<FormattedMessage | ||
id="sharedUXPackages.no_data_views.esqlDocsLink" | ||
defaultMessage="Learn more." | ||
/> | ||
</EuiLink> | ||
), | ||
}} | ||
/> | ||
<EuiSpacer size={'s'} /> | ||
<EuiButton color="success" onClick={onTryESQL} size="s" data-test-subj="tryESQLLink"> | ||
<FormattedMessage | ||
id="sharedUXPackages.no_data_views.esqlButtonLabel" | ||
defaultMessage="Try ES|QL" | ||
/> | ||
</EuiButton> | ||
</EuiText> | ||
)} | ||
</> | ||
); | ||
}; |
9 changes: 9 additions & 0 deletions
9
packages/shared-ux/prompt/no_data_views/impl/src/hooks/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export { useOnTryESQL, type UseOnTryEsqlParams } from './use_on_try_esql'; |
39 changes: 39 additions & 0 deletions
39
packages/shared-ux/prompt/no_data_views/impl/src/hooks/use_on_try_esql.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { useEffect, useState } from 'react'; | ||
import { DISCOVER_ESQL_LOCATOR } from '@kbn/deeplinks-analytics'; | ||
|
||
import { NavigateToAppFn, LocatorClient } from '@kbn/shared-ux-prompt-no-data-views-types'; | ||
|
||
export interface UseOnTryEsqlParams { | ||
locatorClient?: LocatorClient; | ||
navigateToApp: NavigateToAppFn; | ||
} | ||
|
||
export const useOnTryESQL = ({ locatorClient, navigateToApp }: UseOnTryEsqlParams) => { | ||
const [onTryESQL, setOnTryEsql] = useState<(() => void) | undefined>(); | ||
|
||
useEffect(() => { | ||
(async () => { | ||
const location = await locatorClient?.get(DISCOVER_ESQL_LOCATOR)?.getLocation({}); | ||
|
||
if (!location) { | ||
return; | ||
} | ||
|
||
const { app, path, state } = location; | ||
|
||
setOnTryEsql(() => () => { | ||
navigateToApp(app, { path, state }); | ||
}); | ||
})(); | ||
}, [locatorClient, navigateToApp]); | ||
|
||
return onTryESQL; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.