Skip to content

Commit 15a74ab

Browse files
remove shared permission row and have it inline
1 parent 141550c commit 15a74ab

File tree

2 files changed

+78
-146
lines changed

2 files changed

+78
-146
lines changed

apps/desktop/src/components/settings/general/permissions.tsx

Lines changed: 78 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,76 @@
1+
import type { PermissionStatus } from "@hypr/plugin-permissions";
2+
import { Button } from "@hypr/ui/components/ui/button";
3+
import { Spinner } from "@hypr/ui/components/ui/spinner";
4+
import { cn } from "@hypr/utils";
5+
6+
import { AlertCircleIcon, Check } from "lucide-react";
7+
18
import { usePermissions } from "../../../hooks/use-permissions";
2-
import { PermissionRow } from "../../shared/permission-row";
9+
10+
function PermissionRow({
11+
title,
12+
description,
13+
status,
14+
isPending,
15+
onAction,
16+
}: {
17+
title: string;
18+
description: string;
19+
status: PermissionStatus | undefined;
20+
isPending: boolean;
21+
onAction: () => void;
22+
}) {
23+
const isAuthorized = status === "authorized";
24+
const isDenied = status === "denied";
25+
26+
const displayMessage = isAuthorized
27+
? "Good to go :)"
28+
: isDenied
29+
? "You should toggle in the Settings manually"
30+
: description;
31+
32+
const buttonText = isAuthorized
33+
? "Access Granted"
34+
: isDenied
35+
? "Open Settings"
36+
: "Enable";
37+
38+
return (
39+
<div className="flex items-start justify-between gap-4">
40+
<div className="flex-1">
41+
<div className={cn("flex items-center gap-2 mb-1", !isAuthorized && "text-red-500")}>
42+
{!isAuthorized && <AlertCircleIcon className="size-4" />}
43+
<h3 className="text-sm font-medium">
44+
{title}
45+
</h3>
46+
</div>
47+
<p className="text-xs text-neutral-600">
48+
{displayMessage}
49+
</p>
50+
</div>
51+
<Button
52+
variant={isAuthorized ? "outline" : "default"}
53+
className="w-40 text-xs shadow-none"
54+
disabled={isAuthorized || isPending}
55+
onClick={onAction}
56+
>
57+
{isPending
58+
? (
59+
<>
60+
<Spinner className="mr-1" />
61+
Requesting...
62+
</>
63+
)
64+
: (
65+
<>
66+
{isAuthorized ? <Check size={16} /> : null}
67+
{buttonText}
68+
</>
69+
)}
70+
</Button>
71+
</div>
72+
);
73+
}
374

475
export function Permissions() {
576
const {
@@ -19,25 +90,25 @@ export function Permissions() {
1990
<h2 className="font-semibold mb-4">Permissions</h2>
2091
<div className="space-y-4">
2192
<PermissionRow
22-
title="Microphone access"
93+
title="Microphone"
94+
description="Required to record your voice during meetings and calls"
2395
status={micPermissionStatus.data}
2496
isPending={micPermission.isPending}
2597
onAction={handleMicPermissionAction}
26-
variant="compact"
2798
/>
2899
<PermissionRow
29-
title="System audio access"
100+
title="System audio"
101+
description="Required to capture other participants' voices in meetings"
30102
status={systemAudioPermissionStatus.data}
31103
isPending={systemAudioPermission.isPending}
32104
onAction={handleSystemAudioPermissionAction}
33-
variant="compact"
34105
/>
35106
<PermissionRow
36-
title="Accessibility access"
107+
title="Accessibility"
108+
description="Required to detect meeting apps and sync mute status"
37109
status={accessibilityPermissionStatus.data}
38110
isPending={accessibilityPermission.isPending}
39111
onAction={handleAccessibilityPermissionAction}
40-
variant="compact"
41112
/>
42113
</div>
43114
</div>

apps/desktop/src/components/shared/permission-row.tsx

Lines changed: 0 additions & 139 deletions
This file was deleted.

0 commit comments

Comments
 (0)