Skip to content

Commit 5075da6

Browse files
committed
chore: update version and refactor LocalTable components
- Bumped version from 1.4.0 to 1.5.0 in package.json. - Refactored LocalTable and LocalTableHeader components to utilize encryption key retrieval and provide user guidance for key generation. - Improved error handling in useCloudSync hook to display detailed error messages.
1 parent 4b45b45 commit 5075da6

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

tauri-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"author": "milisp",
99
"license": "MIT",
1010
"private": true,
11-
"version": "1.4.0",
11+
"version": "1.5.0",
1212
"type": "module",
1313
"scripts": {
1414
"dev": "vite",

tauri-app/src/components/manage/LocalTable/LocalTableHeader.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
// Always use English comments for code
33
import { BatchActionsDropdown } from "@/components/manage/BatchActionsDropdown";
44
import { Button } from "@/components/ui/button";
5+
import { getEncryptionKey } from "@/utils/encryption";
56
import { Cloud, Key, Monitor } from "lucide-react";
67
import React from "react";
8+
import { useNavigate } from "react-router";
79

810
interface LocalTableHeaderProps {
911
isSyncing: boolean;
@@ -26,6 +28,9 @@ export const LocalTableHeader: React.FC<LocalTableHeaderProps> = ({
2628
handleBatchDisable,
2729
handleBatchDelete,
2830
}) => {
31+
const key = getEncryptionKey();
32+
const navigate = useNavigate();
33+
2934
return (
3035
<div className="flex justify-between items-center">
3136
<div className="flex gap-3 items-center">
@@ -51,6 +56,13 @@ export const LocalTableHeader: React.FC<LocalTableHeaderProps> = ({
5156
Cloud Sync
5257
<Key className="h-3 w-3 opacity-60" />
5358
</Button>
59+
60+
{!key && (
61+
<Button onClick={() => navigate("/settings")}>
62+
<Cloud className="h-4 w-4" />
63+
Go to generate encryption key for end to end sync to cloud
64+
</Button>
65+
)}
5466
</div>
5567
<BatchActionsDropdown
5668
hasSelectedRows={Object.keys(rowSelection).length > 0}

tauri-app/src/components/manage/LocalTable/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// Main LocalTable component, refactored to use hooks and header component
2-
// Always use English comments for code
32
import { CloudSyncDialog } from "@/components/manage/CloudSyncDialog";
43
import { LocalSyncDialog } from "@/components/manage/LocalSyncDialog";
54
import { RefreshMcpConfig } from "@/components/manage/RefreshMcpConfig";
@@ -43,6 +42,7 @@ export const LocalTable = ({ isAuthenticated, user }: LocalTableProps) => {
4342
const [showMissingKeyDialog, setShowMissingKeyDialog] = useState(false);
4443
const showGlobalDialog = useGlobalDialogStore((s) => s.showDialog);
4544
const navigate = useNavigate();
45+
const key = getEncryptionKey();
4646

4747
const {
4848
config,
@@ -140,7 +140,6 @@ export const LocalTable = ({ isAuthenticated, user }: LocalTableProps) => {
140140
return;
141141
}
142142
}
143-
const key = getEncryptionKey();
144143
if (!key) {
145144
setShowMissingKeyDialog(true);
146145
return;

tauri-app/src/components/manage/team/TeamLocalTable.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const TeamLocalTable = ({}: TeamLocalTableProps) => {
2323
const { getTeamConfigPath } = useConfigFileStore();
2424
const { selectedTeamId } = useTeamStore();
2525
const filePath = getTeamConfigPath(selectedTeamId) ?? null;
26+
const key = getEncryptionKey(selectedTeamId);
2627

2728
const [cloudSyncDialogOpen, setCloudSyncDialogOpen] = useState(false);
2829
const [isDeleting, _setIsDeleting] = useState(false);
@@ -121,6 +122,12 @@ export const TeamLocalTable = ({}: TeamLocalTableProps) => {
121122
Upload
122123
<Key className="h-3 w-3 opacity-60" />
123124
</Button>
125+
{!key && (
126+
<Button onClick={() => navigate("/settings")}>
127+
<Cloud className="h-4 w-4" />
128+
Go to generate encryption key for end to end sync to cloud
129+
</Button>
130+
)}
124131
</div>
125132
<BatchActionsDropdown
126133
hasSelectedRows={Object.keys(rowSelection).length > 0}

tauri-app/src/hooks/useCloudSync.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ export const useCloudSync = (
3434

3535
const fetchCloudDownload = useCallback(async () => {
3636
try {
37-
setIsSyncing(true);
3837
const serverConfigs = await downloadConfigsFromCloud();
3938
return serverConfigs;
4039
} catch (e) {
41-
toast.error("Cloud fetch failed");
42-
} finally {
43-
setIsSyncing(false);
40+
// Try to show the most useful error info
41+
const msg =
42+
e instanceof Error
43+
? e.message + (e.stack ? "\n" + e.stack : "")
44+
: JSON.stringify(e);
45+
toast.error(msg);
4446
}
4547
}, []);
4648

0 commit comments

Comments
 (0)