Updates #613. Squashed commit of the following: commit 9a3ba15bdb8476dde045631362d76572a68a4e5c Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Thu Jan 19 12:46:48 2023 +0700 client: review dark theme colors commit c456cdcb6ffec044917b0396ad3cfa8b5c3bce10 Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Wed Jan 18 23:46:32 2023 +0700 client: review dark theme colors commit 4b042ba4f433c89488b18ec38f5864d5ffaf8657 Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Wed Jan 18 23:34:37 2023 +0700 client: review dark theme colors commit 1ff34f751b4d9342495070af85f3dae86c285aee Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Wed Jan 18 18:59:46 2023 +0700 client: default language commit ca9abc11a8c155c78f73903906ed452e95764e99 Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Wed Jan 18 12:23:50 2023 +0700 client: default language commit 01a057a40e879d1bc2013989d6eb56a296ba16a3 Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Wed Jan 18 11:53:58 2023 +0700 client: review dark theme colors commit aa3658f35c49f8ae19077b333075207082383a17 Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Wed Jan 18 11:14:08 2023 +0700 client: review dark theme colors commit 8df726382155fcc3b2e6e632d53f42d0be638c77 Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Tue Jan 17 13:41:21 2023 +0700 client: dark theme colors commit bd84ae46272743874d2350291b22b90b7fbedf0e Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Tue Jan 17 13:05:46 2023 +0700 client: dark theme colors commit 136ea5608a1a22b6a54a362741b2fdd708f345e2 Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Tue Jan 17 10:51:22 2023 +0700 all: docs commit 784be8741b730a12d665d7e2a29c140c0746e927 Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Mon Jan 16 17:59:26 2023 +0700 client: imp code commit a83de0948fe034e7be35c04a607b1171915c0263 Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Mon Jan 16 14:13:54 2023 +0700 client: dark theme login commit 6c4ef19da01efc6a1e4ea76085b7b7382c331eca Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Mon Jan 16 13:27:35 2023 +0700 client: dark theme css commit 5cf564ea1203e9472d200975ee98d93b6b868210 Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Mon Jan 16 13:18:00 2023 +0700 client: imp code commit 1bbbd20972345c08e944b7c4bb0330c0d30d827a Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Mon Jan 16 12:49:03 2023 +0700 client: imp code commit cb07680d3cd7acdbdb7bdc9d9abaa388a9df8e4c Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Mon Jan 16 12:24:14 2023 +0700 client: auto theme handling commit d34910d4dd5edb694b6da55a2260b4fea784e7e0 Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Fri Jan 13 23:31:24 2023 +0700 home: imp docs commit 8abe4f6f7182dc3dbcbbe73652294ee6584a4f2f Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Thu Jan 12 18:35:48 2023 +0700 client: theme dropdown
174 lines
5.1 KiB
JavaScript
174 lines
5.1 KiB
JavaScript
import { handleActions } from 'redux-actions';
|
|
import * as actions from '../actions';
|
|
import { areEqualVersions } from '../helpers/version';
|
|
import { STANDARD_DNS_PORT, STANDARD_WEB_PORT } from '../helpers/constants';
|
|
|
|
const dashboard = handleActions(
|
|
{
|
|
[actions.setDnsRunningStatus]: (state, { payload }) => (
|
|
{
|
|
...state,
|
|
isCoreRunning: payload,
|
|
}
|
|
),
|
|
[actions.dnsStatusRequest]: (state) => ({
|
|
...state,
|
|
processing: true,
|
|
}),
|
|
[actions.dnsStatusFailure]: (state) => ({
|
|
...state,
|
|
processing: false,
|
|
}),
|
|
[actions.dnsStatusSuccess]: (state, { payload }) => {
|
|
const {
|
|
version,
|
|
dns_port: dnsPort,
|
|
dns_addresses: dnsAddresses,
|
|
protection_enabled: protectionEnabled,
|
|
http_port: httpPort,
|
|
language,
|
|
} = payload;
|
|
const newState = {
|
|
...state,
|
|
isCoreRunning: true,
|
|
processing: false,
|
|
dnsVersion: version,
|
|
dnsPort,
|
|
dnsAddresses,
|
|
protectionEnabled,
|
|
language,
|
|
httpPort,
|
|
};
|
|
return newState;
|
|
},
|
|
|
|
[actions.getVersionRequest]: (state) => ({
|
|
...state,
|
|
processingVersion: true,
|
|
}),
|
|
[actions.getVersionFailure]: (state) => ({
|
|
...state,
|
|
processingVersion: false,
|
|
}),
|
|
[actions.getVersionSuccess]: (state, { payload }) => {
|
|
const currentVersion = state.dnsVersion === 'undefined' ? 0 : state.dnsVersion;
|
|
|
|
if (!payload.disabled && !areEqualVersions(currentVersion, payload.new_version)) {
|
|
const {
|
|
announcement_url: announcementUrl,
|
|
new_version: newVersion,
|
|
can_autoupdate: canAutoUpdate,
|
|
} = payload;
|
|
|
|
const newState = {
|
|
...state,
|
|
announcementUrl,
|
|
newVersion,
|
|
canAutoUpdate,
|
|
isUpdateAvailable: true,
|
|
processingVersion: false,
|
|
checkUpdateFlag: !payload.disabled,
|
|
};
|
|
return newState;
|
|
}
|
|
|
|
return {
|
|
...state,
|
|
processingVersion: false,
|
|
checkUpdateFlag: !payload.disabled,
|
|
};
|
|
},
|
|
|
|
[actions.getUpdateRequest]: (state) => ({
|
|
...state,
|
|
processingUpdate: true,
|
|
}),
|
|
[actions.getUpdateFailure]: (state) => ({
|
|
...state,
|
|
processingUpdate: false,
|
|
}),
|
|
[actions.getUpdateSuccess]: (state) => {
|
|
const newState = {
|
|
...state,
|
|
processingUpdate: false,
|
|
};
|
|
return newState;
|
|
},
|
|
|
|
[actions.toggleProtectionRequest]: (state) => ({
|
|
...state,
|
|
processingProtection: true,
|
|
}),
|
|
[actions.toggleProtectionFailure]: (state) => ({
|
|
...state,
|
|
processingProtection: false,
|
|
}),
|
|
[actions.toggleProtectionSuccess]: (state) => {
|
|
const newState = {
|
|
...state,
|
|
protectionEnabled: !state.protectionEnabled,
|
|
processingProtection: false,
|
|
};
|
|
return newState;
|
|
},
|
|
|
|
[actions.getClientsRequest]: (state) => ({
|
|
...state,
|
|
processingClients: true,
|
|
}),
|
|
[actions.getClientsFailure]: (state) => ({
|
|
...state,
|
|
processingClients: false,
|
|
}),
|
|
[actions.getClientsSuccess]: (state, { payload }) => {
|
|
const newState = {
|
|
...state,
|
|
...payload,
|
|
processingClients: false,
|
|
};
|
|
return newState;
|
|
},
|
|
|
|
[actions.getProfileRequest]: (state) => ({
|
|
...state,
|
|
processingProfile: true,
|
|
}),
|
|
[actions.getProfileFailure]: (state) => ({
|
|
...state,
|
|
processingProfile: false,
|
|
}),
|
|
[actions.getProfileSuccess]: (state, { payload }) => ({
|
|
...state,
|
|
name: payload.name,
|
|
theme: payload.theme,
|
|
processingProfile: false,
|
|
}),
|
|
[actions.changeThemeSuccess]: (state, { payload }) => ({
|
|
...state,
|
|
theme: payload.theme,
|
|
}),
|
|
},
|
|
{
|
|
processing: true,
|
|
isCoreRunning: true,
|
|
processingVersion: true,
|
|
processingClients: true,
|
|
processingUpdate: false,
|
|
processingProfile: true,
|
|
protectionEnabled: false,
|
|
processingProtection: false,
|
|
httpPort: STANDARD_WEB_PORT,
|
|
dnsPort: STANDARD_DNS_PORT,
|
|
dnsAddresses: [],
|
|
dnsVersion: '',
|
|
clients: [],
|
|
autoClients: [],
|
|
supportedTags: [],
|
|
name: '',
|
|
theme: 'auto',
|
|
checkUpdateFlag: false,
|
|
},
|
|
);
|
|
|
|
export default dashboard;
|