Skip to content

Commit

Permalink
resolve comment
Browse files Browse the repository at this point in the history
  • Loading branch information
codemaster08240328 committed Apr 1, 2022
1 parent 75ff343 commit a66d6fa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions superset-frontend/src/views/CRUD/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ export function useImportResource(
resourceLabel,
[
...error.errors.map(payload => payload.message),
'Please re-export your file and try importing again',
t('Please re-export your file and try importing again'),
].join('\n'),
),
);
Expand All @@ -467,7 +467,7 @@ export function useImportResource(
updateState({ loading: false });
});
},
[handleErrorMsg, resourceLabel, resourceName],
[],
);

return { state, importResource };
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/views/CRUD/utils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ test('detects if the error message is terminal or if it requires uses interventi
expect(isTerminal).toBe(false);
});

test('error message is terminal when the extra field not contains other keys excepting issue_codes', () => {
test('error message is terminal when the "extra" field contains only the "issue_codes" key', () => {
expect(hasTerminalValidation(terminalErrorsWithOnlyIssuesCode.errors)).toBe(
true,
);
Expand Down
10 changes: 5 additions & 5 deletions superset-frontend/src/views/CRUD/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -400,14 +400,14 @@ export const getAlreadyExists = (errors: Record<string, any>[]) =>

export const hasTerminalValidation = (errors: Record<string, any>[]) =>
errors.some(error => {
const not_issues_codes = Object.entries(error.extra).filter(
([key, _]) => key !== 'issue_codes',
const noIssuesCodes = Object.entries(error.extra).filter(
([key]) => key !== 'issue_codes',
);

if (not_issues_codes.length === 0) return true;
if (noIssuesCodes.length === 0) return true;

return !not_issues_codes.every(
([_, payload]) => isNeedsPassword(payload) || isAlreadyExists(payload),
return !noIssuesCodes.every(
([, payload]) => isNeedsPassword(payload) || isAlreadyExists(payload),
);
});

Expand Down

0 comments on commit a66d6fa

Please sign in to comment.