Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/containers/Tenant/Query/QueryEditor/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
DEFAULT_IS_QUERY_RESULT_COLLAPSED,
DEFAULT_SIZE_RESULT_PANE_KEY,
LAST_USED_QUERY_ACTION_KEY,
LAST_USED_QUERY_TEXT,
} from '../../../../utils/constants';
import {
useEventHandler,
Expand Down Expand Up @@ -104,6 +105,8 @@ export default function QueryEditor(props: QueryEditorProps) {
LAST_USED_QUERY_ACTION_KEY,
);

const [lastUsedQueryText, setLastUsedQueryText] = useSetting<string>(LAST_USED_QUERY_TEXT);

const [sendQuery] = queryApi.useUseSendQueryMutation();

React.useEffect(() => {
Expand Down Expand Up @@ -140,6 +143,7 @@ export default function QueryEditor(props: QueryEditorProps) {
const query = text ?? input;

setLastUsedQueryAction(QUERY_ACTIONS.execute);
setLastUsedQueryText(query);
if (!isEqual(lastQueryExecutionSettings, querySettings)) {
resetBanner();
setLastQueryExecutionSettings(querySettings);
Expand Down Expand Up @@ -172,7 +176,7 @@ export default function QueryEditor(props: QueryEditorProps) {

const handleGetExplainQueryClick = useEventHandler(() => {
setLastUsedQueryAction(QUERY_ACTIONS.explain);

setLastUsedQueryText(input);
if (!isEqual(lastQueryExecutionSettings, querySettings)) {
resetBanner();
setLastQueryExecutionSettings(querySettings);
Expand Down Expand Up @@ -368,6 +372,7 @@ export default function QueryEditor(props: QueryEditorProps) {
tenantName={tenantName}
path={path}
showPreview={showPreview}
queryText={lastUsedQueryText}
/>
</div>
</SplitPane>
Expand All @@ -386,6 +391,7 @@ interface ResultProps {
tenantName: string;
path: string;
showPreview?: boolean;
queryText: string;
}
function Result({
resultVisibilityState,
Expand All @@ -397,6 +403,7 @@ function Result({
tenantName,
path,
showPreview,
queryText,
}: ResultProps) {
if (showPreview) {
return <Preview database={tenantName} path={path} type={type} />;
Expand All @@ -412,6 +419,7 @@ function Result({
isResultsCollapsed={resultVisibilityState.collapsed}
onExpandResults={onExpandResultHandler}
onCollapseResults={onCollapseResultHandler}
queryText={queryText}
/>
);
}
Expand Down
23 changes: 19 additions & 4 deletions src/containers/Tenant/Query/QueryResult/QueryResultViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {isQueryCancelledError} from '../utils/isQueryCancelledError';

import {Ast} from './components/Ast/Ast';
import {Graph} from './components/Graph/Graph';
import {PlanToSvgButton} from './components/PlanToSvgButton/PlanToSvgButton';
import {QueryInfoDropdown} from './components/QueryInfoDropdown/QueryInfoDropdown';
import {QueryJSONViewer} from './components/QueryJSONViewer/QueryJSONViewer';
import {QueryResultError} from './components/QueryResultError/QueryResultError';
import {ResultSetsViewer} from './components/ResultSetsViewer/ResultSetsViewer';
Expand Down Expand Up @@ -83,6 +83,7 @@ interface ExecuteResultProps {
tenantName: string;
onCollapseResults: VoidFunction;
onExpandResults: VoidFunction;
queryText?: string;
}

export function QueryResultViewer({
Expand All @@ -91,6 +92,7 @@ export function QueryResultViewer({
isResultsCollapsed,
theme,
tenantName,
queryText,
onCollapseResults,
onExpandResults,
}: ExecuteResultProps) {
Expand Down Expand Up @@ -180,6 +182,21 @@ export function QueryResultViewer({
);
};

const renderQueryInfoDropdown = () => {
return (
<QueryInfoDropdown
queryResultsInfo={{
ast: data.ast,
stats: data.stats,
queryText,
Copy link
Contributor

Choose a reason for hiding this comment

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

lets' move queryText on top, so it would be easier to identify what about diagnostics file is?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

plan: data.plan,
}}
database={tenantName}
hasPlanToSvg={Boolean(data?.plan && useShowPlanToSvg && isExecute)}
/>
);
};

const renderStubMessage = () => {
return (
<StubMessage
Expand Down Expand Up @@ -268,16 +285,14 @@ export function QueryResultViewer({
{data?.traceId && isExecute ? (
<TraceButton traceId={data.traceId} isTraceReady={result.isTraceReady} />
) : null}
{data?.plan && useShowPlanToSvg && isExecute ? (
<PlanToSvgButton plan={data?.plan} database={tenantName} />
) : null}
</div>
);
};

const renderRightControls = () => {
return (
<div className={b('controls-right')}>
{renderQueryInfoDropdown()}
{renderClipboardButton()}
<EnableFullscreenButton />
<PaneVisibilityToggleButtons
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.query-info-dropdown {
&__menu-item {
align-items: start;
}

&__menu-item-content {
display: flex;
flex-direction: column;

padding: var(--g-spacing-1) 0;
}

&__icon {
margin-top: var(--g-spacing-2);
margin-right: var(--g-spacing-2);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import {Ellipsis} from '@gravity-ui/icons';
import type {ButtonProps} from '@gravity-ui/uikit';
import {Button, DropdownMenu} from '@gravity-ui/uikit';

import type {QueryResultsInfo} from './useQueryInfoMenuItems';
import {useQueryInfoMenuItems} from './useQueryInfoMenuItems';

import './QueryInfoDropdown.scss';

interface QueryInfoDropdownProps {
queryResultsInfo: QueryResultsInfo;
database: string;
hasPlanToSvg: boolean;
}

export function QueryInfoDropdown({
queryResultsInfo,
database,
hasPlanToSvg,
}: QueryInfoDropdownProps) {
const {isLoading, items} = useQueryInfoMenuItems({
queryResultsInfo,
database,
hasPlanToSvg,
});

const renderSwitcher = (props: ButtonProps) => {
return (
<Button view="flat-secondary" loading={isLoading} disabled={isLoading} {...props}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets add ActionTooltip for title.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added

<Button.Icon>
<Ellipsis />
</Button.Icon>
</Button>
);
};

if (!items.length) {
return null;
}

return (
<DropdownMenu
popupProps={{
placement: ['bottom-end', 'left'],
}}
renderSwitcher={renderSwitcher}
items={items}
size="xl"
/>
);
}
Loading
Loading