Skip to content

Commit

Permalink
Revert "ADG-7473 get table page size from local storage"
Browse files Browse the repository at this point in the history
This reverts commit b6bf48a.
  • Loading branch information
IldarKamalov committed Oct 9, 2023
1 parent 960f3a1 commit 8302506
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 70 deletions.
4 changes: 1 addition & 3 deletions client/src/components/Dashboard/Clients.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { BLOCK_ACTIONS, STATUS_COLORS } from '../../helpers/constants';
import { toggleClientBlock } from '../../actions/access';
import { renderFormattedClientCell } from '../../helpers/renderFormattedClientCell';
import { getStats } from '../../actions/stats';
import { LocalStorageHelper, LOCAL_STORAGE_KEYS } from '../../helpers/localStorageHelper';

const getClientsPercentColor = (percent) => {
if (percent > 50) {
Expand Down Expand Up @@ -136,8 +135,7 @@ const Clients = ({
showPagination={false}
noDataText={t('no_clients_found')}
minRows={6}
defaultPageSize={LocalStorageHelper.getItem(LOCAL_STORAGE_KEYS.CLIENTS_PAGE_SIZE) || 100}
onPageSizeChange={(size) => LocalStorageHelper.setItem(LOCAL_STORAGE_KEYS.CLIENTS_PAGE_SIZE, size)}
defaultPageSize={100}
className="-highlight card-table-overflow--limited clients__table"
getTrProps={(_state, rowInfo) => {
if (!rowInfo) {
Expand Down
4 changes: 1 addition & 3 deletions client/src/components/Filters/Rewrites/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ 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 @@ -86,8 +85,7 @@ class Table extends Component {
loading={processing || processingAdd || processingDelete}
className="-striped -highlight card-table-overflow"
showPagination
defaultPageSize={LocalStorageHelper.getItem(LOCAL_STORAGE_KEYS.REWRITES_PAGE_SIZE) || 10}
onPageSizeChange={(size) => LocalStorageHelper.setItem(LOCAL_STORAGE_KEYS.REWRITES_PAGE_SIZE, size)}
defaultPageSize={10}
minRows={5}
ofText="/"
previousText={t('previous_btn')}
Expand Down
8 changes: 1 addition & 7 deletions client/src/components/Filters/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ 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 @@ -127,17 +126,12 @@ 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={LocalStorageHelper.getItem(localStorageKey) || 10}
onPageSizeChange={(size) => LocalStorageHelper.setItem(localStorageKey, size)}
defaultPageSize={10}
loading={loading}
minRows={6}
ofText="/"
Expand Down
6 changes: 1 addition & 5 deletions client/src/components/Settings/Clients/AutoClients.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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 @@ -86,10 +85,7 @@ class AutoClients extends Component {
]}
className="-striped -highlight card-table-overflow"
showPagination
defaultPageSize={LocalStorageHelper.getItem(LOCAL_STORAGE_KEYS.AUTO_CLIENTS_PAGE_SIZE) || 10}
onPageSizeChange={(size) => (
LocalStorageHelper.setItem(LOCAL_STORAGE_KEYS.AUTO_CLIENTS_PAGE_SIZE, size)
)}
defaultPageSize={10}
minRows={5}
ofText="/"
previousText={t('previous_btn')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ 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 @@ -343,10 +342,7 @@ const ClientsTable = ({
]}
className="-striped -highlight card-table-overflow"
showPagination
defaultPageSize={LocalStorageHelper.getItem(LOCAL_STORAGE_KEYS.CLIENTS_PAGE_SIZE) || 10}
onPageSizeChange={(size) => (
LocalStorageHelper.setItem(LOCAL_STORAGE_KEYS.CLIENTS_PAGE_SIZE, size)
)}
defaultPageSize={10}
minRows={5}
ofText="/"
previousText={t('previous_btn')}
Expand Down
2 changes: 2 additions & 0 deletions client/src/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,4 +553,6 @@ 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: 27 additions & 3 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,13 +680,37 @@ 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) => {
LocalStorageHelper.setItem(LOCAL_STORAGE_KEYS.THEME, theme);
setStorageItem(LOCAL_STORAGE_THEME_KEY, theme);
};

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

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

/**
* Sets UI theme.
Expand Down
44 changes: 0 additions & 44 deletions client/src/helpers/localStorageHelper.js

This file was deleted.

0 comments on commit 8302506

Please sign in to comment.