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

[Backport 2.x] [Discover-next] Add query editor extensions #7075

Merged
merged 1 commit into from
Jun 22, 2024

Conversation

opensearch-trigger-bot[bot]
Copy link
Contributor

@opensearch-trigger-bot opensearch-trigger-bot bot commented Jun 20, 2024

Backport 4f54049 from #7034.

Changelog

  • skip

### Description

see #6894

This PR picks #6894, #6895, #6933, #6972 to main. Additionally,
- separates extensions from query enhancements
- adds banner support
- partially revert #6972 as it's pending on the data source commit to main
- renames search bar extension to query editor extension

A query editor extension can display a UI component above the query editor and/or a banner above the language selector. The component has the ability to read and write discover search bar states to enhance the search experience for users. The configuration is part of UI Enhancements.

```ts
export interface QueryEditorExtensionDependencies {
  /**
   * Currently selected index patterns.
   */
  indexPatterns?: Array<IIndexPattern | string>;
  /**
   * Currently selected data source.
   */
  dataSource?: DataSource;
  /**
   * Currently selected query language.
   */
  language: string;
}

export interface QueryEditorExtensionConfig {
  /**
   * The id for the search bar extension.
   */
  id: string;
  /**
   * Lower order indicates higher position on UI.
   */
  order: number;
  /**
   * A function that determines if the search bar extension is enabled and should be rendered on UI.
   * @returns whether the extension is enabled.
   */
  isEnabled: (dependencies: QueryEditorExtensionDependencies) => Promise<boolean>;
  /**
   * A function that returns the search bar extension component. The component
   * will be displayed on top of the query editor in the search bar.
   * @param dependencies - The dependencies required for the extension.
   * @returns The component the search bar extension.
   */
  getComponent?: (dependencies: QueryEditorExtensionDependencies) => React.ReactElement | null;
  /**
   * A function that returns the search bar extension banner. The banner is a
   * component that will be displayed on top of the search bar.
   * @param dependencies - The dependencies required for the extension.
   * @returns The component the search bar extension.
   */
  getBanner?: (dependencies: QueryEditorExtensionDependencies) => React.ReactElement | null;
}

export interface UiEnhancements {
  query?: QueryEnhancement;
+ queryEditorExtension?: QueryEditorExtensionConfig;
}
```
Developers can utilize search bar extensions to add additional features to the search bar, such as query assist.

Issues resolved: #6077

A search bar extension can display a UI component above the query bar. The component has the ability to read and write discover search bar states to enhance the search experience for users. The configuration is part of Query Enhancements.

Signed-off-by: Joshua Li <joshuali925@gmail.com>
(cherry picked from commit 4f54049)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Copy link
Contributor

❌ Invalid Changelog Heading

The '## Changelog' heading in your PR description is either missing or malformed. Please make sure that your PR description includes a '## Changelog' heading with proper spelling, capitalization, spacing, and Markdown syntax.

@github-actions github-actions bot added the Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry label Jun 20, 2024
Copy link

codecov bot commented Jun 20, 2024

Codecov Report

Attention: Patch coverage is 75.75758% with 8 lines in your changes missing coverage. Please review.

Project coverage is 67.56%. Comparing base (727ec51) to head (0e89438).

Files Patch % Lines
src/plugins/data/public/ui/ui_service.ts 0.00% 3 Missing ⚠️
...query_editor_extensions/query_editor_extension.tsx 88.23% 0 Missing and 2 partials ⚠️
src/plugins/data/public/ui/settings/settings.ts 0.00% 2 Missing ⚠️
.../ui/query_editor/query_editor_extensions/index.tsx 75.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##              2.x    #7075   +/-   ##
=======================================
  Coverage   67.56%   67.56%           
=======================================
  Files        3443     3446    +3     
  Lines       67860    67892   +32     
  Branches    11019    11024    +5     
=======================================
+ Hits        45849    45874   +25     
- Misses      19352    19357    +5     
- Partials     2659     2661    +2     
Flag Coverage Δ
Linux_1 33.09% <0.00%> (-0.01%) ⬇️
Linux_2 55.23% <ø> (ø)
Linux_3 45.27% <75.75%> (+0.01%) ⬆️
Linux_4 35.02% <0.00%> (-0.01%) ⬇️
Windows_1 33.11% <0.00%> (-0.01%) ⬇️
Windows_2 55.18% <ø> (ø)
Windows_3 45.28% <75.75%> (+0.03%) ⬆️
Windows_4 35.02% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kavilla kavilla merged commit 3f5cff8 into 2.x Jun 22, 2024
69 of 71 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autocut Skip the changelog verification check on backports discover-next repeat-contributor Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry v2.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants