-
-
Access Control
-
- Control access to your relay and manage flagged pubkeys
-
+
+
+
+
+
+
Access Control
+
+ Control access to your relay and manage flagged pubkeys
+
+
+
}
+ onClick={handleRefresh}
+ loading={loading || statsLoading}
+ >
+ Refresh
+
- }
- onClick={handleRefresh}
- loading={loading || statsLoading}
- >
- Refresh
-
-
-
- {activeView === 'blocked' && (
-
- )}
-
-
- setActiveView('blocked')}
- >
- Blocked Access
-
- setActiveView('flagged')}
- >
- Flagged Access
-
-
-
- {activeView === 'blocked' ? (
-
- ) : (
-
- )}
-
-
+
+ {activeView === 'blocked' && (
+
+ )}
+
+
+ setActiveView('blocked')}
+ >
+ Blocked Access
+
+ setActiveView('flagged')}
+ >
+ Flagged Access
+
+
+
+ {activeView === 'blocked' ? (
+
+ ) : (
+
+ )}
+
+
+
);
};
diff --git a/src/components/blocked-pubkeys/components/BlockPubkeyForm.tsx b/src/components/blocked-pubkeys/components/BlockPubkeyForm.tsx
index d54c1fff..c8f91ee4 100644
--- a/src/components/blocked-pubkeys/components/BlockPubkeyForm.tsx
+++ b/src/components/blocked-pubkeys/components/BlockPubkeyForm.tsx
@@ -1,11 +1,29 @@
import React, { useState } from 'react';
import { Form, Input, Button, Card } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
+import styled from 'styled-components';
interface BlockPubkeyFormProps {
onSubmit: (pubkey: string, reason?: string) => Promise
;
disabled: boolean;
}
+const CardRoot = styled(Card)`
+ border-color: var(--border-base-color) !important;
+ border-width: 1px;
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
+ background-color: var(--secondary-background-color) !important;
+
+ & .ant-card-head {
+ border-bottom-color: var(--border-base-color) !important;
+ }
+}
+`;
+const TextArea = styled(Input.TextArea)`
+ background-color: var(--layout-sider-bg-color) !important;
+`
+const InputArea = styled(Input)`
+ background-color: var(--layout-sider-bg-color) !important;
+`;
export const BlockPubkeyForm: React.FC = ({
onSubmit,
@@ -34,9 +52,10 @@ export const BlockPubkeyForm: React.FC = ({
}
return Promise.resolve();
};
+
return (
-
+
-
@@ -72,6 +91,6 @@ export const BlockPubkeyForm: React.FC = ({
-
+
);
};
diff --git a/src/components/blocked-pubkeys/components/BlockedPubkeysTable.tsx b/src/components/blocked-pubkeys/components/BlockedPubkeysTable.tsx
index e2f24b04..86fba54c 100644
--- a/src/components/blocked-pubkeys/components/BlockedPubkeysTable.tsx
+++ b/src/components/blocked-pubkeys/components/BlockedPubkeysTable.tsx
@@ -127,7 +127,7 @@ export const BlockedPubkeysTable: React.FC = ({
return (
<>
- setSearchText(e.target.value)}
@@ -136,7 +136,7 @@ export const BlockedPubkeysTable: React.FC = ({
/>
- = ({
showSizeChanger: true,
showTotal: (total) => `Total: ${total} blocked pubkeys`,
}}
- locale={{ emptyText: 'No blocked pubkeys' }}
+ locale={{ emptyText: No blocked pubkeys }}
/>
= ({
/>
- = ({
showSizeChanger: true,
showTotal: (total) => `Total: ${total} flagged pubkeys`,
}}
- locale={{ emptyText: statsLoading ? 'Loading...' : 'No flagged pubkeys found' }}
+ locale={{ emptyText: statsLoading ?Loading... : No flagged pubkeys found }}
/>
{/* Block Confirmation Modal */}
diff --git a/src/styles/themes/dark/darkTheme.ts b/src/styles/themes/dark/darkTheme.ts
index fe905825..d7d7dde8 100644
--- a/src/styles/themes/dark/darkTheme.ts
+++ b/src/styles/themes/dark/darkTheme.ts
@@ -66,7 +66,7 @@ export const darkColorsTheme: ITheme = {
siderBackground: '#121430',
spinnerBase: '#339CFD',
scroll: '#797C9A',
- border: '#ffffff',
+ border: '#a9a9a9',// changed to a grayer color
borderNft: '#797C9A',
textMain: '#ffffff',
textLight: '#9A9B9F',
@@ -91,7 +91,7 @@ export const darkColorsTheme: ITheme = {
notificationWarning: '#FFF4E7',
notificationError: '#FFE2E2',
heading: BASE_COLORS.white,
- borderBase: '#a9a9a9',
+ borderBase: '#c7c6ca78',
disable: '#7e7e7e',
disabledBg: '#1c2137',
layoutBodyBg: '#1e2142',
From 523be8d74026afc3c05af7a5523d51dfa3f65433 Mon Sep 17 00:00:00 2001
From: TONE-E <90010906+AnthonyMarin@users.noreply.github.com>
Date: Tue, 10 Jun 2025 17:41:19 -0700
Subject: [PATCH 03/10] add icon to card
---
src/components/blocked-pubkeys/BlockedPubkeys.tsx | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/components/blocked-pubkeys/BlockedPubkeys.tsx b/src/components/blocked-pubkeys/BlockedPubkeys.tsx
index 226afd80..9b2fc3a1 100644
--- a/src/components/blocked-pubkeys/BlockedPubkeys.tsx
+++ b/src/components/blocked-pubkeys/BlockedPubkeys.tsx
@@ -7,6 +7,7 @@ import { BlockedPubkeysTable } from './components/BlockedPubkeysTable';
import { FlaggedPubkeysTable } from './components/FlaggedPubkeysTable';
import { BlockPubkeyForm } from './components/BlockPubkeyForm';
import { useModerationStats } from '@app/hooks/useModerationStats';
+import { LockFilled } from '@ant-design/icons';
import * as S from './BlockedPubkeys.styles';
const { Title, Text } = Typography;
@@ -35,7 +36,7 @@ export const BlockedPubkeys: React.FC = () => {
-
Access Control
+ Access Control
Control access to your relay and manage flagged pubkeys
From df7cac1b7de4785f3def1549bd73d94335efaa7f Mon Sep 17 00:00:00 2001
From: TONE-E <90010906+AnthonyMarin@users.noreply.github.com>
Date: Tue, 10 Jun 2025 17:41:45 -0700
Subject: [PATCH 04/10] add container to table
---
.../components/FlaggedPubkeysTable.tsx | 26 ++++++++++---------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/src/components/blocked-pubkeys/components/FlaggedPubkeysTable.tsx b/src/components/blocked-pubkeys/components/FlaggedPubkeysTable.tsx
index 670439dd..916b0307 100644
--- a/src/components/blocked-pubkeys/components/FlaggedPubkeysTable.tsx
+++ b/src/components/blocked-pubkeys/components/FlaggedPubkeysTable.tsx
@@ -110,18 +110,20 @@ export const FlaggedPubkeysTable: React.FC = ({
/>
-
`Total: ${total} flagged pubkeys`,
- }}
- locale={{ emptyText: statsLoading ?Loading... : No flagged pubkeys found }}
- />
+
+ `Total: ${total} flagged pubkeys`,
+ }}
+ locale={{ emptyText: statsLoading ?Loading... : No flagged pubkeys found }}
+ />
+
{/* Block Confirmation Modal */}
Date: Tue, 10 Jun 2025 17:54:56 -0700
Subject: [PATCH 05/10] darken light text on light theme
---
src/styles/themes/light/lightTheme.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/styles/themes/light/lightTheme.ts b/src/styles/themes/light/lightTheme.ts
index 245982e4..43490c9a 100644
--- a/src/styles/themes/light/lightTheme.ts
+++ b/src/styles/themes/light/lightTheme.ts
@@ -69,7 +69,7 @@ export const lightColorsTheme: ITheme = {
border: '#cce1f4',
borderNft: '#79819A',
textMain: '#404040',
- textLight: '#9A9B9F',
+ textLight: '#777778',
textSuperLight: '#BEC0C6',
textSecondary: BASE_COLORS.white,
textDark: '#404040',
From aac5356aa76d77b36b2fbc042a4b5a16346cc624 Mon Sep 17 00:00:00 2001
From: TONE-E <90010906+AnthonyMarin@users.noreply.github.com>
Date: Tue, 10 Jun 2025 17:55:17 -0700
Subject: [PATCH 06/10] remove border radius from table
---
.../blocked-pubkeys/BlockedPubkeys.styles.ts | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/components/blocked-pubkeys/BlockedPubkeys.styles.ts b/src/components/blocked-pubkeys/BlockedPubkeys.styles.ts
index f8f153dd..7d187b65 100644
--- a/src/components/blocked-pubkeys/BlockedPubkeys.styles.ts
+++ b/src/components/blocked-pubkeys/BlockedPubkeys.styles.ts
@@ -9,12 +9,7 @@ export const TableRoot = styled(Table)`
& .ant-table-thead .ant-table-cell {
background-color: var(--secondary-background-color);
}
- .ant-table-container table > thead > tr:first-child th:last-child {
- border-top-right-radius: 12px;
- }
- .ant-table-container table > thead > tr:first-child th:first-child {
- border-top-left-radius: 12px;
- }
+
.ant-table-tbody {
background-color: var(--layout-sider-bg-color);
}
@@ -38,7 +33,13 @@ export const BaseColRoot = styled(BaseCol)`
height: 100%;
`;
export const TableContainer = styled.div`
- border-radius: 8px;
+ border-radius: 12px;
+ margin: 0 2px;
+ padding-top: 0.4rem;
+ padding-bottom: 2rem;
+ background-color: var(--secondary-background-color);
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
+ border: 1px solid var(--border-base-color);
`;
export const CardRoot = styled(Card)`
border: none;
@@ -110,4 +111,5 @@ export const EmptyList = styled.div`
align-items: center;
justify-content: center;
color: var(--text-light-color);
+ border-bottom: none;
`;
From 03fae8f33a36fc1ea58773fecf14cdedda59d665 Mon Sep 17 00:00:00 2001
From: TONE-E <90010906+AnthonyMarin@users.noreply.github.com>
Date: Tue, 10 Jun 2025 17:55:37 -0700
Subject: [PATCH 07/10] add container to blocked access table
---
.../components/BlockedPubkeysTable.tsx | 26 ++++++++++---------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/src/components/blocked-pubkeys/components/BlockedPubkeysTable.tsx b/src/components/blocked-pubkeys/components/BlockedPubkeysTable.tsx
index 86fba54c..9d12bb6b 100644
--- a/src/components/blocked-pubkeys/components/BlockedPubkeysTable.tsx
+++ b/src/components/blocked-pubkeys/components/BlockedPubkeysTable.tsx
@@ -136,18 +136,20 @@ export const BlockedPubkeysTable: React.FC = ({
/>
- `Total: ${total} blocked pubkeys`,
- }}
- locale={{ emptyText: No blocked pubkeys }}
- />
+
+ `Total: ${total} blocked pubkeys`,
+ }}
+ locale={{ emptyText: No blocked pubkeys }}
+ />
+
Date: Tue, 10 Jun 2025 18:17:54 -0700
Subject: [PATCH 08/10] add space to right side of form items
---
.../components/BlockPubkeyForm.tsx | 59 ++++++++-----------
1 file changed, 23 insertions(+), 36 deletions(-)
diff --git a/src/components/blocked-pubkeys/components/BlockPubkeyForm.tsx b/src/components/blocked-pubkeys/components/BlockPubkeyForm.tsx
index c8f91ee4..5fcabead 100644
--- a/src/components/blocked-pubkeys/components/BlockPubkeyForm.tsx
+++ b/src/components/blocked-pubkeys/components/BlockPubkeyForm.tsx
@@ -2,6 +2,7 @@ import React, { useState } from 'react';
import { Form, Input, Button, Card } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import styled from 'styled-components';
+import { BREAKPOINTS } from '@app/styles/themes/constants';
interface BlockPubkeyFormProps {
onSubmit: (pubkey: string, reason?: string) => Promise;
@@ -13,22 +14,25 @@ const CardRoot = styled(Card)`
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
background-color: var(--secondary-background-color) !important;
- & .ant-card-head {
- border-bottom-color: var(--border-base-color) !important;
+ & .ant-card-head {
+ border-bottom-color: var(--border-base-color) !important;
}
}
`;
const TextArea = styled(Input.TextArea)`
background-color: var(--layout-sider-bg-color) !important;
-`
+`;
const InputArea = styled(Input)`
background-color: var(--layout-sider-bg-color) !important;
`;
+export const FormItemContainer = styled.div`
+ width: 100%;
+ @media screen and (min-width: ${BREAKPOINTS.md}px) {
+ padding-right: 1.5rem;
+ }
+`;
-export const BlockPubkeyForm: React.FC = ({
- onSubmit,
- disabled,
-}) => {
+export const BlockPubkeyForm: React.FC = ({ onSubmit, disabled }) => {
const [form] = Form.useForm();
const [submitting, setSubmitting] = useState(false);
@@ -52,41 +56,24 @@ export const BlockPubkeyForm: React.FC = ({
}
return Promise.resolve();
};
-
return (
-
-
-
+
-
-
+
+
+
+
+
- }
- loading={submitting}
- disabled={disabled}
- >
+ } loading={submitting} disabled={disabled}>
Block Pubkey
From 3534e12b01a93da782369a776fd9c6d88dc32d75 Mon Sep 17 00:00:00 2001
From: TONE-E <90010906+AnthonyMarin@users.noreply.github.com>
Date: Tue, 10 Jun 2025 18:42:08 -0700
Subject: [PATCH 09/10] create table creator to get rid of type error
---
.../blocked-pubkeys/BlockedPubkeys.styles.ts | 20 +----
.../blocked-pubkeys/BlockedPubkeys.tsx | 83 +++++++++----------
.../components/BlockedPubkeysTable.tsx | 51 +++++-------
.../components/FlaggedPubkeysTable.tsx | 70 +++++++++-------
4 files changed, 103 insertions(+), 121 deletions(-)
diff --git a/src/components/blocked-pubkeys/BlockedPubkeys.styles.ts b/src/components/blocked-pubkeys/BlockedPubkeys.styles.ts
index 7d187b65..3a65298b 100644
--- a/src/components/blocked-pubkeys/BlockedPubkeys.styles.ts
+++ b/src/components/blocked-pubkeys/BlockedPubkeys.styles.ts
@@ -1,26 +1,8 @@
import styled from 'styled-components';
import Card from 'antd/lib/card/Card';
-import Table from 'antd/es/table';
+import { Table, TableProps } from 'antd';
import { Input } from 'antd';
import { BaseCol } from '../common/BaseCol/BaseCol';
-export const TableRoot = styled(Table)`
- border-radius: 12px;
-
- & .ant-table-thead .ant-table-cell {
- background-color: var(--secondary-background-color);
- }
-
- .ant-table-tbody {
- background-color: var(--layout-sider-bg-color);
- }
- .ant-table-placeholder .ant-table-cell {
- background-color: var(--layout-sider-bg-color);
- transition: none;
- }
- .ant-table-placeholder .ant-table-cell:hover {
- background-color: var(--layout-sider-bg-color);
- }
-`;
export const InputRoot = styled(Input)`
background-color: var(--layout-sider-bg-color);
& input {
diff --git a/src/components/blocked-pubkeys/BlockedPubkeys.tsx b/src/components/blocked-pubkeys/BlockedPubkeys.tsx
index 9b2fc3a1..9857726d 100644
--- a/src/components/blocked-pubkeys/BlockedPubkeys.tsx
+++ b/src/components/blocked-pubkeys/BlockedPubkeys.tsx
@@ -1,5 +1,5 @@
-import React, { useState } from 'react';
-import { Space, Typography } from 'antd';
+import React, { useState, FC } from 'react';
+import { Space, Typography, Table, TableProps } from 'antd';
import useBlockedPubkeys from '@app/hooks/useBlockedPubkeys';
import { BaseButton } from '@app/components/common/BaseButton/BaseButton';
import { ReloadOutlined } from '@ant-design/icons';
@@ -8,20 +8,37 @@ import { FlaggedPubkeysTable } from './components/FlaggedPubkeysTable';
import { BlockPubkeyForm } from './components/BlockPubkeyForm';
import { useModerationStats } from '@app/hooks/useModerationStats';
import { LockFilled } from '@ant-design/icons';
+import styled from 'styled-components';
import * as S from './BlockedPubkeys.styles';
const { Title, Text } = Typography;
+export function createStyledTable() {
+ const GenericTable: FC> = (props) => ;
+
+ return styled(GenericTable)`
+ border-radius: 12px;
+
+ & .ant-table-thead .ant-table-cell {
+ background-color: var(--secondary-background-color);
+ }
+
+ .ant-table-tbody {
+ background-color: var(--layout-sider-bg-color);
+ }
+ .ant-table-placeholder .ant-table-cell {
+ background-color: var(--layout-sider-bg-color);
+ transition: none;
+ }
+ .ant-table-placeholder .ant-table-cell:hover {
+ background-color: var(--layout-sider-bg-color);
+ }
+ `;
+}
export const BlockedPubkeys: React.FC = () => {
const [activeView, setActiveView] = useState<'blocked' | 'flagged'>('blocked');
- const {
- blockedPubkeys,
- count,
- loading,
- fetchBlockedPubkeys,
- addBlockedPubkey,
- removeBlockedPubkey,
- } = useBlockedPubkeys();
+ const { blockedPubkeys, count, loading, fetchBlockedPubkeys, addBlockedPubkey, removeBlockedPubkey } =
+ useBlockedPubkeys();
const { fetchStats, loading: statsLoading } = useModerationStats();
// Refresh all data
@@ -31,56 +48,38 @@ export const BlockedPubkeys: React.FC = () => {
};
return (
-
+
-
Access Control
-
+
+ Access Control
+
+
Control access to your relay and manage flagged pubkeys
-
}
- onClick={handleRefresh}
- loading={loading || statsLoading}
- >
+
} onClick={handleRefresh} loading={loading || statsLoading}>
Refresh
-
- {activeView === 'blocked' && (
-
- )}
-
+
+ {activeView === 'blocked' && }
+
- setActiveView('blocked')}
- >
+ setActiveView('blocked')}>
Blocked Access
- setActiveView('flagged')}
- >
+ setActiveView('flagged')}>
Flagged Access
-
+
{activeView === 'blocked' ? (
-
+
) : (
-
+
)}
diff --git a/src/components/blocked-pubkeys/components/BlockedPubkeysTable.tsx b/src/components/blocked-pubkeys/components/BlockedPubkeysTable.tsx
index 9d12bb6b..cd2cfa8a 100644
--- a/src/components/blocked-pubkeys/components/BlockedPubkeysTable.tsx
+++ b/src/components/blocked-pubkeys/components/BlockedPubkeysTable.tsx
@@ -1,28 +1,25 @@
import React, { useState } from 'react';
-import { Table, Input, Button, Modal, Tooltip, Space, Badge, Spin } from 'antd';
-import { DeleteOutlined, CopyOutlined, SearchOutlined, FlagOutlined } from '@ant-design/icons';
+import { Button, Modal, Tooltip, Space, Spin, TableColumnsType, Table } from 'antd';
+import { DeleteOutlined, CopyOutlined, SearchOutlined } from '@ant-design/icons';
import { BlockedPubkey } from '@app/api/blockedPubkeys.api';
import { useModerationStats } from '@app/hooks/useModerationStats';
import * as S from '../BlockedPubkeys.styles';
+import { createStyledTable } from '../BlockedPubkeys';
interface BlockedPubkeysTableProps {
blockedPubkeys: BlockedPubkey[];
loading: boolean;
onUnblock: (pubkey: string) => Promise;
}
-
-export const BlockedPubkeysTable: React.FC = ({
- blockedPubkeys,
- loading,
- onUnblock,
-}) => {
+const TableRoot = createStyledTable();
+export const BlockedPubkeysTable: React.FC = ({ blockedPubkeys, loading, onUnblock }) => {
const [searchText, setSearchText] = useState('');
const [confirmModalVisible, setConfirmModalVisible] = useState(false);
const [currentPubkey, setCurrentPubkey] = useState('');
const { getFlagCountsForPubkeys, loading: statsLoading } = useModerationStats();
-
+
// Get flag counts for all pubkeys in the table
- const pubkeyFlagCounts = getFlagCountsForPubkeys(blockedPubkeys.map(bp => bp.pubkey));
+ const pubkeyFlagCounts = getFlagCountsForPubkeys(blockedPubkeys.map((bp) => bp.pubkey));
// Handle pubkey copy
const handleCopy = (pubkey: string) => {
@@ -43,9 +40,10 @@ export const BlockedPubkeysTable: React.FC = ({
};
// Filter pubkeys based on search
- const filteredPubkeys = blockedPubkeys.filter(item =>
- item.pubkey.toLowerCase().includes(searchText.toLowerCase()) ||
- (item.reason && item.reason.toLowerCase().includes(searchText.toLowerCase()))
+ const filteredPubkeys = blockedPubkeys.filter(
+ (item) =>
+ item.pubkey.toLowerCase().includes(searchText.toLowerCase()) ||
+ (item.reason && item.reason.toLowerCase().includes(searchText.toLowerCase())),
);
// Format pubkey for display (truncate)
@@ -56,7 +54,7 @@ export const BlockedPubkeysTable: React.FC = ({
return `${cleanPubkey.substring(0, 6)}...${cleanPubkey.substring(cleanPubkey.length - 6)}`;
};
- const columns = [
+ const columns: TableColumnsType = [
{
title: 'Pubkey',
dataIndex: 'pubkey',
@@ -65,12 +63,7 @@ export const BlockedPubkeysTable: React.FC = ({
{formatPubkey(pubkey)}
- }
- type="text"
- size="small"
- onClick={() => handleCopy(pubkey)}
- />
+ } type="text" size="small" onClick={() => handleCopy(pubkey)} />
),
@@ -96,7 +89,7 @@ export const BlockedPubkeysTable: React.FC = ({
{statsLoading ? (
) : (
- 10 ? 'var(--error-color)' : count > 5 ? 'var(--warning-color)' : 'var(--primary-color)'}
>
{count}
@@ -105,7 +98,7 @@ export const BlockedPubkeysTable: React.FC = ({
);
},
- sorter: (a: BlockedPubkey, b: BlockedPubkey) =>
+ sorter: (a: BlockedPubkey, b: BlockedPubkey) =>
(pubkeyFlagCounts[a.pubkey] || 0) - (pubkeyFlagCounts[b.pubkey] || 0),
defaultSortOrder: 'descend' as const,
},
@@ -113,11 +106,7 @@ export const BlockedPubkeysTable: React.FC = ({
title: 'Actions',
key: 'actions',
render: (_: any, record: BlockedPubkey) => (
- }
- onClick={() => showConfirmModal(record.pubkey)}
- >
+ } onClick={() => showConfirmModal(record.pubkey)}>
Unblock
),
@@ -130,14 +119,14 @@ export const BlockedPubkeysTable: React.FC = ({
setSearchText(e.target.value)}
+ onChange={(e) => setSearchText(e.target.value)}
prefix={}
allowClear
/>
- = ({
okButtonProps={{ danger: true }}
>
Are you sure you want to unblock this pubkey?
- {currentPubkey.replace('blocked_pubkey:', '')}
+
+ {currentPubkey.replace('blocked_pubkey:', '')}
+
>
);
diff --git a/src/components/blocked-pubkeys/components/FlaggedPubkeysTable.tsx b/src/components/blocked-pubkeys/components/FlaggedPubkeysTable.tsx
index 916b0307..1e6a963c 100644
--- a/src/components/blocked-pubkeys/components/FlaggedPubkeysTable.tsx
+++ b/src/components/blocked-pubkeys/components/FlaggedPubkeysTable.tsx
@@ -1,17 +1,18 @@
import React, { useState } from 'react';
-import { Input, Button, Modal } from 'antd';
+import { Input, Button, Modal, TableColumnsType } from 'antd';
import { StopOutlined, SearchOutlined } from '@ant-design/icons';
-import { useModerationStats, UserStat } from '@app/hooks/useModerationStats';
+import { useModerationStats } from '@app/hooks/useModerationStats';
import { BlockedPubkey } from '@app/api/blockedPubkeys.api';
+import type { UserStat } from '@app/hooks/useModerationStats';
+import { createStyledTable } from '../BlockedPubkeys';
import * as S from '../BlockedPubkeys.styles';
-
interface FlaggedPubkeysTableProps {
blockedPubkeys: BlockedPubkey[]; // Already blocked pubkeys to filter out
onBlock: (pubkey: string, reason?: string) => Promise;
disabled?: boolean;
}
-
+const TableRoot = createStyledTable();
export const FlaggedPubkeysTable: React.FC = ({
blockedPubkeys,
onBlock,
@@ -22,16 +23,19 @@ export const FlaggedPubkeysTable: React.FC = ({
const [currentPubkey, setCurrentPubkey] = useState('');
const [blockReason, setBlockReason] = useState('');
const { stats, loading: statsLoading } = useModerationStats();
-
+
// Filter out already blocked pubkeys and return the rest
- const flaggedUsers = stats?.by_user.filter(
- user => !blockedPubkeys.some(bp =>
- bp.pubkey === user.pubkey ||
- bp.pubkey === `blocked_pubkey:${user.pubkey}` ||
- user.pubkey === `blocked_pubkey:${bp.pubkey}`
- )
- ) || [];
-
+ const flaggedUsers =
+ stats?.by_user.filter(
+ (user) =>
+ !blockedPubkeys.some(
+ (bp) =>
+ bp.pubkey === user.pubkey ||
+ bp.pubkey === `blocked_pubkey:${user.pubkey}` ||
+ user.pubkey === `blocked_pubkey:${bp.pubkey}`,
+ ),
+ ) || [];
+
// Format pubkey for display (truncate)
const formatPubkey = (pubkey: string) => {
// Strip the prefix first for consistent display
@@ -39,26 +43,24 @@ export const FlaggedPubkeysTable: React.FC = ({
if (cleanPubkey.length <= 12) return cleanPubkey;
return `${cleanPubkey.substring(0, 6)}...${cleanPubkey.substring(cleanPubkey.length - 6)}`;
};
-
+
// Filter by search
- const filteredPubkeys = flaggedUsers.filter(
- item => item.pubkey.toLowerCase().includes(searchText.toLowerCase())
- );
-
+ const filteredPubkeys = flaggedUsers.filter((item) => item.pubkey.toLowerCase().includes(searchText.toLowerCase()));
+
// Show block modal with default reason
const showBlockModal = (pubkey: string, flagCount: number) => {
setCurrentPubkey(pubkey);
setBlockReason(`Blocked due to high flag count (${flagCount} flags)`);
setBlockModalVisible(true);
};
-
+
// Handle block confirmation with custom reason
const handleConfirmBlock = async () => {
await onBlock(currentPubkey, blockReason);
setBlockModalVisible(false);
};
-
- const columns = [
+
+ const columns: TableColumnsType = [
{
title: 'Pubkey',
dataIndex: 'pubkey',
@@ -71,7 +73,7 @@ export const FlaggedPubkeysTable: React.FC = ({
key: 'count',
render: (count: number) => (
- 10 ? 'var(--error-color)' : count > 5 ? 'var(--warning-color)' : 'var(--primary-color)'}
>
{count}
@@ -97,21 +99,21 @@ export const FlaggedPubkeysTable: React.FC = ({
),
},
];
-
+
return (
<>
setSearchText(e.target.value)}
+ onChange={(e) => setSearchText(e.target.value)}
prefix={}
allowClear
/>
-
+
- = ({
showSizeChanger: true,
showTotal: (total) => `Total: ${total} flagged pubkeys`,
}}
- locale={{ emptyText: statsLoading ?Loading... : No flagged pubkeys found }}
+ locale={{
+ emptyText: statsLoading ? (
+ Loading...
+ ) : (
+ No flagged pubkeys found
+ ),
+ }}
/>
-
-
+
+
{/* Block Confirmation Modal */}
= ({
okButtonProps={{ danger: true }}
>
Are you sure you want to block this pubkey?
- {formatPubkey(currentPubkey)}
+
+ {formatPubkey(currentPubkey)}
+
Reason:
Date: Wed, 11 Jun 2025 11:49:45 -0700
Subject: [PATCH 10/10] fixed bad component placement
---
src/components/blocked-pubkeys/BlockedPubkeys.tsx | 3 ++-
.../blocked-pubkeys/components/BlockedPubkeysTable.tsx | 2 +-
.../blocked-pubkeys/components/FlaggedPubkeysTable.tsx | 3 ++-
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/components/blocked-pubkeys/BlockedPubkeys.tsx b/src/components/blocked-pubkeys/BlockedPubkeys.tsx
index 9857726d..70ddbb2e 100644
--- a/src/components/blocked-pubkeys/BlockedPubkeys.tsx
+++ b/src/components/blocked-pubkeys/BlockedPubkeys.tsx
@@ -16,7 +16,7 @@ const { Title, Text } = Typography;
export function createStyledTable() {
const GenericTable: FC> = (props) => ;
- return styled(GenericTable)`
+ const StyledTable = styled(GenericTable)`
border-radius: 12px;
& .ant-table-thead .ant-table-cell {
@@ -34,6 +34,7 @@ export function createStyledTable() {
background-color: var(--layout-sider-bg-color);
}
`;
+ return StyledTable;
}
export const BlockedPubkeys: React.FC = () => {
const [activeView, setActiveView] = useState<'blocked' | 'flagged'>('blocked');
diff --git a/src/components/blocked-pubkeys/components/BlockedPubkeysTable.tsx b/src/components/blocked-pubkeys/components/BlockedPubkeysTable.tsx
index cd2cfa8a..71ac5f59 100644
--- a/src/components/blocked-pubkeys/components/BlockedPubkeysTable.tsx
+++ b/src/components/blocked-pubkeys/components/BlockedPubkeysTable.tsx
@@ -11,12 +11,12 @@ interface BlockedPubkeysTableProps {
loading: boolean;
onUnblock: (pubkey: string) => Promise;
}
-const TableRoot = createStyledTable();
export const BlockedPubkeysTable: React.FC = ({ blockedPubkeys, loading, onUnblock }) => {
const [searchText, setSearchText] = useState('');
const [confirmModalVisible, setConfirmModalVisible] = useState(false);
const [currentPubkey, setCurrentPubkey] = useState('');
const { getFlagCountsForPubkeys, loading: statsLoading } = useModerationStats();
+ const TableRoot = createStyledTable();
// Get flag counts for all pubkeys in the table
const pubkeyFlagCounts = getFlagCountsForPubkeys(blockedPubkeys.map((bp) => bp.pubkey));
diff --git a/src/components/blocked-pubkeys/components/FlaggedPubkeysTable.tsx b/src/components/blocked-pubkeys/components/FlaggedPubkeysTable.tsx
index 1e6a963c..26abf076 100644
--- a/src/components/blocked-pubkeys/components/FlaggedPubkeysTable.tsx
+++ b/src/components/blocked-pubkeys/components/FlaggedPubkeysTable.tsx
@@ -12,7 +12,7 @@ interface FlaggedPubkeysTableProps {
onBlock: (pubkey: string, reason?: string) => Promise;
disabled?: boolean;
}
-const TableRoot = createStyledTable();
+
export const FlaggedPubkeysTable: React.FC = ({
blockedPubkeys,
onBlock,
@@ -23,6 +23,7 @@ export const FlaggedPubkeysTable: React.FC = ({
const [currentPubkey, setCurrentPubkey] = useState('');
const [blockReason, setBlockReason] = useState('');
const { stats, loading: statsLoading } = useModerationStats();
+ const TableRoot = createStyledTable();
// Filter out already blocked pubkeys and return the rest
const flaggedUsers =