|
17 | 17 | * under the License. |
18 | 18 | */ |
19 | 19 | import { Dispatch } from 'redux'; |
20 | | -import { makeApi, CategoricalColorNamespace, t } from '@superset-ui/core'; |
| 20 | +import { makeApi, CategoricalColorNamespace } from '@superset-ui/core'; |
21 | 21 | import { isString } from 'lodash'; |
22 | | -import { getClientErrorObject } from 'src/utils/getClientErrorObject'; |
| 22 | +import { getErrorText } from 'src/utils/getClientErrorObject'; |
23 | 23 | import { addDangerToast } from 'src/components/MessageToasts/actions'; |
24 | 24 | import { |
25 | 25 | DashboardInfo, |
@@ -169,18 +169,7 @@ export function saveFilterBarOrientation(orientation: FilterBarOrientation) { |
169 | 169 | dispatch(onSave(lastModifiedTime)); |
170 | 170 | } |
171 | 171 | } catch (errorObject) { |
172 | | - const { error, message } = await getClientErrorObject(errorObject); |
173 | | - let errorText = t('Sorry, an unknown error occurred.'); |
174 | | - |
175 | | - if (error) { |
176 | | - errorText = t( |
177 | | - 'Sorry, there was an error saving this dashboard: %s', |
178 | | - error, |
179 | | - ); |
180 | | - } |
181 | | - if (typeof message === 'string' && message === 'Forbidden') { |
182 | | - errorText = t('You do not have permission to edit this dashboard'); |
183 | | - } |
| 172 | + const errorText = await getErrorText(errorObject, 'dashboard'); |
184 | 173 | dispatch(addDangerToast(errorText)); |
185 | 174 | throw errorObject; |
186 | 175 | } |
@@ -214,18 +203,7 @@ export function saveCrossFiltersSetting(crossFiltersEnabled: boolean) { |
214 | 203 | dispatch(onSave(lastModifiedTime)); |
215 | 204 | } |
216 | 205 | } catch (errorObject) { |
217 | | - const { error, message } = await getClientErrorObject(errorObject); |
218 | | - let errorText = t('Sorry, an unknown error occurred.'); |
219 | | - |
220 | | - if (error) { |
221 | | - errorText = t( |
222 | | - 'Sorry, there was an error saving this dashboard: %s', |
223 | | - error, |
224 | | - ); |
225 | | - } |
226 | | - if (typeof message === 'string' && message === 'Forbidden') { |
227 | | - errorText = t('You do not have permission to edit this dashboard'); |
228 | | - } |
| 206 | + const errorText = await getErrorText(errorObject, 'dashboard'); |
229 | 207 | dispatch(addDangerToast(errorText)); |
230 | 208 | throw errorObject; |
231 | 209 | } |
|
0 commit comments