Skip to content

Commit

Permalink
useOnTryESQL in data_view_management
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Oct 3, 2024
1 parent 4675e30 commit f6ab5d4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { RouteComponentProps, useLocation, withRouter } from 'react-router-dom';
import useObservable from 'react-use/lib/useObservable';

import { reactRouterNavigate, useKibana } from '@kbn/kibana-react-plugin/public';
import { NoDataViewsPromptComponent } from '@kbn/shared-ux-prompt-no-data-views';
import { NoDataViewsPromptComponent, useOnTryESQL } from '@kbn/shared-ux-prompt-no-data-views';
import type { SpacesContextProps } from '@kbn/spaces-plugin/public';
import { DataViewType } from '@kbn/data-views-plugin/public';
import { RollupDeprecationTooltip } from '@kbn/rollup';
Expand Down Expand Up @@ -86,6 +86,7 @@ export const IndexPatternTable = ({
application,
chrome,
dataViews,
share,
IndexPatternEditor,
spaces,
overlays,
Expand Down Expand Up @@ -116,6 +117,12 @@ export const IndexPatternTable = ({
const hasDataView = useObservable(dataViewController.hasDataView$, defaults.hasDataView);
const hasESData = useObservable(dataViewController.hasESData$, defaults.hasEsData);

const useOnTryESQLParams = {
locatorClient: share?.url.locators,
navigateToApp: application.navigateToApp,
};
const onTryESQL = useOnTryESQL(useOnTryESQLParams);

const handleOnChange = ({ queryText, error }: { queryText: string; error: unknown }) => {
if (!error) {
setQuery(queryText);
Expand Down Expand Up @@ -362,18 +369,21 @@ export const IndexPatternTable = ({
</ContextWrapper>
</>
);
if (!hasDataView)
if (!hasDataView) {
displayIndexPatternSection = (
<>
<EuiSpacer size="xxl" />
<NoDataViewsPromptComponent
onClickCreate={() => setShowCreateDialog(true)}
canCreateNewDataView={application.capabilities.indexPatterns.save as boolean}
dataViewsDocLink={docLinks.links.indexPatterns.introduction}
onTryESQL={onTryESQL}
esqlDocLink={docLinks.links.query.queryESQL}
emptyPromptColor={'subdued'}
/>
</>
);
}
if (!hasDataView && !hasESData)
displayIndexPatternSection = (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export async function mountManagementSection(
},
indexPatternManagementStart,
] = await getStartServices();

const canSave = dataViews.getCanSaveSync();

if (!canSave) {
Expand All @@ -91,6 +92,7 @@ export async function mountManagementSection(
chrome,
uiSettings,
settings,
share,
notifications,
overlays,
unifiedSearch,
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/data_view_management/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import type { SpacesPluginStart } from '@kbn/spaces-plugin/public';
import type { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
import type { NoDataPagePluginSetup } from '@kbn/no-data-page-plugin/public';
import { SharePluginStart } from '@kbn/share-plugin/public';
import type { IndexPatternManagementStart } from '.';
import type { DataViewMgmtService } from './management_app/data_view_management_service';

Expand All @@ -53,6 +54,7 @@ export interface IndexPatternManagmentContext extends StartServices {
fieldFormatEditors: IndexPatternFieldEditorStart['fieldFormatEditors'];
IndexPatternEditor: DataViewEditorStart['IndexPatternEditorComponent'];
fieldFormats: FieldFormatsStart;
share?: SharePluginStart;
spaces?: SpacesPluginStart;
savedObjectsManagement: SavedObjectsManagementPluginStart;
noDataPage?: NoDataPagePluginSetup;
Expand Down

0 comments on commit f6ab5d4

Please sign in to comment.