feat: Setup `supersetText` configuration to overwrite errors (#14256)
* Setup error message overwrite config` * fix * bad reabse * bad rebase 2 * remove unneeded comment * working dynamic importing * saveeee * working textUtil file * add ignore tslint * fix linting * fix linting * import order * setup guard statements * linting again * linting again Co-authored-by: Elizabeth Thompson <eschutho@gmail.com>
This commit is contained in:
parent
40fb94dcca
commit
44c09b5383
|
|
@ -54,6 +54,7 @@ envpy3
|
||||||
env36
|
env36
|
||||||
local_config.py
|
local_config.py
|
||||||
/superset_config.py
|
/superset_config.py
|
||||||
|
/superset_text.yml
|
||||||
superset.egg-info/
|
superset.egg-info/
|
||||||
superset/bin/supersetc
|
superset/bin/supersetc
|
||||||
tmp
|
tmp
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -118,6 +118,7 @@
|
||||||
"interweave": "^11.2.0",
|
"interweave": "^11.2.0",
|
||||||
"jquery": "^3.5.1",
|
"jquery": "^3.5.1",
|
||||||
"js-levenshtein": "^1.1.6",
|
"js-levenshtein": "^1.1.6",
|
||||||
|
"js-yaml-loader": "^1.2.2",
|
||||||
"json-bigint": "^1.0.0",
|
"json-bigint": "^1.0.0",
|
||||||
"json-stringify-pretty-compact": "^2.0.0",
|
"json-stringify-pretty-compact": "^2.0.0",
|
||||||
"lodash": "^4.17.20",
|
"lodash": "^4.17.20",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
/* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* eslint-disable global-require */
|
||||||
|
const loadModule = () => {
|
||||||
|
let module;
|
||||||
|
try {
|
||||||
|
// @ts-ignore
|
||||||
|
module = require('../../../superset_text'); // eslint-disable-line import/no-unresolved
|
||||||
|
} catch (e) {
|
||||||
|
module = {};
|
||||||
|
}
|
||||||
|
return module;
|
||||||
|
};
|
||||||
|
|
||||||
|
const supersetText = loadModule();
|
||||||
|
|
||||||
|
export default supersetText;
|
||||||
|
|
@ -28,6 +28,7 @@ import Chart from 'src/types/Chart';
|
||||||
import rison from 'rison';
|
import rison from 'rison';
|
||||||
import { getClientErrorObject } from 'src/utils/getClientErrorObject';
|
import { getClientErrorObject } from 'src/utils/getClientErrorObject';
|
||||||
import { FetchDataConfig } from 'src/components/ListView';
|
import { FetchDataConfig } from 'src/components/ListView';
|
||||||
|
import SupersetText from 'src/utils/textUtils';
|
||||||
import { Dashboard, Filters, SavedQueryObject } from './types';
|
import { Dashboard, Filters, SavedQueryObject } from './types';
|
||||||
|
|
||||||
const createFetchResourceMethod = (method: string) => (
|
const createFetchResourceMethod = (method: string) => (
|
||||||
|
|
@ -159,6 +160,19 @@ export function createErrorHandler(
|
||||||
) {
|
) {
|
||||||
return async (e: SupersetClientResponse | string) => {
|
return async (e: SupersetClientResponse | string) => {
|
||||||
const parsedError = await getClientErrorObject(e);
|
const parsedError = await getClientErrorObject(e);
|
||||||
|
// Taking the first error returned from the API
|
||||||
|
// @ts-ignore
|
||||||
|
const errorsArray = parsedError?.errors;
|
||||||
|
const config = await SupersetText;
|
||||||
|
if (
|
||||||
|
errorsArray &&
|
||||||
|
errorsArray.length &&
|
||||||
|
config &&
|
||||||
|
config.ERRORS &&
|
||||||
|
errorsArray[0].error_type in config.ERRORS
|
||||||
|
) {
|
||||||
|
parsedError.message = config.ERRORS[errorsArray[0].error_type];
|
||||||
|
}
|
||||||
logging.error(e);
|
logging.error(e);
|
||||||
handleErrorFunc(parsedError.message || parsedError.error);
|
handleErrorFunc(parsedError.message || parsedError.error);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ const packageConfig = require('./package.json');
|
||||||
const APP_DIR = path.resolve(__dirname, './');
|
const APP_DIR = path.resolve(__dirname, './');
|
||||||
// output dir
|
// output dir
|
||||||
const BUILD_DIR = path.resolve(__dirname, '../superset/static/assets');
|
const BUILD_DIR = path.resolve(__dirname, '../superset/static/assets');
|
||||||
|
const ROOT_DIR = path.resolve(__dirname, '..');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
mode = 'development',
|
mode = 'development',
|
||||||
|
|
@ -286,7 +287,7 @@ const config = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
modules: [APP_DIR, 'node_modules'],
|
modules: [APP_DIR, 'node_modules', ROOT_DIR],
|
||||||
alias: {
|
alias: {
|
||||||
'react-dom': '@hot-loader/react-dom',
|
'react-dom': '@hot-loader/react-dom',
|
||||||
// Force using absolute import path of some packages in the root node_modules,
|
// Force using absolute import path of some packages in the root node_modules,
|
||||||
|
|
@ -304,7 +305,7 @@ const config = {
|
||||||
'./node_modules/@superset-ui/chart-controls',
|
'./node_modules/@superset-ui/chart-controls',
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
extensions: ['.ts', '.tsx', '.js', '.jsx'],
|
extensions: ['.ts', '.tsx', '.js', '.jsx', '.yml'],
|
||||||
symlinks: false,
|
symlinks: false,
|
||||||
},
|
},
|
||||||
context: APP_DIR, // to automatically find tsconfig.json
|
context: APP_DIR, // to automatically find tsconfig.json
|
||||||
|
|
@ -438,6 +439,11 @@ const config = {
|
||||||
esModule: false,
|
esModule: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
test: /\.ya?ml$/,
|
||||||
|
include: ROOT_DIR,
|
||||||
|
loader: 'js-yaml-loader',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
externals: {
|
externals: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue