Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add framework to show related indexed views inside dataset selector and show banner in the Discover canvas for the selected dataset #8818

Closed

Conversation

riysaxen-amzn
Copy link
Contributor

@riysaxen-amzn riysaxen-amzn commented Nov 6, 2024

Description

This has all the changes from Base PR: #8701


In this PR we add support for

Selecting indexed view inside dataset selector. The indexed view is an Opensearch index which can be created for an external source like S3. When user selects an indexed view, we use this index for querying the data
Showing a banner at the top of Discover results canvas. This banner can be used to show actions related to the selected dataset. The first use we will add for this banner would be to show a callout to create an indexed view while searching an external source, or when an indexed view is selected, we can show an entry point to select other indexed view

and UTs for Configurator


 PASS  src/plugins/data/public/ui/dataset_selector/configurator.test.tsx (7.025 s)
  Configurator Component
    ✓ should render the component with the correct title and description (153 ms)
    ✓ should call onCancel when cancel button is clicked (83 ms)
    ✓ should call onPrevious when previous button is clicked (72 ms)
    ✓ should disable the submit button when conditions are not met (70 ms)
    ✓ should update state correctly when language is selected (68 ms)
    ✓ should fetch indexed views on mount and display them (53 ms)
    ✓ should initialize selectedLanguage with the current language from queryString (46 ms)
    ✓ should default selectedLanguage to the first language if currentLanguage is not supported (39 ms)
    ✓ should display the supported language dropdown correctly (41 ms)
    ✓ should disable the confirm button when submit is disabled (151 ms)

Test Suites: 1 passed, 1 total
Tests:       10 passed, 10 total
Snapshots:   0 total
Time:        7.964 s, estimated 8 s
Ran all test suites matching /src\/plugins\/data\/public\/ui\/dataset_selector\/configurator.test.tsx/i.

Issues Resolved

Screenshot

iv1
iv2

Testing the changes

Changelog

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

amsiglan and others added 9 commits November 1, 2024 14:45
…s in dataset selector

Signed-off-by: Amardeepsingh Siglani <[email protected]>
Signed-off-by: Amardeepsingh Siglani <[email protected]>
Signed-off-by: Amardeepsingh Siglani <[email protected]>
Signed-off-by: Amardeepsingh Siglani <[email protected]>
Signed-off-by: Amardeepsingh Siglani <[email protected]>
Signed-off-by: Amardeepsingh Siglani <[email protected]>
Signed-off-by: Riya Saxena <[email protected]>
Signed-off-by: Riya Saxena <[email protected]>
@@ -0,0 +1,3 @@
feat:
- Add framework to show banner at the top in discover results canvas ([#8701](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8818))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think you also want to update 8701

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

virajsanghvi
virajsanghvi previously approved these changes Nov 7, 2024
Copy link
Collaborator

@virajsanghvi virajsanghvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-running ci to see if some checks will pass (different set than last time) but approving to unblock.

Will want to follow up and correct the pr number in the changelog fragment

Signed-off-by: Riya Saxena <[email protected]>
virajsanghvi
virajsanghvi previously approved these changes Nov 7, 2024
Copy link
Collaborator

@virajsanghvi virajsanghvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked screenshot for cigroup6, refresh button was present so likely a delay in showing up

@kavilla kavilla added discover for discover reinvent discover-next labels Nov 7, 2024
| {
componentType: DatasetCanvasBannerComponentType.CALLOUT;
title: string;
iconType?: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


export type DatasetCanvasBannerProps =
| {
componentType: DatasetCanvasBannerComponentType.CALLOUT;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if my understanding of this is correct. This should just be type as it is redundant if this component is already a component and developers will understand that the type is associated to the type of component.

@@ -256,6 +258,29 @@ export interface DatasetField {
// TODO: osdFieldType?
}

export enum DatasetCanvasBannerComponentType {
CALLOUT = 'callout',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for making this a string. but could we follow current pattern could we make this all caps: https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/plugins/data/common/datasets/types.ts#L136

might be a nitpick but it's easier to write code expecting strings to be in a certain casing

@@ -256,6 +258,29 @@ export interface DatasetField {
// TODO: osdFieldType?
}

export enum DatasetCanvasBannerComponentType {
CALLOUT = 'callout',
CUSTOM = 'custom',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CUSTOM = 'custom',
CUSTOM = 'CUSTOM',


export type DatasetCanvasBannerProps =
| {
componentType: DatasetCanvasBannerComponentType.CALLOUT;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
componentType: DatasetCanvasBannerComponentType.CALLOUT;
type: DatasetCanvasBannerComponentType.CALLOUT;

@@ -493,6 +493,7 @@ export {
QueryStart,
PersistedLog,
LanguageReference,
IndexedViewsService,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't we rename this to DatasetIndexedViewsService?

@@ -34,6 +34,7 @@ export {
DatasetService,
DatasetServiceContract,
DatasetTypeConfig,
DatasetIndexedViewsService as IndexedViewsService,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole point of prefixing is to avoid name collision. Exporting it without a prefix out of here doesn't mitigate that.

CUSTOM = 'custom',
}

export type DatasetCanvasBannerProps =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should have a BaseDatasetCanvasBannerProps or DatasetCanvasBannerProps that has required props to add a new banner. Then create a type called DatasetCanvasCalloutBannerProps and DatasetCanvasCustomBannerProps or something.

if developing these union types become quiet difficult to understand sometimes and caused the linter to complain because the type isn't strict enough. easier to work with explicit types.

as far as the base props i think we should have at least

export type DatasetCanvasBannerProps = {
 // required. unique id, this will be used to associate a dataset to a canvas props. this is different than title because title is something that could be displayed but if i have two devs trying to add a new banner called `Index Callout Banner` (haven't looked at the code yet) but if the component doesn't change in an ID then maybe we won't render an update by accident.
  id: string;
  title: string; // required. going from optional to required would be a breaking change. and haven't looked at how this is used but i can imagine we don't really want to have a case where title is undefined.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that or title to be name similar to the flyout stuff.

we should also consider maybe key but we should def include

className?: string;
'data-test-subj'?: string;

writing tests on this abstract types would make this so much easier and if we have to style them the className will help

@@ -256,6 +258,29 @@ export interface DatasetField {
// TODO: osdFieldType?
}

export enum DatasetCanvasBannerComponentType {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export enum DatasetCanvasBannerComponentType {
export enum DATASET_CANVAS_BANNER_COMPONENT_TYPES {

@@ -247,6 +247,8 @@ export interface Dataset extends BaseDataset {
timeFieldName?: string;
/** Optional language to default to from the language selector */
language?: string;
/** Optional name of the indexed view to search data from */
indexedView?: string;
Copy link
Member

@kavilla kavilla Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add more insight on what this is?
is this to be the id of the indexedView component. is this a unique id generated from something?

without much context this for me this seems something like a data view is that correct @riysaxen-amzn ? if you can update to include an example above that would help with this insight

can any developer add an indexed view or is it only related to a specific data type? the dataset interface was derived from the index pattern interface so that we can leverage the current system setup. the current system setup assumes the title is the thing it will query. if this is changing that assumption it might be worth considering if this is a different interface like DataViewset extends BaseDataset

cc: @virajsanghvi, @AMoo-Miki , @ashwin-pc curious your opinion here

@@ -40,10 +41,21 @@ export const Configurator = ({
const queryString = queryService.queryString;
const languageService = queryService.queryString.getLanguageService();
const indexPatternsService = getIndexPatterns();
const type = queryString.getDatasetService().getType(baseDataset.type);
const type = queryString?.getDatasetService().getType(baseDataset.type);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

queryString manager shouldn't be optional how come? the type might be undefined but the app won't work if queryString is undefined

@ruanyl
Copy link
Member

ruanyl commented Nov 8, 2024

@riysaxen-amzn FYI, noticed there is a conflict :)

@virajsanghvi virajsanghvi mentioned this pull request Nov 12, 2024
7 tasks
@amsiglan amsiglan closed this Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants