@knotpad/app 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/brief.js +165 -78
- package/package.json +6 -86
- package/app/(app)/calendar/page.tsx +0 -57
- package/app/(app)/error.tsx +0 -35
- package/app/(app)/graph/page.tsx +0 -32
- package/app/(app)/guide/page.tsx +0 -21
- package/app/(app)/kanban/loading.tsx +0 -24
- package/app/(app)/kanban/page.tsx +0 -59
- package/app/(app)/layout.tsx +0 -122
- package/app/(app)/list/loading.tsx +0 -21
- package/app/(app)/list/page.tsx +0 -137
- package/app/(app)/loading.tsx +0 -18
- package/app/(app)/notes/[noteId]/page.tsx +0 -84
- package/app/(app)/notes/layout.tsx +0 -30
- package/app/(app)/notes/page.tsx +0 -39
- package/app/(app)/page.tsx +0 -5
- package/app/(app)/settings/agent-token/page.tsx +0 -59
- package/app/(app)/settings/backup/page.tsx +0 -49
- package/app/(app)/settings/billing/page.tsx +0 -53
- package/app/(app)/settings/calendar/page.tsx +0 -41
- package/app/(app)/settings/layout.test.tsx +0 -39
- package/app/(app)/settings/layout.tsx +0 -71
- package/app/(app)/settings/page.tsx +0 -4
- package/app/(app)/settings/security/page.tsx +0 -43
- package/app/(app)/settings/team/page.tsx +0 -74
- package/app/(app)/settings/workspace/page.tsx +0 -27
- package/app/(app)/tasks/[taskId]/page.tsx +0 -79
- package/app/(auth)/forgot-password/page.tsx +0 -106
- package/app/(auth)/guest/page.tsx +0 -56
- package/app/(auth)/layout.tsx +0 -13
- package/app/(auth)/login/page.tsx +0 -14
- package/app/(auth)/register/page.tsx +0 -193
- package/app/(auth)/reset-password/page.tsx +0 -138
- package/app/api/account/claim/route.tsx +0 -135
- package/app/api/admin/backfill-encryption/route.tsx +0 -43
- package/app/api/admin/license/route.tsx +0 -42
- package/app/api/auth/2fa/route.tsx +0 -148
- package/app/api/auth/[...nextauth]/route.tsx +0 -3
- package/app/api/auth/change-password/route.tsx +0 -61
- package/app/api/auth/check-2fa/route.tsx +0 -19
- package/app/api/auth/forgot-password/route.tsx +0 -65
- package/app/api/auth/reset-password/route.tsx +0 -52
- package/app/api/auth/verify-2fa/route.tsx +0 -88
- package/app/api/backup/download/db/route.ts +0 -29
- package/app/api/backup/download/notes/route.ts +0 -25
- package/app/api/backup/settings/route.ts +0 -92
- package/app/api/billing/checkout/route.tsx +0 -81
- package/app/api/billing/migrate/route.tsx +0 -163
- package/app/api/billing/portal/route.tsx +0 -24
- package/app/api/billing/setup-intent/route.tsx +0 -55
- package/app/api/billing/status/route.tsx +0 -36
- package/app/api/billing/subscribe/route.tsx +0 -85
- package/app/api/billing/webhook/route.tsx +0 -199
- package/app/api/calendar-feeds/[feedId]/route.tsx +0 -67
- package/app/api/calendar-feeds/[feedId]/sync/route.tsx +0 -37
- package/app/api/calendar-feeds/events/route.tsx +0 -82
- package/app/api/calendar-feeds/route.tsx +0 -52
- package/app/api/calendar-feeds/sync-all/route.tsx +0 -34
- package/app/api/cron/calendar-feeds/route.tsx +0 -31
- package/app/api/cron/stale-tasks/route.tsx +0 -51
- package/app/api/cron/sync/route.tsx +0 -34
- package/app/api/devices/[deviceId]/route.tsx +0 -25
- package/app/api/devices/route.tsx +0 -41
- package/app/api/export/route.tsx +0 -40
- package/app/api/feedback/route.tsx +0 -54
- package/app/api/folders/[folderId]/route.tsx +0 -51
- package/app/api/folders/route.tsx +0 -37
- package/app/api/graph/route.tsx +0 -242
- package/app/api/guest/route.tsx +0 -58
- package/app/api/health/route.tsx +0 -10
- package/app/api/holidays/countries/route.tsx +0 -14
- package/app/api/holidays/route.tsx +0 -49
- package/app/api/holidays/states/route.tsx +0 -21
- package/app/api/invites/[token]/route.tsx +0 -131
- package/app/api/invites/route.tsx +0 -74
- package/app/api/mcp/generate-token/route.tsx +0 -55
- package/app/api/mcp/revoke-token/[tokenId]/route.tsx +0 -30
- package/app/api/mcp/update-alias/[tokenId]/route.tsx +0 -22
- package/app/api/notes/[noteId]/export/route.tsx +0 -45
- package/app/api/notes/[noteId]/route.tsx +0 -360
- package/app/api/notes/route.tsx +0 -112
- package/app/api/notifications/route.tsx +0 -44
- package/app/api/register/route.tsx +0 -67
- package/app/api/restore/route.tsx +0 -148
- package/app/api/sync/conflicts/[conflictId]/route.tsx +0 -134
- package/app/api/sync/conflicts/route.tsx +0 -48
- package/app/api/sync/status/route.tsx +0 -49
- package/app/api/sync/trigger/route.tsx +0 -15
- package/app/api/tasks/[taskId]/detail/route.tsx +0 -68
- package/app/api/tasks/[taskId]/route.tsx +0 -259
- package/app/api/tasks/bulk/route.tsx +0 -133
- package/app/api/tasks/route.tsx +0 -36
- package/app/api/workspace/active/route.tsx +0 -39
- package/app/api/workspace/create-team/route.tsx +0 -42
- package/app/api/workspace/kanban-statuses/route.tsx +0 -71
- package/app/api/workspace/members/[memberId]/route.tsx +0 -69
- package/app/api/workspace/route.tsx +0 -24
- package/app/download/page.tsx +0 -170
- package/app/favicon.ico +0 -0
- package/app/generated/prisma/client.d.ts +0 -1
- package/app/generated/prisma/client.js +0 -5
- package/app/generated/prisma/default.d.ts +0 -1
- package/app/generated/prisma/default.js +0 -5
- package/app/generated/prisma/edge.d.ts +0 -1
- package/app/generated/prisma/edge.js +0 -497
- package/app/generated/prisma/index-browser.js +0 -523
- package/app/generated/prisma/index.d.ts +0 -46376
- package/app/generated/prisma/index.js +0 -497
- package/app/generated/prisma/package.json +0 -144
- package/app/generated/prisma/query_compiler_fast_bg.js +0 -2
- package/app/generated/prisma/query_compiler_fast_bg.wasm +0 -0
- package/app/generated/prisma/query_compiler_fast_bg.wasm-base64.js +0 -2
- package/app/generated/prisma/runtime/client.d.ts +0 -3386
- package/app/generated/prisma/runtime/client.js +0 -86
- package/app/generated/prisma/runtime/index-browser.d.ts +0 -90
- package/app/generated/prisma/runtime/index-browser.js +0 -6
- package/app/generated/prisma/runtime/wasm-compiler-edge.js +0 -76
- package/app/generated/prisma/schema.prisma +0 -456
- package/app/generated/prisma/wasm-edge-light-loader.mjs +0 -5
- package/app/generated/prisma/wasm-worker-loader.mjs +0 -5
- package/app/globals.css +0 -54
- package/app/invite/[token]/page.tsx +0 -52
- package/app/layout.tsx +0 -90
- package/app/mcp/route.tsx +0 -430
- package/app/opengraph-image.tsx +0 -120
- package/app/page.tsx +0 -398
- package/app/privacy/page.tsx +0 -69
- package/app/robots.tsx +0 -25
- package/app/sitemap.tsx +0 -36
- package/app/terms/page.tsx +0 -69
- package/app/upgrade/page.tsx +0 -75
- package/auth.config.ts +0 -33
- package/auth.ts +0 -79
- package/components/auth/login-form.tsx +0 -302
- package/components/auth/password-checklist.tsx +0 -31
- package/components/auth/password-input.tsx +0 -36
- package/components/auth/switch-account-button.test.tsx +0 -22
- package/components/auth/switch-account-button.tsx +0 -19
- package/components/auth/two-factor-input.tsx +0 -116
- package/components/billing/billing-dashboard.tsx +0 -265
- package/components/billing/card-form.tsx +0 -210
- package/components/billing/claim-account-form.tsx +0 -99
- package/components/branding/app-logo.test.tsx +0 -20
- package/components/branding/app-logo.tsx +0 -25
- package/components/calendar/calendar-agenda.tsx +0 -150
- package/components/calendar/calendar-drag.test.tsx +0 -177
- package/components/calendar/calendar-grid.tsx +0 -357
- package/components/calendar/calendar-hooks.test.tsx +0 -27
- package/components/calendar/calendar-hooks.ts +0 -351
- package/components/calendar/calendar-toolbar.test.tsx +0 -68
- package/components/calendar/calendar-toolbar.tsx +0 -291
- package/components/calendar/calendar-types.ts +0 -148
- package/components/calendar/calendar-view.test.tsx +0 -295
- package/components/calendar/calendar-view.tsx +0 -307
- package/components/calendar/day-detail-popover.tsx +0 -174
- package/components/calendar/task-chip.tsx +0 -86
- package/components/command/command-palette.test.tsx +0 -33
- package/components/command/command-palette.tsx +0 -310
- package/components/download-cta.tsx +0 -87
- package/components/feedback/feedback-popup.tsx +0 -207
- package/components/graph/graph-draw.ts +0 -337
- package/components/graph/graph-overlays.tsx +0 -160
- package/components/graph/graph-page.test.tsx +0 -131
- package/components/graph/graph-page.tsx +0 -263
- package/components/graph/graph-types.ts +0 -47
- package/components/graph/graph-view.tsx +0 -322
- package/components/guide/guide-view.tsx +0 -522
- package/components/kanban/kanban-board.test.tsx +0 -128
- package/components/kanban/kanban-board.tsx +0 -361
- package/components/kanban/kanban-card-menu.tsx +0 -102
- package/components/kanban/kanban-card.tsx +0 -227
- package/components/kanban/kanban-column.tsx +0 -49
- package/components/kanban/kanban-status-context.tsx +0 -28
- package/components/landing/calendar-sandbox.test.tsx +0 -15
- package/components/landing/calendar-sandbox.tsx +0 -107
- package/components/landing/graph-sandbox.test.tsx +0 -27
- package/components/landing/graph-sandbox.tsx +0 -80
- package/components/landing/kanban-sandbox.test.tsx +0 -24
- package/components/landing/kanban-sandbox.tsx +0 -101
- package/components/landing/landing-showcase.test.tsx +0 -21
- package/components/landing/landing-showcase.tsx +0 -54
- package/components/landing/list-sandbox.tsx +0 -86
- package/components/landing/mock-workspace.ts +0 -168
- package/components/landing/notes-sandbox.test.tsx +0 -14
- package/components/landing/notes-sandbox.tsx +0 -88
- package/components/layout/app-shell.tsx +0 -83
- package/components/layout/backup-scheduler.tsx +0 -122
- package/components/layout/bottom-nav.tsx +0 -43
- package/components/layout/icon-bar.test.tsx +0 -29
- package/components/layout/icon-bar.tsx +0 -118
- package/components/layout/mobile-top-bar.tsx +0 -68
- package/components/layout/notes-panel-folder.tsx +0 -127
- package/components/layout/notes-panel-note-item.tsx +0 -140
- package/components/layout/notes-panel-task-tab.tsx +0 -63
- package/components/layout/notes-panel-types.ts +0 -44
- package/components/layout/notes-panel.tsx +0 -476
- package/components/layout/notification-bell.tsx +0 -251
- package/components/layout/paywall-screen.tsx +0 -41
- package/components/layout/pro-banner.tsx +0 -76
- package/components/layout/sw-register.tsx +0 -27
- package/components/layout/workspace-switcher.tsx +0 -90
- package/components/notes/mobile-bottom-sheet.tsx +0 -99
- package/components/notes/note-editor-context-menu.tsx +0 -47
- package/components/notes/note-editor-dom.ts +0 -33
- package/components/notes/note-editor-dropdowns.tsx +0 -484
- package/components/notes/note-editor-hooks.ts +0 -692
- package/components/notes/note-editor-keyboard.ts +0 -305
- package/components/notes/note-editor-overlay.tsx +0 -90
- package/components/notes/note-editor.test.tsx +0 -372
- package/components/notes/note-editor.tsx +0 -662
- package/components/notes/note-preview-pane.tsx +0 -156
- package/components/notes/note-tabs.tsx +0 -120
- package/components/notes/note-types.tsx +0 -157
- package/components/settings/accept-invite.tsx +0 -108
- package/components/settings/agent-token-settings.tsx +0 -369
- package/components/settings/backup-restore-settings.test.tsx +0 -25
- package/components/settings/backup-restore-settings.tsx +0 -327
- package/components/settings/calendar-feeds-settings.tsx +0 -489
- package/components/settings/calendar-general-settings.tsx +0 -174
- package/components/settings/confirm-danger-action.test.tsx +0 -215
- package/components/settings/confirm-danger-action.tsx +0 -65
- package/components/settings/security-settings.tsx +0 -252
- package/components/settings/settings-guidance.test.tsx +0 -98
- package/components/settings/team-settings.tsx +0 -319
- package/components/settings/two-factor-auth.tsx +0 -296
- package/components/settings/workspace-settings-client.tsx +0 -363
- package/components/settings/workspace-settings-form.tsx +0 -73
- package/components/sync/conflict-viewer.tsx +0 -247
- package/components/sync/sync-indicator.tsx +0 -171
- package/components/tasks/snippet-thread.tsx +0 -119
- package/components/tasks/status-dot.tsx +0 -47
- package/components/tasks/task-badge.tsx +0 -43
- package/components/tasks/task-detail.test.tsx +0 -187
- package/components/tasks/task-detail.tsx +0 -458
- package/components/tasks/task-list-filters.test.tsx +0 -75
- package/components/tasks/task-list-filters.tsx +0 -163
- package/components/tasks/task-list-types.ts +0 -20
- package/components/tasks/task-list.test.tsx +0 -175
- package/components/tasks/task-list.tsx +0 -481
- package/components/tasks/task-row.tsx +0 -85
- package/components/tasks/task-table-row.tsx +0 -259
- package/components/ui/skeleton.tsx +0 -3
- package/components/ui/toast.test.tsx +0 -42
- package/components/ui/toast.tsx +0 -70
- package/electron/main.ts +0 -251
- package/electron/preload.ts +0 -56
- package/instrumentation.tsx +0 -23
- package/lib/api-error.ts +0 -50
- package/lib/backup/backup-runner.test.ts +0 -32
- package/lib/backup/backup-runner.ts +0 -19
- package/lib/backup/backup-schedule.test.ts +0 -23
- package/lib/backup/backup-schedule.ts +0 -55
- package/lib/backup/backup-settings.test.ts +0 -30
- package/lib/backup/backup-settings.ts +0 -27
- package/lib/backup/export-notes-zip.test.ts +0 -26
- package/lib/backup/export-notes-zip.ts +0 -82
- package/lib/backup/export-workspace-backup.test.ts +0 -17
- package/lib/backup/export-workspace-backup.ts +0 -77
- package/lib/backup/restore-workspace-from-export.test.ts +0 -18
- package/lib/backup/restore-workspace-from-export.ts +0 -183
- package/lib/backup/types.ts +0 -14
- package/lib/brand-icons.ts +0 -1
- package/lib/calendar-feed-crypto.ts +0 -38
- package/lib/calendar-feed.ts +0 -239
- package/lib/client/online-status.ts +0 -47
- package/lib/conflict-resolver.test.ts +0 -57
- package/lib/conflict-resolver.ts +0 -240
- package/lib/db-init.ts +0 -79
- package/lib/email.ts +0 -159
- package/lib/encryption.test.ts +0 -41
- package/lib/encryption.ts +0 -98
- package/lib/extract-snippet.test.ts +0 -123
- package/lib/extract-snippet.ts +0 -69
- package/lib/kanban-status.ts +0 -55
- package/lib/license.ts +0 -21
- package/lib/limits.ts +0 -31
- package/lib/mcp-auth.test.ts +0 -58
- package/lib/mcp-auth.ts +0 -65
- package/lib/mcp-contract.test.ts +0 -25
- package/lib/mcp-contract.ts +0 -210
- package/lib/mcp-handler.ts +0 -31
- package/lib/mcp-url.test.ts +0 -12
- package/lib/mcp-url.ts +0 -7
- package/lib/mentions.test.ts +0 -45
- package/lib/mentions.ts +0 -73
- package/lib/note-crypto.ts +0 -108
- package/lib/note-sync.ts +0 -201
- package/lib/note-title.ts +0 -93
- package/lib/prisma.ts +0 -193
- package/lib/pro-flush.ts +0 -292
- package/lib/rate-limit.ts +0 -57
- package/lib/stripe.ts +0 -38
- package/lib/sync-worker.ts +0 -388
- package/lib/task-parser.test.ts +0 -91
- package/lib/task-parser.ts +0 -81
- package/lib/task-utils.ts +0 -52
- package/lib/use-is-electron.ts +0 -19
- package/lib/use-is-mobile.ts +0 -22
- package/lib/validation/calendar-feed.ts +0 -31
- package/lib/validation/note.ts +0 -27
- package/lib/validation/task.ts +0 -26
- package/lib/view-preferences.test.ts +0 -54
- package/lib/view-preferences.ts +0 -28
- package/lib/workspace.ts +0 -66
- package/next.config.ts +0 -21
- package/postcss.config.mjs +0 -7
- package/prisma/migrations/20260519021916_init/migration.sql +0 -388
- package/prisma/migrations/20260519061113_drop_sync_password/migration.sql +0 -8
- package/prisma/migrations/20260520065016_add_task_start_date/migration.sql +0 -2
- package/prisma/migrations/20260529010600_remove_encryption_fields/migration.sql +0 -12
- package/prisma/migrations/20260529020000_restore_encryption_salt/migration.sql +0 -3
- package/prisma/migrations/20260529030000_add_folders/migration.sql +0 -17
- package/prisma/migrations/20260605000000_deferred_fixes/migration.sql +0 -31
- package/prisma/migrations/20260605020806_add_pending_sync_to_note_and_task/migration.sql +0 -5
- package/prisma/migrations/20260605063634_add_stripe_webhook_event_sync_lock/migration.sql +0 -14
- package/prisma/migrations/20260605100000_add_prod_indexes/migration.sql +0 -26
- package/prisma/migrations/20260608081404_add_kanban_statuses/migration.sql +0 -23
- package/prisma/migrations/20260611032723_add_calendar_feeds/migration.sql +0 -43
- package/prisma/migrations/20260611040000_add_calendar_feed_color/migration.sql +0 -2
- package/prisma/migrations/20260611050000_add_task_priority/migration.sql +0 -14
- package/prisma/migrations/20260612060000_add_critical_priority/migration.sql +0 -2
- package/prisma/migrations/20260613090000_add_backup_settings/migration.sql +0 -25
- package/prisma/migrations/20260614160000_add_feedback/migration.sql +0 -20
- package/prisma/migrations/20260614210000_add_2fa/migration.sql +0 -4
- package/prisma/migrations/migration_lock.toml +0 -3
- package/prisma/schema.prisma +0 -457
- package/public/Logo_icon.svg +0 -1
- package/public/file.svg +0 -1
- package/public/globe.svg +0 -1
- package/public/icon-192.png +0 -0
- package/public/icon-512.png +0 -0
- package/public/icon.svg +0 -4
- package/public/icon_dark.svg +0 -1
- package/public/knotpad_icon.svg +0 -1
- package/public/knotpad_logo_full.svg +0 -1
- package/public/manifest.json +0 -14
- package/public/next.svg +0 -1
- package/public/sw.js +0 -137
- package/public/vercel.svg +0 -1
- package/public/window.svg +0 -1
- package/tsconfig.json +0 -35
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useState, useRef, useEffect, useCallback, useMemo } from "react";
|
|
4
|
-
import { useRouter } from "next/navigation";
|
|
5
|
-
import { Trash2 } from "lucide-react";
|
|
6
|
-
import type { KanbanStatusConfig } from "@/lib/kanban-status";
|
|
7
|
-
import { ConfirmDangerAction } from "@/components/settings/confirm-danger-action";
|
|
8
|
-
|
|
9
|
-
const HEX_MAP: Record<string, string> = {
|
|
10
|
-
"border-zinc-700": "#3f3f46",
|
|
11
|
-
"border-red-700": "#b91c1c",
|
|
12
|
-
"border-orange-700": "#c2410c",
|
|
13
|
-
"border-amber-700": "#b45309",
|
|
14
|
-
"border-yellow-700": "#a16207",
|
|
15
|
-
"border-lime-700": "#4d7c0f",
|
|
16
|
-
"border-green-700": "#15803d",
|
|
17
|
-
"border-emerald-700": "#047857",
|
|
18
|
-
"border-teal-700": "#0f766e",
|
|
19
|
-
"border-cyan-700": "#0e7490",
|
|
20
|
-
"border-sky-700": "#0369a1",
|
|
21
|
-
"border-blue-700": "#1d4ed8",
|
|
22
|
-
"border-indigo-700": "#4338ca",
|
|
23
|
-
"border-violet-700": "#6d28d9",
|
|
24
|
-
"border-purple-700": "#7e22ce",
|
|
25
|
-
"border-fuchsia-700": "#a21caf",
|
|
26
|
-
"border-pink-700": "#be185d",
|
|
27
|
-
"border-rose-700": "#be123c",
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
function closestColorClass(hex: string): string {
|
|
31
|
-
const t = hex.replace("#", "");
|
|
32
|
-
const tr = parseInt(t.slice(0, 2), 16);
|
|
33
|
-
const tg = parseInt(t.slice(2, 4), 16);
|
|
34
|
-
const tb = parseInt(t.slice(4, 6), 16);
|
|
35
|
-
let best = "border-zinc-700";
|
|
36
|
-
let bestDist = Infinity;
|
|
37
|
-
for (const [cls, h] of Object.entries(HEX_MAP)) {
|
|
38
|
-
const s = h.replace("#", "");
|
|
39
|
-
const sr = parseInt(s.slice(0, 2), 16);
|
|
40
|
-
const sg = parseInt(s.slice(2, 4), 16);
|
|
41
|
-
const sb = parseInt(s.slice(4, 6), 16);
|
|
42
|
-
const dist = Math.sqrt((tr - sr) ** 2 + (tg - sg) ** 2 + (tb - sb) ** 2);
|
|
43
|
-
if (dist < bestDist) {
|
|
44
|
-
bestDist = dist;
|
|
45
|
-
best = cls;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return best;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function hexForClass(cls: string): string {
|
|
52
|
-
return HEX_MAP[cls] ?? "#3f3f46";
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function ColorPicker({
|
|
56
|
-
value,
|
|
57
|
-
onChange,
|
|
58
|
-
disabled,
|
|
59
|
-
}: {
|
|
60
|
-
value: string;
|
|
61
|
-
onChange: (cls: string) => void;
|
|
62
|
-
disabled?: boolean;
|
|
63
|
-
}) {
|
|
64
|
-
const inputRef = useRef<HTMLInputElement>(null);
|
|
65
|
-
return (
|
|
66
|
-
<button
|
|
67
|
-
type="button"
|
|
68
|
-
disabled={disabled}
|
|
69
|
-
onClick={() => inputRef.current?.click()}
|
|
70
|
-
style={{ backgroundColor: hexForClass(value) }}
|
|
71
|
-
className="relative h-6 w-6 shrink-0 rounded-full ring-1 ring-white/20 transition-transform hover:scale-110 disabled:opacity-50 disabled:hover:scale-100"
|
|
72
|
-
title="Pick colour"
|
|
73
|
-
>
|
|
74
|
-
<input
|
|
75
|
-
ref={inputRef}
|
|
76
|
-
type="color"
|
|
77
|
-
value={hexForClass(value)}
|
|
78
|
-
disabled={disabled}
|
|
79
|
-
onChange={(e) => onChange(closestColorClass(e.target.value))}
|
|
80
|
-
className="pointer-events-none absolute opacity-0"
|
|
81
|
-
/>
|
|
82
|
-
</button>
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
type Props = {
|
|
87
|
-
workspace: { id: string; name: string; slug: string };
|
|
88
|
-
kanbanStatuses: KanbanStatusConfig[];
|
|
89
|
-
canEdit: boolean;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export function WorkspaceSettingsClient({ workspace, kanbanStatuses, canEdit }: Props) {
|
|
93
|
-
const router = useRouter();
|
|
94
|
-
const [name, setName] = useState(workspace.name);
|
|
95
|
-
const [statuses, setStatuses] = useState<KanbanStatusConfig[]>(kanbanStatuses);
|
|
96
|
-
const [saving, setSaving] = useState(false);
|
|
97
|
-
const [saved, setSaved] = useState(false);
|
|
98
|
-
const [error, setError] = useState("");
|
|
99
|
-
const [deleteConfirm, setDeleteConfirm] = useState<{ open: boolean; index: number }>({ open: false, index: -1 });
|
|
100
|
-
|
|
101
|
-
const isDirty = useMemo(() => {
|
|
102
|
-
if (name !== workspace.name) return true;
|
|
103
|
-
if (JSON.stringify(statuses) !== JSON.stringify(kanbanStatuses)) return true;
|
|
104
|
-
return false;
|
|
105
|
-
}, [name, statuses, workspace.name, kanbanStatuses]);
|
|
106
|
-
|
|
107
|
-
useEffect(() => {
|
|
108
|
-
if (!isDirty) return;
|
|
109
|
-
function handler(e: BeforeUnloadEvent) {
|
|
110
|
-
e.preventDefault();
|
|
111
|
-
}
|
|
112
|
-
window.addEventListener("beforeunload", handler);
|
|
113
|
-
return () => window.removeEventListener("beforeunload", handler);
|
|
114
|
-
}, [isDirty]);
|
|
115
|
-
|
|
116
|
-
const handleDiscard = useCallback(() => {
|
|
117
|
-
setName(workspace.name);
|
|
118
|
-
setStatuses(kanbanStatuses);
|
|
119
|
-
setError("");
|
|
120
|
-
setSaved(false);
|
|
121
|
-
}, [workspace.name, kanbanStatuses]);
|
|
122
|
-
|
|
123
|
-
function updateStatus(index: number, patch: Partial<KanbanStatusConfig>) {
|
|
124
|
-
setStatuses((prev) => prev.map((s, i) => (i === index ? { ...s, ...patch } : s)));
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function moveStatus(index: number, direction: -1 | 1) {
|
|
128
|
-
const newIndex = index + direction;
|
|
129
|
-
if (newIndex < 0 || newIndex >= statuses.length) return;
|
|
130
|
-
setStatuses((prev) => {
|
|
131
|
-
const next = [...prev];
|
|
132
|
-
const [removed] = next.splice(index, 1);
|
|
133
|
-
next.splice(newIndex, 0, removed);
|
|
134
|
-
return next.map((s, i) => ({ ...s, order: i }));
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function addStatus() {
|
|
139
|
-
const existingKeys = new Set(statuses.map((s) => s.key));
|
|
140
|
-
let idx = 1;
|
|
141
|
-
while (existingKeys.has(`STATUS_${idx}`)) idx++;
|
|
142
|
-
setStatuses((prev) => [
|
|
143
|
-
...prev,
|
|
144
|
-
{
|
|
145
|
-
key: `STATUS_${idx}`,
|
|
146
|
-
label: "New Status",
|
|
147
|
-
color: "border-zinc-700",
|
|
148
|
-
order: prev.length,
|
|
149
|
-
isVisible: true,
|
|
150
|
-
},
|
|
151
|
-
]);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function removeStatus(index: number) {
|
|
155
|
-
setDeleteConfirm({ open: true, index });
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
async function confirmDeleteStatus() {
|
|
159
|
-
const { index } = deleteConfirm;
|
|
160
|
-
setStatuses((prev) =>
|
|
161
|
-
prev
|
|
162
|
-
.filter((_, i) => i !== index)
|
|
163
|
-
.map((s, i) => ({ ...s, order: i }))
|
|
164
|
-
);
|
|
165
|
-
setDeleteConfirm({ open: false, index: -1 });
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
async function handleSave(e: React.FormEvent) {
|
|
169
|
-
e.preventDefault();
|
|
170
|
-
setSaving(true);
|
|
171
|
-
setError("");
|
|
172
|
-
setSaved(false);
|
|
173
|
-
|
|
174
|
-
try {
|
|
175
|
-
const [workspaceRes, statusesRes] = await Promise.all([
|
|
176
|
-
fetch("/api/workspace", {
|
|
177
|
-
method: "PATCH",
|
|
178
|
-
headers: { "Content-Type": "application/json" },
|
|
179
|
-
body: JSON.stringify({ name }),
|
|
180
|
-
}),
|
|
181
|
-
fetch("/api/workspace/kanban-statuses", {
|
|
182
|
-
method: "PUT",
|
|
183
|
-
headers: { "Content-Type": "application/json" },
|
|
184
|
-
body: JSON.stringify({ statuses }),
|
|
185
|
-
}),
|
|
186
|
-
]);
|
|
187
|
-
|
|
188
|
-
setSaving(false);
|
|
189
|
-
|
|
190
|
-
const workspaceOk = workspaceRes.ok;
|
|
191
|
-
const statusesOk = statusesRes.ok;
|
|
192
|
-
|
|
193
|
-
if (!workspaceOk) {
|
|
194
|
-
const d = await workspaceRes.json().catch(() => ({}));
|
|
195
|
-
setError(d.error ?? "Failed to save workspace name");
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
if (!statusesOk) {
|
|
199
|
-
const d = await statusesRes.json().catch(() => ({}));
|
|
200
|
-
setError(d.error ?? "Failed to save Kanban statuses");
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
setSaved(true);
|
|
205
|
-
setTimeout(() => setSaved(false), 2000);
|
|
206
|
-
router.refresh();
|
|
207
|
-
} catch {
|
|
208
|
-
setSaving(false);
|
|
209
|
-
setError("Failed to save");
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return (
|
|
214
|
-
<form onSubmit={handleSave} className="max-w-lg space-y-10">
|
|
215
|
-
{/* Workspace name */}
|
|
216
|
-
<div className="space-y-6">
|
|
217
|
-
<div>
|
|
218
|
-
<h2 className="text-base font-semibold text-zinc-200">Workspace</h2>
|
|
219
|
-
<p className="text-sm text-zinc-500 mt-1">
|
|
220
|
-
Manage your workspace name and settings.
|
|
221
|
-
</p>
|
|
222
|
-
</div>
|
|
223
|
-
<div className="space-y-4">
|
|
224
|
-
<div className="space-y-1">
|
|
225
|
-
<label className="text-sm font-medium text-zinc-300">Workspace name</label>
|
|
226
|
-
<input
|
|
227
|
-
value={name}
|
|
228
|
-
onChange={(e) => setName(e.target.value)}
|
|
229
|
-
disabled={!canEdit}
|
|
230
|
-
className="w-full rounded-md border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-zinc-100 focus:border-zinc-500 focus:outline-none ring-focus disabled:opacity-50"
|
|
231
|
-
/>
|
|
232
|
-
</div>
|
|
233
|
-
<div className="space-y-1">
|
|
234
|
-
<label className="text-sm font-medium text-zinc-300">Slug</label>
|
|
235
|
-
<input
|
|
236
|
-
value={workspace.slug}
|
|
237
|
-
disabled
|
|
238
|
-
className="w-full rounded-md border border-zinc-800 bg-zinc-900/50 px-3 py-2 text-sm text-zinc-500"
|
|
239
|
-
/>
|
|
240
|
-
<p className="text-xs text-zinc-600">Slug cannot be changed after creation.</p>
|
|
241
|
-
</div>
|
|
242
|
-
</div>
|
|
243
|
-
</div>
|
|
244
|
-
|
|
245
|
-
{/* Kanban statuses */}
|
|
246
|
-
<div className="space-y-6">
|
|
247
|
-
<div>
|
|
248
|
-
<h2 className="text-base font-semibold text-zinc-200">Kanban Statuses</h2>
|
|
249
|
-
<p className="text-sm text-zinc-500 mt-1">
|
|
250
|
-
Customise the labels, order, and border colours for your Kanban columns.
|
|
251
|
-
</p>
|
|
252
|
-
</div>
|
|
253
|
-
<div className="space-y-2">
|
|
254
|
-
{statuses.map((status, i) => (
|
|
255
|
-
<div
|
|
256
|
-
key={status.key}
|
|
257
|
-
className="flex items-center gap-3 rounded-md border border-zinc-800 bg-zinc-900/40 px-3 py-2.5"
|
|
258
|
-
>
|
|
259
|
-
<div className="flex flex-col gap-0.5">
|
|
260
|
-
<button
|
|
261
|
-
type="button"
|
|
262
|
-
disabled={i === 0 || !canEdit}
|
|
263
|
-
onClick={() => moveStatus(i, -1)}
|
|
264
|
-
className="text-zinc-600 hover:text-zinc-400 disabled:opacity-30 disabled:hover:text-zinc-600"
|
|
265
|
-
>
|
|
266
|
-
▲
|
|
267
|
-
</button>
|
|
268
|
-
<button
|
|
269
|
-
type="button"
|
|
270
|
-
disabled={i === statuses.length - 1 || !canEdit}
|
|
271
|
-
onClick={() => moveStatus(i, 1)}
|
|
272
|
-
className="text-zinc-600 hover:text-zinc-400 disabled:opacity-30 disabled:hover:text-zinc-600"
|
|
273
|
-
>
|
|
274
|
-
▼
|
|
275
|
-
</button>
|
|
276
|
-
</div>
|
|
277
|
-
|
|
278
|
-
<div className="flex flex-1 items-center gap-3">
|
|
279
|
-
<ColorPicker
|
|
280
|
-
value={status.color}
|
|
281
|
-
onChange={(c) => updateStatus(i, { color: c })}
|
|
282
|
-
disabled={!canEdit}
|
|
283
|
-
/>
|
|
284
|
-
<input
|
|
285
|
-
value={status.label}
|
|
286
|
-
onChange={(e) => updateStatus(i, { label: e.target.value })}
|
|
287
|
-
disabled={!canEdit}
|
|
288
|
-
className="flex-1 rounded-md border border-zinc-700 bg-zinc-900 px-2 py-1 text-sm text-zinc-100 focus:border-zinc-500 focus:outline-none ring-focus disabled:opacity-50"
|
|
289
|
-
/>
|
|
290
|
-
</div>
|
|
291
|
-
|
|
292
|
-
{canEdit && (
|
|
293
|
-
<button
|
|
294
|
-
type="button"
|
|
295
|
-
onClick={() => removeStatus(i)}
|
|
296
|
-
className="text-zinc-600 hover:text-red-400 transition-colors"
|
|
297
|
-
title="Delete status"
|
|
298
|
-
>
|
|
299
|
-
<Trash2 size={14} />
|
|
300
|
-
</button>
|
|
301
|
-
)}
|
|
302
|
-
|
|
303
|
-
<div className="h-8 w-1.5 rounded-full" style={{ backgroundColor: hexForClass(status.color) }} />
|
|
304
|
-
</div>
|
|
305
|
-
))}
|
|
306
|
-
</div>
|
|
307
|
-
{canEdit && (
|
|
308
|
-
<button
|
|
309
|
-
type="button"
|
|
310
|
-
onClick={addStatus}
|
|
311
|
-
className="rounded-md border border-zinc-700 bg-zinc-900 px-3 py-1.5 text-sm text-zinc-300 hover:bg-zinc-800 transition-colors"
|
|
312
|
-
>
|
|
313
|
-
+ Add status
|
|
314
|
-
</button>
|
|
315
|
-
)}
|
|
316
|
-
</div>
|
|
317
|
-
|
|
318
|
-
{/* Unified save */}
|
|
319
|
-
{error && <p className="text-sm text-red-400">{error}</p>}
|
|
320
|
-
{canEdit && (
|
|
321
|
-
<div className="flex items-center gap-3">
|
|
322
|
-
{isDirty && (
|
|
323
|
-
<>
|
|
324
|
-
<span className="text-sm text-zinc-400">Unsaved changes</span>
|
|
325
|
-
<button
|
|
326
|
-
type="button"
|
|
327
|
-
onClick={handleDiscard}
|
|
328
|
-
className="rounded-md border border-zinc-700 bg-zinc-900 px-4 py-2 text-sm text-zinc-300 hover:bg-zinc-800 transition-colors"
|
|
329
|
-
>
|
|
330
|
-
Discard
|
|
331
|
-
</button>
|
|
332
|
-
</>
|
|
333
|
-
)}
|
|
334
|
-
<button
|
|
335
|
-
type="submit"
|
|
336
|
-
disabled={saving || !isDirty}
|
|
337
|
-
className="rounded-md bg-zinc-100 px-4 py-2 text-sm font-medium text-zinc-900 hover:bg-zinc-200 disabled:opacity-50"
|
|
338
|
-
>
|
|
339
|
-
{saving ? "Saving…" : saved ? "Saved ✓" : "Save changes"}
|
|
340
|
-
</button>
|
|
341
|
-
</div>
|
|
342
|
-
)}
|
|
343
|
-
|
|
344
|
-
{/* Company info */}
|
|
345
|
-
<div className="pt-6 border-t border-zinc-800">
|
|
346
|
-
<p className="text-[11px] text-zinc-700">
|
|
347
|
-
Knotpad is a product of Nexstrive Services · Registration: 202303272747 (TR0292898-P) · Kuala Lumpur, Malaysia
|
|
348
|
-
</p>
|
|
349
|
-
</div>
|
|
350
|
-
|
|
351
|
-
{/* Confirmation dialog */}
|
|
352
|
-
<ConfirmDangerAction
|
|
353
|
-
open={deleteConfirm.open}
|
|
354
|
-
title="Delete Status"
|
|
355
|
-
body="Delete this status? Tasks currently using it will remain but won't appear in Kanban columns."
|
|
356
|
-
confirmLabel="Delete"
|
|
357
|
-
cancelLabel="Cancel"
|
|
358
|
-
onConfirm={confirmDeleteStatus}
|
|
359
|
-
onClose={() => setDeleteConfirm({ open: false, index: -1 })}
|
|
360
|
-
/>
|
|
361
|
-
</form>
|
|
362
|
-
);
|
|
363
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
import { useRouter } from "next/navigation";
|
|
5
|
-
|
|
6
|
-
type Workspace = { id: string; name: string; slug: string };
|
|
7
|
-
|
|
8
|
-
export function WorkspaceSettingsForm({
|
|
9
|
-
workspace,
|
|
10
|
-
canEdit,
|
|
11
|
-
}: {
|
|
12
|
-
workspace: Workspace;
|
|
13
|
-
canEdit: boolean;
|
|
14
|
-
}) {
|
|
15
|
-
const router = useRouter();
|
|
16
|
-
const [name, setName] = useState(workspace.name);
|
|
17
|
-
const [saving, setSaving] = useState(false);
|
|
18
|
-
const [saved, setSaved] = useState(false);
|
|
19
|
-
const [error, setError] = useState("");
|
|
20
|
-
|
|
21
|
-
async function handleSave(e: React.FormEvent) {
|
|
22
|
-
e.preventDefault();
|
|
23
|
-
setSaving(true);
|
|
24
|
-
setError("");
|
|
25
|
-
const res = await fetch("/api/workspace", {
|
|
26
|
-
method: "PATCH",
|
|
27
|
-
headers: { "Content-Type": "application/json" },
|
|
28
|
-
body: JSON.stringify({ name }),
|
|
29
|
-
});
|
|
30
|
-
setSaving(false);
|
|
31
|
-
if (res.ok) {
|
|
32
|
-
setSaved(true);
|
|
33
|
-
setTimeout(() => setSaved(false), 2000);
|
|
34
|
-
router.refresh();
|
|
35
|
-
} else {
|
|
36
|
-
const d = await res.json();
|
|
37
|
-
setError(d.error ?? "Failed to save");
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<form onSubmit={handleSave} className="space-y-4">
|
|
43
|
-
<div className="space-y-1">
|
|
44
|
-
<label className="text-sm font-medium text-zinc-300">Workspace name</label>
|
|
45
|
-
<input
|
|
46
|
-
value={name}
|
|
47
|
-
onChange={(e) => setName(e.target.value)}
|
|
48
|
-
disabled={!canEdit}
|
|
49
|
-
className="w-full rounded-md border border-zinc-700 bg-zinc-900 px-3 py-2 text-sm text-zinc-100 focus:border-zinc-500 focus:outline-none ring-focus disabled:opacity-50"
|
|
50
|
-
/>
|
|
51
|
-
</div>
|
|
52
|
-
<div className="space-y-1">
|
|
53
|
-
<label className="text-sm font-medium text-zinc-300">Slug</label>
|
|
54
|
-
<input
|
|
55
|
-
value={workspace.slug}
|
|
56
|
-
disabled
|
|
57
|
-
className="w-full rounded-md border border-zinc-800 bg-zinc-900/50 px-3 py-2 text-sm text-zinc-500"
|
|
58
|
-
/>
|
|
59
|
-
<p className="text-xs text-zinc-600">Slug cannot be changed after creation.</p>
|
|
60
|
-
</div>
|
|
61
|
-
{error && <p className="text-sm text-red-400">{error}</p>}
|
|
62
|
-
{canEdit && (
|
|
63
|
-
<button
|
|
64
|
-
type="submit"
|
|
65
|
-
disabled={saving}
|
|
66
|
-
className="rounded-md bg-zinc-100 px-4 py-2 text-sm font-medium text-zinc-900 hover:bg-zinc-200 disabled:opacity-50"
|
|
67
|
-
>
|
|
68
|
-
{saving ? "Saving…" : saved ? "Saved ✓" : "Save changes"}
|
|
69
|
-
</button>
|
|
70
|
-
)}
|
|
71
|
-
</form>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
4
|
-
import { X, CheckCircle2, Loader2, AlertTriangle } from "lucide-react";
|
|
5
|
-
|
|
6
|
-
type Conflict = {
|
|
7
|
-
id: string;
|
|
8
|
-
entityType: string;
|
|
9
|
-
entityId: string;
|
|
10
|
-
label: string;
|
|
11
|
-
localValue: string;
|
|
12
|
-
cloudValue: string;
|
|
13
|
-
createdAt: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type Props = {
|
|
17
|
-
onClose: () => void;
|
|
18
|
-
onResolved?: () => void;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export function ConflictViewer({ onClose, onResolved }: Props) {
|
|
22
|
-
const [conflicts, setConflicts] = useState<Conflict[]>([]);
|
|
23
|
-
const [selected, setSelected] = useState<Conflict | null>(null);
|
|
24
|
-
const [customValue, setCustomValue] = useState("");
|
|
25
|
-
const [resolving, setResolving] = useState(false);
|
|
26
|
-
const [loading, setLoading] = useState(true);
|
|
27
|
-
const [loadError, setLoadError] = useState<string | null>(null);
|
|
28
|
-
const [resolveError, setResolveError] = useState<string | null>(null);
|
|
29
|
-
|
|
30
|
-
async function loadConflicts() {
|
|
31
|
-
setLoading(true);
|
|
32
|
-
setLoadError(null);
|
|
33
|
-
try {
|
|
34
|
-
const res = await fetch("/api/sync/conflicts");
|
|
35
|
-
if (!res.ok) throw new Error(`${res.status}`);
|
|
36
|
-
const data = await res.json();
|
|
37
|
-
setConflicts(data);
|
|
38
|
-
if (data.length > 0) setSelected((prev) => prev ?? data[0]);
|
|
39
|
-
} catch {
|
|
40
|
-
setLoadError("Couldn't load conflicts — check your connection and try again.");
|
|
41
|
-
} finally {
|
|
42
|
-
setLoading(false);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
loadConflicts();
|
|
48
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
|
-
}, []);
|
|
50
|
-
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
if (selected) setCustomValue(selected.localValue);
|
|
53
|
-
}, [selected]);
|
|
54
|
-
|
|
55
|
-
async function resolve(resolution: "local" | "cloud" | "custom") {
|
|
56
|
-
if (!selected) return;
|
|
57
|
-
setResolving(true);
|
|
58
|
-
setResolveError(null);
|
|
59
|
-
try {
|
|
60
|
-
const res = await fetch(`/api/sync/conflicts/${selected.id}`, {
|
|
61
|
-
method: "PATCH",
|
|
62
|
-
headers: { "Content-Type": "application/json" },
|
|
63
|
-
body: JSON.stringify({
|
|
64
|
-
resolution,
|
|
65
|
-
value: resolution === "custom" ? customValue : undefined,
|
|
66
|
-
}),
|
|
67
|
-
});
|
|
68
|
-
if (!res.ok) {
|
|
69
|
-
const body = await res.json().catch(() => ({}));
|
|
70
|
-
throw new Error((body as { error?: string }).error ?? `${res.status}`);
|
|
71
|
-
}
|
|
72
|
-
const remaining = conflicts.filter((c) => c.id !== selected.id);
|
|
73
|
-
setConflicts(remaining);
|
|
74
|
-
setSelected(remaining[0] ?? null);
|
|
75
|
-
if (remaining.length === 0) {
|
|
76
|
-
onResolved?.();
|
|
77
|
-
onClose();
|
|
78
|
-
}
|
|
79
|
-
} catch (err) {
|
|
80
|
-
setResolveError((err as Error).message ?? "Resolution failed — please try again.");
|
|
81
|
-
} finally {
|
|
82
|
-
setResolving(false);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm">
|
|
88
|
-
<div className="flex w-[900px] max-w-[95vw] max-h-[85vh] flex-col rounded-xl border border-zinc-700 bg-zinc-950 shadow-2xl">
|
|
89
|
-
{/* Header */}
|
|
90
|
-
<div className="flex items-center justify-between border-b border-zinc-800 px-6 py-4">
|
|
91
|
-
<div className="flex items-center gap-2">
|
|
92
|
-
<AlertTriangle size={16} className="text-amber-400" />
|
|
93
|
-
<h2 className="text-sm font-semibold text-zinc-100">
|
|
94
|
-
Sync Conflicts
|
|
95
|
-
</h2>
|
|
96
|
-
{conflicts.length > 0 && (
|
|
97
|
-
<span className="rounded-full bg-amber-500/20 px-2 py-0.5 text-xs font-medium text-amber-400">
|
|
98
|
-
{conflicts.length} remaining
|
|
99
|
-
</span>
|
|
100
|
-
)}
|
|
101
|
-
</div>
|
|
102
|
-
<button
|
|
103
|
-
onClick={onClose}
|
|
104
|
-
className="flex h-7 w-7 items-center justify-center rounded text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300"
|
|
105
|
-
>
|
|
106
|
-
<X size={16} />
|
|
107
|
-
</button>
|
|
108
|
-
</div>
|
|
109
|
-
|
|
110
|
-
{loading && (
|
|
111
|
-
<div className="flex flex-1 items-center justify-center py-16 text-zinc-500">
|
|
112
|
-
<Loader2 size={20} className="animate-spin" />
|
|
113
|
-
</div>
|
|
114
|
-
)}
|
|
115
|
-
|
|
116
|
-
{!loading && loadError && (
|
|
117
|
-
<div className="flex flex-1 flex-col items-center justify-center gap-3 py-16">
|
|
118
|
-
<AlertTriangle size={24} className="text-red-400" />
|
|
119
|
-
<p className="text-sm text-red-300">{loadError}</p>
|
|
120
|
-
<button
|
|
121
|
-
onClick={loadConflicts}
|
|
122
|
-
className="rounded-md bg-zinc-800 px-3 py-1.5 text-xs text-zinc-300 hover:bg-zinc-700"
|
|
123
|
-
>
|
|
124
|
-
Retry
|
|
125
|
-
</button>
|
|
126
|
-
</div>
|
|
127
|
-
)}
|
|
128
|
-
|
|
129
|
-
{!loading && !loadError && conflicts.length === 0 && (
|
|
130
|
-
<div className="flex flex-1 flex-col items-center justify-center gap-3 py-16">
|
|
131
|
-
<CheckCircle2 size={32} className="text-emerald-500" />
|
|
132
|
-
<p className="text-sm text-zinc-400">All conflicts resolved</p>
|
|
133
|
-
</div>
|
|
134
|
-
)}
|
|
135
|
-
|
|
136
|
-
{!loading && !loadError && selected && (
|
|
137
|
-
<div className="flex flex-1 min-h-0">
|
|
138
|
-
{/* Conflict list (left sidebar) */}
|
|
139
|
-
{conflicts.length > 1 && (
|
|
140
|
-
<aside className="w-52 shrink-0 border-r border-zinc-800 overflow-y-auto py-2">
|
|
141
|
-
{conflicts.map((c) => (
|
|
142
|
-
<button
|
|
143
|
-
key={c.id}
|
|
144
|
-
onClick={() => setSelected(c)}
|
|
145
|
-
className={`w-full px-4 py-2.5 text-left text-xs transition-colors ${
|
|
146
|
-
selected.id === c.id
|
|
147
|
-
? "bg-zinc-800 text-zinc-100"
|
|
148
|
-
: "text-zinc-400 hover:bg-zinc-800/60 hover:text-zinc-200"
|
|
149
|
-
}`}
|
|
150
|
-
>
|
|
151
|
-
<p className="truncate font-medium">{c.label}</p>
|
|
152
|
-
<p className="text-zinc-600 capitalize">{c.entityType}</p>
|
|
153
|
-
</button>
|
|
154
|
-
))}
|
|
155
|
-
</aside>
|
|
156
|
-
)}
|
|
157
|
-
|
|
158
|
-
{/* Diff view */}
|
|
159
|
-
<div className="flex flex-1 min-w-0 flex-col overflow-hidden">
|
|
160
|
-
<div className="border-b border-zinc-800 px-6 py-3">
|
|
161
|
-
<p className="text-xs text-zinc-500">
|
|
162
|
-
<span className="font-medium text-zinc-300">{selected.label}</span>
|
|
163
|
-
{" · "}
|
|
164
|
-
<span className="capitalize">{selected.entityType}</span>
|
|
165
|
-
{" · "}
|
|
166
|
-
<span>{new Date(selected.createdAt).toLocaleString()}</span>
|
|
167
|
-
</p>
|
|
168
|
-
</div>
|
|
169
|
-
|
|
170
|
-
<div className="grid flex-1 min-h-0 grid-cols-2 divide-x divide-zinc-800">
|
|
171
|
-
{/* Local version */}
|
|
172
|
-
<div className="flex flex-col min-h-0 overflow-hidden">
|
|
173
|
-
<div className="border-b border-zinc-800 bg-zinc-900/50 px-4 py-2">
|
|
174
|
-
<p className="text-xs font-medium text-blue-400">Local version</p>
|
|
175
|
-
<p className="text-[10px] text-zinc-600">Your unsync'd changes</p>
|
|
176
|
-
</div>
|
|
177
|
-
<pre className="flex-1 overflow-auto p-4 text-xs leading-relaxed text-zinc-300 whitespace-pre-wrap font-mono">
|
|
178
|
-
{selected.localValue}
|
|
179
|
-
</pre>
|
|
180
|
-
</div>
|
|
181
|
-
|
|
182
|
-
{/* Cloud version */}
|
|
183
|
-
<div className="flex flex-col min-h-0 overflow-hidden">
|
|
184
|
-
<div className="border-b border-zinc-800 bg-zinc-900/50 px-4 py-2">
|
|
185
|
-
<p className="text-xs font-medium text-purple-400">Cloud version</p>
|
|
186
|
-
<p className="text-[10px] text-zinc-600">Changes from another device</p>
|
|
187
|
-
</div>
|
|
188
|
-
<pre className="flex-1 overflow-auto p-4 text-xs leading-relaxed text-zinc-300 whitespace-pre-wrap font-mono">
|
|
189
|
-
{selected.cloudValue}
|
|
190
|
-
</pre>
|
|
191
|
-
</div>
|
|
192
|
-
</div>
|
|
193
|
-
|
|
194
|
-
{/* Custom edit */}
|
|
195
|
-
<div className="border-t border-zinc-800 px-6 py-3">
|
|
196
|
-
<p className="mb-2 text-xs text-zinc-500">
|
|
197
|
-
Or edit a merged version manually:
|
|
198
|
-
</p>
|
|
199
|
-
<textarea
|
|
200
|
-
value={customValue}
|
|
201
|
-
onChange={(e) => setCustomValue(e.target.value)}
|
|
202
|
-
rows={3}
|
|
203
|
-
className="w-full resize-none rounded border border-zinc-700 bg-zinc-900 px-3 py-2 text-xs text-zinc-200 font-mono placeholder:text-zinc-600 focus:border-zinc-500 focus:outline-none ring-focus"
|
|
204
|
-
/>
|
|
205
|
-
</div>
|
|
206
|
-
|
|
207
|
-
{/* Actions */}
|
|
208
|
-
<div className="border-t border-zinc-800 px-6 py-4 flex items-center justify-between gap-3">
|
|
209
|
-
<div className="flex-1 min-w-0">
|
|
210
|
-
{resolveError ? (
|
|
211
|
-
<p className="text-xs text-red-400 truncate">{resolveError}</p>
|
|
212
|
-
) : (
|
|
213
|
-
<p className="text-xs text-zinc-600">Choose which version to keep, or save your manual edit.</p>
|
|
214
|
-
)}
|
|
215
|
-
</div>
|
|
216
|
-
<div className="flex items-center gap-2">
|
|
217
|
-
<button
|
|
218
|
-
onClick={() => resolve("local")}
|
|
219
|
-
disabled={resolving}
|
|
220
|
-
className="rounded-md bg-blue-600 px-3 py-1.5 text-xs font-medium text-white hover:bg-blue-500 disabled:opacity-50 transition-colors"
|
|
221
|
-
>
|
|
222
|
-
Keep local
|
|
223
|
-
</button>
|
|
224
|
-
<button
|
|
225
|
-
onClick={() => resolve("cloud")}
|
|
226
|
-
disabled={resolving}
|
|
227
|
-
className="rounded-md bg-purple-600 px-3 py-1.5 text-xs font-medium text-white hover:bg-purple-500 disabled:opacity-50 transition-colors"
|
|
228
|
-
>
|
|
229
|
-
Keep cloud
|
|
230
|
-
</button>
|
|
231
|
-
<button
|
|
232
|
-
onClick={() => resolve("custom")}
|
|
233
|
-
disabled={resolving || !customValue.trim()}
|
|
234
|
-
className="rounded-md bg-zinc-700 px-3 py-1.5 text-xs font-medium text-zinc-200 hover:bg-zinc-600 disabled:opacity-50 transition-colors"
|
|
235
|
-
>
|
|
236
|
-
Save edit
|
|
237
|
-
</button>
|
|
238
|
-
{resolving && <Loader2 size={14} className="animate-spin text-zinc-500" />}
|
|
239
|
-
</div>
|
|
240
|
-
</div>
|
|
241
|
-
</div>
|
|
242
|
-
</div>
|
|
243
|
-
)}
|
|
244
|
-
</div>
|
|
245
|
-
</div>
|
|
246
|
-
);
|
|
247
|
-
}
|