-
Notifications
You must be signed in to change notification settings - Fork 885
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
Fix object empty check and minor perf issue in query editor extensions #7077
Merged
kavilla
merged 9 commits into
opensearch-project:main
from
joshuali925:query-editor-extensions
Jun 28, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bac6cc4
Fix object empty check in query editor extensions
joshuali925 f02e725
fix render order
joshuali925 fc5369e
add changelog
joshuali925 5b3e358
remove unused handleListUpdate
joshuali925 2cb217e
Revert "remove unused handleListUpdate"
joshuali925 3c8d096
Merge branch 'main' into query-editor-extensions
joshuali925 6391986
remove unused handleListUpdate
joshuali925 397b402
Changeset file for PR #7077 deleted
opensearch-changeset-bot[bot] 1de91d9
Changeset file for PR #7077 created/updated
opensearch-changeset-bot[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fix: | ||
- Fix object empty check and minor perf issue in query editor extensions ([#7077](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7077)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ import { | |
} from '../../../../opensearch_dashboards_react/public'; | ||
import { UI_SETTINGS } from '../../../common'; | ||
import { fromUser, getQueryLog, PersistedLog } from '../../query'; | ||
import { QueryEditorExtensions } from './query_editor_extensions'; | ||
import { Settings } from '../types'; | ||
import { NoDataPopover } from './no_data_popover'; | ||
import QueryEditorUI from './query_editor'; | ||
|
@@ -71,8 +70,6 @@ export interface QueryEditorTopRowProps { | |
export default function QueryEditorTopRow(props: QueryEditorTopRowProps) { | ||
const [isDateRangeInvalid, setIsDateRangeInvalid] = useState(false); | ||
const [isQueryEditorFocused, setIsQueryEditorFocused] = useState(false); | ||
const queryEditorHeaderRef = useRef<HTMLDivElement | null>(null); | ||
const queryEditorBannerRef = useRef<HTMLDivElement | null>(null); | ||
|
||
const opensearchDashboards = useOpenSearchDashboards<IDataPluginServices>(); | ||
const { uiSettings, storage, appName } = opensearchDashboards.services; | ||
|
@@ -85,7 +82,6 @@ export default function QueryEditorTopRow(props: QueryEditorTopRowProps) { | |
props.settings && | ||
props.settings.getQueryEnhancements(queryLanguage)?.searchBar) || | ||
null; | ||
const queryEditorExtensionMap = props.settings?.getQueryEditorExtensionMap(); | ||
const parsedQuery = | ||
!queryUiEnhancement || isValidQuery(props.query) | ||
? props.query! | ||
|
@@ -235,6 +231,7 @@ export default function QueryEditorTopRow(props: QueryEditorTopRowProps) { | |
<QueryEditor | ||
disableAutoFocus={props.disableAutoFocus} | ||
indexPatterns={props.indexPatterns!} | ||
dataSource={props.dataSource} | ||
prepend={props.prepend} | ||
query={parsedQuery} | ||
containerRef={props.containerRef} | ||
|
@@ -247,33 +244,12 @@ export default function QueryEditorTopRow(props: QueryEditorTopRowProps) { | |
persistedLog={persistedLog} | ||
className="osdQueryEditor" | ||
dataTestSubj={props.dataTestSubj} | ||
queryEditorHeaderRef={queryEditorHeaderRef} | ||
queryEditorBannerRef={queryEditorBannerRef} | ||
queryLanguage={queryLanguage} | ||
/> | ||
</EuiFlexItem> | ||
); | ||
} | ||
|
||
function renderQueryEditorExtensions() { | ||
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. this is a good clean up. that i need to do after restructuring. I have a clean up task in #6957 but some of the render functions i added are in the wrong location and that's cause i tried to not touch query string input. so thanks for starting the clean up! |
||
if ( | ||
!shouldRenderQueryEditorExtensions() || | ||
!queryEditorHeaderRef.current || | ||
!queryEditorBannerRef.current || | ||
!queryLanguage | ||
) | ||
return; | ||
return ( | ||
<QueryEditorExtensions | ||
language={queryLanguage} | ||
configMap={queryEditorExtensionMap} | ||
componentContainer={queryEditorHeaderRef.current} | ||
bannerContainer={queryEditorBannerRef.current} | ||
indexPatterns={props.indexPatterns} | ||
dataSource={props.dataSource} | ||
/> | ||
); | ||
} | ||
|
||
function renderSharingMetaFields() { | ||
const { from, to } = getDateRange(); | ||
const dateRangePretty = prettyDuration( | ||
|
@@ -305,10 +281,6 @@ export default function QueryEditorTopRow(props: QueryEditorTopRowProps) { | |
); | ||
} | ||
|
||
function shouldRenderQueryEditorExtensions(): boolean { | ||
return Boolean(queryEditorExtensionMap && Object.keys(queryEditorExtensionMap).length); | ||
} | ||
|
||
function renderUpdateButton() { | ||
const button = props.customSubmitButton ? ( | ||
React.cloneElement(props.customSubmitButton, { onClick: onClickSubmitButton }) | ||
|
@@ -401,7 +373,6 @@ export default function QueryEditorTopRow(props: QueryEditorTopRowProps) { | |
direction="column" | ||
justifyContent="flexEnd" | ||
> | ||
{renderQueryEditorExtensions()} | ||
{renderQueryEditor()} | ||
<EuiFlexItem> | ||
<EuiFlexGroup responsive={false} gutterSize="none"> | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! nice clean up!