Skip to content

Commit

Permalink
Merge pull request elastic#29 from TattdCodeMonkey/serverless/poc/nav…
Browse files Browse the repository at this point in the history
…igation-search

[poc]: serverless_search
  • Loading branch information
clintandrewhall authored Mar 8, 2023
2 parents 540e041 + eeef257 commit 87031e6
Show file tree
Hide file tree
Showing 31 changed files with 405 additions and 24 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ packages/kbn-server-http-tools @elastic/kibana-core
packages/kbn-server-route-repository @elastic/apm-ui
x-pack/plugins/serverless @elastic/appex-sharedux
x-pack/plugins/serverless_observability @elastic/appex-sharedux
x-pack/plugins/serverless_search @elastic/appex-sharedux @elastic/enterprise-search-frontend
x-pack/plugins/serverless_security @elastic/appex-sharedux
test/plugin_functional/plugins/session_notifications @elastic/kibana-core
x-pack/plugins/session_view @elastic/awp-viz
Expand Down
10 changes: 10 additions & 0 deletions config/serverless.es.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
xpack.apm.enabled: false
xpack.canvas.enabled: false
xpack.reporting.enabled: false
xpack.uptime.enabled: false
xpack.watcher.enabled: false

enterpriseSearch.enabled: true
xpack.serverless.search.enabled: true

uiSettings.overrides.defaultRoute: /app/enterprise_search/content/search_indices
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@
"@kbn/server-route-repository": "link:packages/kbn-server-route-repository",
"@kbn/serverless": "link:x-pack/plugins/serverless",
"@kbn/serverless-observability": "link:x-pack/plugins/serverless_observability",
"@kbn/serverless-search": "link:x-pack/plugins/serverless_search",
"@kbn/serverless-security": "link:x-pack/plugins/serverless_security",
"@kbn/session-notifications-plugin": "link:test/plugin_functional/plugins/session_notifications",
"@kbn/session-view-plugin": "link:x-pack/plugins/session_view",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface ManagementAppDependencies {
sections: SectionsServiceStart;
kibanaVersion: string;
setBreadcrumbs: (newBreadcrumbs: ChromeBreadcrumb[]) => void;
getIsSidebarEnabled: () => boolean;
}

export const ManagementApp = ({ dependencies, history, theme$ }: ManagementAppProps) => {
Expand Down Expand Up @@ -75,18 +76,21 @@ export const ManagementApp = ({ dependencies, history, theme$ }: ManagementAppPr
return null;
}

const solution: KibanaPageTemplateProps['solutionNav'] = {
name: i18n.translate('management.nav.label', {
defaultMessage: 'Management',
}),
icon: 'managementApp',
'data-test-subj': 'mgtSideBarNav',
items: managementSidebarNav({
selectedId,
sections,
history,
}),
};
const solution: KibanaPageTemplateProps['solutionNav'] | undefined =
dependencies.getIsSidebarEnabled()
? {
name: i18n.translate('management.nav.label', {
defaultMessage: 'Management',
}),
icon: 'managementApp',
'data-test-subj': 'mgtSideBarNav',
items: managementSidebarNav({
selectedId,
sections,
history,
}),
}
: undefined;

return (
<I18nProvider>
Expand Down
7 changes: 7 additions & 0 deletions src/plugins/management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export class ManagementPlugin

private hasAnyEnabledApps = true;

private isSidebarEnabled = true;

constructor(private initializerContext: PluginInitializerContext) {}

public setup(core: CoreSetup, { home, share }: ManagementSetupDependencies) {
Expand All @@ -93,6 +95,7 @@ export class ManagementPlugin
visible: () => this.hasAnyEnabledApps,
});
}
const managementPlugin = this;

core.application.register({
id: MANAGEMENT_APP_ID,
Expand All @@ -111,13 +114,17 @@ export class ManagementPlugin
sections: getSectionsServiceStartPrivate(),
kibanaVersion,
setBreadcrumbs: coreStart.chrome.setBreadcrumbs,
getIsSidebarEnabled: () => managementPlugin.isSidebarEnabled,
});
},
});

return {
sections: this.managementSections.setup(),
locator,
setIsSidebarEnabled: (enabled: boolean) => {
this.isSidebarEnabled = enabled;
},
};
}

Expand Down
1 change: 1 addition & 0 deletions src/plugins/management/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type { ManagementAppLocatorParams } from '../common/locator';
export interface ManagementSetup {
sections: SectionsServiceSetup;
locator: LocatorPublic<ManagementAppLocatorParams>;
setIsSidebarEnabled: (enabled: boolean) => void;
}

export interface DefinedSections {
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,8 @@
"@kbn/serverless/*": ["x-pack/plugins/serverless/*"],
"@kbn/serverless-observability": ["x-pack/plugins/serverless_observability"],
"@kbn/serverless-observability/*": ["x-pack/plugins/serverless_observability/*"],
"@kbn/serverless-search": ["x-pack/plugins/serverless_search"],
"@kbn/serverless-search/*": ["x-pack/plugins/serverless_search/*"],
"@kbn/serverless-security": ["x-pack/plugins/serverless_security"],
"@kbn/serverless-security/*": ["x-pack/plugins/serverless_security/*"],
"@kbn/session-notifications-plugin": ["test/plugin_functional/plugins/session_notifications"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,22 @@ import { SearchEnginesPopover } from './search_engines_popover';
import { SyncsContextMenu } from './syncs_context_menu';

// Used to populate rightSideItems of an EuiPageTemplate, which is rendered right-to-left
export const getHeaderActions = (indexData?: ElasticsearchIndexWithIngestion) => {
export const getHeaderActions = (
indexData?: ElasticsearchIndexWithIngestion,
hasAppSearchAccess?: boolean
) => {
const ingestionMethod = getIngestionMethod(indexData);
return [
...(isCrawlerIndex(indexData) && indexData.connector ? [<CrawlerStatusIndicator />] : []),
...(isConnectorIndex(indexData) ? [<SyncsContextMenu />] : []),
<SearchEnginesPopover
indexName={indexData?.name}
ingestionMethod={ingestionMethod}
isHiddenIndex={indexData?.hidden}
/>,
...(hasAppSearchAccess || hasAppSearchAccess === undefined
? [
<SearchEnginesPopover
indexName={indexData?.name}
ingestionMethod={ingestionMethod}
isHiddenIndex={indexData?.hidden}
/>,
]
: []),
];
};
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ export const SearchIndex: React.FC = () => {
* This needs to be checked for any of the 3 registered search guideIds
* Putting it here guarantees that if a user is viewing an index with data, it'll be marked as complete
*/
const { guidedOnboarding } = useValues(KibanaLogic);
const {
guidedOnboarding,
productAccess: { hasAppSearchAccess },
} = useValues(KibanaLogic);
const isAppGuideActive = useObservable(
guidedOnboarding.guidedOnboardingApi!.isGuideStepActive$('appSearch', 'add_data')
);
Expand Down Expand Up @@ -222,7 +225,7 @@ export const SearchIndex: React.FC = () => {
isLoading={isInitialLoading}
pageHeader={{
pageTitle: indexName,
rightSideItems: getHeaderActions(index),
rightSideItems: getHeaderActions(index, hasAppSearchAccess),
}}
>
{isCrawlerIndex(index) && !index.connector ? (
Expand Down
13 changes: 12 additions & 1 deletion x-pack/plugins/enterprise_search/public/applications/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,17 @@ import { mountLicensingLogic } from './shared/licensing';

export const renderApp = (
App: React.FC<InitialAppData>,
{ params, core, plugins }: { params: AppMountParameters; core: CoreStart; plugins: PluginsStart },
{
params,
core,
plugins,
isSidebarEnabled,
}: {
params: AppMountParameters;
core: CoreStart;
plugins: PluginsStart;
isSidebarEnabled: boolean;
},
{ config, data }: { config: ClientConfigType; data: ClientData }
) => {
const { publicUrl, errorConnectingMessage, ...initialData } = data;
Expand Down Expand Up @@ -64,6 +74,7 @@ export const renderApp = (
charts: plugins.charts,
cloud: plugins.cloud,
uiSettings: core.uiSettings,
isSidebarEnabled,
guidedOnboarding: plugins.guidedOnboarding,
history: params.history,
navigateToUrl: core.application.navigateToUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ interface KibanaLogicProps {
application: ApplicationStart;
config: { host?: string };
productAccess: ProductAccess;
isSidebarEnabled: boolean;
// Kibana core
capabilities: Capabilities;
history: ScopedHistory;
Expand All @@ -49,6 +50,7 @@ interface KibanaLogicProps {
// Optional plugins
cloud?: CloudSetup;
}

export interface KibanaValues extends Omit<KibanaLogicProps, 'cloud'> {
cloud: Partial<CloudSetup>;
isCloud: boolean;
Expand All @@ -65,6 +67,7 @@ export const KibanaLogic = kea<MakeLogicType<KibanaValues>>({
cloud: [props.cloud || {}, {}],
guidedOnboarding: [props.guidedOnboarding, {}],
history: [props.history, {}],
isSidebarEnabled: [props.isSidebarEnabled, {}],
navigateToUrl: [
(url: string, options?: CreateHrefOptions) => {
const deps = { history: props.history, http: HttpLogic.values.http };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ import { KibanaLogic } from '../kibana';
import { generateNavLink } from './nav_link_helpers';

export const useEnterpriseSearchNav = () => {
const { productAccess } = useValues(KibanaLogic);
const { isSidebarEnabled, productAccess } = useValues(KibanaLogic);

if (!isSidebarEnabled) return undefined;
const enginesSectionEnabled = productAccess.hasSearchEnginesAccess;

const navItems: Array<EuiSideNavItemType<unknown>> = [
Expand Down Expand Up @@ -243,6 +244,7 @@ export const useEnterpriseSearchNav = () => {

export const useEnterpriseSearchEngineNav = (engineName?: string, isEmptyState?: boolean) => {
const navItems = useEnterpriseSearchNav();
if (!navItems) return undefined;
if (!engineName) return navItems;
const searchItem = navItems.find((item) => item.id === 'enginesSearch');
if (!searchItem || !searchItem.items) return navItems;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ export const EnterpriseSearchPageTemplateWrapper: React.FC<PageTemplateProps> =
),
}}
isEmptyState={isEmptyState && !isLoading}
solutionNav={solutionNav ? { icon: 'logoEnterpriseSearch', ...solutionNav } : undefined}
solutionNav={
solutionNav && solutionNav.items
? { icon: 'logoEnterpriseSearch', ...solutionNav }
: undefined
}
>
{setPageChrome}
{readOnlyMode && (
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/enterprise_search/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ import { EnterpriseSearchPlugin } from './plugin';
export const plugin = (initializerContext: PluginInitializerContext) => {
return new EnterpriseSearchPlugin(initializerContext);
};

export type { EnterpriseSearchPublicSetup, EnterpriseSearchPublicStart } from './plugin';
14 changes: 13 additions & 1 deletion x-pack/plugins/enterprise_search/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export interface ClientData extends InitialAppData {
errorConnectingMessage?: string;
}

export type EnterpriseSearchPublicSetup = ReturnType<EnterpriseSearchPlugin['setup']>;
export type EnterpriseSearchPublicStart = ReturnType<EnterpriseSearchPlugin['start']>;

interface PluginsSetup {
cloud?: CloudSetup;
home?: HomePublicPluginSetup;
Expand All @@ -64,6 +67,7 @@ export class EnterpriseSearchPlugin implements Plugin {
private config: ClientConfigType;
private hasInitialized: boolean = false;
private data: ClientData = {} as ClientData;
private isSidebarEnabled: boolean = true;

constructor(initializerContext: PluginInitializerContext) {
this.config = initializerContext.config.get<ClientConfigType>();
Expand Down Expand Up @@ -288,6 +292,14 @@ export class EnterpriseSearchPlugin implements Plugin {
showOnHomePage: false,
});
}

return {
navigation: {
setIsSidebarEnabled: (enabled: boolean) => {
this.isSidebarEnabled = enabled;
},
},
};
}

public start(core: CoreStart) {
Expand All @@ -312,7 +324,7 @@ export class EnterpriseSearchPlugin implements Plugin {
: undefined;
const plugins = { ...pluginsStart, cloud } as PluginsStart;

return { params, core: coreStart, plugins };
return { params, core: coreStart, plugins, isSidebarEnabled: this.isSidebarEnabled };
}

private getPluginData() {
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/serverless_search/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build
/target
9 changes: 9 additions & 0 deletions x-pack/plugins/serverless_search/.i18nrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"prefix": "serverlessSearch",
"paths": {
"serverlessSearch": "."
},
"translations": [
"translations/ja-JP.json"
]
}
3 changes: 3 additions & 0 deletions x-pack/plugins/serverless_search/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# serverlessSearch

A witty, fitting description to come.
9 changes: 9 additions & 0 deletions x-pack/plugins/serverless_search/common/index.ts
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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export const PLUGIN_ID = 'serverlessSearch';
export const PLUGIN_NAME = 'serverlessSearch';
23 changes: 23 additions & 0 deletions x-pack/plugins/serverless_search/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"type": "plugin",
"id": "@kbn/serverless-search",
"owner": "@elastic/appex-sharedux",
"description": "Serverless customizations for search.",
"plugin": {
"id": "serverlessSearch",
"server": true,
"browser": true,
"configPath": [
"xpack",
"serverless",
"search"
],
"requiredPlugins": [
"serverless",
"enterpriseSearch",
"management"
],
"optionalPlugins": [],
"requiredBundles": []
}
}
11 changes: 11 additions & 0 deletions x-pack/plugins/serverless_search/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@kbn/serverless-search",
"version": "1.0.0",
"license": "Elastic License 2.0",
"private": true,
"scripts": {
"build": "yarn plugin-helpers build",
"plugin-helpers": "node ../../../scripts/plugin_helpers",
"kbn": "node ../../../scripts/kbn"
}
}
16 changes: 16 additions & 0 deletions x-pack/plugins/serverless_search/public/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { ServerlessSearchPlugin } from './plugin';

// This exports static code and TypeScript types,
// as well as, Kibana Platform `plugin()` initializer.
export function plugin() {
return new ServerlessSearchPlugin();
}

export type { ServerlessSearchPluginSetup, ServerlessSearchPluginStart } from './types';
Loading

0 comments on commit 87031e6

Please sign in to comment.