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

[Data Explorer][Discover 2.0] Fix display for index pattern without a default time field #4821

Merged

Conversation

ananzh
Copy link
Member

@ananzh ananzh commented Aug 25, 2023

Description

This PR is blocked by #4816
Please see the 2nd commit. Need to rebase after #4816 is merged.

  • Before
Screenshot 2023-08-25 at 09 54 18
  • After
    no date picker in the top nav
    only show hits if index pattern has no time field
Screenshot 2023-08-25 at 00 20 46

Issues Resolved

#4820

Check List

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

@codecov
Copy link

codecov bot commented Aug 25, 2023

Codecov Report

Merging #4821 (df20e7c) into main (72ced4d) will increase coverage by 0.03%.
Report is 1 commits behind head on main.
The diff coverage is n/a.

❗ Current head df20e7c differs from pull request most recent head c9073dd. Consider uploading reports for the commit c9073dd to get more accurate results

@@            Coverage Diff             @@
##             main    #4821      +/-   ##
==========================================
+ Coverage   66.39%   66.43%   +0.03%     
==========================================
  Files        3397     3398       +1     
  Lines       64805    64893      +88     
  Branches    10359    10359              
==========================================
+ Hits        43028    43110      +82     
- Misses      19218    19304      +86     
+ Partials     2559     2479      -80     
Flag Coverage Δ
Linux_1 34.85% <ø> (ø)
Linux_2 55.15% <ø> (ø)
Linux_3 44.24% <ø> (ø)
Linux_4 35.06% <ø> (+0.14%) ⬆️
Windows_1 34.87% <ø> (ø)
Windows_2 55.12% <ø> (ø)
Windows_3 44.24% <ø> (+<0.01%) ⬆️
Windows_4 35.06% <ø> (+0.14%) ⬆️

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

see 22 files with indirect coverage changes

@ananzh ananzh force-pushed the feature/data-explorer-no-timefield branch from 92207a1 to b6c449f Compare August 30, 2023 21:30
@ananzh ananzh changed the base branch from feature/data-explorer to main August 30, 2023 21:31
@ananzh ananzh force-pushed the feature/data-explorer-no-timefield branch 4 times, most recently from cb95e58 to 99d7b03 Compare August 30, 2023 23:17
@ashwin-pc ashwin-pc added the Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry label Aug 30, 2023
Copy link
Member

@ashwin-pc ashwin-pc left a comment

Choose a reason for hiding this comment

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

You accidentally removed a flag that allows the search bar queries to be saved. the rest of the PR looks good :)

return (
<TopNavMenu
appName={PLUGIN_ID}
config={topNavLinks}
showSearchBar
showSaveQuery
showDatePicker={showDatePicker}
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
showDatePicker={showDatePicker}
showDatePicker={showDatePicker}
showSaveQuery

Copy link
Member Author

Choose a reason for hiding this comment

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

will add

@@ -100,7 +105,7 @@ export function ContextApp({
onSort={() => {}}
sort={sort}
rows={rows}
displayTimeColumn={true}
displayTimeColumn={displayTimeColumn || true}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since displayTimeColumn is boolean too, this will be true always. I don't think that was your intention.

Copy link
Member Author

Choose a reason for hiding this comment

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

The displayTimeColumn constant could technically be undefined if indexPattern is undefined or if uiSettings.get(DOC_HIDE_TIME_COLUMN_SETTING, false) returns a falsy value and indexPattern?.isTimeBased() is undefined.

I have updated it to be

const displayTimeColumn = useMemo(
    () => !!(!uiSettings.get(DOC_HIDE_TIME_COLUMN_SETTING, false) && indexPattern?.isTimeBased()),
    [indexPattern, uiSettings]
);

to convert the value of the expression to a boolean, turning undefined or any other falsy values to false. And I changed this line to displayTimeColumn={displayTimeColumn.

Comment on lines -21 to -24
if (!hits || !bucketInterval || !chartData) {
// TODO: handle better
return null;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just double checking. We are good with not having bucketInterval or chartData?

Copy link
Member Author

Choose a reason for hiding this comment

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

hits itself is enough. hits = 0 will always has no chartData or bucketInterval.

@@ -93,7 +103,7 @@ export const DiscoverTable = ({ history }: Props) => {
onSort={onSetSort}
sort={sort}
rows={rows}
displayTimeColumn={true}
displayTimeColumn={displayTimeColumn || true}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn't seem right.

Copy link
Member Author

Choose a reason for hiding this comment

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

same as above.

@ananzh ananzh force-pushed the feature/data-explorer-no-timefield branch from d17d9bf to df20e7c Compare August 31, 2023 16:40
…ield

Issue Resolve
opensearch-project#4820

Signed-off-by: ananzh <ananzh@amazon.com>
@ananzh ananzh force-pushed the feature/data-explorer-no-timefield branch from df20e7c to c9073dd Compare August 31, 2023 18:25
@ashwin-pc ashwin-pc merged commit 83cd7f6 into opensearch-project:main Aug 31, 2023
54 checks passed
@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-4821-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 83cd7f629c3211a9d5d216b80cc5c3db40adefbc
# Push it to GitHub
git push --set-upstream origin backport/backport-4821-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-4821-to-2.x.

opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 1, 2023
…ield (#4821)

Issue Resolve
#4820

Signed-off-by: ananzh <ananzh@amazon.com>
(cherry picked from commit 83cd7f6)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
ashwin-pc pushed a commit that referenced this pull request Sep 1, 2023
…ield (#4821) (#4901)

Issue Resolve
#4820


(cherry picked from commit 83cd7f6)

Signed-off-by: ananzh <ananzh@amazon.com>
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 data explorer Issues related to the Data Explorer project discover for discover reinvent Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry v2.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants