Skip to content

Commit

Permalink
refactor(frontend): run prettify on all files
Browse files Browse the repository at this point in the history
  • Loading branch information
anfragment committed Dec 1, 2023
1 parent 1464bc7 commit d639090
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 104 deletions.
32 changes: 5 additions & 27 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import {
Button,
ButtonGroup,
Icon,
IconSize,
FocusStyleManager,
NonIdealState,
Alert,
} from '@blueprintjs/core';
import { Button, ButtonGroup, Icon, IconSize, FocusStyleManager, NonIdealState, Alert } from '@blueprintjs/core';
import { useState, useEffect } from 'react';

import { StartProxy, StopProxy } from '../wailsjs/go/main/App';
Expand All @@ -23,9 +15,7 @@ function App() {
}, []);

const [proxyState, setProxyState] = useState<'on' | 'off' | 'loading'>('off');
const [activeTab, setActiveTab] = useState<
'home' | 'filterLists' | 'settings'
>('home');
const [activeTab, setActiveTab] = useState<'home' | 'filterLists' | 'settings'>('home');

const start = async () => {
setProxyState('loading');
Expand Down Expand Up @@ -55,25 +45,13 @@ function App() {
</h1>
</div>
<ButtonGroup fill minimal className="tabs">
<Button
icon="circle"
active={activeTab === 'home'}
onClick={() => setActiveTab('home')}
>
<Button icon="circle" active={activeTab === 'home'} onClick={() => setActiveTab('home')}>
Home
</Button>
<Button
icon="filter"
active={activeTab === 'filterLists'}
onClick={() => setActiveTab('filterLists')}
>
<Button icon="filter" active={activeTab === 'filterLists'} onClick={() => setActiveTab('filterLists')}>
Filter lists
</Button>
<Button
icon="settings"
active={activeTab === 'settings'}
onClick={() => setActiveTab('settings')}
>
<Button icon="settings" active={activeTab === 'settings'} onClick={() => setActiveTab('settings')}>
Settings
</Button>
</ButtonGroup>
Expand Down
15 changes: 2 additions & 13 deletions frontend/src/FilterLists/CreateFilterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,11 @@ export function CreateFilterList({ onAdd }: { onAdd: () => void }) {
return (
<div className="filter-lists__create-filter-list">
<FormGroup label="URL" labelFor="url" labelInfo="(required)">
<InputGroup
id="url"
placeholder="https://example.com/filter-list.txt"
required
type="url"
inputRef={urlRef}
/>
<InputGroup id="url" placeholder="https://example.com/filter-list.txt" required type="url" inputRef={urlRef} />
</FormGroup>

<FormGroup label="Name" labelFor="name" labelInfo="(optional)">
<InputGroup
id="name"
placeholder="Example filter list"
type="text"
inputRef={nameRef}
/>
<InputGroup id="name" placeholder="Example filter list" type="text" inputRef={nameRef} />
</FormGroup>

<Button
Expand Down
52 changes: 9 additions & 43 deletions frontend/src/FilterLists/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
import {
Spinner,
SpinnerSize,
Switch,
Button,
MenuItem,
} from '@blueprintjs/core';
import { Spinner, SpinnerSize, Switch, Button, MenuItem } from '@blueprintjs/core';
import { Select } from '@blueprintjs/select';
import { useState, useEffect } from 'react';

import {
GetFilterLists,
RemoveFilterList,
ToggleFilterList,
} from '../../wailsjs/go/config/config';
import { GetFilterLists, RemoveFilterList, ToggleFilterList } from '../../wailsjs/go/config/config';
// eslint-disable-next-line import/order
import { type config } from '../../wailsjs/go/models';

Expand Down Expand Up @@ -56,20 +46,8 @@ export function FilterLists() {
<>
{item[0].toUpperCase() + item.slice(1)}
<span className="bp5-text-muted filter-lists__select-count">
(
{
state.filterLists.filter(
(filterList) =>
filterList.type === item && filterList.enabled,
).length
}
/
{
state.filterLists.filter(
(filterList) => filterList.type === item,
).length
}
)
({state.filterLists.filter((filterList) => filterList.type === item && filterList.enabled).length}/
{state.filterLists.filter((filterList) => filterList.type === item).length})
</span>
</>
}
Expand All @@ -85,15 +63,10 @@ export function FilterLists() {
popoverProps={{ minimal: true, matchTargetWidth: true }}
filterable={false}
>
<Button
text={type[0].toUpperCase() + type.slice(1)}
rightIcon="caret-down"
/>
<Button text={type[0].toUpperCase() + type.slice(1)} rightIcon="caret-down" />
</Select>

{state.loading && (
<Spinner size={SpinnerSize.SMALL} className="filter-lists__spinner" />
)}
{state.loading && <Spinner size={SpinnerSize.SMALL} className="filter-lists__spinner" />}

{state.filterLists
.filter((filterList) => filterList.type === type)
Expand All @@ -106,9 +79,7 @@ export function FilterLists() {
/>
))}

{type === FilterListType.CUSTOM && (
<CreateFilterList onAdd={fetchLists} />
)}
{type === FilterListType.CUSTOM && <CreateFilterList onAdd={fetchLists} />}
</>
);
}
Expand All @@ -133,10 +104,7 @@ function ListItem({
disabled={switchLoading}
onChange={async (e) => {
setSwitchLoading(true);
const err = await ToggleFilterList(
filterList.url,
e.currentTarget.checked,
);
const err = await ToggleFilterList(filterList.url, e.currentTarget.checked);
if (err) {
AppToaster.show({
message: `Failed to toggle filter list: ${err}`,
Expand All @@ -150,9 +118,7 @@ function ListItem({
className="filter-lists__list-switch"
/>
</div>
<div className="bp5-text-muted filter-lists__list-url">
{filterList.url}
</div>
<div className="bp5-text-muted filter-lists__list-url">{filterList.url}</div>

{showDelete && (
<Button
Expand Down
15 changes: 3 additions & 12 deletions frontend/src/RequestLog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ export function RequestLog() {
return (
<div className="request-log">
{logs.length === 0 ? (
<p className="request-log__empty">
Start browsing to see blocked requests.
</p>
<p className="request-log__empty">Start browsing to see blocked requests.</p>
) : (
<CardList compact>
{logs.map((log) => (
Expand All @@ -64,18 +62,11 @@ function RequestLogCard({ log }: { log: Log }) {

return (
<>
<Card
key={log.id}
className="request-log__card"
interactive
onClick={() => setIsOpen(!isOpen)}
>
<Card key={log.id} className="request-log__card" interactive onClick={() => setIsOpen(!isOpen)}>
<Tag minimal intent="danger">
{hostname}
</Tag>
<div className="bp5-text-muted">
{log.createdAt.toLocaleTimeString([], { timeStyle: 'short' })}
</div>
<div className="bp5-text-muted">{log.createdAt.toLocaleTimeString([], { timeStyle: 'short' })}</div>
</Card>

<Collapse isOpen={isOpen}>
Expand Down
14 changes: 5 additions & 9 deletions frontend/src/SettingsManager/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { NumericInput, FormGroup, Tag } from '@blueprintjs/core';
import { useEffect, useState } from 'react';

import { GetPort, SetPort } from '../../wailsjs/go/config/config';

import './index.css';
import { AppToaster } from '../common/toaster';

Expand All @@ -28,21 +27,18 @@ export function SettingsManager() {
return (
<div className="settings-manager">
<div className="settings-manager__section">
<Tag
large
intent="warning"
fill
className="settings-manager__section-header"
>
<Tag large intent="warning" fill className="settings-manager__section-header">
Advanced
</Tag>

<div className="settings-manager__section-body">
<FormGroup
label="Port"
labelFor="port"
helperText={`The port the proxy server will listen on (0 for random).
Be careful when using a port below 1024 as it may require elevated privileges.`}
helperText={`
The port the proxy server will listen on (0 for random).
Be careful when using a port below 1024 as it may require elevated privileges.
`}
>
<NumericInput
id="port"
Expand Down

0 comments on commit d639090

Please sign in to comment.