Skip to content

Commit 19050ec

Browse files
committed
added refresh button to settings, fixed existing name warnings
1 parent b52ac09 commit 19050ec

File tree

5 files changed

+50
-24
lines changed

5 files changed

+50
-24
lines changed

src/components/habit/form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export const HabitForm: React.FC<P> = ({ value, onChange, onCancel }) => {
8989
value={habit.name}
9090
onChange={(e) => update((h) => (h.name = e.target.value))}
9191
/>
92-
{habitNameSet.has(habit.name) && (
92+
{!loading && habitNameSet.has(habit.name) && (
9393
<div className="flex items-center gap-1 text-xs text-amber-600">
9494
<AlertTriangle size={14} /> Habit already exists!
9595
</div>

src/components/habit/list.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ export const HabitList: React.FC = () => {
5656
</Link>
5757
</>
5858
) : (
59-
<div className="flex items-center justify-center gap-2">
60-
<RefreshButton />
59+
<div className="flex items-center justify-center gap-2 p-2 pb-4">
60+
<RefreshButton disabled={isReordering} />
6161
<Button
6262
variant="ghost"
6363
className="w-fit"

src/components/refresh-button.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ export const RefreshButton: React.FC<React.ComponentProps<typeof Button>> = (pro
1414
const loading = repoIsFetching || collectionIsFetching
1515

1616
return (
17-
<Button variant="ghost" disabled={loading} onClick={() => void refresh()} {...props}>
17+
<Button
18+
variant="ghost"
19+
onClick={() => void refresh()}
20+
{...props}
21+
disabled={loading || props.disabled}
22+
>
1823
<RefreshCw className={cn({ "animate-spin": loading })} />
1924
Refresh
2025
</Button>

src/components/settings-page.tsx

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ import { LogoutButton } from "@/components/auth/logout-button"
33
import { useStoredDisplayOptions } from "@/lib/displayOptions"
44
import { useQueryClient } from "@tanstack/react-query"
55
import { Link } from "@tanstack/react-router"
6-
import { ExternalLink, Monitor, Moon, Sun, Trash2 } from "lucide-react"
6+
import { Monitor, Moon, Sun, Tags, Trash2 } from "lucide-react"
77
import React from "react"
88
import { toast } from "sonner"
99

1010
import { DisplayOptionsForm } from "./display-options-form"
11+
import { GitHubIcon } from "./github-icon"
1112
import { PageHeader } from "./page-header"
13+
import { RefreshButton } from "./refresh-button"
14+
import { useRepoContext } from "./repo/context"
1215
import { RepoSelector } from "./repo/selector"
1316
import { Button } from "./ui/button"
1417
import { Label } from "./ui/label"
@@ -20,6 +23,9 @@ export const SettingsPage: React.FC = () => {
2023
const { theme, setTheme, saturation, setSaturation } = React.useContext(ThemeContext)
2124
const [displayOptions, setDisplayOptions] = useStoredDisplayOptions()
2225
const queryClient = useQueryClient()
26+
const repo = useRepoContext()
27+
28+
const repoURL = `https://github.com/${repo?.full_name}`
2329

2430
const clearCache = () => {
2531
queryClient.removeQueries()
@@ -30,22 +36,22 @@ export const SettingsPage: React.FC = () => {
3036
<>
3137
<PageHeader title="Settings" />
3238

33-
<div className="flex flex-col gap-5 p-5 pt-0 w-full max-w-216">
39+
<div className="flex flex-col gap-7 p-5 pt-0 w-full max-w-216">
3440
<div className="flex flex-col gap-3">
35-
<Label>Account</Label>
41+
<Label className="text-muted-foreground">Account</Label>
3642
<div className="flex items-center gap-2">
3743
<AccountBadge />
3844
<LogoutButton variant="destructive" className="w-fit" />
3945
</div>
4046
</div>
4147

4248
<div className="flex flex-col gap-3">
43-
<Label>Repository</Label>
49+
<Label className="text-muted-foreground">Repository</Label>
4450
<RepoSelector />
4551
</div>
4652

4753
<div className="flex flex-col gap-3">
48-
<Label>Theme</Label>
54+
<Label className="text-muted-foreground">Theme</Label>
4955
<div className="flex items-center gap-2">
5056
<Button
5157
variant="outline"
@@ -77,7 +83,7 @@ export const SettingsPage: React.FC = () => {
7783
</div>
7884

7985
<div className="flex flex-col gap-3">
80-
<Label>Color saturation</Label>
86+
<Label className="text-muted-foreground">Color saturation</Label>
8187
<Slider
8288
value={[saturation]}
8389
onValueChange={(v) => setSaturation(v[0])}
@@ -89,23 +95,38 @@ export const SettingsPage: React.FC = () => {
8995
</div>
9096

9197
<div className="flex flex-col gap-3">
92-
<Label>Tags</Label>
93-
<Link to="/tags">
94-
<Button variant="outline" className="w-fit">
95-
<ExternalLink />
96-
Manage
97-
</Button>
98-
</Link>
98+
<Label className="text-muted-foreground">Data</Label>
99+
<div className="flex items-center gap-2">
100+
<a href={repoURL} target="_blank">
101+
<Button variant="outline">
102+
<GitHubIcon inverted className="w-4 h-4" />
103+
Root
104+
</Button>
105+
</a>
106+
107+
<Link to="/tags">
108+
<Button variant="outline" className="w-fit">
109+
<Tags />
110+
Tags
111+
</Button>
112+
</Link>
113+
</div>
99114
</div>
100115

101-
<DisplayOptionsForm options={displayOptions} onChange={setDisplayOptions} />
116+
<div className="flex flex-col gap-3">
117+
<Label className="text-muted-foreground">Display options</Label>
118+
<DisplayOptionsForm options={displayOptions} onChange={setDisplayOptions} />
119+
</div>
102120

103121
<div className="flex flex-col gap-3">
104-
<Label>Cache</Label>
105-
<Button variant="outline" className="w-fit" onClick={clearCache}>
106-
<Trash2 />
107-
Clear cache
108-
</Button>
122+
<Label className="text-muted-foreground">Cache</Label>
123+
<div className="flex items-center gap-2">
124+
<Button variant="outline" className="w-fit" onClick={clearCache}>
125+
<Trash2 />
126+
Clear cache
127+
</Button>
128+
<RefreshButton variant="outline" />
129+
</div>
109130
</div>
110131
</div>
111132
</>

src/components/tag/form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export const TagForm: React.FC<P> = ({ value, onChange, onCancel }) => {
7777
value={tag.name}
7878
onChange={(e) => update((t) => (t.name = e.target.value))}
7979
/>
80-
{tagSet.has(tag.name) && (
80+
{!loading && tagSet.has(tag.name) && (
8181
<div className="flex items-center gap-1 text-xs text-amber-600">
8282
<AlertTriangle size={14} /> Tag already exists!
8383
</div>

0 commit comments

Comments
 (0)