-
Notifications
You must be signed in to change notification settings - Fork 276
fix(compass-indexes): fix margin for error banner and update search incompatible view ui COMPASS-10745 #8160
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
base: main
Are you sure you want to change the base?
Changes from all commits
a7833c6
37a1e89
ad0f0bb
81bd4d0
ef43981
dc5a0d1
46b75db
9604759
d0423b2
374351a
d81e318
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ const ViewPipelineIncompatibleBanner = ({ | |
| variant={hasNoSearchIndexes ? 'warning' : 'danger'} | ||
| data-testid="view-not-search-compatible-banner" | ||
| > | ||
| {!hasNoSearchIndexes && ( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh my! 🙈 |
||
| {hasNoSearchIndexes && ( | ||
| <> | ||
| <b>Looking for search indexes?</b> <br /> | ||
| </> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import { expect } from 'chai'; | ||
|
|
||
| import { shouldShowIndexesToolbarButtons } from './should-show-indexes-toolbar-buttons'; | ||
|
|
||
| const baseParams = { | ||
| isReadonlyView: false, | ||
| serverVersion: '8.1.0', | ||
| isSearchManagementActive: true, | ||
| isViewPipelineSearchQueryable: true, | ||
| hasSearchIndexes: false, | ||
| }; | ||
|
|
||
| describe('shouldShowIndexesToolbarButtons', function () { | ||
| it('always shows the toolbar for non-views', function () { | ||
| expect( | ||
| shouldShowIndexesToolbarButtons({ | ||
| ...baseParams, | ||
| isReadonlyView: false, | ||
| // even when nothing search-related applies | ||
| isSearchManagementActive: false, | ||
| isViewPipelineSearchQueryable: false, | ||
| }) | ||
| ).to.be.true; | ||
| }); | ||
|
|
||
| describe('for a readonly view', function () { | ||
| const viewParams = { ...baseParams, isReadonlyView: true }; | ||
|
|
||
| it('hides the toolbar when the server version is below 8.1', function () { | ||
| expect( | ||
| shouldShowIndexesToolbarButtons({ | ||
| ...viewParams, | ||
| serverVersion: '8.0.0', | ||
| }) | ||
| ).to.be.false; | ||
| }); | ||
|
|
||
| it('hides the toolbar when search management is not active', function () { | ||
| expect( | ||
| shouldShowIndexesToolbarButtons({ | ||
| ...viewParams, | ||
| isSearchManagementActive: false, | ||
| }) | ||
| ).to.be.false; | ||
| }); | ||
|
|
||
| it('shows the toolbar for a search-queryable view', function () { | ||
| expect( | ||
| shouldShowIndexesToolbarButtons({ | ||
| ...viewParams, | ||
| isViewPipelineSearchQueryable: true, | ||
| }) | ||
| ).to.be.true; | ||
| }); | ||
|
|
||
| describe('when the pipeline is not search-queryable', function () { | ||
| const incompatibleViewParams = { | ||
| ...viewParams, | ||
| isViewPipelineSearchQueryable: false, | ||
| }; | ||
|
|
||
| it('hides the toolbar when there are no existing search indexes', function () { | ||
| expect( | ||
| shouldShowIndexesToolbarButtons({ | ||
| ...incompatibleViewParams, | ||
| hasSearchIndexes: false, | ||
| }) | ||
| ).to.be.false; | ||
| }); | ||
|
|
||
| it('shows the toolbar when there are existing search indexes', function () { | ||
| expect( | ||
| shouldShowIndexesToolbarButtons({ | ||
| ...incompatibleViewParams, | ||
| hasSearchIndexes: true, | ||
| }) | ||
| ).to.be.true; | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { VIEW_PIPELINE_UTILS } from '@mongodb-js/mongodb-constants'; | ||
|
|
||
| /** | ||
| * Returns true when the indexes toolbar action buttons (create index, refresh, | ||
| * segmented control, etc.) should be shown. | ||
| */ | ||
| export function shouldShowIndexesToolbarButtons({ | ||
| isReadonlyView, | ||
| serverVersion, | ||
| isSearchManagementActive, | ||
| isViewPipelineSearchQueryable, | ||
| hasSearchIndexes, | ||
| }: { | ||
| isReadonlyView: boolean; | ||
| serverVersion: string; | ||
| isSearchManagementActive: boolean; | ||
| isViewPipelineSearchQueryable: boolean; | ||
| hasSearchIndexes: boolean; | ||
| }): boolean { | ||
| // Non-views always show the toolbar. | ||
| if (!isReadonlyView) { | ||
| return true; | ||
| } | ||
|
|
||
| // Views need 8.1+ and search management enabled. | ||
| if ( | ||
| !VIEW_PIPELINE_UTILS.isVersionSearchCompatibleForViewsCompass( | ||
| serverVersion | ||
| ) || | ||
| !isSearchManagementActive | ||
| ) { | ||
| return false; | ||
| } | ||
|
|
||
| // Search-queryable views, or incompatible views that still have existing | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. incompatible here refers to
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, for isVersionSearchCompatibleForViewsCompass we don't return the toolbar buttons and just display a banner telling them to upgrade. |
||
| // indexes show toolbar. | ||
| return isViewPipelineSearchQueryable || hasSearchIndexes; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.