Skip to content

Commit

Permalink
[Search] Deprecate canDeployEntSearch config value (elastic#204272)
Browse files Browse the repository at this point in the history
  • Loading branch information
TattdCodeMonkey authored and JoseLuisGJ committed Dec 19, 2024
1 parent f89c3b3 commit 9756d6c
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
'data_visualizer.resultLinks.fileBeat.enabled (boolean)',
'dev_tools.deeplinks.navLinkStatus (string?)',
'discover.experimental.enabledProfiles (array?)',
'enterpriseSearch.canDeployEntSearch (boolean?)',
'enterpriseSearch.host (string?)',
'enterpriseSearch.ui.enabled (boolean?)',
'home.disableWelcomeScreen (boolean?)',
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/enterprise_search/common/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export interface Meta {
}

export interface ClientConfigType {
canDeployEntSearch: boolean;
host?: string;
ui: {
enabled: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ export const SyncsContextMenu: React.FC<SyncsContextMenuProps> = ({ disabled = f
const shouldShowIncrementalSync =
productFeatures.hasIncrementalSyncEnabled && hasIncrementalSyncFeature;

const isEnterpriseSearchNotAvailable = Boolean(
config.host && config.canDeployEntSearch && errorConnectingMessage
);
const isEnterpriseSearchNotAvailable = Boolean(config.host && errorConnectingMessage);
const isSyncsDisabled =
(connector?.is_native && isEnterpriseSearchNotAvailable) ||
ingestionStatus === IngestionStatus.INCOMPLETE ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,13 @@ describe('EnterpriseSearchContent', () => {

it('renders EnterpriseSearchContentConfigured when config.host is set & available', () => {
setMockValues({
config: { canDeployEntSearch: true, host: 'some.url' },
config: { host: 'some.url' },
errorConnectingMessage: '',
});
const wrapper = shallow(<EnterpriseSearchContent />);

expect(wrapper.find(EnterpriseSearchContentConfigured)).toHaveLength(1);
});

it('renders EnterpriseSearchContentConfigured when config.host is not set & Ent Search cannot be deployed', () => {
setMockValues({ config: { canDeployEntSearch: false, host: '' }, errorConnectingMessage: '' });
const wrapper = shallow(<EnterpriseSearchContent />);

expect(wrapper.find(EnterpriseSearchContentConfigured)).toHaveLength(1);
});
});

describe('EnterpriseSearchContentConfigured', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { WorkplaceSearchProductCard } from './workplace_search_product_card';

describe('EnterpriseSearchProductCard', () => {
beforeEach(() => {
setMockValues({ config: { canDeployEntSearch: true, host: 'localhost' } });
setMockValues({ config: { host: 'localhost' } });
});

it('renders both services with access', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ import { ProductSelector } from '.';

describe('ProductSelector', () => {
it('renders the overview page, product cards, & setup guide CTAs with no host set', () => {
setMockValues({ config: { canDeployEntSearch: true, host: '' } });
setMockValues({ config: { host: '' } });
const wrapper = shallow(<ProductSelector />);

expect(wrapper.find(ElasticsearchProductCard)).toHaveLength(1);
});

it('renders the trial callout', () => {
setMockValues({ config: { canDeployEntSearch: true, host: 'localhost' } });
setMockValues({ config: { host: 'localhost' } });
const wrapper = shallow(<ProductSelector />);

expect(wrapper.find(TrialCallout)).toHaveLength(1);
});

describe('access checks when host is set', () => {
beforeEach(() => {
setMockValues({ config: { canDeployEntSearch: true, host: 'localhost' } });
setMockValues({ config: { host: 'localhost' } });
});

it('does not render the Setup CTA when there is a host', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export const mockKibanaProps: KibanaLogicProps = {
isCloudEnabled: false,
},
config: {
canDeployEntSearch: true,
host: 'http://localhost:3002',
ui: {
enabled: true,
Expand Down
126 changes: 61 additions & 65 deletions x-pack/plugins/enterprise_search/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,55 +441,53 @@ export class EnterpriseSearchPlugin implements Plugin {

registerLocators(share!);

if (config.canDeployEntSearch) {
core.application.register({
appRoute: APP_SEARCH_PLUGIN.URL,
category: DEFAULT_APP_CATEGORIES.enterpriseSearch,
deepLinks: appSearchLinks,
euiIconType: ENTERPRISE_SEARCH_OVERVIEW_PLUGIN.LOGO,
id: APP_SEARCH_PLUGIN.ID,
mount: async (params: AppMountParameters) => {
const kibanaDeps = await this.getKibanaDeps(core, params, cloud);
const { chrome, http } = kibanaDeps.core;
chrome.docTitle.change(APP_SEARCH_PLUGIN.NAME);
core.application.register({
appRoute: APP_SEARCH_PLUGIN.URL,
category: DEFAULT_APP_CATEGORIES.enterpriseSearch,
deepLinks: appSearchLinks,
euiIconType: ENTERPRISE_SEARCH_OVERVIEW_PLUGIN.LOGO,
id: APP_SEARCH_PLUGIN.ID,
mount: async (params: AppMountParameters) => {
const kibanaDeps = await this.getKibanaDeps(core, params, cloud);
const { chrome, http } = kibanaDeps.core;
chrome.docTitle.change(APP_SEARCH_PLUGIN.NAME);

await this.getInitialData(http);
const pluginData = this.getPluginData();
await this.getInitialData(http);
const pluginData = this.getPluginData();

const { renderApp } = await import('./applications');
const { AppSearch } = await import('./applications/app_search');
const { renderApp } = await import('./applications');
const { AppSearch } = await import('./applications/app_search');

return renderApp(AppSearch, kibanaDeps, pluginData);
},
title: APP_SEARCH_PLUGIN.NAME,
visibleIn: [],
});
return renderApp(AppSearch, kibanaDeps, pluginData);
},
title: APP_SEARCH_PLUGIN.NAME,
visibleIn: [],
});

core.application.register({
appRoute: WORKPLACE_SEARCH_PLUGIN.URL,
category: DEFAULT_APP_CATEGORIES.enterpriseSearch,
euiIconType: ENTERPRISE_SEARCH_OVERVIEW_PLUGIN.LOGO,
id: WORKPLACE_SEARCH_PLUGIN.ID,
mount: async (params: AppMountParameters) => {
const kibanaDeps = await this.getKibanaDeps(core, params, cloud);
const { chrome, http } = kibanaDeps.core;
chrome.docTitle.change(WORKPLACE_SEARCH_PLUGIN.NAME);

// The Workplace Search Personal dashboard needs the chrome hidden. We hide it globally
// here first to prevent a flash of chrome on the Personal dashboard and unhide it for admin routes.
if (this.config.host) chrome.setIsVisible(false);
await this.getInitialData(http);
const pluginData = this.getPluginData();

const { renderApp } = await import('./applications');
const { WorkplaceSearch } = await import('./applications/workplace_search');

return renderApp(WorkplaceSearch, kibanaDeps, pluginData);
},
title: WORKPLACE_SEARCH_PLUGIN.NAME,
visibleIn: [],
});
}
core.application.register({
appRoute: WORKPLACE_SEARCH_PLUGIN.URL,
category: DEFAULT_APP_CATEGORIES.enterpriseSearch,
euiIconType: ENTERPRISE_SEARCH_OVERVIEW_PLUGIN.LOGO,
id: WORKPLACE_SEARCH_PLUGIN.ID,
mount: async (params: AppMountParameters) => {
const kibanaDeps = await this.getKibanaDeps(core, params, cloud);
const { chrome, http } = kibanaDeps.core;
chrome.docTitle.change(WORKPLACE_SEARCH_PLUGIN.NAME);

// The Workplace Search Personal dashboard needs the chrome hidden. We hide it globally
// here first to prevent a flash of chrome on the Personal dashboard and unhide it for admin routes.
if (this.config.host) chrome.setIsVisible(false);
await this.getInitialData(http);
const pluginData = this.getPluginData();

const { renderApp } = await import('./applications');
const { WorkplaceSearch } = await import('./applications/workplace_search');

return renderApp(WorkplaceSearch, kibanaDeps, pluginData);
},
title: WORKPLACE_SEARCH_PLUGIN.NAME,
visibleIn: [],
});

if (plugins.home) {
plugins.home.featureCatalogue.registerSolution({
Expand All @@ -511,27 +509,25 @@ export class EnterpriseSearchPlugin implements Plugin {
title: ANALYTICS_PLUGIN.NAME,
});

if (config.canDeployEntSearch) {
plugins.home.featureCatalogue.register({
category: 'data',
description: APP_SEARCH_PLUGIN.DESCRIPTION,
icon: 'appSearchApp',
id: APP_SEARCH_PLUGIN.ID,
path: APP_SEARCH_PLUGIN.URL,
showOnHomePage: false,
title: APP_SEARCH_PLUGIN.NAME,
});
plugins.home.featureCatalogue.register({
category: 'data',
description: APP_SEARCH_PLUGIN.DESCRIPTION,
icon: 'appSearchApp',
id: APP_SEARCH_PLUGIN.ID,
path: APP_SEARCH_PLUGIN.URL,
showOnHomePage: false,
title: APP_SEARCH_PLUGIN.NAME,
});

plugins.home.featureCatalogue.register({
category: 'data',
description: WORKPLACE_SEARCH_PLUGIN.DESCRIPTION,
icon: 'workplaceSearchApp',
id: WORKPLACE_SEARCH_PLUGIN.ID,
path: WORKPLACE_SEARCH_PLUGIN.URL,
showOnHomePage: false,
title: WORKPLACE_SEARCH_PLUGIN.NAME,
});
}
plugins.home.featureCatalogue.register({
category: 'data',
description: WORKPLACE_SEARCH_PLUGIN.DESCRIPTION,
icon: 'workplaceSearchApp',
id: WORKPLACE_SEARCH_PLUGIN.ID,
path: WORKPLACE_SEARCH_PLUGIN.URL,
showOnHomePage: false,
title: WORKPLACE_SEARCH_PLUGIN.NAME,
});

plugins.home.featureCatalogue.register({
category: 'data',
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/enterprise_search/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const plugin = async (initializerContext: PluginInitializerContext) => {
export const configSchema = schema.object({
accessCheckTimeout: schema.number({ defaultValue: 5000 }),
accessCheckTimeoutWarning: schema.number({ defaultValue: 300 }),
canDeployEntSearch: schema.boolean({ defaultValue: true }),
customHeaders: schema.maybe(schema.object({}, { unknowns: 'allow' })),
enabled: schema.boolean({ defaultValue: true }),
hasConnectors: schema.boolean({ defaultValue: true }),
Expand Down Expand Up @@ -44,8 +43,8 @@ export const configSchema = schema.object({
export type ConfigType = TypeOf<typeof configSchema>;

export const config: PluginConfigDescriptor<ConfigType> = {
deprecations: ({ unused }) => [unused('canDeployEntSearch', { level: 'warning' })],
exposeToBrowser: {
canDeployEntSearch: true,
host: true,
ui: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ describe('checkAccess', () => {
const mockDependencies = {
request: { auth: { isAuthenticated: true } },
config: {
canDeployEntSearch: true,
host: 'http://localhost:3002',
},
globalConfigService: new GlobalConfigService(),
Expand Down
23 changes: 9 additions & 14 deletions x-pack/plugins/enterprise_search/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ export class EnterpriseSearchPlugin implements Plugin {
ENTERPRISE_SEARCH_OVERVIEW_PLUGIN.ID,
ENTERPRISE_SEARCH_CONTENT_PLUGIN.ID,
ELASTICSEARCH_PLUGIN.ID,
...(config.canDeployEntSearch ? [APP_SEARCH_PLUGIN.ID, WORKPLACE_SEARCH_PLUGIN.ID] : []),
APP_SEARCH_PLUGIN.ID,
WORKPLACE_SEARCH_PLUGIN.ID,
SEARCH_EXPERIENCES_PLUGIN.ID,
VECTOR_SEARCH_PLUGIN.ID,
SEMANTIC_SEARCH_PLUGIN.ID,
Expand Down Expand Up @@ -300,9 +301,9 @@ export class EnterpriseSearchPlugin implements Plugin {
};

registerConfigDataRoute(dependencies);
if (config.canDeployEntSearch) registerAppSearchRoutes(dependencies);
registerAppSearchRoutes(dependencies);
registerEnterpriseSearchRoutes(dependencies);
if (config.canDeployEntSearch) registerWorkplaceSearchRoutes(dependencies);
registerWorkplaceSearchRoutes(dependencies);
// Enterprise Search Routes
if (config.hasConnectors) registerConnectorRoutes(dependencies);
if (config.hasWebCrawler) registerCrawlerRoutes(dependencies);
Expand All @@ -319,10 +320,8 @@ export class EnterpriseSearchPlugin implements Plugin {
* Bootstrap the routes, saved objects, and collector for telemetry
*/
savedObjects.registerType(enterpriseSearchTelemetryType);
if (config.canDeployEntSearch) {
savedObjects.registerType(appSearchTelemetryType);
savedObjects.registerType(workplaceSearchTelemetryType);
}
savedObjects.registerType(appSearchTelemetryType);
savedObjects.registerType(workplaceSearchTelemetryType);
let savedObjectsStarted: SavedObjectsServiceStart;

void getStartServices().then(([coreStart]) => {
Expand All @@ -331,10 +330,8 @@ export class EnterpriseSearchPlugin implements Plugin {
if (usageCollection) {
registerESTelemetryUsageCollector(usageCollection, savedObjectsStarted, this.logger);
registerCNTelemetryUsageCollector(usageCollection, this.logger);
if (config.canDeployEntSearch) {
registerASTelemetryUsageCollector(usageCollection, savedObjectsStarted, this.logger);
registerWSTelemetryUsageCollector(usageCollection, savedObjectsStarted, this.logger);
}
registerASTelemetryUsageCollector(usageCollection, savedObjectsStarted, this.logger);
registerWSTelemetryUsageCollector(usageCollection, savedObjectsStarted, this.logger);
}
});
registerTelemetryRoute({ ...dependencies, getSavedObjectsService: () => savedObjectsStarted });
Expand Down Expand Up @@ -370,9 +367,7 @@ export class EnterpriseSearchPlugin implements Plugin {
/**
* Register a config for the search guide
*/
if (config.canDeployEntSearch) {
guidedOnboarding?.registerGuideConfig(appSearchGuideId, appSearchGuideConfig);
}
guidedOnboarding?.registerGuideConfig(appSearchGuideId, appSearchGuideConfig);
if (config.hasWebCrawler) {
guidedOnboarding?.registerGuideConfig(websiteSearchGuideId, websiteSearchGuideConfig);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ describe('Search search provider', () => {
it('does not return results for legacy app search', () => {
const searchProvider = getSearchResultProvider(
{
canDeployEntSearch: true,
hasConnectors: false,
hasWebCrawler: false,
} as any,
Expand All @@ -315,7 +314,6 @@ describe('Search search provider', () => {
it('does not return results for legacy workplace search', () => {
const searchProvider = getSearchResultProvider(
{
canDeployEntSearch: true,
hasConnectors: false,
hasWebCrawler: false,
} as any,
Expand Down

0 comments on commit 9756d6c

Please sign in to comment.