diff --git a/client/src/actions/index.js b/client/src/actions/index.js index 88e14ef9..3087c47d 100644 --- a/client/src/actions/index.js +++ b/client/src/actions/index.js @@ -2,8 +2,7 @@ import { createAction } from 'redux-actions'; import { t } from 'i18next'; import axios from 'axios'; -import versionCompare from '../helpers/versionCompare'; -import { normalizeTextarea, sortClients } from '../helpers/helpers'; +import { normalizeTextarea, sortClients, isVersionGreater } from '../helpers/helpers'; import { SETTINGS_NAMES, CHECK_TIMEOUT } from '../helpers/constants'; import { getTlsStatus } from './encryption'; import apiClient from '../api/Api'; @@ -125,7 +124,7 @@ export const getVersion = (recheck = false) => async (dispatch, getState) => { const { dnsVersion } = getState().dashboard; const currentVersion = dnsVersion === 'undefined' ? 0 : dnsVersion; - if (data && versionCompare(currentVersion, data.new_version) === -1) { + if (data && isVersionGreater(currentVersion, data.new_version)) { dispatch(addSuccessToast('updates_checked')); } else { dispatch(addSuccessToast('updates_version_equal')); @@ -227,7 +226,22 @@ export const getDnsStatus = () => async (dispatch) => { dispatch(getTlsStatus()); } catch (error) { dispatch(addErrorToast({ error })); - dispatch(initSettingsFailure()); + dispatch(dnsStatusFailure()); + } +}; + +export const getDnsSettingsRequest = createAction('GET_DNS_SETTINGS_REQUEST'); +export const getDnsSettingsFailure = createAction('GET_DNS_SETTINGS_FAILURE'); +export const getDnsSettingsSuccess = createAction('GET_DNS_SETTINGS_SUCCESS'); + +export const getDnsSettings = () => async (dispatch) => { + dispatch(getDnsSettingsRequest()); + try { + const dnsStatus = await apiClient.getGlobalStatus(); + dispatch(getDnsSettingsSuccess(dnsStatus)); + } catch (error) { + dispatch(addErrorToast({ error })); + dispatch(getDnsSettingsFailure()); } }; @@ -279,7 +293,7 @@ export const setUpstream = config => async (dispatch) => { await apiClient.setUpstream(values); dispatch(addSuccessToast('updated_upstream_dns_toast')); - dispatch(setUpstreamSuccess()); + dispatch(setUpstreamSuccess(config)); } catch (error) { dispatch(addErrorToast({ error })); dispatch(setUpstreamFailure()); diff --git a/client/src/components/Settings/Dns/Access/Form.js b/client/src/components/Settings/Dns/Access/Form.js index 9096102d..29c9bc8b 100644 --- a/client/src/components/Settings/Dns/Access/Form.js +++ b/client/src/components/Settings/Dns/Access/Form.js @@ -5,7 +5,9 @@ import { Trans, withNamespaces } from 'react-i18next'; import flow from 'lodash/flow'; const Form = (props) => { - const { handleSubmit, submitting, invalid } = props; + const { + handleSubmit, submitting, invalid, processingSet, + } = props; return (