Skip to content

Commit 1a02250

Browse files
committed
fix: review fixes
1 parent af06c3a commit 1a02250

File tree

4 files changed

+33
-35
lines changed

4 files changed

+33
-35
lines changed

src/containers/Tenant/Query/QueryEditor/QueryEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ function Result({
313313
theme={theme}
314314
tenantName={tenantName}
315315
isResultsCollapsed={resultVisibilityState.collapsed}
316-
isCancelError={Boolean(cancelQueryResponse?.isLoading)}
316+
isCancelError={Boolean(cancelQueryResponse?.error)}
317317
isCancelling={Boolean(cancelQueryResponse?.isLoading)}
318318
onExpandResults={onExpandResultHandler}
319319
onCollapseResults={onCollapseResultHandler}

src/services/api/streaming.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,19 @@ import {
66
isSessionChunk,
77
isStreamDataChunk,
88
} from '../../store/reducers/query/utils';
9-
import type {Actions, TracingLevel} from '../../types/api/query';
10-
import type {QuerySyntax, StatisticsMode} from '../../types/store/query';
9+
import type {Actions, StreamQueryParams} from '../../types/api/query';
1110
import type {QueryResponseChunk, SessionChunk, StreamDataChunk} from '../../types/store/streaming';
1211
import {
1312
BINARY_DATA_IN_PLAIN_TEXT_DISPLAY,
1413
DEV_ENABLE_TRACING_FOR_ALL_REQUESTS,
1514
} from '../../utils/constants';
15+
import {isRedirectToAuth} from '../../utils/response';
1616
import {settingsManager} from '../settings';
1717

1818
import {BaseYdbAPI} from './base';
1919

2020
const BOUNDARY = 'boundary';
2121

22-
export interface StreamQueryParams {
23-
query?: string;
24-
database?: string;
25-
action?: Actions;
26-
syntax?: QuerySyntax;
27-
stats?: StatisticsMode;
28-
tracingLevel?: TracingLevel;
29-
transaction_mode?: string;
30-
timeout?: number;
31-
limit_rows?: number;
32-
output_chunk_max_size: number;
33-
concurrent_results?: boolean;
34-
}
35-
3622
export interface StreamQueryOptions {
3723
signal?: AbortSignal;
3824
onStreamDataChunk: (chunk: StreamDataChunk) => void;
@@ -41,7 +27,10 @@ export interface StreamQueryOptions {
4127
}
4228

4329
export class StreamingAPI extends BaseYdbAPI {
44-
async streamQuery(params: StreamQueryParams, options: StreamQueryOptions) {
30+
async streamQuery<Action extends Actions>(
31+
params: StreamQueryParams<Action>,
32+
options: StreamQueryOptions,
33+
) {
4534
const base64 = !settingsManager.readUserSettingsValue(
4635
BINARY_DATA_IN_PLAIN_TEXT_DISPLAY,
4736
true,
@@ -78,6 +67,11 @@ export class StreamingAPI extends BaseYdbAPI {
7867
});
7968

8069
if (!response.ok) {
70+
const responseData = await response.json().catch(() => ({}));
71+
if (isRedirectToAuth({status: response.status, data: responseData})) {
72+
window.location.assign(responseData.authUrl);
73+
return;
74+
}
8175
throw new Error(`${response.status}`);
8276
}
8377

src/services/api/viewer.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ import type {
1515
Actions,
1616
ErrorResponse,
1717
QueryAPIResponse,
18-
Stats,
19-
Timeout,
20-
TracingLevel,
18+
SendQueryParams,
2119
} from '../../types/api/query';
2220
import type {JsonRenderRequestParams, JsonRenderResponse} from '../../types/api/render';
2321
import type {TEvDescribeSchemeResult} from '../../types/api/schema';
@@ -32,7 +30,6 @@ import type {TTenantInfo, TTenants} from '../../types/api/tenant';
3230
import type {DescribeTopicResult} from '../../types/api/topic';
3331
import type {TEvVDiskStateResponse} from '../../types/api/vdisk';
3432
import type {TUserToken} from '../../types/api/whoami';
35-
import type {QuerySyntax, TransactionMode} from '../../types/store/query';
3633
import {BINARY_DATA_IN_PLAIN_TEXT_DISPLAY} from '../../utils/constants';
3734
import type {Nullable} from '../../utils/typecheckers';
3835
import {settingsManager} from '../settings';
@@ -329,18 +326,7 @@ export class ViewerAPI extends BaseYdbAPI {
329326
}
330327

331328
sendQuery<Action extends Actions>(
332-
params: {
333-
query?: string;
334-
database?: string;
335-
action?: Action;
336-
syntax?: QuerySyntax;
337-
stats?: Stats;
338-
tracingLevel?: TracingLevel;
339-
transaction_mode?: TransactionMode;
340-
timeout?: Timeout;
341-
query_id?: string;
342-
limit_rows?: number;
343-
},
329+
params: SendQueryParams<Action>,
344330
{concurrentId, signal, withRetries}: AxiosOptions = {},
345331
) {
346332
const base64 = !settingsManager.readUserSettingsValue(

src/types/api/query.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {TRACING_LEVELS} from '../../utils/query';
2-
import type {StatisticsMode} from '../store/query';
2+
import type {QuerySyntax, StatisticsMode, TransactionMode} from '../store/query';
33

44
// ==== types from backend protos ====
55
interface Position {
@@ -315,6 +315,24 @@ export type CancelResponse = {
315315
stats?: TKqpStatsQuery;
316316
};
317317

318+
export interface SendQueryParams<Action extends Actions> {
319+
query?: string;
320+
database?: string;
321+
action?: Action;
322+
syntax?: QuerySyntax;
323+
stats?: Stats;
324+
tracingLevel?: TracingLevel;
325+
transaction_mode?: TransactionMode;
326+
timeout?: Timeout;
327+
query_id?: string;
328+
limit_rows?: number;
329+
}
330+
331+
export interface StreamQueryParams<Action extends Actions> extends SendQueryParams<Action> {
332+
output_chunk_max_size?: number;
333+
concurrent_results?: boolean;
334+
}
335+
318336
// ==== Combined API response ====
319337
export type QueryAPIResponseByAction<Action extends Actions> = Action extends ExplainActions
320338
? GenericExplainResponse<Action>

0 commit comments

Comments
 (0)