Skip to content

Commit

Permalink
client: add warning toast
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Jul 29, 2022
1 parent ea2272d commit 3b21067
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions client/src/__locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@
"updated_upstream_dns_toast": "Upstream servers successfully saved",
"dns_test_ok_toast": "Specified DNS servers are working correctly",
"dns_test_not_ok_toast": "Server \"{{key}}\": could not be used, please check that you've written it correctly",
"dns_test_warning_toast": "Server \"{{key}}\": doesn't respond for the test request and thus may not work properly",
"unblock": "Unblock",
"block": "Block",
"disallow_this_client": "Disallow this client",
Expand Down
6 changes: 4 additions & 2 deletions client/src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,15 @@ export const testUpstream = (
const testMessages = Object.keys(upstreamResponse)
.map((key) => {
const message = upstreamResponse[key];
if (message !== 'OK') {
if (message.startsWith('WARNING:')) {
dispatch(addErrorToast({ error: i18next.t('dns_test_warning_toast', { key }) }));
} else if (message !== 'OK') {
dispatch(addErrorToast({ error: i18next.t('dns_test_not_ok_toast', { key }) }));
}
return message;
});

if (testMessages.every((message) => message === 'OK')) {
if (testMessages.every((message) => message === 'OK' || message.startsWith('WARNING:'))) {
dispatch(addSuccessToast('dns_test_ok_toast'));
}

Expand Down

0 comments on commit 3b21067

Please sign in to comment.