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

[Discover 2.0] Fixed recent query and Data Selector styles #7918

Merged
merged 1 commit into from
Aug 29, 2024

Conversation

ashwin-pc
Copy link
Member

@ashwin-pc ashwin-pc commented Aug 29, 2024

Description

This PR contains the following changes:

  • Fixes recent query to not show duplicates
  • Fixes recent query styles
  • Fixed Data selector height issue

Issues Resolved

Screenshot

Screen.Recording.2024-08-29.at.5.55.03.AM.mov

Testing the changes

Changelog

  • skip

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

Copy link

codecov bot commented Aug 29, 2024

Codecov Report

Attention: Patch coverage is 20.00000% with 20 lines in your changes missing coverage. Please review.

Project coverage is 64.29%. Comparing base (07504f6) to head (2bde337).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...ns/data/public/query/query_string/query_history.ts 20.00% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7918      +/-   ##
==========================================
- Coverage   64.30%   64.29%   -0.01%     
==========================================
  Files        3674     3674              
  Lines       81138    81150      +12     
  Branches    12927    12928       +1     
==========================================
+ Hits        52174    52176       +2     
- Misses      25752    25764      +12     
+ Partials     3212     3210       -2     
Flag Coverage Δ
Linux_1 30.21% <8.00%> (-0.01%) ⬇️
Linux_2 56.19% <ø> (ø)
Linux_3 40.61% <20.00%> (+<0.01%) ⬆️
Linux_4 31.40% <8.00%> (-0.01%) ⬇️
Windows_1 30.22% <8.00%> (-0.01%) ⬇️
Windows_2 56.14% <ø> (ø)
Windows_3 40.61% <20.00%> (-0.01%) ⬇️
Windows_4 31.40% <8.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.

Copy link
Member

@sejli sejli left a comment

Choose a reason for hiding this comment

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

LGTM

import { Query, TimeRange } from '../..';

// Todo: Implement a more advanced QueryHistory class when needed for recent query history
const MAX_HISTORY_SIZE = 500;
Copy link
Member

Choose a reason for hiding this comment

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

Should we make this a UI_SETTING?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call. Fast follow maybe? This was what Abby introduced in her PR but we don't today show any more than 10 to the user anyways, so having this value be user configurable isn't very useful yet. Once we implement more features for the table, then it makes sense adding it as an advanced setting

Copy link
Member

@joshuali925 joshuali925 left a comment

Choose a reason for hiding this comment

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

nothing blocking

id: idx,
query: query.query.query,
timeRange: query.timeRange,
time: moment(query.time).format('MMM D, YYYY HH:mm:ss'),
Copy link
Member

Choose a reason for hiding this comment

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

maybe later, i remember user can config the format when date time is displayed, should this be read from user config?

Copy link
Member

Choose a reason for hiding this comment

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

yeah from ui settings

public getHistory(): any[] {
return this.getHistoryKeys()
.map((key) => this.storage.get(key))
.sort((a, b) => b.time - a.time);
Copy link
Member

Choose a reason for hiding this comment

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

getHistoryKeys already sorts by time, is this sort needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. I added that sort afterwards. This is no longer needed

export class QueryHistory {
constructor(private readonly storage: DataStorage) {}
private changeEmitter: BehaviorSubject<any[]>;
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 the type is just

    interface QueryHistoryItem {
      time: number;
      query: Query;
      dateRange?: TimeRange;
    };

Copy link
Member

Choose a reason for hiding this comment

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

imo i think the type should extend savedquery

@sejli sejli merged commit 7f9aabb into opensearch-project:main Aug 29, 2024
75 of 76 checks passed
keys.splice(0, 500); // only maintain most recent X;
keys.forEach((key) => {
this.storage.remove(key);
public addQueryToHistory(query: Query, dateRange?: TimeRange): void {
Copy link
Member

Choose a reason for hiding this comment

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

should we just use the LRU library we have?

<RecentQueriesTable
isVisible={this.state.isRecentQueryVisible && useQueryEditor}
queryString={this.queryString}
onClickRecentQuery={this.onClickRecentQuery}
Copy link
Member

Choose a reason for hiding this comment

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

how come not just onClick?

@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-7918-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 7f9aabbb02a7fe96f86b007663fe2774ceb6ad98
# Push it to GitHub
git push --set-upstream origin backport/backport-7918-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-7918-to-2.x.

<div className="osdQueryEditor__body">{languageEditor.Body()}</div>
<RecentQueriesTable
isVisible={this.state.isRecentQueryVisible && useQueryEditor}
queryString={this.queryString}
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 it can access the service with the gettersetters

opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 29, 2024
Signed-off-by: Ashwin P Chandran <[email protected]>
(cherry picked from commit 7f9aabb)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
kavilla pushed a commit that referenced this pull request Aug 29, 2024
…7927)

(cherry picked from commit 7f9aabb)

Signed-off-by: Ashwin P Chandran <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x discover for discover reinvent distinguished-contributor Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry v2.17.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants