Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 7 additions & 2 deletions src/components/MetricChart/MetricChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
setChartDataWasNotLoaded,
setChartError,
} from './reducer';
import i18n from './i18n';

import './MetricChart.scss';

Expand Down Expand Up @@ -181,14 +182,18 @@ export const MetricChart = ({
return;
}

// In some cases error could be in response with 200 status code
// Response could be a plain html for ydb versions without charts support
// Or there could be an error in response with 200 status code
// It happens when request is OK, but chart data cannot be returned due to some reason
// Example: charts are not enabled in the DB ('GraphShard is not enabled' error)
if (Array.isArray(response)) {
const preparedData = convertResponse(response, metrics);
dispatch(setChartData(preparedData));
} else {
const err = {statusText: response.error};
const err = {
statusText:
typeof response === 'string' ? i18n('not-supported') : response.error,
};

throw err;
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/MetricChart/i18n/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"not-supported": "Charts are not supported on current ydb version"
}
7 changes: 7 additions & 0 deletions src/components/MetricChart/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {registerKeysets} from '../../../utils/i18n';

import en from './en.json';

const COMPONENT = 'ydb-metric-chart';

export default registerKeysets(COMPONENT, {en});
7 changes: 5 additions & 2 deletions src/types/api/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
* source: https://github.com/ydb-platform/ydb/blob/main/ydb/core/viewer/json_render.h
*/

export type JsonRenderResponse =
export type JsonRenderResponse = JsonRenderErrorResponse | MetricData[];

/** Response could be a plain html with 404 on ydb versions without charts support */
type JsonRenderErrorResponse =
| {
error?: string;
status?: string;
}
| MetricData[];
| string;

export interface MetricData {
datapoints: MetricDatapoint[];
Expand Down