-
Notifications
You must be signed in to change notification settings - Fork 32
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
UI fixes for loading state, empty tree, added toast for error, fixed no indicies error #176
Changes from 6 commits
589951b
2e184ce
5efe351
beb860e
3017d31
f83de12
4f37950
ff41b4c
a2a756c
a47f644
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,37 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { ToastInputFields } from '../../../../src/core/public'; | ||
import { coreRefs } from '../../public/framework/core_refs'; | ||
|
||
type Color = 'success' | 'primary' | 'warning' | 'danger' | undefined; | ||
|
||
export const useToast = () => { | ||
const toasts = coreRefs.toasts!; | ||
|
||
const setToast = (title: string, color: Color = 'success', text?: string) => { | ||
const newToast: ToastInputFields = { | ||
id: new Date().toISOString(), | ||
title, | ||
text, | ||
}; | ||
switch (color) { | ||
case 'danger': { | ||
toasts.addDanger(newToast); | ||
break; | ||
} | ||
case 'warning': { | ||
toasts.addWarning(newToast); | ||
break; | ||
} | ||
default: { | ||
toasts.addSuccess(newToast); | ||
break; | ||
} | ||
} | ||
}; | ||
|
||
return { setToast }; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -878,6 +878,7 @@ export class Main extends React.Component<MainProps, MainState> { | |
pplQuery={this.state.pplQueriesString} | ||
pplTranslations={this.state.queryTranslations} | ||
updatePPLQueries={this.updatePPLQueries} | ||
selectedDatasource={this.state.selectedDatasource} | ||
asyncLoading={this.state.asyncLoading} | ||
/> | ||
); | ||
|
@@ -962,33 +963,38 @@ export class Main extends React.Component<MainProps, MainState> { | |
style={{ | ||
maxWidth: '400px', | ||
width: '400px', | ||
maxHeight: '1200px', | ||
overflowY: 'auto', | ||
overflowX: 'hidden', | ||
height: 'calc(100vh - 254px)', | ||
}} | ||
> | ||
<EuiFlexGroup direction="column"> | ||
<EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
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. Is this flex item needed here? I don't see it part of any flex group 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. Removed it |
||
<EuiFlexGroup direction="row" gutterSize="s"> | ||
<EuiFlexItem grow={false}> | ||
<EuiFlexGroup direction="row" gutterSize="s"> | ||
<EuiFlexItem grow={false}> | ||
<EuiButtonIcon | ||
display="base" | ||
iconType="refresh" | ||
size="m" | ||
aria-label="refresh" | ||
onClick={this.handleReloadTree} | ||
/> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<CreateButton | ||
updateSQLQueries={this.updateSQLQueries} | ||
selectedDatasource={this.state.selectedDatasource} | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
<EuiButtonIcon | ||
display="base" | ||
iconType="refresh" | ||
size="m" | ||
aria-label="refresh" | ||
onClick={this.handleReloadTree} | ||
/> | ||
</EuiFlexItem> | ||
<EuiSpacer /> | ||
<EuiFlexItem grow={false}> | ||
<CreateButton | ||
updateSQLQueries={this.updateSQLQueries} | ||
selectedDatasource={this.state.selectedDatasource} | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFlexItem> | ||
<EuiSpacer size="l" /> | ||
<EuiFlexGroup | ||
direction="column" | ||
style={{ | ||
overflowY: 'auto', | ||
overflowX: 'hidden', | ||
height: 'calc(100vh - 308px)', | ||
}} | ||
> | ||
<EuiFlexItem grow={false}> | ||
<TableView | ||
http={this.httpClient} | ||
selectedItems={this.state.selectedDatasource} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import { | |
EuiButton, | ||
EuiCodeBlock, | ||
EuiCodeEditor, | ||
EuiComboBoxOptionOption, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiModal, | ||
|
@@ -29,6 +30,7 @@ interface PPLPageProps { | |
updatePPLQueries: (query: string) => void; | ||
pplQuery: string; | ||
pplTranslations: ResponseDetail<TranslateResult>[]; | ||
selectedDatasource: EuiComboBoxOptionOption[]; | ||
asyncLoading: boolean; | ||
} | ||
|
||
|
@@ -147,17 +149,31 @@ export class PPLPage extends React.Component<PPLPageProps, PPLPageState> { | |
Clear | ||
</EuiButton> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false} onClick={() => this.props.onTranslate(this.props.pplQuery)}> | ||
<EuiButton | ||
className="sql-editor-button" | ||
onClick={showModal} | ||
isDisabled={this.props.asyncLoading} | ||
{this.props.selectedDatasource && | ||
this.props.selectedDatasource[0].label === 'OpenSearch' ? ( | ||
<EuiFlexItem grow={false} onClick={() => this.props.onTranslate(this.props.pplQuery)}> | ||
<EuiButton | ||
className="sql-editor-button" | ||
onClick={showModal} | ||
isDisabled={this.props.asyncLoading} | ||
> | ||
Explain | ||
</EuiButton> | ||
</EuiFlexItem> | ||
) : ( | ||
<EuiFlexItem | ||
grow={false} | ||
onClick={() => | ||
this.props.updatePPLQueries('source = <datasource>.<database>.<table> | head 10') | ||
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. Should move the query to common/constants 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. moved query to constants |
||
} | ||
> | ||
Explain | ||
</EuiButton> | ||
{modal} | ||
</EuiFlexItem> | ||
<EuiButton className="sql-editor-button" isDisabled={this.props.asyncLoading}> | ||
Sample Query | ||
</EuiButton> | ||
</EuiFlexItem> | ||
)} | ||
</EuiFlexGroup> | ||
{modal} | ||
</EuiPanel> | ||
); | ||
} | ||
|
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.
Have we tested the acceleration flyout with the function change here?
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.
not able to test anything, right now