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 549ef06 commit 78cbe2d
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const KibanaNoDataPage = ({
noDataConfig,
allowAdHocDataView,
showPlainSpinner,
esqlLink,
}: KibanaNoDataPageProps) => {
// These hooks are temporary, until this component is moved to a package.
const services = useServices();
Expand Down Expand Up @@ -52,12 +53,13 @@ export const KibanaNoDataPage = ({
}

if (!hasUserDataViews && dataExists) {
console.log(esqlLink);
return (
<NoDataViewsPrompt
onDataViewCreated={onDataViewCreated}
allowAdHocDataView={allowAdHocDataView}
showESQL={dataExists}
esqlLink={``}
esqlLink={esqlLink}
/>
);
}
Expand Down
1 change: 1 addition & 0 deletions packages/shared-ux/page/kibana_no_data/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ export interface KibanaNoDataPageProps {
allowAdHocDataView?: boolean;
/** Set to true if the kibana is customly branded */
showPlainSpinner: boolean;
esqlLink: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const NoDataViewsPrompt = ({
);

const icon = <Illustration />;

console.log(esqlLink);
const actions = (
<NoDataButtonLink
onClickCreate={onClickCreate}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import { reactRouterNavigate, useKibana } from '@kbn/kibana-react-plugin/public'
import type { SpacesContextProps } from '@kbn/spaces-plugin/public';
import { NoDataViewsPromptComponent } from '@kbn/shared-ux-prompt-no-data-views';
import { DISCOVER_APP_ID } from '@kbn/deeplinks-analytics';
import { DataViewsServicePublic } from '@kbn/data-views-plugin/public/types';
import { SharePluginStart } from '@kbn/share-plugin/public';
import { EmptyIndexListPrompt } from '../empty_index_list_prompt';
import { IndexPatternManagmentContext } from '../../types';
import { IndexPatternTableItem } from '../types';
Expand Down Expand Up @@ -70,7 +72,25 @@ interface Props extends RouteComponentProps {

const getEmptyFunctionComponent: React.FC<SpacesContextProps> = ({ children }) => <>{children}</>;

export const IndexPatternTable = async ({
const helperFunction = async (dataViews: DataViewsServicePublic, url: SharePluginStart['url']) => {
const defaultDataView = await dataViews.getDefaultDataView({ displayErrors: false });
console.log('\n\n\n\n\n\n default data view', defaultDataView);
const params = {
query: {
esql: `from ${defaultDataView?.getIndexPattern()} | limit 10`,
},
dataViewSpec: defaultDataView?.toSpec(),
};

const location = await url.locators
.get(DISCOVER_APP_ID)
?.getLocation(params)
.then((location) => location);
console.log({ location });
return location;
};

export const IndexPatternTable = ({
history,
canSave,
showCreateDialog: showCreateDialogProp = false,
Expand All @@ -85,7 +105,7 @@ export const IndexPatternTable = async ({
spaces,
overlays,
docLinks,
share,
url,
} = useKibana<IndexPatternManagmentContext>().services;
const [query, setQuery] = useState('');
const [showCreateDialog, setShowCreateDialog] = useState<boolean>(showCreateDialogProp);
Expand Down Expand Up @@ -115,17 +135,9 @@ export const IndexPatternTable = async ({
setQuery(queryText);
}
};
const defaultDataView = await dataViews.getDefaultDataView({ displayErrors: false });

const params = {
query: {
esql: `from ${defaultDataView?.getIndexPattern()} | limit 10`,
},
dataViewSpec: defaultDataView?.toSpec(),
};

const discoverLocation = await share.url.locators.get(DISCOVER_APP_ID)?.getLocation(params);

console.log('share start', url);
const discoverLocation = helperFunction(dataViews, url);
console.log('\n\n\n\n discover Location', discoverLocation);
const esqlLink = `/app/${discoverLocation?.app}${discoverLocation?.path}`;

const renderDeleteButton = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ export async function mountManagementSection(
unifiedSearch,
spaces,
savedObjectsManagement,
url,
},
indexPatternManagementStart,
] = await getStartServices();
console.log(url);
const canSave = dataViews.getCanSaveSync();

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

const editPath = '/dataView/:id/field/:fieldName';
const createPath = '/dataView/:id/create-field/';
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/data_view_management/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { indexPatternEditorPluginMock } from '@kbn/data-view-editor-plugin/publi
import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks';
import { fieldFormatsServiceMock } from '@kbn/field-formats-plugin/public/mocks';
import { savedObjectsManagementPluginMock } from '@kbn/saved-objects-management-plugin/public/mocks';
import { sharePluginMock } from '@kbn/share-plugin/public/mocks';
import {
IndexPatternManagementSetup,
IndexPatternManagementStart,
Expand Down Expand Up @@ -87,6 +88,7 @@ const createIndexPatternManagmentContext = (): {
fieldFormats: fieldFormatsServiceMock.createStartContract(),
theme,
savedObjectsManagement,
url: sharePluginMock.createStartContract().url,
};
};

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/data_view_management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import { SpacesPluginStart } from '@kbn/spaces-plugin/public';
import { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
import { SharePluginStart } from '@kbn/share-plugin/public';

export interface IndexPatternManagementSetupDependencies {
management: ManagementSetup;
Expand All @@ -34,6 +35,7 @@ export interface IndexPatternManagementStartDependencies {
spaces?: SpacesPluginStart;
unifiedSearch: UnifiedSearchPublicPluginStart;
savedObjectsManagement: SavedObjectsManagementPluginStart;
url: SharePluginStart['url'];
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data_view_management/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface IndexPatternManagmentContext {
fieldFormatEditors: IndexPatternFieldEditorStart['fieldFormatEditors'];
IndexPatternEditor: DataViewEditorStart['IndexPatternEditorComponent'];
fieldFormats: FieldFormatsStart;
share: SharePluginStart;
url: SharePluginStart['url'];
spaces?: SpacesPluginStart;
theme: ThemeServiceStart;
savedObjectsManagement: SavedObjectsManagementPluginStart;
Expand Down

0 comments on commit 78cbe2d

Please sign in to comment.