Skip to content

Commit

Permalink
+ client: remove block button from clients with client_id
Browse files Browse the repository at this point in the history
  • Loading branch information
IldarKamalov committed Jan 26, 2021
1 parent 32991a0 commit 35ff14f
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions client/src/components/Dashboard/Clients.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Card from '../ui/Card';
import Cell from '../ui/Cell';

import { getPercent, sortIp } from '../../helpers/helpers';
import { BLOCK_ACTIONS, STATUS_COLORS } from '../../helpers/constants';
import { BLOCK_ACTIONS, R_CLIENT_ID, STATUS_COLORS } from '../../helpers/constants';
import { toggleClientBlock } from '../../actions/access';
import { renderFormattedClientCell } from '../../helpers/renderFormattedClientCell';
import { getStats } from '../../actions/stats';
Expand All @@ -35,6 +35,10 @@ const CountCell = (row) => {
};

const renderBlockingButton = (ip, disallowed, disallowed_rule) => {
if (R_CLIENT_ID.test(ip)) {
return null;
}

const dispatch = useDispatch();
const { t } = useTranslation();
const processingSet = useSelector((state) => state.access.processingSet);
Expand All @@ -59,17 +63,19 @@ const renderBlockingButton = (ip, disallowed, disallowed_rule) => {
const text = disallowed ? BLOCK_ACTIONS.UNBLOCK : BLOCK_ACTIONS.BLOCK;

const isNotInAllowedList = disallowed && disallowed_rule === '';
return <div className="table__action pl-4">
<button
return (
<div className="table__action pl-4">
<button
type="button"
className={buttonClass}
onClick={isNotInAllowedList ? undefined : onClick}
disabled={isNotInAllowedList || processingSet}
title={t(isNotInAllowedList ? 'client_not_in_allowed_clients' : text)}
>
<Trans>{text}</Trans>
</button>
</div>;
>
<Trans>{text}</Trans>
</button>
</div>
);
};

const ClientCell = (row) => {
Expand Down

0 comments on commit 35ff14f

Please sign in to comment.