Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rshen91 committed Dec 12, 2023
1 parent 78cbe2d commit 5fb8241
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export const KibanaNoDataPage = ({
<NoDataViewsPrompt
onDataViewCreated={onDataViewCreated}
allowAdHocDataView={allowAdHocDataView}
showESQL={dataExists}
esqlLink={esqlLink}
/>
);
Expand Down
67 changes: 27 additions & 40 deletions packages/shared-ux/prompt/no_data_views/impl/src/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import React from 'react';
interface NoDataButtonProps {
onClickCreate: (() => void) | undefined;
canCreateNewDataView: boolean;
showESQL: boolean;
esqlLocator: string;
}

Expand All @@ -25,45 +24,33 @@ const createDataViewText = i18n.translate('sharedUXPackages.noDataViewsPrompt.ad
export const NoDataButtonLink = ({
onClickCreate,
canCreateNewDataView,
showESQL,
esqlLocator,
}: NoDataButtonProps) => {
if (canCreateNewDataView && !showESQL) {
return (
<EuiButton
onClick={onClickCreate}
iconType="plusInCircle"
fill={true}
data-test-subj="createDataViewButton"
>
{createDataViewText}
</EuiButton>
);
} else if (showESQL) {
return (
<>
<EuiButton
onClick={onClickCreate}
iconType="plusInCircle"
fill={true}
data-test-subj="createDataViewButton"
>
{createDataViewText}
</EuiButton>
<EuiSpacer size="m" />
- OR -
<EuiSpacer size="m" />
<EuiText size="s">
<FormattedMessage
id="sharedUx.no_data_views.button"
defaultMessage="Query your data directly with ES|QL (Beta). "
/>
<EuiLink href={esqlLocator} target={'_blank'} external>
Try ES|QL
</EuiLink>
</EuiText>
</>
);
}
return null;
return (
<>
{canCreateNewDataView && (
<>
<EuiButton
onClick={onClickCreate}
iconType="plusInCircle"
fill={true}
data-test-subj="createDataViewButton"
>
{createDataViewText}
</EuiButton>
<EuiSpacer size="m" />- OR -
</>
)}
<EuiSpacer size="m" />
<EuiText size="s">
<FormattedMessage
id="sharedUx.no_data_views.button"
defaultMessage="Query your data directly with ES|QL (Beta). "
/>
<EuiLink href={esqlLocator} target={'_blank'} external>
Try ES|QL
</EuiLink>
</EuiText>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export const NoDataViewsPrompt = ({
onClickCreate,
canCreateNewDataView,
dataViewsDocLink,
showESQL,
esqlLink,
emptyPromptColor = 'plain',
}: NoDataViewsPromptComponentProps) => {
Expand Down Expand Up @@ -86,7 +85,6 @@ export const NoDataViewsPrompt = ({
<NoDataButtonLink
onClickCreate={onClickCreate}
canCreateNewDataView={canCreateNewDataView}
showESQL={showESQL}
esqlLocator={esqlLink}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type CloseDataViewEditorFn = ReturnType<NoDataViewsPromptServices['openDataViewE
*/
export const NoDataViewsPrompt = ({
onDataViewCreated,
showESQL,
esqlLink,
allowAdHocDataView = false,
}: NoDataViewsPromptProps) => {
Expand Down Expand Up @@ -75,7 +74,7 @@ export const NoDataViewsPrompt = ({

return (
<NoDataViewsPromptComponent
{...{ onClickCreate, canCreateNewDataView, dataViewsDocLink, showESQL, esqlLink }}
{...{ onClickCreate, canCreateNewDataView, dataViewsDocLink, esqlLink }}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ export class StorybookMock extends AbstractStorybookMock<
{},
ServiceArguments
> {
propArguments = {};
propArguments = {
esqlLink: {
options: ['some/link', undefined],
control: { type: 'radio' },
},
};
serviceArguments = {
canCreateNewDataView: {
control: 'boolean',
Expand All @@ -42,6 +47,7 @@ export class StorybookMock extends AbstractStorybookMock<
getProps() {
return {
onDataViewCreated: action('onDataViewCreated'),
esqlLink: 'test link'
};
}

Expand Down
4 changes: 0 additions & 4 deletions packages/shared-ux/prompt/no_data_views/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ export interface NoDataViewsPromptKibanaDependencies {
export interface NoDataViewsPromptComponentProps {
/** True if the user has permission to create a data view, false otherwise. */
canCreateNewDataView: boolean;
/** True if there is ES data and ESQL can be set */
showESQL: boolean;
/** Link to ES|QL in Discover */
esqlLink: string;
/** Click handler for create button. **/
Expand All @@ -81,8 +79,6 @@ export interface NoDataViewsPromptComponentProps {
export interface NoDataViewsPromptProps {
/** Handler for successfully creating a new data view. */
onDataViewCreated: (dataView: unknown) => void;
/** if set to true ESQL link will appear even if there are no data views */
showESQL: boolean;
/** Link to ES|QL in Discover */
esqlLink: string;
/** if set to true allows creation of an ad-hoc data view from data view editor */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ interface Props extends RouteComponentProps {
const getEmptyFunctionComponent: React.FC<SpacesContextProps> = ({ children }) => <>{children}</>;

const helperFunction = async (dataViews: DataViewsServicePublic, url: SharePluginStart['url']) => {
console.log(dataViews, url)
const defaultDataView = await dataViews.getDefaultDataView({ displayErrors: false });
console.log('\n\n\n\n\n\n default data view', defaultDataView);
const params = {
Expand Down Expand Up @@ -107,6 +108,7 @@ export const IndexPatternTable = ({
docLinks,
url,
} = useKibana<IndexPatternManagmentContext>().services;
console.log('url line 111 in index pattern table', url)
const [query, setQuery] = useState('');
const [showCreateDialog, setShowCreateDialog] = useState<boolean>(showCreateDialogProp);
const [selectedItems, setSelectedItems] = useState<IndexPatternTableItem[]>([]);
Expand Down Expand Up @@ -381,7 +383,6 @@ export const IndexPatternTable = ({
canCreateNewDataView={application.capabilities.indexPatterns.save as boolean}
dataViewsDocLink={docLinks.links.indexPatterns.introduction}
emptyPromptColor={'subdued'}
showESQL
esqlLink={esqlLink}
/>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export async function mountManagementSection(
},
indexPatternManagementStart,
] = await getStartServices();
console.log(url);
console.log('get start service url', url);
const canSave = dataViews.getCanSaveSync();

if (!canSave) {
Expand Down Expand Up @@ -92,9 +92,8 @@ export async function mountManagementSection(
spaces: spaces?.hasOnlyDefaultSpace ? undefined : spaces,
theme,
savedObjectsManagement,
url,
url
};
console.log('\n\n\n\n share url', url);

const editPath = '/dataView/:id/field/:fieldName';
const createPath = '/dataView/:id/create-field/';
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/data_view_management/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { FieldFormatsStart } from '@kbn/field-formats-plugin/public';
import { SpacesPluginStart } from '@kbn/spaces-plugin/public';
import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
import type { SettingsStart } from '@kbn/core-ui-settings-browser';
import { SharePluginStart } from '@kbn/share-plugin/public';
import { BrowserUrlService } from '@kbn/share-plugin/public';
import { IndexPatternManagementStart } from '.';

export interface IndexPatternManagmentContext {
Expand All @@ -48,7 +48,7 @@ export interface IndexPatternManagmentContext {
fieldFormatEditors: IndexPatternFieldEditorStart['fieldFormatEditors'];
IndexPatternEditor: DataViewEditorStart['IndexPatternEditorComponent'];
fieldFormats: FieldFormatsStart;
url: SharePluginStart['url'];
url: BrowserUrlService;
spaces?: SpacesPluginStart;
theme: ThemeServiceStart;
savedObjectsManagement: SavedObjectsManagementPluginStart;
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/management/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type { CardsNavigationComponentProps } from '@kbn/management-cards-naviga
import { AppNavLinkStatus } from '@kbn/core/public';
import { ManagementSection, RegisterManagementSectionArgs } from './utils';
import type { ManagementAppLocatorParams } from '../common/locator';
import { SharePluginStart } from '@kbn/share-plugin/public';

export interface ManagementSetup {
sections: SectionsServiceSetup;
Expand Down Expand Up @@ -73,6 +74,7 @@ export interface ManagementAppMountParams {
setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void;
history: ScopedHistory;
theme$: Observable<CoreTheme>;
url: SharePluginStart['url']
}

export interface CreateManagementItemArgs {
Expand Down

0 comments on commit 5fb8241

Please sign in to comment.