Skip to content

Commit b9d7638

Browse files
committed
Format and refactor ServerPage
1 parent d2aa44e commit b9d7638

File tree

22 files changed

+129
-99
lines changed

22 files changed

+129
-99
lines changed

tauri-app/src-tauri/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
windows_subsystem = "windows"
55
)]
66

7-
use std::env;
8-
use std::sync::{Arc, Mutex};
97
use serde::{Deserialize, Serialize};
108
use serde_json::Value;
11-
use tauri_plugin_deep_link::DeepLinkExt;
9+
use std::env;
10+
use std::sync::{Arc, Mutex};
1211

1312
mod client;
1413
mod cmd;
@@ -71,7 +70,6 @@ pub fn run() {
7170
encryption::generate_encryption_key,
7271
encryption::encrypt_data,
7372
encryption::decrypt_data,
74-
get_latest_deep_link,
7573
])
7674
.manage(Arc::new(Mutex::new(None::<String>)))
7775
.setup(|_app| {

tauri-app/src/components/common/AuthUnavailable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ export default function AuthUnavailable() {
2121
</div>
2222
</div>
2323
);
24-
}
24+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { Badge } from "@/components/ui/badge";
2+
import { Button } from "@/components/ui/button";
3+
import { openUrl } from "@/utils/urlHelper";
4+
5+
export function ServerMeta({
6+
icon: Icon,
7+
value,
8+
}: {
9+
icon: React.ElementType;
10+
value?: string | number;
11+
}) {
12+
if (!value) return null;
13+
return (
14+
<div className="flex items-center space-x-2">
15+
<Icon size={16} />
16+
<span>{typeof value === "number" ? value.toLocaleString() : value}</span>
17+
</div>
18+
);
19+
}
20+
21+
export function ServerBadge({ isOfficial }: { isOfficial: boolean }) {
22+
return (
23+
<Badge variant={isOfficial ? "secondary" : "outline"} className="uppercase">
24+
{isOfficial ? "Official" : "Community"}
25+
</Badge>
26+
);
27+
}
28+
29+
export function ServerActions({
30+
source,
31+
onGetClick,
32+
}: {
33+
source: string;
34+
onGetClick: () => void;
35+
}) {
36+
return (
37+
<div className="flex gap-2">
38+
<Button variant="outline" onClick={() => openUrl(source)}>
39+
View Source
40+
</Button>
41+
<Button variant="outline" onClick={onGetClick}>
42+
get
43+
</Button>
44+
</div>
45+
);
46+
}

tauri-app/src/constants/clients.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ const clients = [
1111
];
1212

1313
export const availableClients = clients;
14-
export const clientOptions = [...clients, { value: "custom", label: "Custom", free: true }];
14+
export const clientOptions = [
15+
...clients,
16+
{ value: "custom", label: "Custom", free: true },
17+
];

tauri-app/src/hooks/useDeepLink.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { useNavigate } from "react-router-dom";
55
import { toast } from "sonner";
66

77
function debugLog(msg: string) {
8-
if (import.meta.env.VITE_IS_DEV === 'true') {
9-
alert(msg)
8+
if (import.meta.env.VITE_IS_DEV === "true") {
9+
alert(msg);
1010
}
1111
}
1212

@@ -17,7 +17,6 @@ export const useDeepLink = () => {
1717
const navigate = useNavigate();
1818
const [isHandlingDeepLink, setIsHandlingDeepLink] = useState(false);
1919

20-
2120
useEffect(() => {
2221
const urlObj = new URL(window.location.href);
2322
const searchParams = new URLSearchParams(urlObj.search);
@@ -48,7 +47,8 @@ export const useDeepLink = () => {
4847

4948
const code = searchParams.get("code");
5049
if (code && supabase) {
51-
const { data, error } = await supabase.auth.exchangeCodeForSession(code);
50+
const { data, error } =
51+
await supabase.auth.exchangeCodeForSession(code);
5252
if (error) throw error;
5353
if (data.session) {
5454
toast.success("User authenticated successfully");

tauri-app/src/hooks/useGithubReadmeJson.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ export function useGithubReadmeJson() {
1313
* @param githubUrl The GitHub repository URL
1414
* @returns Array of parsed JSON objects (or null for failed parses)
1515
*/
16-
const fetchAllJsonBlocks = async (githubUrl: string): Promise<any[] | null> => {
16+
const fetchAllJsonBlocks = async (
17+
githubUrl: string,
18+
): Promise<any[] | null> => {
1719
setError(null);
1820
setLoading(true);
1921
try {
2022
// Parse GitHub repo url
2123
const match = githubUrl.match(
22-
/github.com\/(?<owner>[^/]+)\/(?<repo>[^/?#]+)(?:[/?#]|$)/
24+
/github.com\/(?<owner>[^/]+)\/(?<repo>[^/?#]+)(?:[/?#]|$)/,
2325
);
2426
if (!match || !match.groups) {
2527
setError("Invalid GitHub repository URL");
@@ -78,4 +80,4 @@ export function useGithubReadmeJson() {
7880
};
7981

8082
return { loading, error, fetchAllJsonBlocks, fetchJson };
81-
}
83+
}

tauri-app/src/hooks/useMcpConfig.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ export function useMcpConfig(
107107
}, [selectedClient, selectedPath, executeMcpOperation]);
108108

109109
const updateConfig = useCallback(
110-
async (key: string, updatedConfig: ConfigType["mcpServers"][string], isDisabled?: boolean) => {
110+
async (
111+
key: string,
112+
updatedConfig: ConfigType["mcpServers"][string],
113+
isDisabled?: boolean,
114+
) => {
111115
try {
112116
if (isDisabled) {
113117
await executeMcpOperation(
@@ -223,11 +227,11 @@ export function useMcpConfig(
223227
try {
224228
setIsLoading(true);
225229
setError(null);
226-
230+
227231
// Get paths for both clients
228232
const fromPath = getClientPath(fromClient);
229233
const toPath = getClientPath(toClient);
230-
234+
231235
await executeMcpOperation(
232236
invoke("sync_mcp_config", {
233237
fromClient,
@@ -251,7 +255,13 @@ export function useMcpConfig(
251255
setIsLoading(false);
252256
}
253257
},
254-
[selectedClient, selectedPath, executeMcpOperation, loadConfig, getClientPath],
258+
[
259+
selectedClient,
260+
selectedPath,
261+
executeMcpOperation,
262+
loadConfig,
263+
getClientPath,
264+
],
255265
);
256266

257267
const batchDeleteServers = useCallback(

tauri-app/src/hooks/useTeamTrial.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ export function useTeamTrial() {
1919
const isTrialActive = !!user?.trialActive;
2020
// Whether the trial has expired
2121
const isTrialExpired =
22-
isTrialActive && user?.trialEndsAt && new Date(user.trialEndsAt).getTime() <= Date.now();
22+
isTrialActive &&
23+
user?.trialEndsAt &&
24+
new Date(user.trialEndsAt).getTime() <= Date.now();
2325
// Whether the user is eligible to start a trial
2426
const isEligibleForTrial = !isTeamUser && !isTrialActive;
2527

@@ -35,7 +37,9 @@ export function useTeamTrial() {
3537
navigate(0);
3638
}, 1200);
3739
} catch (e: any) {
38-
toast.error(e?.message || "Failed to start trial. Please try again later.");
40+
toast.error(
41+
e?.message || "Failed to start trial. Please try again later.",
42+
);
3943
setLoading(false);
4044
}
4145
}, [navigate]);
@@ -50,4 +54,4 @@ export function useTeamTrial() {
5054
startTrial,
5155
fetchUser,
5256
};
53-
}
57+
}

tauri-app/src/hooks/useTeamTrialStatus.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ export function useTeamTrialStatus(providedUser?: any) {
1313

1414
// Memoize the status calculation
1515
return useMemo(() => {
16-
const trialExpired = actualUser?.trialActive && actualUser?.trialEndsAt && new Date(actualUser.trialEndsAt) <= new Date();
16+
const trialExpired =
17+
actualUser?.trialActive &&
18+
actualUser?.trialEndsAt &&
19+
new Date(actualUser.trialEndsAt) <= new Date();
1720
const hasTrial = actualUser?.trialActive;
1821
const isTeamUser = actualUser?.tier === "TEAM";
1922
const isTeamOrTrialActive = isTeamUser || (hasTrial && !trialExpired);
2023
return { trialExpired, hasTrial, isTeamUser, isTeamOrTrialActive };
2124
}, [actualUser]);
22-
}
25+
}

tauri-app/src/hooks/useTier.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ export function useIsFreeUser() {
66
const { isAuthenticated } = useAuth();
77
const { user } = useUserStore();
88
return isAuthenticated && user?.tier === "FREE";
9-
}
9+
}

0 commit comments

Comments
 (0)