mirror of
https://github.com/grafana/grafana.git
synced 2024-11-28 11:44:26 -06:00
Search: Fixes issue with Recent/Starred section always displaying "General" folder (#58746)
This commit is contained in:
parent
028751a18a
commit
20e6ac397e
@ -26,7 +26,7 @@ describe('FolderSection', () => {
|
||||
window.localStorage.clear();
|
||||
});
|
||||
|
||||
describe('when where are no results', () => {
|
||||
describe('when there are no results', () => {
|
||||
const emptySearchData: DataFrame = {
|
||||
fields: [
|
||||
{ name: 'kind', type: FieldType.string, config: {}, values: new ArrayVector([]) },
|
||||
@ -100,8 +100,19 @@ describe('FolderSection', () => {
|
||||
{ name: 'uid', type: FieldType.string, config: {}, values: new ArrayVector(['my-dashboard-1']) },
|
||||
{ name: 'url', type: FieldType.string, config: {}, values: new ArrayVector(['/my-dashboard-1']) },
|
||||
{ name: 'tags', type: FieldType.other, config: {}, values: new ArrayVector([['foo', 'bar']]) },
|
||||
{ name: 'location', type: FieldType.string, config: {}, values: new ArrayVector(['/my-dashboard-1']) },
|
||||
{ name: 'location', type: FieldType.string, config: {}, values: new ArrayVector(['my-folder-1']) },
|
||||
],
|
||||
meta: {
|
||||
custom: {
|
||||
locationInfo: {
|
||||
'my-folder-1': {
|
||||
name: 'My folder 1',
|
||||
kind: 'folder',
|
||||
url: '/my-folder-1',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
length: 1,
|
||||
};
|
||||
|
||||
@ -205,5 +216,23 @@ describe('FolderSection', () => {
|
||||
expect(mockSelectionToggle).toHaveBeenCalledWith('dashboard', 'my-dashboard-1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when in a pseudo-folder (i.e. Starred/Recent)', () => {
|
||||
const mockRecentSection = {
|
||||
kind: 'folder',
|
||||
uid: '__recent',
|
||||
title: 'Recent',
|
||||
itemsUIDs: ['my-dashboard-1'],
|
||||
};
|
||||
|
||||
it('shows the correct folder name next to the dashboard', async () => {
|
||||
render(<FolderSection section={mockRecentSection} onTagSelected={mockOnTagSelected} />);
|
||||
|
||||
await userEvent.click(await screen.findByRole('button', { name: mockRecentSection.title }));
|
||||
expect(getGrafanaSearcher().search).toHaveBeenCalled();
|
||||
expect(await screen.findByText('My dashboard 1')).toBeInTheDocument();
|
||||
expect(await screen.findByText('My folder 1')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -82,8 +82,8 @@ export const FolderSection = ({
|
||||
id: 666, // do not use me!
|
||||
isStarred: false,
|
||||
tags: item.tags ?? [],
|
||||
folderUid,
|
||||
folderTitle,
|
||||
folderUid: folderUid || item.location,
|
||||
folderTitle: folderTitle || raw.view.dataFrame.meta?.custom?.locationInfo[item.location].name,
|
||||
}));
|
||||
return v;
|
||||
}, [sectionExpanded, tags]);
|
||||
|
Loading…
Reference in New Issue
Block a user