-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compare queries card to search use case overview page (#427)
* add query compare card Signed-off-by: Hailong Cui <[email protected]> * add comments Signed-off-by: Hailong Cui <[email protected]> --------- Signed-off-by: Hailong Cui <[email protected]>
- Loading branch information
1 parent
e061e66
commit 924b570
Showing
6 changed files
with
351 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
public/components/service_card/__test__/compare_query_card.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { registerCompareQueryCard } from '../compare_query_card'; | ||
|
||
describe('CompareQueryCard', () => { | ||
const registerContentProviderMock = jest.fn(); | ||
|
||
const contentManagement = { | ||
registerContentProvider: registerContentProviderMock, | ||
updatePageSection: jest.fn(), | ||
renderPage: jest.fn(), | ||
}; | ||
|
||
it('registerCompareQueryCard', () => { | ||
registerCompareQueryCard(contentManagement, {}); | ||
const call = registerContentProviderMock.mock.calls[0]; | ||
expect(call[0].getTargetArea()).toEqual('search_overview/config_evaluate_search'); | ||
expect(call[0].getContent()).toMatchInlineSnapshot(` | ||
Object { | ||
"cardProps": Object { | ||
"children": <EuiFlexGroup | ||
justifyContent="flexEnd" | ||
> | ||
<EuiFlexItem | ||
grow={false} | ||
> | ||
<EuiButton | ||
onClick={[Function]} | ||
size="s" | ||
> | ||
Compare search results | ||
</EuiButton> | ||
</EuiFlexItem> | ||
</EuiFlexGroup>, | ||
"layout": "horizontal", | ||
}, | ||
"description": "The search comparison tool lets you compare the results of two different DSL queries applied to the same user query.", | ||
"getIcon": [Function], | ||
"id": "compare_query", | ||
"kind": "card", | ||
"order": 20, | ||
"title": "Compare queries", | ||
} | ||
`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiIcon } from '@elastic/eui'; | ||
import { i18n } from '@osd/i18n'; | ||
import { PLUGIN_ID } from '../../../common'; | ||
import { ContentManagementPluginStart } from '../../../../../src/plugins/content_management/public'; | ||
import { CoreStart } from '../../../../../src/core/public'; | ||
import compareQueriesIcon from './icon.svg'; | ||
|
||
export const registerCompareQueryCard = ( | ||
contentManagement: ContentManagementPluginStart, | ||
core: CoreStart | ||
) => { | ||
const icon = ( | ||
<EuiIcon size="original" aria-label="compare search queries" type={compareQueriesIcon} /> | ||
); | ||
|
||
const footer = ( | ||
<EuiFlexGroup justifyContent="flexEnd"> | ||
<EuiFlexItem grow={false}> | ||
<EuiButton | ||
size="s" | ||
onClick={() => { | ||
core.application.navigateToApp(PLUGIN_ID); | ||
}} | ||
> | ||
{i18n.translate('searchRelevanceDashboards.compareQueryCard.footer', { | ||
defaultMessage: 'Compare search results', | ||
})} | ||
</EuiButton> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); | ||
|
||
contentManagement.registerContentProvider({ | ||
id: 'compare_query_card', | ||
getContent: () => ({ | ||
id: 'compare_query', | ||
kind: 'card', | ||
order: 20, | ||
title: i18n.translate('searchRelevanceDashboards.compareQueryCard.title', { | ||
defaultMessage: 'Compare queries', | ||
}), | ||
description: i18n.translate('searchRelevanceDashboards.compareQueryCard.description', { | ||
defaultMessage: | ||
'The search comparison tool lets you compare the results of two different DSL queries applied to the same user query.', | ||
}), | ||
getIcon: () => icon, | ||
cardProps: { | ||
children: footer, | ||
layout: 'horizontal', | ||
}, | ||
}), | ||
getTargetArea: () => 'search_overview/config_evaluate_search', | ||
}); | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.