-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI: Advanced section with pull batch size (#822)
Adds an advanced section which currently has pull batch size as a field. In future this section will have more fields <img width="904" alt="Screenshot 2023-12-14 at 7 09 05 PM" src="https://github.com/PeerDB-io/peerdb/assets/65964360/99725db8-cf57-4e76-bf76-579061fe8c34">
- Loading branch information
1 parent
40feee0
commit 46208f1
Showing
4 changed files
with
131 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
'use client'; | ||
import { RequiredIndicator } from '@/components/RequiredIndicator'; | ||
import { Label } from '@/lib/Label'; | ||
import { RowWithSwitch, RowWithTextField } from '@/lib/Layout'; | ||
import { Switch } from '@/lib/Switch'; | ||
import { TextField } from '@/lib/TextField'; | ||
import { InfoPopover } from '../../../../components/InfoPopover'; | ||
import { MirrorSetting } from '../helpers/common'; | ||
|
||
interface FieldProps { | ||
setting: MirrorSetting; | ||
handleChange: (val: string | boolean, setting: MirrorSetting) => void; | ||
} | ||
|
||
const CDCFields = ({ setting, handleChange }: FieldProps) => { | ||
return setting.type === 'switch' ? ( | ||
<RowWithSwitch | ||
label={<Label>{setting.label}</Label>} | ||
action={ | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<Switch | ||
onCheckedChange={(state: boolean) => handleChange(state, setting)} | ||
/> | ||
{setting.tips && ( | ||
<InfoPopover tips={setting.tips} link={setting.helpfulLink} /> | ||
)} | ||
</div> | ||
} | ||
/> | ||
) : ( | ||
<RowWithTextField | ||
label={ | ||
<Label> | ||
{setting.label} | ||
{RequiredIndicator(setting.required)} | ||
</Label> | ||
} | ||
action={ | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<TextField | ||
variant='simple' | ||
type={setting.type} | ||
defaultValue={setting.default} | ||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => | ||
handleChange(e.target.value, setting) | ||
} | ||
/> | ||
{setting.tips && ( | ||
<InfoPopover tips={setting.tips} link={setting.helpfulLink} /> | ||
)} | ||
</div> | ||
} | ||
/> | ||
); | ||
}; | ||
|
||
export default CDCFields; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters