Skip to content

Commit

Permalink
[Search] [Onboarding] Update Breadcrumbs and title for search detail …
Browse files Browse the repository at this point in the history
…page (elastic#196538)

## Summary

Update breadcrumbs and title when on search details page.



https://github.com/user-attachments/assets/1f6177ac-e273-492a-91da-1d7fadb30bf1



### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
joemcelroy and kibanamachine authored Oct 17, 2024
1 parent c79f0ae commit e1f227d
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 2 deletions.
1 change: 1 addition & 0 deletions x-pack/plugins/search_indices/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"cloud",
"console",
"usageCollection",
"serverless"
],
"requiredBundles": [
"kibanaReact",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ export const SearchIndexDetailsPage = () => {
const indexName = decodeURIComponent(useParams<{ indexName: string }>().indexName);
const tabId = decodeURIComponent(useParams<{ tabId: string }>().tabId);

const { console: consolePlugin, docLinks, application, history, share } = useKibana().services;
const {
console: consolePlugin,
docLinks,
application,
history,
share,
chrome,
serverless,
} = useKibana().services;
const {
data: index,
refetch,
Expand Down Expand Up @@ -70,6 +78,25 @@ export const SearchIndexDetailsPage = () => {
setDocumentsLoading(isInitialLoading);
setDocumentsExists(!(!isInitialLoading && indexDocuments?.results?.data.length === 0));
}, [indexDocuments, isInitialLoading, setDocumentsExists, setDocumentsLoading]);

useEffect(() => {
chrome.docTitle.change(indexName);

if (serverless) {
serverless.setBreadcrumbs([
{
text: i18n.translate('xpack.searchIndices.indexBreadcrumbLabel', {
defaultMessage: 'Index Management',
}),
href: '/app/management/data/index_management/indices',
},
{
text: indexName,
},
]);
}
}, [chrome, indexName, serverless]);

const usageTracker = useUsageTracker();

const detailsPageTabs: EuiTabbedContentTab[] = useMemo(() => {
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/search_indices/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type {
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { IndexManagementPluginStart } from '@kbn/index-management-shared-types';
import type { AppDeepLinkId } from '@kbn/core-chrome-browser';
import { ServerlessPluginStart } from '@kbn/serverless/public';

export interface SearchIndicesPluginSetup {
enabled: boolean;
Expand Down Expand Up @@ -50,6 +51,7 @@ export type SearchIndicesServicesContext = CoreStart &
SearchIndicesAppPluginStartDependencies & {
history: AppMountParameters['history'];
indexManagement: IndexManagementPluginStart;
serverless: ServerlessPluginStart;
};

export interface AppUsageTracker {
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/search_indices/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"@kbn/search-api-keys-components",
"@kbn/search-shared-ui",
"@kbn/deeplinks-search",
"@kbn/core-chrome-browser"
"@kbn/core-chrome-browser",
"@kbn/serverless"
],
"exclude": [
"target/**/*",
Expand Down
6 changes: 6 additions & 0 deletions x-pack/test/functional/page_objects/index_management_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ export function IndexManagementPageProvider({ getService }: FtrProviderContext)
async sectionHeadingText() {
return await testSubjects.getVisibleText('appTitle');
},

async expectToBeOnIndicesManagement() {
const headingText = await testSubjects.getVisibleText('appTitle');
expect(headingText).to.be('Index Management');
},

async reloadIndices() {
await testSubjects.click('reloadIndicesButton');
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,20 @@ export function SvlSearchIndexDetailPageProvider({ getService }: FtrProviderCont
await testSubjects.existOrFail('mappingsTab');
await testSubjects.existOrFail('settingsTab');
},

async expectBreadcrumbNavigationWithIndexName(indexName: string) {
await testSubjects.existOrFail('euiBreadcrumb');
expect(await testSubjects.getVisibleText('breadcrumb last')).to.contain(indexName);
},

async clickOnIndexManagementBreadcrumb() {
const breadcrumbs = await testSubjects.findAll('breadcrumb');
for (const breadcrumb of breadcrumbs) {
if ((await breadcrumb.getVisibleText()) === 'Index Management') {
await breadcrumb.click();
return;
}
}
},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await pageObjects.svlSearchIndexDetailPage.expectQuickStatsAIMappingsToHaveVectorFields();
});

it('should have breadcrumb navigation', async () => {
await pageObjects.svlSearchIndexDetailPage.expectBreadcrumbNavigationWithIndexName(
indexName
);
await pageObjects.svlSearchIndexDetailPage.clickOnIndexManagementBreadcrumb();
await pageObjects.indexManagement.expectToBeOnIndicesManagement();
await svlSearchNavigation.navigateToIndexDetailPage(indexName);
});

it('should show code examples for adding documents', async () => {
await pageObjects.svlSearchIndexDetailPage.expectAddDocumentCodeExamples();
await pageObjects.svlSearchIndexDetailPage.expectSelectedLanguage('python');
Expand Down

0 comments on commit e1f227d

Please sign in to comment.