mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Ent Search Deprecation] Redirect enterprise_search to elasticsearch Urls (#204890)
This PR resolves this https://github.com/elastic/search-team/issues/7961. This PR redirects all enterprise_search urls to elasticsearch urls. https://github.com/user-attachments/assets/d0fec395-f758-478f-a478-ad12ccdd57dd --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
6a84cccbde
commit
ca28d2dc5b
6 changed files with 263 additions and 0 deletions
|
@ -141,6 +141,7 @@ export const applicationUsageSchema = {
|
|||
enterpriseSearchAnalytics: commonSchema,
|
||||
enterpriseSearchApplications: commonSchema,
|
||||
enterpriseSearchAISearch: commonSchema,
|
||||
enterpriseSearchRedirect: commonSchema,
|
||||
enterpriseSearchSemanticSearch: commonSchema,
|
||||
enterpriseSearchVectorSearch: commonSchema,
|
||||
enterpriseSearchElasticsearch: commonSchema,
|
||||
|
|
|
@ -2753,6 +2753,137 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"enterpriseSearchRedirect": {
|
||||
"properties": {
|
||||
"appId": {
|
||||
"type": "keyword",
|
||||
"_meta": {
|
||||
"description": "The application being tracked"
|
||||
}
|
||||
},
|
||||
"viewId": {
|
||||
"type": "keyword",
|
||||
"_meta": {
|
||||
"description": "Always `main`"
|
||||
}
|
||||
},
|
||||
"clicks_total": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "General number of clicks in the application since we started counting them"
|
||||
}
|
||||
},
|
||||
"clicks_7_days": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "General number of clicks in the application over the last 7 days"
|
||||
}
|
||||
},
|
||||
"clicks_30_days": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "General number of clicks in the application over the last 30 days"
|
||||
}
|
||||
},
|
||||
"clicks_90_days": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "General number of clicks in the application over the last 90 days"
|
||||
}
|
||||
},
|
||||
"minutes_on_screen_total": {
|
||||
"type": "float",
|
||||
"_meta": {
|
||||
"description": "Minutes the application is active and on-screen since we started counting them."
|
||||
}
|
||||
},
|
||||
"minutes_on_screen_7_days": {
|
||||
"type": "float",
|
||||
"_meta": {
|
||||
"description": "Minutes the application is active and on-screen over the last 7 days"
|
||||
}
|
||||
},
|
||||
"minutes_on_screen_30_days": {
|
||||
"type": "float",
|
||||
"_meta": {
|
||||
"description": "Minutes the application is active and on-screen over the last 30 days"
|
||||
}
|
||||
},
|
||||
"minutes_on_screen_90_days": {
|
||||
"type": "float",
|
||||
"_meta": {
|
||||
"description": "Minutes the application is active and on-screen over the last 90 days"
|
||||
}
|
||||
},
|
||||
"views": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"properties": {
|
||||
"appId": {
|
||||
"type": "keyword",
|
||||
"_meta": {
|
||||
"description": "The application being tracked"
|
||||
}
|
||||
},
|
||||
"viewId": {
|
||||
"type": "keyword",
|
||||
"_meta": {
|
||||
"description": "The application view being tracked"
|
||||
}
|
||||
},
|
||||
"clicks_total": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "General number of clicks in the application sub view since we started counting them"
|
||||
}
|
||||
},
|
||||
"clicks_7_days": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "General number of clicks in the active application sub view over the last 7 days"
|
||||
}
|
||||
},
|
||||
"clicks_30_days": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "General number of clicks in the active application sub view over the last 30 days"
|
||||
}
|
||||
},
|
||||
"clicks_90_days": {
|
||||
"type": "long",
|
||||
"_meta": {
|
||||
"description": "General number of clicks in the active application sub view over the last 90 days"
|
||||
}
|
||||
},
|
||||
"minutes_on_screen_total": {
|
||||
"type": "float",
|
||||
"_meta": {
|
||||
"description": "Minutes the application sub view is active and on-screen since we started counting them."
|
||||
}
|
||||
},
|
||||
"minutes_on_screen_7_days": {
|
||||
"type": "float",
|
||||
"_meta": {
|
||||
"description": "Minutes the application is active and on-screen active application sub view over the last 7 days"
|
||||
}
|
||||
},
|
||||
"minutes_on_screen_30_days": {
|
||||
"type": "float",
|
||||
"_meta": {
|
||||
"description": "Minutes the application is active and on-screen active application sub view over the last 30 days"
|
||||
}
|
||||
},
|
||||
"minutes_on_screen_90_days": {
|
||||
"type": "float",
|
||||
"_meta": {
|
||||
"description": "Minutes the application is active and on-screen active application sub view over the last 90 days"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"enterpriseSearchSemanticSearch": {
|
||||
"properties": {
|
||||
"appId": {
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* 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 React from 'react';
|
||||
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
|
||||
import { render, waitFor } from '@testing-library/react';
|
||||
|
||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
|
||||
import { ApplicationRedirect } from '.';
|
||||
|
||||
jest.mock('@kbn/kibana-react-plugin/public', () => ({
|
||||
useKibana: jest.fn(),
|
||||
}));
|
||||
|
||||
describe('RedirectWithReplace', () => {
|
||||
const navigateToUrlMock = jest.fn();
|
||||
const coreMock = {
|
||||
application: {
|
||||
navigateToUrl: navigateToUrlMock,
|
||||
},
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
(useKibana as jest.Mock).mockReturnValue({ services: coreMock });
|
||||
|
||||
// Mock window.location.pathname
|
||||
Object.defineProperty(window, 'location', {
|
||||
writable: true,
|
||||
value: { pathname: '/enterprise_search/content/search_indices' },
|
||||
});
|
||||
});
|
||||
|
||||
it('should redirect to the new path', async () => {
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<ApplicationRedirect />
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(navigateToUrlMock).toHaveBeenCalledWith('/elasticsearch/content/search_indices');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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 React, { useEffect } from 'react';
|
||||
|
||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import { Routes, Route } from '@kbn/shared-ux-router';
|
||||
|
||||
const RedirectWithReplace = () => {
|
||||
const { application } = useKibana().services;
|
||||
|
||||
useEffect(() => {
|
||||
const fullPath = location.pathname;
|
||||
|
||||
// Construct the new path by replacing 'enterprise_search' with 'elasticsearch'
|
||||
const newPath = fullPath.replace('/enterprise_search', '/elasticsearch');
|
||||
|
||||
// Perform the client-side navigation using core
|
||||
application?.navigateToUrl(newPath);
|
||||
}, []);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export const ApplicationRedirect = () => {
|
||||
return (
|
||||
<Routes>
|
||||
<Route path="/*" component={RedirectWithReplace} />
|
||||
</Routes>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
preset: '@kbn/test',
|
||||
rootDir: '../../../../../../../..',
|
||||
roots: [
|
||||
'<rootDir>/x-pack/solutions/search/plugins/enterprise_search/public/applications/enterprise_search_redirect',
|
||||
],
|
||||
collectCoverage: true,
|
||||
coverageReporters: ['text', 'html'],
|
||||
collectCoverageFrom: [
|
||||
'<rootDir>/x-pack/solutions/search/plugins/enterprise_search/public/applications/**/*.{ts,tsx}',
|
||||
'!<rootDir>/x-pack/solutions/search/plugins/enterprise_search/public/*.ts',
|
||||
'!<rootDir>/x-pack/solutions/search/plugins/enterprise_search/server/*.ts',
|
||||
'!<rootDir>/x-pack/solutions/search/plugins/enterprise_search/public/applications/test_helpers/**/*.{ts,tsx}',
|
||||
],
|
||||
coverageDirectory:
|
||||
'<rootDir>/target/kibana-coverage/jest/x-pack/solutions/search/plugins/enterprise_search/public/applications/enterprise_search_redirect',
|
||||
modulePathIgnorePatterns: [
|
||||
'<rootDir>/x-pack/solutions/search/plugins/enterprise_search/public/applications/app_search/cypress',
|
||||
'<rootDir>/x-pack/solutions/search/plugins/enterprise_search/public/applications/workplace_search/cypress',
|
||||
],
|
||||
};
|
|
@ -489,6 +489,23 @@ export class EnterpriseSearchPlugin implements Plugin {
|
|||
visibleIn: [],
|
||||
});
|
||||
|
||||
core.application.register({
|
||||
appRoute: '/app/enterprise_search',
|
||||
category: DEFAULT_APP_CATEGORIES.enterpriseSearch,
|
||||
id: 'enterpriseSearchRedirect',
|
||||
mount: async (params: AppMountParameters) => {
|
||||
const kibanaDeps = await this.getKibanaDeps(core, params, cloud);
|
||||
const pluginData = this.getPluginData();
|
||||
|
||||
const { renderApp } = await import('./applications');
|
||||
const { ApplicationRedirect } = await import('./applications/enterprise_search_redirect');
|
||||
|
||||
return renderApp(ApplicationRedirect, kibanaDeps, pluginData);
|
||||
},
|
||||
title: 'EnterpriseSearchRedirect',
|
||||
visibleIn: [],
|
||||
});
|
||||
|
||||
if (plugins.home) {
|
||||
plugins.home.featureCatalogue.registerSolution({
|
||||
description: ENTERPRISE_SEARCH_OVERVIEW_PLUGIN.DESCRIPTION,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue