Skip to content

Commit

Permalink
Merge branch 'master' into ADG-7200
Browse files Browse the repository at this point in the history
  • Loading branch information
IldarKamalov committed Oct 11, 2023
2 parents 58a6c76 + 6a36615 commit d3267bb
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 39 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ NOTE: Add new changes BELOW THIS COMMENT.

### Fixed

- Incorrect domain-specific upstream matching for `DS` queries ([#6156]).
- Improper validation of password length ([#6280]).
- Wrong algorithm for filtering self addresses from the list of private upstream
DNS servers ([#6231]).
- An accidental change in DNS rewrite priority ([#6226]).

[#1700]: https://github.com/AdguardTeam/AdGuardHome/issues/1700
[#4569]: https://github.com/AdguardTeam/AdGuardHome/issues/4569
[#6156]: https://github.com/AdguardTeam/AdGuardHome/issues/6156
[#6226]: https://github.com/AdguardTeam/AdGuardHome/issues/6226
[#6231]: https://github.com/AdguardTeam/AdGuardHome/issues/6231
[#6233]: https://github.com/AdguardTeam/AdGuardHome/issues/6233
Expand Down
4 changes: 3 additions & 1 deletion client/src/components/Filters/Rewrites/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ReactTable from 'react-table';
import { withTranslation } from 'react-i18next';
import { sortIp } from '../../../helpers/helpers';
import { MODAL_TYPE } from '../../../helpers/constants';
import { LocalStorageHelper, LOCAL_STORAGE_KEYS } from '../../../helpers/localStorageHelper';

class Table extends Component {
cellWrap = ({ value }) => (
Expand Down Expand Up @@ -85,7 +86,8 @@ class Table extends Component {
loading={processing || processingAdd || processingDelete}
className="-striped -highlight card-table-overflow"
showPagination
defaultPageSize={10}
defaultPageSize={LocalStorageHelper.getItem(LOCAL_STORAGE_KEYS.REWRITES_PAGE_SIZE) || 10}
onPageSizeChange={(size) => LocalStorageHelper.setItem(LOCAL_STORAGE_KEYS.REWRITES_PAGE_SIZE, size)}
minRows={5}
ofText="/"
previousText={t('previous_btn')}
Expand Down
8 changes: 7 additions & 1 deletion client/src/components/Filters/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import CellWrap from '../ui/CellWrap';
import { MODAL_TYPE } from '../../helpers/constants';
import { formatDetailedDateTime } from '../../helpers/helpers';
import { isValidAbsolutePath } from '../../helpers/form';
import { LOCAL_STORAGE_KEYS, LocalStorageHelper } from '../../helpers/localStorageHelper';

class Table extends Component {
getDateCell = (row) => CellWrap(row, formatDetailedDateTime);
Expand Down Expand Up @@ -126,12 +127,17 @@ class Table extends Component {
loading, filters, t, whitelist,
} = this.props;

const localStorageKey = whitelist
? LOCAL_STORAGE_KEYS.ALLOWLIST_PAGE_SIZE
: LOCAL_STORAGE_KEYS.BLOCKLIST_PAGE_SIZE;

return (
<ReactTable
data={filters}
columns={this.columns}
showPagination
defaultPageSize={10}
defaultPageSize={LocalStorageHelper.getItem(localStorageKey) || 10}
onPageSizeChange={(size) => LocalStorageHelper.setItem(localStorageKey, size)}
loading={loading}
minRows={6}
ofText="/"
Expand Down
6 changes: 5 additions & 1 deletion client/src/components/Settings/Clients/AutoClients.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import CellWrap from '../../ui/CellWrap';
import whoisCell from './whoisCell';
import LogsSearchLink from '../../ui/LogsSearchLink';
import { sortIp } from '../../../helpers/helpers';
import { LocalStorageHelper, LOCAL_STORAGE_KEYS } from '../../../helpers/localStorageHelper';

const COLUMN_MIN_WIDTH = 200;

Expand Down Expand Up @@ -85,7 +86,10 @@ class AutoClients extends Component {
]}
className="-striped -highlight card-table-overflow"
showPagination
defaultPageSize={10}
defaultPageSize={LocalStorageHelper.getItem(LOCAL_STORAGE_KEYS.AUTO_CLIENTS_PAGE_SIZE) || 10}
onPageSizeChange={(size) => (
LocalStorageHelper.setItem(LOCAL_STORAGE_KEYS.AUTO_CLIENTS_PAGE_SIZE, size)
)}
minRows={5}
ofText="/"
previousText={t('previous_btn')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Card from '../../../ui/Card';
import CellWrap from '../../../ui/CellWrap';
import LogsSearchLink from '../../../ui/LogsSearchLink';
import Modal from '../Modal';
import { LocalStorageHelper, LOCAL_STORAGE_KEYS } from '../../../../helpers/localStorageHelper';

const ClientsTable = ({
clients,
Expand Down Expand Up @@ -342,7 +343,10 @@ const ClientsTable = ({
]}
className="-striped -highlight card-table-overflow"
showPagination
defaultPageSize={10}
defaultPageSize={LocalStorageHelper.getItem(LOCAL_STORAGE_KEYS.CLIENTS_PAGE_SIZE) || 10}
onPageSizeChange={(size) => (
LocalStorageHelper.setItem(LOCAL_STORAGE_KEYS.CLIENTS_PAGE_SIZE, size)
)}
minRows={5}
ofText="/"
previousText={t('previous_btn')}
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Settings/LogsConfig/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class LogsConfig extends Component {
interval,
customInterval,
anonymize_client_ip,
ignored: ignored.join('\n'),
ignored: ignored?.join('\n'),
}}
onSubmit={this.handleFormSubmit}
processing={processing}
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Settings/StatsConfig/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class StatsConfig extends Component {
interval,
customInterval,
enabled,
ignored: ignored.join('\n'),
ignored: ignored?.join('\n'),
}}
onSubmit={this.handleFormSubmit}
processing={processing}
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/ui/Card.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}

.dashboard .card-table-overflow--limited {
max-height: 18rem;
max-height: 19rem;
}

.card-actions {
Expand Down
2 changes: 0 additions & 2 deletions client/src/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,4 @@ export const DISABLE_PROTECTION_TIMINGS = {
TOMORROW: 24 * 60 * 60 * 1000,
};

export const LOCAL_STORAGE_THEME_KEY = 'account_theme';

export const LOCAL_TIMEZONE_VALUE = 'Local';
30 changes: 3 additions & 27 deletions client/src/helpers/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import {
STANDARD_WEB_PORT,
SPECIAL_FILTER_ID,
THEMES,
LOCAL_STORAGE_THEME_KEY,
} from './constants';
import { LOCAL_STORAGE_KEYS, LocalStorageHelper } from './localStorageHelper';

/**
* @param time {string} The time to format
Expand Down Expand Up @@ -680,37 +680,13 @@ export const setHtmlLangAttr = (language) => {
window.document.documentElement.lang = language;
};

/**
* Set local storage field
*
* @param {string} key
* @param {string} value
*/

export const setStorageItem = (key, value) => {
if (window.localStorage) {
window.localStorage.setItem(key, value);
}
};

/**
* Get local storage field
*
* @param {string} key
*/

export const getStorageItem = (key) => (window.localStorage
? window.localStorage.getItem(key)
: null);

/**
* Set local storage theme field
*
* @param {string} theme
*/

export const setTheme = (theme) => {
setStorageItem(LOCAL_STORAGE_THEME_KEY, theme);
LocalStorageHelper.setItem(LOCAL_STORAGE_KEYS.THEME, theme);
};

/**
Expand All @@ -719,7 +695,7 @@ export const setTheme = (theme) => {
* @returns {string}
*/

export const getTheme = () => getStorageItem(LOCAL_STORAGE_THEME_KEY) || THEMES.light;
export const getTheme = () => LocalStorageHelper.getItem(LOCAL_STORAGE_KEYS.THEME) || THEMES.light;

/**
* Sets UI theme.
Expand Down
44 changes: 44 additions & 0 deletions client/src/helpers/localStorageHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
export const LOCAL_STORAGE_KEYS = {
THEME: 'account_theme',
BLOCKLIST_PAGE_SIZE: 'blocklist_page_size',
ALLOWLIST_PAGE_SIZE: 'allowlist_page_size',
CLIENTS_PAGE_SIZE: 'clients_page_size',
REWRITES_PAGE_SIZE: 'rewrites_page_size',
AUTO_CLIENTS_PAGE_SIZE: 'auto_clients_page_size',
};

export const LocalStorageHelper = {
setItem(key, value) {
try {
localStorage.setItem(key, JSON.stringify(value));
} catch (error) {
console.error(`Error setting ${key} in local storage: ${error.message}`);
}
},

getItem(key) {
try {
const item = localStorage.getItem(key);
return item ? JSON.parse(item) : null;
} catch (error) {
console.error(`Error getting ${key} from local storage: ${error.message}`);
return null;
}
},

removeItem(key) {
try {
localStorage.removeItem(key);
} catch (error) {
console.error(`Error removing ${key} from local storage: ${error.message}`);
}
},

clear() {
try {
localStorage.clear();
} catch (error) {
console.error(`Error clearing local storage: ${error.message}`);
}
},
};
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/AdguardTeam/AdGuardHome
go 1.20

require (
github.com/AdguardTeam/dnsproxy v0.56.0
github.com/AdguardTeam/dnsproxy v0.56.1
github.com/AdguardTeam/golibs v0.17.1
github.com/AdguardTeam/urlfilter v0.17.0
github.com/NYTimes/gziphandler v1.1.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/AdguardTeam/dnsproxy v0.56.0 h1:kAg88woRTWTgqVEB2i2Uhze8Lv0JF1zTIAGhe0prjKM=
github.com/AdguardTeam/dnsproxy v0.56.0/go.mod h1:fqmehcE3cHFNqKbWQpIjGk7GqBy7ur1v5At499lFjRc=
github.com/AdguardTeam/dnsproxy v0.56.1 h1:QltfyWO7k4mxWERCEYDzkQnKzvZX/zkneWjbuJ0TU6o=
github.com/AdguardTeam/dnsproxy v0.56.1/go.mod h1:fqmehcE3cHFNqKbWQpIjGk7GqBy7ur1v5At499lFjRc=
github.com/AdguardTeam/golibs v0.17.1 h1:j3Ehhld5GI/amcHYG+CF0sJ4OOzAQ06BY3N/iBYJZ1M=
github.com/AdguardTeam/golibs v0.17.1/go.mod h1:DKhCIXHcUYtBhU8ibTLKh1paUL96n5zhQBlx763sj+U=
github.com/AdguardTeam/urlfilter v0.17.0 h1:tUzhtR9wMx704GIP3cibsDQJrixlMHfwoQbYJfPdFow=
Expand Down

0 comments on commit d3267bb

Please sign in to comment.