Skip to content

Commit 1dd1680

Browse files
committed
Improve exclusive mode permissions and enhance switch visibility
- Add 'All Users' option to exclusive mode write access for more flexibility - Create custom styled switches with better visibility in off state - Use dark gray background (#434343) for unchecked switches instead of faded appearance - Add proper styling for loading and disabled switch states - Improve user experience in both table view and modal forms - Maintain excellent appearance of checked/on state while making off state clearly visible
1 parent 32ed6c8 commit 1dd1680

3 files changed

Lines changed: 68 additions & 8 deletions

File tree

src/components/allowed-users/components/NPubManagement/NPubManagement.styles.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import styled from 'styled-components';
2+
import { Switch } from 'antd';
23
import { media } from '@app/styles/themes/constants';
34

45
export const Container = styled.div`
@@ -62,4 +63,58 @@ export const BulkImportContainer = styled.div`
6263
}
6364
}
6465
}
66+
`;
67+
68+
export const StyledSwitch = styled(Switch)`
69+
&.ant-switch {
70+
/* When switch is OFF (unchecked) */
71+
background-color: #434343 !important;
72+
border: 1px solid #666 !important;
73+
74+
/* When switch is ON (checked) */
75+
&.ant-switch-checked {
76+
background-color: var(--primary-color) !important;
77+
border: 1px solid var(--primary-color) !important;
78+
}
79+
80+
/* Handle styling */
81+
.ant-switch-handle {
82+
background-color: #fff !important;
83+
border: 1px solid #d9d9d9;
84+
85+
&::before {
86+
background-color: #fff !important;
87+
}
88+
}
89+
90+
/* Disabled state */
91+
&.ant-switch-disabled {
92+
background-color: #2a2a2a !important;
93+
border: 1px solid #444 !important;
94+
opacity: 0.6;
95+
96+
.ant-switch-handle {
97+
background-color: #666 !important;
98+
}
99+
}
100+
101+
/* Loading state */
102+
&.ant-switch-loading {
103+
background-color: #434343 !important;
104+
border: 1px solid #666 !important;
105+
106+
&.ant-switch-checked {
107+
background-color: var(--primary-color) !important;
108+
opacity: 0.7;
109+
}
110+
}
111+
}
112+
`;
113+
114+
export const PermissionLabel = styled.div`
115+
display: flex;
116+
align-items: center;
117+
gap: 8px;
118+
color: var(--text-main-color);
119+
font-size: 14px;
65120
`;

src/components/allowed-users/components/NPubManagement/NPubManagement.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useEffect } from 'react';
2-
import { Button, Input, Table, Space, Modal, Form, Select, message, Popconfirm, Switch } from 'antd';
2+
import { Button, Input, Table, Space, Modal, Form, Select, message, Popconfirm } from 'antd';
33
import { PlusOutlined, UploadOutlined, DeleteOutlined, DownloadOutlined } from '@ant-design/icons';
44
import { useAllowedUsersNpubs, useAllowedUsersValidation } from '@app/hooks/useAllowedUsers';
55
import { AllowedUsersSettings, AllowedUsersMode } from '@app/types/allowedUsers.types';
@@ -220,9 +220,9 @@ export const NPubManagement: React.FC<NPubManagementProps> = ({
220220
key: 'readAccess',
221221
align: 'center' as const,
222222
render: (_: any, record: UnifiedUser) => (
223-
<Switch
223+
<S.StyledSwitch
224224
checked={record.readAccess}
225-
onChange={(checked) => handleToggleAccess(record.npub, 'read', checked)}
225+
onChange={(checked: boolean) => handleToggleAccess(record.npub, 'read', checked)}
226226
loading={readNpubs.loading}
227227
size="small"
228228
/>
@@ -233,9 +233,9 @@ export const NPubManagement: React.FC<NPubManagementProps> = ({
233233
key: 'writeAccess',
234234
align: 'center' as const,
235235
render: (_: any, record: UnifiedUser) => (
236-
<Switch
236+
<S.StyledSwitch
237237
checked={record.writeAccess}
238-
onChange={(checked) => handleToggleAccess(record.npub, 'write', checked)}
238+
onChange={(checked: boolean) => handleToggleAccess(record.npub, 'write', checked)}
239239
loading={writeNpubs.loading}
240240
size="small"
241241
/>
@@ -346,10 +346,14 @@ export const NPubManagement: React.FC<NPubManagementProps> = ({
346346
>
347347
<Space direction="vertical">
348348
<Form.Item name="readAccess" valuePropName="checked" style={{ marginBottom: 8 }}>
349-
<Switch size="small" /> Read Access
349+
<S.PermissionLabel>
350+
<S.StyledSwitch size="small" /> Read Access
351+
</S.PermissionLabel>
350352
</Form.Item>
351353
<Form.Item name="writeAccess" valuePropName="checked" style={{ marginBottom: 0 }}>
352-
<Switch size="small" /> Write Access
354+
<S.PermissionLabel>
355+
<S.StyledSwitch size="small" /> Write Access
356+
</S.PermissionLabel>
353357
</Form.Item>
354358
</Space>
355359
</Form.Item>

src/types/allowedUsers.types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ export const MODE_CONFIGURATIONS: Record<AllowedUsersMode, ModeOptions> = {
8585
{ value: 'all_users', label: 'All Users' }
8686
],
8787
writeOptions: [
88-
{ value: 'allowed_users', label: 'Allowed Users' }
88+
{ value: 'allowed_users', label: 'Allowed Users' },
89+
{ value: 'all_users', label: 'All Users' }
8990
],
9091
allowsFreeTiers: true,
9192
requiresNpubManagement: true

0 commit comments

Comments
 (0)