-
Notifications
You must be signed in to change notification settings - Fork 33
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
Adjusting Create Acceleration Flyout Props #289
Changes from all commits
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { EuiButton } from '@elastic/eui'; | ||
import React, { useEffect } from 'react'; | ||
import { catalogCacheRefs } from '../../../public/framework/catalog_cache_refs'; | ||
import { getRenderCreateAccelerationFlyout } from '../../../public/dependencies/register_observability_dependencies'; | ||
|
||
interface AccelerationFlyoutButtonProps { | ||
datasource: string; | ||
asyncLoading: boolean; | ||
} | ||
|
||
export const AccelerationFlyoutButton = (props: AccelerationFlyoutButtonProps) => { | ||
const { datasource, asyncLoading } = props; | ||
|
||
const renderCreateAccelerationFlyout = getRenderCreateAccelerationFlyout(); | ||
const { loadStatus, startLoading, stopLoading } = catalogCacheRefs.useLoadTableColumnsToCache(); | ||
|
||
useEffect(() => { | ||
return () => { | ||
stopLoading(); | ||
}; | ||
}, []); | ||
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. missing dependency. |
||
|
||
return ( | ||
<EuiButton | ||
className="sql-accelerate-button" | ||
onClick={() => | ||
renderCreateAccelerationFlyout(datasource, loadStatus, startLoading, stopLoading) | ||
} | ||
isDisabled={asyncLoading} | ||
> | ||
Accelerate Table | ||
</EuiButton> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,8 @@ | |
import { SAMPLE_SQL_QUERY } from '../../../common/constants'; | ||
import { getRenderCreateAccelerationFlyout } from '../../dependencies/register_observability_dependencies'; | ||
import { ResponseDetail, TranslateResult } from '../Main/main'; | ||
import { catalogCacheRefs } from '../../framework/catalog_cache_refs'; | ||
import { AccelerationFlyoutButton } from './AccelerationFlyoutButton'; | ||
|
||
interface SQLPageProps { | ||
http: CoreStart['http']; | ||
|
@@ -34,7 +36,7 @@ | |
onClear: () => void; | ||
updateSQLQueries: (query: string) => void; | ||
sqlQuery: string; | ||
sqlTranslations: ResponseDetail<TranslateResult>[]; | ||
selectedDatasource: EuiComboBoxOptionOption[]; | ||
asyncLoading: boolean; | ||
openAccelerationFlyout: boolean; | ||
|
@@ -67,7 +69,13 @@ | |
} | ||
|
||
setAccelerationFlyout = () => { | ||
this.renderCreateAccelerationFlyout(this.props.selectedDatasource[0].label); | ||
const { loadStatus, startLoading, stopLoading } = catalogCacheRefs.useLoadTableColumnsToCache(); | ||
this.renderCreateAccelerationFlyout( | ||
this.props.selectedDatasource[0].label, | ||
loadStatus, | ||
startLoading, | ||
stopLoading | ||
); | ||
Comment on lines
71
to
+78
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. What is this function used for? 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 used for users coming from URL to see the acceleration flyout open. |
||
}; | ||
|
||
componentDidUpdate(prevProps: SQLPageProps) { | ||
|
@@ -98,7 +106,7 @@ | |
|
||
const explainContent = sqlTranslationsNotEmpty() | ||
? this.props.sqlTranslations | ||
.map((queryTranslation: any) => JSON.stringify(queryTranslation.data, null, 2)) | ||
.join('\n') | ||
: 'This query is not explainable.'; | ||
|
||
|
@@ -210,15 +218,10 @@ | |
{this.props.selectedDatasource && | ||
this.props.selectedDatasource[0].label !== 'OpenSearch' && ( | ||
<EuiFlexItem grow={false}> | ||
<EuiButton | ||
className="sql-accelerate-button" | ||
onClick={() => | ||
this.renderCreateAccelerationFlyout(this.props.selectedDatasource[0].label) | ||
} | ||
isDisabled={this.props.asyncLoading} | ||
> | ||
Accelerate Table | ||
</EuiButton> | ||
<AccelerationFlyoutButton | ||
datasource={this.props.selectedDatasource[0].label} | ||
asyncLoading={this.props.asyncLoading} | ||
/> | ||
</EuiFlexItem> | ||
)} | ||
</EuiFlexGroup> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,16 @@ export const [ | |
export const [ | ||
getRenderCreateAccelerationFlyout, | ||
setRenderCreateAccelerationFlyout, | ||
] = createGetterSetter<(dataSource: string) => void>('renderCreateAccelerationFlyout'); | ||
] = createGetterSetter< | ||
( | ||
dataSource: string, | ||
loadStatus: any, | ||
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. How should 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. we can use |
||
startLoading: (dataSourceName: string, databaseName?: string, tableName?: string) => void, | ||
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. I saw there are repeated patterns not only in this PR where we have a same set of interfaces for functions and components but the interfaces are duplicated and redefined repeatedly, feel like we should define common interfaces and reuse them or leverage utility types for composing types and interfaces. It's ok for this PR and release but we should follow up on this later. |
||
stopLoading: () => void, | ||
databaseName?: string, | ||
tableName?: string | ||
) => void | ||
>('renderCreateAccelerationFlyout'); | ||
|
||
export const registerObservabilityDependencies = (start?: ObservabilityStart) => { | ||
if (!start) return; | ||
|
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.
Is this state equivalent to
DirectQueryLoadingStatus
?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.
yes