Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
Drive: drag an item onto a folder, or a folder up the path, to move it — at once, as Finder does
Yashwanth Kamireddie7d30adf464e
diff --git a/.uiverify/drive-drag.mjs b/.uiverify/drive-drag.mjsnew file mode 100644index 0000000..ca6ff74--- /dev/null+++ b/.uiverify/drive-drag.mjs@@ -0,0 +1,27 @@+// Dragged onto a folder, a Drive item moves into it — gone from here at once, Apple asked to+// put it there. A file is not a place to drop, nor is an item on itself.+import { engine } from "./engine.mjs";+import { SERVICES, installStub } from "./stub.mjs";+const b = await engine.launch();+const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } });+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, driveFixture: true });+const page = await ctx.newPage();+await page.goto("http://localhost:4173", { waitUntil: "networkidle" });+await page.locator(".nav-item", { hasText: "iCloud Drive" }).click();+await page.waitForTimeout(400);+let failures = 0;+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };+const row = (name) => page.locator(".drive-rows .drive-row", { hasText: name }).first();+const names = () => page.locator("button.drive-row-hit .drive-name").allInnerTexts();++await row("Keynote").dragTo(row("Semester Plan"));+await page.waitForTimeout(200);+ok(!(await page.evaluate(() => window.__moves?.length)), "a file is not somewhere to drop");++await row("Semester Plan").dragTo(row("Downloads"));+await page.waitForTimeout(150);+ok(!(await names()).some((n) => n.startsWith("Semester Plan")), "dropped on a folder, it leaves this one at once");+const sent = await page.evaluate(() => window.__moves?.at(-1));+ok(sent?.drivewsid === "FILE::d" && sent?.destinationId === "FOLDER::a", `and Apple is asked to move it there ${JSON.stringify(sent)}`);+await b.close();+process.exitCode = failures ? 1 : 0;diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjsindex ccb82e9..1a13f16 100644--- a/.uiverify/stub.mjs+++ b/.uiverify/stub.mjs@@ -279,7 +279,8 @@ export function installStub({ screen, services, twoFactor, calendarFixture, notereturn null;case "drive_sync_folder": return driveItems.length;case "drive_download": return "/home/user/Downloads/file.pdf";- case "drive_create_folder": case "drive_rename": case "drive_delete": case "drive_move": return null;+ case "drive_move": (window.__moves ??= []).push(args); await new Promise((r) => setTimeout(r, 600)); return null;+ case "drive_create_folder": case "drive_rename": case "drive_delete": return null;case "drive_item": return null;case "auth_two_factor_options": return twoFactor;case "auth_resend_code": return null;diff --git a/check.sh b/check.shindex 1142b79..8a946ed 100755--- a/check.sh+++ b/check.sh@@ -63,6 +63,7 @@ step "reminder keys" node .uiverify/reminders-keys.mjsstep "contacts order" node .uiverify/contacts-order.mjsstep "contacts lists" node .uiverify/contacts-lists.mjsstep "drive keys" node .uiverify/drive-keys.mjs+step "drive drag" node .uiverify/drive-drag.mjsstep "contacts vcard" node .uiverify/contacts-vcard.mjsstep "contacts select" node .uiverify/contacts-select.mjsstep "calendar alerts" node .uiverify/calendar-alerts.mjsdiff --git a/src/screens/DriveView.tsx b/src/screens/DriveView.tsxindex 7810115..abdafe1 100644--- a/src/screens/DriveView.tsx+++ b/src/screens/DriveView.tsx@@ -321,6 +321,9 @@ export function DriveView() {const [selected, setSelected] = useState<string | null>(null);/** The ⋯ menu, or the same menu opened by a right-click, for one item. */const [menu, setMenu] = useState<{ item: DriveItem; x: number; y: number; alignRight: boolean } | null>(null);+ /** An item of Drive's own being dragged onto a folder, and the folder it is over. */+ const dragItem = useRef<DriveItem | null>(null);+ const [dropOn, setDropOn] = useState<string | null>(null);/** True while files are held over the window, so the drop target can say so. */const [dropping, setDropping] = useState(false);@@ -632,6 +635,8 @@ export function DriveView() {try {void getCurrentWebview().onDragDropEvent((event) => {+ // A row of Drive's own being moved is not a file arriving from this machine.+ if (dragItem.current) return;if (event.payload.type === "over") setDropping(true);else if (event.payload.type === "leave") setDropping(false);else if (event.payload.type === "drop") {@@ -699,9 +704,24 @@ export function DriveView() {</span>)}<button- className="crumb"+ className={`crumb${dropOn === crumb.id ? " is-drop" : ""}`}aria-current={i === trail.length - 1}onClick={() => setTrail((t) => t.slice(0, i + 1))}+ // A folder further up the path takes a dragged item too, as Finder's path bar does.+ onDragOver={(e) => {+ if (!dragItem.current || i === trail.length - 1) return;+ e.preventDefault();+ e.dataTransfer.dropEffect = "move";+ if (dropOn !== crumb.id) setDropOn(crumb.id);+ }}+ onDragLeave={() => setDropOn((d) => (d === crumb.id ? null : d))}+ onDrop={(e) => {+ e.preventDefault();+ const moving = dragItem.current;+ dragItem.current = null;+ setDropOn(null);+ if (moving && i < trail.length - 1) void move(moving, crumb.id);+ }}>{crumb.name}</button>@@ -884,7 +904,30 @@ export function DriveView() {</div>) : (<div- className={`drive-row${container ? " is-folder" : ""}${busy ? " is-busy" : ""}${menu?.item.drivewsid === item.drivewsid ? " is-menu" : ""}${selected === item.drivewsid ? " is-selected" : ""}`}+ className={`drive-row${container ? " is-folder" : ""}${busy ? " is-busy" : ""}${menu?.item.drivewsid === item.drivewsid ? " is-menu" : ""}${selected === item.drivewsid ? " is-selected" : ""}${dropOn === item.drivewsid ? " is-drop" : ""}`}+ // Dragged onto a folder, an item moves into it — as in Finder and icloud.com.+ draggable={!busy && item.kind !== "APP_LIBRARY"}+ onDragStart={(e) => {+ dragItem.current = item;+ e.dataTransfer.effectAllowed = "move";+ e.dataTransfer.setData("application/x-quince-drive", item.drivewsid);+ }}+ onDragEnd={() => { dragItem.current = null; setDropOn(null); }}+ onDragOver={(e) => {+ const moving = dragItem.current;+ if (!moving || item.kind !== "FOLDER" || moving.drivewsid === item.drivewsid) return;+ e.preventDefault();+ e.dataTransfer.dropEffect = "move";+ if (dropOn !== item.drivewsid) setDropOn(item.drivewsid);+ }}+ onDragLeave={() => setDropOn((d) => (d === item.drivewsid ? null : d))}+ onDrop={(e) => {+ e.preventDefault();+ const moving = dragItem.current;+ dragItem.current = null;+ setDropOn(null);+ if (moving && item.kind === "FOLDER" && moving.drivewsid !== item.drivewsid) void move(moving, item.drivewsid);+ }}onContextMenu={(e) => {e.preventDefault();if (!busy) setMenu({ item, x: e.clientX, y: e.clientY, alignRight: false });diff --git a/src/styles/app.css b/src/styles/app.cssindex 60686ab..c32ca13 100644--- a/src/styles/app.css+++ b/src/styles/app.css@@ -1853,3 +1853,7 @@}.picker-menu.is-up { top: auto; bottom: calc(100% + 4px); }.drive-meta.is-soon { color: var(--sys-red, #ff453a); }++/* A folder or a folder up the path with something held over it, as Finder lights one. */+.drive-row.is-drop { background: color-mix(in srgb, var(--sys-blue, #0a84ff) 16%, transparent); box-shadow: inset 0 0 0 2px var(--sys-blue, #0a84ff); }+.crumb.is-drop { background: color-mix(in srgb, var(--sys-blue, #0a84ff) 16%, transparent); border-radius: 5px; }