Skip to content

Commit

Permalink
[DataViewEditor] Skip empty prompt screen (#130862)
Browse files Browse the repository at this point in the history
* [DataViewEditor] Skip empty prompt screen

* Rename skipEmptyPrompt > skipNoDataViewsPrompt

* Rename skipNoDataViewsPrompt > showEmptyPrompt

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
Maja Grubic and kibanamachine authored May 2, 2022
1 parent 7e5408b commit 15ac520
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const DataViewEditor = ({
services,
defaultTypeIsRollup = false,
requireTimestampField = false,
showEmptyPrompt = true,
}: DataViewEditorPropsWithServices) => {
const { Provider: KibanaReactContextProvider } =
createKibanaReactContext<DataViewEditorContext>(services);
Expand All @@ -35,6 +36,7 @@ export const DataViewEditor = ({
onCancel={onCancel}
defaultTypeIsRollup={defaultTypeIsRollup}
requireTimestampField={requireTimestampField}
showEmptyPrompt={showEmptyPrompt}
/>
</EuiFlyout>
</KibanaReactContextProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export interface Props {
onCancel: () => void;
defaultTypeIsRollup?: boolean;
requireTimestampField?: boolean;
showEmptyPrompt?: boolean;
}

const editorTitle = i18n.translate('indexPatternEditor.title', {
Expand All @@ -69,6 +70,7 @@ const IndexPatternEditorFlyoutContentComponent = ({
onCancel,
defaultTypeIsRollup,
requireTimestampField = false,
showEmptyPrompt = true,
}: Props) => {
const {
services: { http, dataViews, uiSettings, searchClient },
Expand Down Expand Up @@ -316,7 +318,12 @@ const IndexPatternEditorFlyoutContentComponent = ({
);

return (
<EmptyPrompts onCancel={onCancel} allSources={allSources} loadSources={loadSources}>
<EmptyPrompts
onCancel={onCancel}
allSources={allSources}
loadSources={loadSources}
showEmptyPrompt={showEmptyPrompt}
>
<FlyoutPanels.Group flyoutClassName={'indexPatternEditorFlyout'} maxWidth={1180}>
<FlyoutPanels.Item className="fieldEditor__mainFlyoutPanel" border="right">
<EuiTitle data-test-subj="flyoutTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const IndexPatternFlyoutContentContainer = ({
onCancel = () => {},
defaultTypeIsRollup,
requireTimestampField = false,
showEmptyPrompt = true,
}: DataViewEditorProps) => {
const {
services: { dataViews, notifications },
Expand Down Expand Up @@ -48,6 +49,7 @@ const IndexPatternFlyoutContentContainer = ({
onCancel={onCancel}
defaultTypeIsRollup={defaultTypeIsRollup}
requireTimestampField={requireTimestampField}
showEmptyPrompt={showEmptyPrompt}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface Props {
onCancel: () => void;
allSources: MatchedItem[];
loadSources: () => void;
showEmptyPrompt?: boolean;
}

export function isUserDataIndex(source: MatchedItem) {
Expand All @@ -45,7 +46,13 @@ export function isUserDataIndex(source: MatchedItem) {
return true;
}

export const EmptyPrompts: FC<Props> = ({ allSources, onCancel, children, loadSources }) => {
export const EmptyPrompts: FC<Props> = ({
allSources,
onCancel,
children,
loadSources,
showEmptyPrompt,
}) => {
const {
services: { docLinks, application, http, searchClient, dataViews },
} = useKibana<DataViewEditorContext>();
Expand Down Expand Up @@ -93,7 +100,7 @@ export const EmptyPrompts: FC<Props> = ({ allSources, onCancel, children, loadSo
<PromptFooter onCancel={onCancel} />
</>
);
} else {
} else if (showEmptyPrompt) {
// first time
return (
<>
Expand All @@ -108,6 +115,8 @@ export const EmptyPrompts: FC<Props> = ({ allSources, onCancel, children, loadSo
<PromptFooter onCancel={onCancel} />
</>
);
} else {
setGoToForm(true);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/data_view_editor/public/open_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const getEditorOpener =
onCancel = () => {},
defaultTypeIsRollup = false,
requireTimestampField = false,
showEmptyPrompt = true,
}: DataViewEditorProps): CloseEditor => {
const closeEditor = () => {
if (overlayRef) {
Expand Down Expand Up @@ -77,6 +78,7 @@ export const getEditorOpener =
}}
defaultTypeIsRollup={defaultTypeIsRollup}
requireTimestampField={requireTimestampField}
showEmptyPrompt={showEmptyPrompt}
/>
</I18nProvider>
</KibanaReactContextProvider>,
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/data_view_editor/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ export interface DataViewEditorProps {
* Sets whether a timestamp field is required to create an index pattern. Defaults to false.
*/
requireTimestampField?: boolean;
/**
* If set to false, the screen for prompting a user to create a data view will be skipped, and the user will be taken directly
* to data view creation.
*/
showEmptyPrompt?: boolean;
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
Expand Down

0 comments on commit 15ac520

Please sign in to comment.