forge
Explore
Log in

Don't you dare go Hollow

Share page, upload cancel, drop-up menus, single-border toolbar

Browse files at this commit

da9eb91af3067e9fdc9730be1df492bb000997f1Ahmet Kaan GümüşParent: 4cd43f8
  • feat
    • share page, upload cancel, drop-up menus, single-border toolbar
Show full message
feat: share page, upload cancel, drop-up menus, single-border toolbar

- share: new /share/{kind}/{id} page (public link create/revoke with
  copy-once banner, im-user grants by email with download/view-only),
  linked from every row's Options menu; link rows name the target
  instead of its id; can_download checkboxes honest — unchecked no
  longer grants downloads (parse_flag absent=false, regression test)
- upload: every in-flight progress row has a cancel control — XHR abort
  or loop stop + /api/upload/{id}/abort, works across soft navigations,
  'Upload canceled.' card in the corner stack
- options menu: measure against the nearest scrollport, not the
  viewport — the stage's content-height scroll area trapped the menu as
  unpainted scrollable overflow; opens upward when downward is trapped,
  no page movement when it fits
- toolbar: dd triggers and arrow submits no longer wear a second border
  inside the field box; search label shortened to 'Search' so the
  placeholder stops clipping
- settings: upload limit moved into the Everyone panel with a label and
  single 'applies to everyone' note
crates/in-core/src/store/mod.rsmodified+11 -0
@@ -560,6 +560,17 @@ pub trait Store: 'static + Send + Sync {
560 user_id: &str,560 user_id: &str,
561 ) -> Result<()>;561 ) -> Result<()>;
562 562
563+ /// Every grant on one target, newest first — the target's share page. The
564+ /// caller must own the live target: another owner's target is
565+ /// [`StoreError::CrossOwner`], a missing or trashed one
566+ /// [`StoreError::NotFound`], the same rule as [`Store::add_share_user`].
567+ async fn shares_for_target(
568+ &self,
569+ caller_id: &str,
570+ kind: ShareKind,
571+ target_id: &str,
572+ ) -> Result<Vec<ShareUser>>;
573+
563 /// Everything shared with the person that is still live: untrashed574 /// Everything shared with the person that is still live: untrashed
564 /// targets, newest grant first. The person's own library never appears575 /// targets, newest grant first. The person's own library never appears
565 /// here.576 /// here.
crates/in-core/src/store/turso_store.rsmodified+38 -2
@@ -15,8 +15,8 @@ use ulid::Ulid;
15 15
16 use super::secret;16 use super::secret;
17 use super::{17 use super::{
18- CHUNK_SIZE, CreatedLink, File, Folder, Listing, Result, ShareKind, ShareLink, SharedItem,18+ CHUNK_SIZE, CreatedLink, File, Folder, Listing, Result, ShareKind, ShareLink, ShareUser,
19- Store, StoreError, ThumbState, UPLOAD_TTL_HOURS, UploadSession, UploadState, User,19+ SharedItem, Store, StoreError, ThumbState, UPLOAD_TTL_HOURS, UploadSession, UploadState, User,
20 };20 };
21 use super::{ReconcileOptions, reconcile, schema, sniff};21 use super::{ReconcileOptions, reconcile, schema, sniff};
22 use crate::live::{Change, Topic};22 use crate::live::{Change, Topic};
@@ -2064,6 +2064,42 @@ impl Store for TursoStore {
2064 Ok(())2064 Ok(())
2065 }2065 }
2066 2066
2067+ async fn shares_for_target(
2068+ &self,
2069+ caller_id: &str,
2070+ kind: ShareKind,
2071+ target_id: &str,
2072+ ) -> Result<Vec<ShareUser>> {
2073+ // The caller must own a live target — the same rule as the sibling
2074+ // share writes: a stranger's target is cross-owner, a missing or
2075+ // trashed one not-found.
2076+ match target_owner(&self.conn, kind, target_id).await? {
2077+ Some(owner) if owner == caller_id => {}
2078+ Some(_) => return Err(StoreError::CrossOwner),
2079+ None => return Err(StoreError::NotFound),
2080+ }
2081+ let conn = self.conn.lock().await;
2082+ let mut rows = conn
2083+ .query(
2084+ "SELECT kind, target_id, user_id, can_download, created_at FROM share_user \
2085+ WHERE kind = ?1 AND target_id = ?2 ORDER BY created_at DESC, user_id",
2086+ params![kind.as_str(), target_id],
2087+ )
2088+ .await
2089+ .map_err(backend)?;
2090+ let mut out = Vec::new();
2091+ while let Some(row) = rows.next().await.map_err(backend)? {
2092+ out.push(ShareUser {
2093+ kind: ShareKind::parse(&text(&row, 0)?)?,
2094+ target_id: text(&row, 1)?,
2095+ user_id: text(&row, 2)?,
2096+ can_download: row.get::<i64>(3).map_err(backend)? != 0,
2097+ created_at: parse_stamp(&text(&row, 4)?)?,
2098+ });
2099+ }
2100+ Ok(out)
2101+ }
2102+
2067 async fn shares_for_user(&self, user_id: &str) -> Result<Vec<SharedItem>> {2103 async fn shares_for_user(&self, user_id: &str) -> Result<Vec<SharedItem>> {
2068 let conn = self.conn.lock().await;2104 let conn = self.conn.lock().await;
2069 let mut rows = conn2105 let mut rows = conn
crates/in-core/tests/store.rsmodified+34 -0
@@ -1127,6 +1127,40 @@ async fn add_share_user_needs_the_owner() {
1127 assert!(scratch.store.can_see(ShareKind::File, &file.id, &stranger.id).await.unwrap());1127 assert!(scratch.store.can_see(ShareKind::File, &file.id, &stranger.id).await.unwrap());
1128 }1128 }
1129 1129
1130+#[tokio::test]
1131+async fn shares_for_target_lists_grants_for_the_owner() {
1132+ let scratch = Scratch::open().await;
1133+ let user = alice(&scratch.store).await;
1134+ let friend = bob(&scratch.store).await;
1135+ let stranger = scratch.store.provision_user("sub-caro", "caro@example.com", "Caro", 1024).await.unwrap();
1136+ let file = scratch.store.insert_file(&user.id, None, "mine", b"data").await.unwrap();
1137+ // No grants yet.
1138+ assert!(scratch.store.shares_for_target(&user.id, ShareKind::File, &file.id).await.unwrap().is_empty());
1139+ // A stranger may not list another owner's grants; a missing target is
1140+ // not-found, like the sibling share writes answer.
1141+ assert!(matches!(
1142+ scratch.store.shares_for_target(&stranger.id, ShareKind::File, &file.id).await,
1143+ Err(StoreError::CrossOwner)
1144+ ));
1145+ assert!(matches!(
1146+ scratch.store.shares_for_target(&user.id, ShareKind::File, "missing").await,
1147+ Err(StoreError::NotFound)
1148+ ));
1149+ scratch.store.add_share_user(&user.id, ShareKind::File, &file.id, &friend.id, true).await.unwrap();
1150+ scratch.store.add_share_user(&user.id, ShareKind::File, &file.id, &stranger.id, false).await.unwrap();
1151+ let grants = scratch.store.shares_for_target(&user.id, ShareKind::File, &file.id).await.unwrap();
1152+ assert_eq!(grants.len(), 2);
1153+ let flag_of = |id: &str| grants.iter().find(|grant| grant.user_id == id).map(|grant| grant.can_download);
1154+ assert_eq!(flag_of(&friend.id), Some(true));
1155+ assert_eq!(flag_of(&stranger.id), Some(false));
1156+ // A trashed target lists as not-found, like the sibling share writes.
1157+ scratch.store.delete_file(&file.id).await.unwrap();
1158+ assert!(matches!(
1159+ scratch.store.shares_for_target(&user.id, ShareKind::File, &file.id).await,
1160+ Err(StoreError::NotFound)
1161+ ));
1162+}
1163+
1130 #[tokio::test]1164 #[tokio::test]
1131 async fn a_provisioned_user_wears_the_default_preferences() {1165 async fn a_provisioned_user_wears_the_default_preferences() {
1132 let scratch = Scratch::open().await;1166 let scratch = Scratch::open().await;
crates/in-web/src/drive.rsmodified+150 -17
@@ -441,7 +441,7 @@ async fn drive(cx: &Cx) -> Result {
441 }441 }
442 }442 }
443 <form class="field-box field-box-search" method="get" action="/drive">443 <form class="field-box field-box-search" method="get" action="/drive">
444- <span class="field-text">(t(language, Key::SearchPlaceholder))</span>444+ <span class="field-text">(t(language, Key::NavSearch))</span>
445 <input445 <input
446 class="dd-search"446 class="dd-search"
447 type="search"447 type="search"
@@ -535,7 +535,9 @@ async fn drive(cx: &Cx) -> Result {
535 <form id="upload-form" class="file-upload" method="post" action="/files"535 <form id="upload-form" class="file-upload" method="post" action="/files"
536 enctype="multipart/form-data" data-hard=""536 enctype="multipart/form-data" data-hard=""
537 data-failed-label=(t(language, Key::UploadFailed))537 data-failed-label=(t(language, Key::UploadFailed))
538- data-complete-label=(t(language, Key::UploadComplete))>538+ data-complete-label=(t(language, Key::UploadComplete))
539+ data-cancel-label=(t(language, Key::CancelUpload))
540+ data-canceled-label=(t(language, Key::UploadCanceled))>
539 <input type="hidden" name="folder_id" value=(current_id.clone())>541 <input type="hidden" name="folder_id" value=(current_id.clone())>
540 <input id="drive-upload-input" class="file-upload-input" type="file" name="file" multiple="">542 <input id="drive-upload-input" class="file-upload-input" type="file" name="file" multiple="">
541 </form>543 </form>
@@ -593,6 +595,8 @@ async fn drive(cx: &Cx) -> Result {
593 <div class="user-menu-panel">595 <div class="user-menu-panel">
594 <a class="user-menu-item"596 <a class="user-menu-item"
595 href=(format!("{here}{edit_sep}edit={}", folder.id))>(t(language, Key::Rename))</a>597 href=(format!("{here}{edit_sep}edit={}", folder.id))>(t(language, Key::Rename))</a>
598+ <a class="user-menu-item"
599+ href=(format!("/share/folder/{}", folder.id))>(t(language, Key::Share))</a>
596 <form class="user-menu-item-form" method="post" action="/api/folder/move">600 <form class="user-menu-item-form" method="post" action="/api/folder/move">
597 <input type="hidden" name="id" value=(folder.id.clone())>601 <input type="hidden" name="id" value=(folder.id.clone())>
598 <div class="user-menu-item-move">602 <div class="user-menu-item-move">
@@ -642,6 +646,8 @@ async fn drive(cx: &Cx) -> Result {
642 <div class="user-menu-panel">646 <div class="user-menu-panel">
643 <a class="user-menu-item"647 <a class="user-menu-item"
644 href=(format!("{here}{edit_sep}edit={}", file.id))>(t(language, Key::Rename))</a>648 href=(format!("{here}{edit_sep}edit={}", file.id))>(t(language, Key::Rename))</a>
649+ <a class="user-menu-item"
650+ href=(format!("/share/file/{}", file.id))>(t(language, Key::Share))</a>
645 <form class="user-menu-item-form" method="post" action="/api/file/move">651 <form class="user-menu-item-form" method="post" action="/api/file/move">
646 <input type="hidden" name="id" value=(file.id.clone())>652 <input type="hidden" name="id" value=(file.id.clone())>
647 <div class="user-menu-item-move">653 <div class="user-menu-item-move">
@@ -669,6 +675,7 @@ async fn drive(cx: &Cx) -> Result {
669 </main>675 </main>
670 (crate::dropdown::dropdown_script(cx).await?)676 (crate::dropdown::dropdown_script(cx).await?)
671 (upload_script(cx).await?)677 (upload_script(cx).await?)
678+ (options_menu_script(cx).await?)
672 }679 }
673 }680 }
674 681
@@ -703,8 +710,12 @@ fn query_value(query: &str, key: &str) -> Option<String> {
703 /// The upload control's client half: files under 8 MiB ride one multipart710 /// The upload control's client half: files under 8 MiB ride one multipart
704 /// post, files at or over it are split into the chunked protocol's calls —711 /// post, files at or over it are split into the chunked protocol's calls —
705 /// and every upload, small or big, draws the same live progress row (name,712 /// and every upload, small or big, draws the same live progress row (name,
706-/// bar, percent) into the persistent `#in-status` corner stack, which the713+/// bar, percent, cancel) into the persistent `#in-status` corner stack,
707-/// document shell renders on every page.714+/// which the document shell renders on every page. Cancel aborts the small
715+/// path's XHR, or stops the chunked loop and posts the session's abort
716+/// endpoint — the abort handle rides the `window.__inUploads` mirror entry,
717+/// so the row's ✕ keeps working across soft navigations — then the row
718+/// drops and the canceled card announces through `window.__inNotify`.
708 ///719 ///
709 /// The form wears `data-hard` so the soft-nav's multipart replay leaves it720 /// The form wears `data-hard` so the soft-nav's multipart replay leaves it
710 /// alone — two uploaders racing the same bytes would double-insert, and the721 /// alone — two uploaders racing the same bytes would double-insert, and the
@@ -781,9 +792,19 @@ async fn upload_script(cx: &Cx) -> Result {
781 track.appendChild(fill); \792 track.appendChild(fill); \
782 var pct = document.createElement('span'); \793 var pct = document.createElement('span'); \
783 pct.className = 'upload-progress-pct'; \794 pct.className = 'upload-progress-pct'; \
795+ var shut = document.createElement('button'); \
796+ shut.type = 'button'; \
797+ shut.className = 'upload-progress-cancel'; \
798+ shut.textContent = '✕'; \
799+ if (u.cancelLabel) { shut.setAttribute('aria-label', u.cancelLabel); } \
800+ shut.addEventListener('click', function () { \
801+ shut.disabled = true; \
802+ if (u.cancel) { u.cancel(); } \
803+ }); \
784 row.appendChild(name); \804 row.appendChild(name); \
785 row.appendChild(track); \805 row.appendChild(track); \
786 row.appendChild(pct); \806 row.appendChild(pct); \
807+ row.appendChild(shut); \
787 box.appendChild(window.__inAdded(row)); \808 box.appendChild(window.__inAdded(row)); \
788 } \809 } \
789 var text = Math.min(100, Math.round(u.frac * 100)) + '%'; \810 var text = Math.min(100, Math.round(u.frac * 100)) + '%'; \
@@ -798,7 +819,14 @@ async fn upload_script(cx: &Cx) -> Result {
798 } \819 } \
799 function bar(label) { \820 function bar(label) { \
800 if (!window.__inUploads) { window.__inUploads = []; } \821 if (!window.__inUploads) { window.__inUploads = []; } \
801- var u = { id: upSeq(), name: label || '', frac: 0 }; \822+ var form = document.getElementById('upload-form'); \
823+ var cancelLabel = (form && form.getAttribute('data-cancel-label')) || ''; \
824+ var u = { id: upSeq(), name: label || '', frac: 0, cancelLabel: cancelLabel }; \
825+ /* A cancel landing before the transport arms itself (the \
826+ start round-trip) still counts: the flag below stops the \
827+ loop at the next boundary, and sendBig aborts a session \
828+ minted after the click. */ \
829+ u.cancel = function () { u.cancelled = true; }; \
802 window.__inUploads.push(u); \830 window.__inUploads.push(u); \
803 renderUploads(); \831 renderUploads(); \
804 return u; \832 return u; \
@@ -827,6 +855,10 @@ async fn upload_script(cx: &Cx) -> Result {
827 function notify(kind, message) { \855 function notify(kind, message) { \
828 if (window.__inNotify) { window.__inNotify(kind, message); } \856 if (window.__inNotify) { window.__inNotify(kind, message); } \
829 } \857 } \
858+ /* Cancel is not a failure: the rejection below carries a flag the \
859+ submit handler reads, so a deliberate cancel announces the \
860+ canceled card instead of the failed one. */ \
861+ function canceledErr() { var e = new Error('canceled'); e.canceled = true; return e; } \
830 async function startChunked(folder, name, size) { \862 async function startChunked(folder, name, size) { \
831 var r = await fetch('/api/upload/start', { \863 var r = await fetch('/api/upload/start', { \
832 method: 'POST', \864 method: 'POST', \
@@ -837,31 +869,68 @@ async fn upload_script(cx: &Cx) -> Result {
837 if (!answer.ok) { throw new Error(answer.err || 'start'); } \869 if (!answer.ok) { throw new Error(answer.err || 'start'); } \
838 return answer.ok; \870 return answer.ok; \
839 } \871 } \
840- async function sendBig(file, folder, onProgress) { \872+ async function sendBig(file, folder, onProgress, u) { \
841 var session = await startChunked(folder, file.name, file.size); \873 var session = await startChunked(folder, file.name, file.size); \
874+ /* The session id lives on the mirror entry, so the row's \
875+ cancel control still reaches the abort endpoint after a \
876+ soft navigation rebuilt the page around it. A cancel that \
877+ landed during the start flight aborts the fresh session \
878+ straight away instead of leaking it. */ \
879+ if (u) { \
880+ if (u.cancelled) { \
881+ fetch('/api/upload/' + session.id + '/abort', { method: 'POST' }); \
882+ throw canceledErr(); \
883+ } \
884+ u.sessionId = session.id; \
885+ u.cancel = function () { \
886+ u.cancelled = true; \
887+ try { u.abortChunk(); } catch (err) {} \
888+ fetch('/api/upload/' + session.id + '/abort', { method: 'POST' }); \
889+ }; \
890+ } \
842 var total = Math.max(1, file.size); \891 var total = Math.max(1, file.size); \
843 var index = 0; \892 var index = 0; \
893+ var flight = null; \
894+ if (u) { \
895+ u.abortChunk = function () { if (flight) { try { flight.abort(); } catch (err) {} } }; \
896+ } \
844 for (var off = 0; off < file.size; off += LIMIT, index++) { \897 for (var off = 0; off < file.size; off += LIMIT, index++) { \
898+ if (u && u.cancelled) { throw canceledErr(); } \
845 var piece = file.slice(off, Math.min(file.size, off + LIMIT)); \899 var piece = file.slice(off, Math.min(file.size, off + LIMIT)); \
846- var r = await fetch('/api/upload/' + session.id + '/' + index, { \900+ flight = new AbortController(); \
847- method: 'PUT', \901+ var r; \
848- headers: { 'content-type': 'application/octet-stream' }, \902+ try { \
849- body: piece \903+ r = await fetch('/api/upload/' + session.id + '/' + index, { \
850- }); \904+ method: 'PUT', \
905+ headers: { 'content-type': 'application/octet-stream' }, \
906+ body: piece, \
907+ signal: flight.signal \
908+ }); \
909+ } catch (err) { \
910+ if (u && u.cancelled) { throw canceledErr(); } \
911+ throw err; \
912+ } \
851 if (!r.ok) { throw new Error('chunk'); } \913 if (!r.ok) { throw new Error('chunk'); } \
852 onProgress((off + piece.size) / total); \914 onProgress((off + piece.size) / total); \
853 } \915 } \
916+ if (u && u.cancelled) { throw canceledErr(); } \
854 var done = await fetch('/api/upload/' + session.id + '/finish', { method: 'POST' }); \917 var done = await fetch('/api/upload/' + session.id + '/finish', { method: 'POST' }); \
855 var fin = await done.json(); \918 var fin = await done.json(); \
856 if (!fin.ok) { throw new Error((fin.err) || 'finish'); } \919 if (!fin.ok) { throw new Error((fin.err) || 'finish'); } \
857 onProgress(1); \920 onProgress(1); \
858 } \921 } \
859- function sendSmall(action, folder, files, onProgress) { \922+ function sendSmall(action, folder, files, onProgress, u) { \
860 return new Promise(function (resolve, reject) { \923 return new Promise(function (resolve, reject) { \
861 var data = new FormData(); \924 var data = new FormData(); \
862 data.append('folder_id', folder); \925 data.append('folder_id', folder); \
863 files.forEach(function (f) { data.append('file', f, f.name); }); \926 files.forEach(function (f) { data.append('file', f, f.name); }); \
864 var x = new XMLHttpRequest(); \927 var x = new XMLHttpRequest(); \
928+ if (u) { \
929+ u.cancel = function () { \
930+ u.cancelled = true; \
931+ try { x.abort(); } catch (err) {} \
932+ }; \
933+ } \
865 x.open('POST', action); \934 x.open('POST', action); \
866 x.setRequestHeader('accept', 'text/html'); \935 x.setRequestHeader('accept', 'text/html'); \
867 x.upload.onprogress = function (ev) { \936 x.upload.onprogress = function (ev) { \
@@ -873,6 +942,7 @@ async fn upload_script(cx: &Cx) -> Result {
873 else { reject(new Error('small')); } \942 else { reject(new Error('small')); } \
874 }; \943 }; \
875 x.onerror = function () { reject(new Error('small')); }; \944 x.onerror = function () { reject(new Error('small')); }; \
945+ x.onabort = function () { reject(canceledErr()); }; \
876 x.send(data); \946 x.send(data); \
877 }); \947 }); \
878 } \948 } \
@@ -891,6 +961,7 @@ async fn upload_script(cx: &Cx) -> Result {
891 var big = files.filter(function (f) { return f.size >= LIMIT; }); \961 var big = files.filter(function (f) { return f.size >= LIMIT; }); \
892 var failLabel = form.getAttribute('data-failed-label') || 'upload failed'; \962 var failLabel = form.getAttribute('data-failed-label') || 'upload failed'; \
893 var doneLabel = form.getAttribute('data-complete-label') || ''; \963 var doneLabel = form.getAttribute('data-complete-label') || ''; \
964+ var canceledLabel = form.getAttribute('data-canceled-label') || ''; \
894 var landing = window.location.href; \965 var landing = window.location.href; \
895 function settle() { \966 function settle() { \
896 input.value = ''; \967 input.value = ''; \
@@ -904,24 +975,27 @@ async fn upload_script(cx: &Cx) -> Result {
904 var title = small.length === 1 ? small[0].name : (small.length + ' files'); \975 var title = small.length === 1 ? small[0].name : (small.length + ' files'); \
905 var ui = bar(title); \976 var ui = bar(title); \
906 rows.push(ui); \977 rows.push(ui); \
907- var url = await sendSmall(form.getAttribute('action'), folder, small, function (frac) { setProgress(ui, frac); }); \978+ var url = await sendSmall(form.getAttribute('action'), folder, small, function (frac) { setProgress(ui, frac); }, ui); \
908 if (url) { landing = url; } \979 if (url) { landing = url; } \
909 } \980 } \
910 for (var i = 0; i < big.length; i++) { \981 for (var i = 0; i < big.length; i++) { \
911 await (function (file) { \982 await (function (file) { \
912 var ui2 = bar(file.name); \983 var ui2 = bar(file.name); \
913 rows.push(ui2); \984 rows.push(ui2); \
914- return sendBig(file, folder, function (frac) { setProgress(ui2, frac); }); \985+ return sendBig(file, folder, function (frac) { setProgress(ui2, frac); }, ui2); \
915 })(big[i]); \986 })(big[i]); \
916 } \987 } \
917 } catch (err) { \988 } catch (err) { \
918 rows.forEach(dropRow); \989 rows.forEach(dropRow); \
919- var why = err && err.message ? err.message : String(err); \990+ if (err && err.canceled) { \
920- notify('error', failLabel + ' (' + why + ')'); \991+ if (canceledLabel) { notify('ok', canceledLabel); } \
992+ } else { \
993+ var why = err && err.message ? err.message : String(err); \
994+ notify('error', failLabel + ' (' + why + ')'); \
995+ } \
921 settle(); \996 settle(); \
922 return; \997 return; \
923 } \998 } \
924- rows.forEach(dropRow); \
925 /* A refused upload answers 303 into a refusal banner page, which the XHR follows to a 200: the banner carries the message, so only trumpet success when no refusal rode the redirect. */ \999 /* A refused upload answers 303 into a refusal banner page, which the XHR follows to a 200: the banner carries the message, so only trumpet success when no refusal rode the redirect. */ \
926 if (doneLabel && !/[?&]refusal=/.test(landing)) { notify('ok', doneLabel); } \1000 if (doneLabel && !/[?&]refusal=/.test(landing)) { notify('ok', doneLabel); } \
927 settle(); \1001 settle(); \
@@ -982,6 +1056,65 @@ async fn upload_script(cx: &Cx) -> Result {
982 view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }1056 view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }
983 }1057 }
984 1058
1059+/// The row Options menus' client half: a `<details class="entry-options">`
1060+/// panel opens downward by house CSS, which runs a single bottom row's menu
1061+/// past the viewport so Delete hides below the fold. On toggle open the
1062+/// panel is measured one frame later — the toggle fires before the open
1063+/// layout settles, so a synchronous read scrolls menus that fit — and only
1064+/// lifted via the `menu-up` variant class when it spills past the viewport
1065+/// bottom *and* fits better above (the same drop-up idea as `dropdown.rs`'s
1066+/// `place`; `iz` has no details-menu variant to port, only that panel one).
1067+/// The scroll fallback fires only when the menu spills in both directions;
1068+/// a menu that fits as-is never moves the page. Trash rows carry plain
1069+/// restore/purge forms, no menus — nothing to mirror there.
1070+///
1071+/// The Rust `\`-continuations strip newlines, so the emitted script is one
1072+/// long line: only `/* */` comments survive inside it.
1073+async fn options_menu_script(cx: &Cx) -> Result {
1074+ use topcoat::view::Unescaped;
1075+ const JS: &str = "\
1076+ (function () { \
1077+ if (window.__inEntryOptions) { return; } \
1078+ window.__inEntryOptions = true; \
1079+ /* `toggle` does not bubble, but a capture listener still sees it \
1080+ on the way down; per-details listeners would need rewiring \
1081+ after every soft swap, this one survives them. */ \
1082+ document.addEventListener('toggle', function (e) { \
1083+ var details = e.target; \
1084+ if (!details || !details.classList || !details.classList.contains('entry-options')) { return; } \
1085+ if (!details.hasAttribute('open')) { details.classList.remove('menu-up'); return; } \
1086+ var panel = details.querySelector('.user-menu-panel'); \
1087+ if (!panel) { return; } \
1088+ /* The toggle fires before the open layout settles (panel \
1089+ transition, the `:has` overflow lift), so a synchronously \
1090+ read rect is stale and the scroll fallback fired on menus \
1091+ that fit — measure one frame later, post-layout. */ \
1092+ window.requestAnimationFrame(function () { \
1093+ if (!details.hasAttribute('open')) { return; } \
1094+ details.classList.remove('menu-up'); \
1095+ /* The clipper is the nearest scrollport (the stage is a \
1096+ scroll container whose height is content-height on a \
1097+ tall window), not the viewport: an abs-positioned panel \
1098+ past the scrollport's visible bottom is trapped as \
1099+ scrollable overflow — unreadable without scrolling. */ \
1100+ var sc = details.closest('.settings-stage'); \
1101+ var roomBottom = sc ? sc.getBoundingClientRect().bottom : window.innerHeight; \
1102+ var roomTop = sc ? sc.getBoundingClientRect().top : 0; \
1103+ var down = panel.getBoundingClientRect(); \
1104+ if (down.bottom <= roomBottom - 8) { return; } \
1105+ var trigger = details.querySelector('summary'); \
1106+ var anchor = trigger ? trigger.getBoundingClientRect() : details.getBoundingClientRect(); \
1107+ var above = anchor.top - roomTop - 4; \
1108+ var below = roomBottom - anchor.bottom - 4; \
1109+ if (above >= down.height || above > below) { details.classList.add('menu-up'); } \
1110+ var r = panel.getBoundingClientRect(); \
1111+ if (r.top < roomTop && r.bottom > roomBottom) { panel.scrollIntoView({ block: 'nearest' }); } \
1112+ }); \
1113+ }, true); \
1114+ })();";
1115+ view! { cx => <script>(Unescaped::new_unchecked(JS))</script> }
1116+}
1117+
985 #[derive(serde::Deserialize)]1118 #[derive(serde::Deserialize)]
986 struct CreateFolderForm {1119 struct CreateFolderForm {
987 #[serde(default)]1120 #[serde(default)]
crates/in-web/src/i18n.rsmodified+21 -2
@@ -119,6 +119,7 @@ pub enum Key {
119 Uploading,119 Uploading,
120 UploadComplete,120 UploadComplete,
121 UploadFailed,121 UploadFailed,
122+ UploadCanceled,
122 CancelUpload,123 CancelUpload,
123 RetryUpload,124 RetryUpload,
124 // File view.125 // File view.
@@ -202,6 +203,12 @@ pub enum Key {
202 SortOwner,203 SortOwner,
203 // Settings limits redesign (SettingsBuild owns this block).204 // Settings limits redesign (SettingsBuild owns this block).
204 UploadLimitHelp,205 UploadLimitHelp,
206+ EveryoneSubtitle,
207+ UploadLimitSection,
208+ // Per-entry share page (ShareBuild owns this block).
209+ CreateLink,
210+ ExpiresInDays,
211+ NoShares,
205 }212 }
206 213
207 pub fn t(lang: Lang, key: Key) -> &'static str {214 pub fn t(lang: Lang, key: Key) -> &'static str {
@@ -254,6 +261,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
254 Uploading => "Uploading…",261 Uploading => "Uploading…",
255 UploadComplete => "Upload complete.",262 UploadComplete => "Upload complete.",
256 UploadFailed => "The upload failed.",263 UploadFailed => "The upload failed.",
264+ UploadCanceled => "Upload canceled.",
257 CancelUpload => "Cancel the upload",265 CancelUpload => "Cancel the upload",
258 RetryUpload => "Try again",266 RetryUpload => "Try again",
259 FileDetails => "File",267 FileDetails => "File",
@@ -326,7 +334,12 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
326 KindFiles => "Files",334 KindFiles => "Files",
327 SortDeleted => "Deleted",335 SortDeleted => "Deleted",
328 SortOwner => "Owner",336 SortOwner => "Owner",
329- UploadLimitHelp => "The most one uploaded file may be. Applies to everyone.",337+ UploadLimitHelp => "The most one uploaded file may be.",
338+ EveryoneSubtitle => "Per-person storage quotas below; the single-file upload limit follows.",
339+ UploadLimitSection => "Upload limit — applies to everyone.",
340+ CreateLink => "Create link",
341+ ExpiresInDays => "Expires in days",
342+ NoShares => "Not shared with anyone yet.",
330 },343 },
331 Lang::Tr => match key {344 Lang::Tr => match key {
332 Cancel => "Vazgeç",345 Cancel => "Vazgeç",
@@ -375,6 +388,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
375 Uploading => "Yükleniyor…",388 Uploading => "Yükleniyor…",
376 UploadComplete => "Yükleme tamamlandı.",389 UploadComplete => "Yükleme tamamlandı.",
377 UploadFailed => "Yükleme başarısız oldu.",390 UploadFailed => "Yükleme başarısız oldu.",
391+ UploadCanceled => "Yükleme iptal edildi.",
378 CancelUpload => "Yüklemeyi iptal et",392 CancelUpload => "Yüklemeyi iptal et",
379 RetryUpload => "Yeniden dene",393 RetryUpload => "Yeniden dene",
380 FileDetails => "Dosya",394 FileDetails => "Dosya",
@@ -447,7 +461,12 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
447 KindFiles => "Dosyalar",461 KindFiles => "Dosyalar",
448 SortDeleted => "Silindi",462 SortDeleted => "Silindi",
449 SortOwner => "Sahibi",463 SortOwner => "Sahibi",
450- UploadLimitHelp => "Tek bir dosyanın alabileceği en büyük boyut. Herkes için geçerlidir.",464+ UploadLimitHelp => "Tek bir dosyanın alabileceği en büyük boyut.",
465+ EveryoneSubtitle => "Aşağıda kişi başına depolama kotaları; ardından herkes için geçerli tek dosyalık yükleme sınırı.",
466+ UploadLimitSection => "Yükleme sınırı — herkes için geçerlidir.",
467+ CreateLink => "Bağlantı oluştur",
468+ ExpiresInDays => "Bitiş (gün)",
469+ NoShares => "Henüz kimseyle paylaşılmadı.",
451 },470 },
452 }471 }
453 }472 }
crates/in-web/src/settings.rsmodified+38 -27
@@ -4,13 +4,15 @@
4 //! quota usage bar beside it, and the reader's own live share links with4 //! quota usage bar beside it, and the reader's own live share links with
5 //! their revoke buttons — including the copy-once banner after a creation5 //! their revoke buttons — including the copy-once banner after a creation
6 //! (`?created=<token>` on the query, rendered once and never stored).6 //! (`?created=<token>` on the query, rendered once and never stored).
7-//! Admins additionally see every account with its quota and disabled flag.7+//! Admins additionally see every account with its quota and disabled flag,
8-//! `POST /api/settings/quota|disable` are admin-only: the first sets a8+//! plus the instance-wide per-file upload limit in the same Everyone panel.
9-//! user's byte quota, the second disables or re-enables them (a disabled9+//! `POST /api/settings/quota|disable|upload-limit` are admin-only: the first
10+//! sets a user's byte quota, the second disables or re-enables them (a disabled
10 //! account reads as signed-out everywhere, the im session untouched, and11 //! account reads as signed-out everywhere, the im session untouched, and
11-//! disabling yourself is refused).12+//! disabling yourself is refused), and the third sets the per-file ceiling
13+//! for the whole install.
12 14
13-use in_core::store::User;15+use in_core::store::{ShareKind, User};
14 use serde::Deserialize;16 use serde::Deserialize;
15 use topcoat::Result;17 use topcoat::Result;
16 use topcoat::context::Cx;18 use topcoat::context::Cx;
@@ -280,12 +282,26 @@ async fn settings(cx: &Cx) -> Result {
280 .iter()282 .iter()
281 .filter(|link| link.revoked_at.is_none())283 .filter(|link| link.revoked_at.is_none())
282 .collect();284 .collect();
285+ // The display name per live link's target: the row carries only the id.
286+ // A missing or trashed target keeps its id — the grant row outlives the
287+ // trash, and the panel still revokes it. Enrichment never fails the
288+ // page: an unreadable target reads as its id, the way the shared list
289+ // degrades per row.
290+ let mut link_names: Vec<(&in_core::store::ShareLink, String)> = Vec::new();
291+ for link in &live_links {
292+ let name = match link.kind {
293+ ShareKind::File => store.file(&link.target_id).await.ok().flatten().map(|file| file.name),
294+ ShareKind::Folder => store.folder(&link.target_id).await.ok().flatten().map(|folder| folder.name),
295+ }
296+ .unwrap_or_else(|| link.target_id.clone());
297+ link_names.push((*link, name));
298+ }
283 let users = if fresh.admin {299 let users = if fresh.admin {
284 store.users().await?300 store.users().await?
285 } else {301 } else {
286 Vec::new()302 Vec::new()
287 };303 };
288- // The live per-file ceiling, read once for the admin panel below. Only304+ // The live per-file ceiling, read once for the Everyone panel below. Only
289 // admins see it, so only they pay the extra setting read.305 // admins see it, so only they pay the extra setting read.
290 let upload_limit = if fresh.admin {306 let upload_limit = if fresh.admin {
291 Some(crate::server::effective_upload_limit(cx).await)307 Some(crate::server::effective_upload_limit(cx).await)
@@ -368,9 +384,9 @@ async fn settings(cx: &Cx) -> Result {
368 if live_links.is_empty() {384 if live_links.is_empty() {
369 <p class="field-note">(t(language, Key::NoLinks))</p>385 <p class="field-note">(t(language, Key::NoLinks))</p>
370 }386 }
371- for link in live_links {387+ for (link, target_name) in &link_names {
372 <div class="member-row">388 <div class="member-row">
373- <span class="member-name">(format!("{} · {}", link.kind.as_str(), link.target_id.clone()))</span>389+ <span class="member-name">(format!("{} · {}", link.kind.as_str(), target_name.clone()))</span>
374 <span class="field-note">(expiry_line(language, link.expires_at))</span>390 <span class="field-note">(expiry_line(language, link.expires_at))</span>
375 <span class="field-note">(if link.can_download { t(language, Key::CanDownload) } else { t(language, Key::ViewOnly) })</span>391 <span class="field-note">(if link.can_download { t(language, Key::CanDownload) } else { t(language, Key::ViewOnly) })</span>
376 <form class="pop-row-form" method="post" action="/api/share/link/revoke">392 <form class="pop-row-form" method="post" action="/api/share/link/revoke">
@@ -382,30 +398,12 @@ async fn settings(cx: &Cx) -> Result {
382 </div>398 </div>
383 </section>399 </section>
384 if fresh.admin {400 if fresh.admin {
385- if let Some(limit) = upload_limit {
386- <section class="panel">
387- <div class="panel-head">
388- <h2 class="panel-title">(t(language, Key::UploadLimits))</h2>
389- </div>
390- <div class="panel-body">
391- <p class="field-note">(t(language, Key::UploadLimitHelp))</p>
392- <form class="pop-row-form" method="post" action="/api/settings/upload-limit">
393- <span class="field-note">(format!("{}: {}", t(language, Key::CurrentUploadLimit), human_bytes(limit)))</span>
394- <input class="field-input" type="number" name="max_upload" min="0" step="any" value=(bytes_as_unit(limit).0) aria-label=(t(language, Key::MaxUploadBytes))>
395- <select class="field-input" name="max_upload_unit" aria-label=(t(language, Key::MaxUploadBytes))>
396- <option value="MiB" selected=(bytes_as_unit(limit).1 == "MiB")>"MiB"</option>
397- <option value="GiB" selected=(bytes_as_unit(limit).1 == "GiB")>"GiB"</option>
398- </select>
399- <button class="quiet" type="submit">(t(language, Key::Save))</button>
400- </form>
401- </div>
402- </section>
403- }
404 <section class="panel">401 <section class="panel">
405 <div class="panel-head">402 <div class="panel-head">
406 <h2 class="panel-title">(t(language, Key::AdminPanel))</h2>403 <h2 class="panel-title">(t(language, Key::AdminPanel))</h2>
407 </div>404 </div>
408 <div class="panel-body">405 <div class="panel-body">
406+ <p class="field-note">(t(language, Key::EveryoneSubtitle))</p>
409 <div class="table-pan">407 <div class="table-pan">
410 <table class="member-table">408 <table class="member-table">
411 <thead>409 <thead>
@@ -460,6 +458,19 @@ async fn settings(cx: &Cx) -> Result {
460 </tbody>458 </tbody>
461 </table>459 </table>
462 </div>460 </div>
461+ if let Some(limit) = upload_limit {
462+ <p class="field-note">(t(language, Key::UploadLimitSection))</p>
463+ <p class="field-note">(t(language, Key::UploadLimitHelp))</p>
464+ <form class="pop-row-form" method="post" action="/api/settings/upload-limit">
465+ <span class="field-note">(format!("{}: {}", t(language, Key::CurrentUploadLimit), human_bytes(limit)))</span>
466+ <input class="field-input" type="number" name="max_upload" min="0" step="any" value=(bytes_as_unit(limit).0) aria-label=(t(language, Key::MaxUploadBytes))>
467+ <select class="field-input" name="max_upload_unit" aria-label=(t(language, Key::MaxUploadBytes))>
468+ <option value="MiB" selected=(bytes_as_unit(limit).1 == "MiB")>"MiB"</option>
469+ <option value="GiB" selected=(bytes_as_unit(limit).1 == "GiB")>"GiB"</option>
470+ </select>
471+ <button class="quiet" type="submit">(t(language, Key::Save))</button>
472+ </form>
473+ }
463 </div>474 </div>
464 </section>475 </section>
465 }476 }
crates/in-web/src/share.rsmodified+212 -4
@@ -17,15 +17,16 @@
17 //! render the copy-once banner off that pair.17 //! render the copy-once banner off that pair.
18 18
19 use in_core::hash_share_token;19 use in_core::hash_share_token;
20-use in_core::store::{ShareKind, Store, StoreError, ThumbState, User};20+use in_core::store::{File, ShareKind, Store, StoreError, ThumbState, User};
21 use serde::Deserialize;21 use serde::Deserialize;
22 use time::OffsetDateTime;22 use time::OffsetDateTime;
23 use topcoat::Result;23 use topcoat::Result;
24 use topcoat::context::Cx;24 use topcoat::context::Cx;
25+use topcoat::router::error::not_found as page_not_found;
25 use topcoat::router::content::Form;26 use topcoat::router::content::Form;
26 use topcoat::router::request::{headers as request_headers, uri};27 use topcoat::router::request::{headers as request_headers, uri};
27 use topcoat::router::response::IntoResponse;28 use topcoat::router::response::IntoResponse;
28-use topcoat::router::{HeaderName, StatusCode, header, page, path_param, query_params, route};29+use topcoat::router::{HeaderName, HeaderValue, StatusCode, header, page, path_param, query_params, route};
29 use topcoat::view::view;30 use topcoat::view::view;
30 31
31 use crate::i18n::{Key, Lang, lang, t};32 use crate::i18n::{Key, Lang, lang, t};
@@ -34,6 +35,8 @@ use crate::layout::{NavPage, topbar, wordmark};
34 use crate::server::{Refusal, app, back_to, require_user};35 use crate::server::{Refusal, app, back_to, require_user};
35 36
36 path_param!(token);37 path_param!(token);
38+path_param!(kind);
39+path_param!(id);
37 40
38 /// A refusal surfaced as a banner: the `?refusal=<code>&on=<call>` pair the41 /// A refusal surfaced as a banner: the `?refusal=<code>&on=<call>` pair the
39 /// mutation redirects carry, rendered only when `on` names one of `calls` —42 /// mutation redirects carry, rendered only when `on` names one of `calls` —
@@ -214,7 +217,9 @@ async fn create_link(cx: &Cx, Form(input): Form<CreateLinkForm>) -> Redirect {
214 &user.id,217 &user.id,
215 kind,218 kind,
216 &input.target_id,219 &input.target_id,
217- parse_flag(input.can_download.as_deref(), true),220+ // Absent means the checkbox came unchecked: view-only. A checked
221+ // box posts `1`; nothing posted must never mint a download.
222+ parse_flag(input.can_download.as_deref(), false),
218 expires_at,223 expires_at,
219 )224 )
220 .await;225 .await;
@@ -322,7 +327,9 @@ async fn add_share(cx: &Cx, Form(input): Form<ShareUserForm>) -> Redirect {
322 kind,327 kind,
323 &input.target_id,328 &input.target_id,
324 &grantee.id,329 &grantee.id,
325- parse_flag(input.can_download.as_deref(), true),330+ // Absent means the checkbox came unchecked: view-only, like the
331+ // sibling link creator above.
332+ parse_flag(input.can_download.as_deref(), false),
326 )333 )
327 .await334 .await
328 {335 {
@@ -1041,3 +1048,204 @@ fn access_chip(language: Lang, can_download: bool) -> &'static str {
1041 t(language, Key::ViewOnly)1048 t(language, Key::ViewOnly)
1042 }1049 }
1043 }1050 }
1051+
1052+/// `GET /share/{kind}/{id}`: one entry's share surface — the page the drive
1053+/// row's Share item links to. Owner only: a signed-out reader goes back to
1054+/// the landing, and anyone else — a stranger, or a missing or trashed target
1055+/// — answers not-found, the way the other owner surfaces do.
1056+///
1057+/// The public-link panel twins the settings page's shape: the live links for
1058+/// this target with their expiry line, access chip and revoke form — or, when
1059+/// none is live, the create form. The token's copy-once banner renders off
1060+/// the create redirect's `?created=` pair, which lands back here through the
1061+/// posting form's `Referer`, so no handler change was needed. The people
1062+/// panel lists this target's grants with remove forms, plus the add form.
1063+#[page("/share/{kind}/{id}")]
1064+async fn share_entry(cx: &Cx) -> Result {
1065+ let kind_raw: &str = path_param::<Kind>(cx);
1066+ let target_id: &str = path_param::<Id>(cx);
1067+ let Some(kind) = parse_kind(kind_raw) else {
1068+ return Err(page_not_found().into());
1069+ };
1070+ let user = match require_user(cx).await {
1071+ Ok(user) => user,
1072+ Err(_) => {
1073+ let location = (header::LOCATION, HeaderValue::from_static("/"));
1074+ return view! {
1075+ cx =>
1076+ (StatusCode::SEE_OTHER)
1077+ (location)
1078+ };
1079+ }
1080+ };
1081+ let language = lang(cx).await;
1082+ let store = app(cx).store.clone();
1083+ // The owned, live target: present, untrashed, and theirs. Anything else
1084+ // is not-found — a stranger learns nothing about whose it is.
1085+ let (name, file): (String, Option<File>) = match kind {
1086+ ShareKind::File => {
1087+ let Some(file) = store.file(target_id).await? else {
1088+ return Err(page_not_found().into());
1089+ };
1090+ if file.owner_id != user.id || file.deleted_at.is_some() {
1091+ return Err(page_not_found().into());
1092+ }
1093+ (file.name.clone(), Some(file))
1094+ }
1095+ ShareKind::Folder => {
1096+ let Some(folder) = store.folder(target_id).await? else {
1097+ return Err(page_not_found().into());
1098+ };
1099+ if folder.owner_id != user.id || folder.deleted_at.is_some() {
1100+ return Err(page_not_found().into());
1101+ }
1102+ (folder.name.clone(), None)
1103+ }
1104+ };
1105+ // The live links for this target alone, newest first — the settings page
1106+ // lists every link; this page owns just its entry's.
1107+ let links = store.share_links(&user.id).await?;
1108+ let live: Vec<_> = links
1109+ .iter()
1110+ .filter(|link| link.kind == kind && link.target_id == target_id && link.revoked_at.is_none())
1111+ .collect();
1112+ // The grants on this target. The ownership read above already vetted the
1113+ // caller, so a refusal here is only ever the target going missing
1114+ // mid-page — still not-found, never a leak.
1115+ let grants = match store.shares_for_target(&user.id, kind, target_id).await {
1116+ Ok(grants) => grants,
1117+ Err(StoreError::NotFound) | Err(StoreError::CrossOwner) => {
1118+ return Err(page_not_found().into());
1119+ }
1120+ Err(error) => return Err(error.into()),
1121+ };
1122+ let mut people: Vec<(String, String, bool)> = Vec::new();
1123+ for grant in &grants {
1124+ if let Some(grantee) = store.user(&grant.user_id).await? {
1125+ people.push((grantee.display_name, grantee.email, grant.can_download));
1126+ }
1127+ }
1128+ let created = created_token(uri(cx).query().unwrap_or(""));
1129+ let origin = app(cx).config.listen_url();
1130+ view! {
1131+ cx =>
1132+ (topbar(cx, NavPage::Drive, &user, language).await?)
1133+ <main class="settings-stage stage-wide">
1134+ <div class="viewer-head">
1135+ <a class="quiet" href="/drive">(t(language, Key::BackToDrive))</a>
1136+ </div>
1137+ <h1 class="settings-title viewer-title">
1138+ if kind == ShareKind::Folder {
1139+ <span class="file-chip file-chip-folder" aria-hidden="true">"▤"</span>
1140+ }
1141+ if let Some(file) = file.as_ref() {
1142+ (entry_chip(cx, file).await?)
1143+ }
1144+ (name.clone())
1145+ </h1>
1146+ <p class="field-note">(kind.as_str())</p>
1147+ (refusal_banner(cx, language, &["create", "revoke", "add", "remove"]).await?)
1148+ if let Some(token) = created {
1149+ <section class="panel">
1150+ <div class="panel-head">
1151+ <h2 class="panel-title">(t(language, Key::LinkCreated))</h2>
1152+ </div>
1153+ <div class="panel-body">
1154+ <p class="field-note">(t(language, Key::CopyLinkOnce))</p>
1155+ <p class="member-link-value">(format!("{origin}/s/{token}"))</p>
1156+ </div>
1157+ </section>
1158+ }
1159+ <section class="panel">
1160+ <div class="panel-head">
1161+ <h2 class="panel-title">(t(language, Key::ShareLink))</h2>
1162+ </div>
1163+ <div class="panel-body">
1164+ if live.is_empty() {
1165+ <form class="pop-row-form" method="post" action="/api/share/link/create">
1166+ <input type="hidden" name="kind" value=(kind.as_str())>
1167+ <input type="hidden" name="target_id" value=(target_id.to_string())>
1168+ <label class="field">
1169+ <input type="checkbox" name="can_download" value="1" checked="">
1170+ <span class="field-label">(t(language, Key::CanDownload))</span>
1171+ </label>
1172+ <label class="field">
1173+ <span class="field-label">(t(language, Key::ExpiresInDays))</span>
1174+ <input class="field-input" type="number" name="expires_in_days" min="1" step="1">
1175+ </label>
1176+ <button type="submit">(t(language, Key::CreateLink))</button>
1177+ </form>
1178+ }
1179+ for link in live {
1180+ <div class="member-row">
1181+ <span class="member-name">(format!("{} · {}", link.kind.as_str(), name.clone()))</span>
1182+ <span class="field-note">(expiry_line(language, link.expires_at))</span>
1183+ <span class="field-note">(access_chip(language, link.can_download))</span>
1184+ <form class="pop-row-form" method="post" action="/api/share/link/revoke">
1185+ <input type="hidden" name="id" value=(link.id.clone())>
1186+ <button type="submit">(t(language, Key::RevokeLink))</button>
1187+ </form>
1188+ </div>
1189+ }
1190+ </div>
1191+ </section>
1192+ <section class="panel">
1193+ <div class="panel-head">
1194+ <h2 class="panel-title">(t(language, Key::SharedWith))</h2>
1195+ </div>
1196+ <div class="panel-body">
1197+ if people.is_empty() {
1198+ <p class="field-note">(t(language, Key::NoShares))</p>
1199+ }
1200+ for person in &people {
1201+ <div class="member-row">
1202+ <span class="member-name">(person.0.clone())</span>
1203+ <span class="field-note">(person.1.clone())</span>
1204+ <span class="field-note">(access_chip(language, person.2))</span>
1205+ <form class="pop-row-form" method="post" action="/api/share/user/remove">
1206+ <input type="hidden" name="kind" value=(kind.as_str())>
1207+ <input type="hidden" name="target_id" value=(target_id.to_string())>
1208+ <input type="hidden" name="email" value=(person.1.clone())>
1209+ <button type="submit">(t(language, Key::RemoveAccess))</button>
1210+ </form>
1211+ </div>
1212+ }
1213+ <form class="pop-row-form" method="post" action="/api/share/user/add">
1214+ <input type="hidden" name="kind" value=(kind.as_str())>
1215+ <input type="hidden" name="target_id" value=(target_id.to_string())>
1216+ <input class="field-input" type="email" name="email" required="" placeholder=(t(language, Key::SharePlaceholder)) aria-label=(t(language, Key::EmailAddress))>
1217+ <label class="field">
1218+ <input type="checkbox" name="can_download" value="1" checked="">
1219+ <span class="field-label">(t(language, Key::CanDownload))</span>
1220+ </label>
1221+ <button type="submit">(t(language, Key::Share))</button>
1222+ </form>
1223+ </div>
1224+ </section>
1225+ </main>
1226+ }
1227+}
1228+
1229+/// The just-minted token off the redirect's `?created=` pair, if present.
1230+/// Twins the drive and settings pages' helper; all three render the same
1231+/// copy-once banner off the same pair.
1232+fn created_token(query: &str) -> Option<String> {
1233+ query.split('&').find_map(|pair| {
1234+ let (name, value) = pair.split_once('=')?;
1235+ (name == "created" && !value.is_empty()).then(|| value.to_string())
1236+ })
1237+}
1238+
1239+/// When the link stops opening, or never on its own. Twins the settings
1240+/// page's helper; the share page renders the same expiry line.
1241+fn expiry_line(language: Lang, expires_at: Option<OffsetDateTime>) -> String {
1242+ match expires_at {
1243+ Some(at) => format!(
1244+ "{} {}",
1245+ t(language, Key::ExpiresLabel),
1246+ at.format(&time::format_description::well_known::Rfc3339)
1247+ .unwrap_or_else(|_| "?".to_string())
1248+ ),
1249+ None => t(language, Key::NeverExpires).to_string(),
1250+ }
1251+}
crates/in-web/tests/http.rsmodified+64 -1
@@ -1365,6 +1365,69 @@ async fn view_only_link_download_is_dead_card() {
1365 );1365 );
1366 }1366 }
1367 1367
1368+/// An unchecked `can_download` box posts nothing at all, and nothing posted
1369+/// must never mint a download: the absent flag reads view-only, the way an
1370+/// explicitly refused one does — while the checked box still opens the bytes.
1371+#[tokio::test]
1372+async fn link_create_without_the_flag_is_view_only() {
1373+ let app = TestApp::build().await;
1374+ let admin = app.sign_in("sub-admin", "ada@in.test", "Ada").await;
1375+ let owner = owner_of(&app, "sub-admin").await;
1376+ let file = file_id(&app, &owner, "plain.txt", b"plain bytes").await;
1377+ // No can_download pair — what an unchecked checkbox posts.
1378+ let answer = app
1379+ .post(
1380+ "/api/share/link/create",
1381+ Some(&admin),
1382+ &[("kind", "file"), ("target_id", &file)],
1383+ )
1384+ .await;
1385+ assert!(answer.accepted(), "create refused: {:?}", answer.location);
1386+ let token = created_token(answer.location.as_deref().unwrap());
1387+ let page = app.get(&format!("/s/{token}"), None).await;
1388+ assert_eq!(page.status, StatusCode::OK, "{}", page.text());
1389+ assert!(page.text().contains("plain.txt"), "{}", page.text());
1390+ let blocked = app.get(&format!("/s/{token}?dl=1"), None).await;
1391+ assert_eq!(blocked.status, StatusCode::OK, "{}", blocked.text());
1392+ assert!(
1393+ blocked.text().contains("no longer works"),
1394+ "absent-flag download showed: {}",
1395+ blocked.text()
1396+ );
1397+ // Both share surfaces print the target's name, never its raw id.
1398+ let named = app.get(&format!("/share/file/{file}"), Some(&admin)).await;
1399+ assert_eq!(named.status, StatusCode::OK, "{}", named.text());
1400+ assert!(
1401+ named.text().contains("file · plain.txt"),
1402+ "share page showed no name: {}",
1403+ named.text()
1404+ );
1405+ let settings = app.get("/settings", Some(&admin)).await;
1406+ assert_eq!(settings.status, StatusCode::OK, "{}", settings.text());
1407+ assert!(
1408+ settings.text().contains("file · plain.txt"),
1409+ "settings panel showed no name: {}",
1410+ settings.text()
1411+ );
1412+ // The checked box still opens the bytes.
1413+ let answer = app
1414+ .post(
1415+ "/api/share/link/create",
1416+ Some(&admin),
1417+ &[
1418+ ("kind", "file"),
1419+ ("target_id", &file),
1420+ ("can_download", "1"),
1421+ ],
1422+ )
1423+ .await;
1424+ assert!(answer.accepted(), "create refused: {:?}", answer.location);
1425+ let token = created_token(answer.location.as_deref().unwrap());
1426+ let bytes = app.get(&format!("/s/{token}?dl=1"), None).await;
1427+ assert_eq!(bytes.status, StatusCode::OK);
1428+ assert_eq!(bytes.bytes, b"plain bytes");
1429+}
1430+
1368 #[tokio::test]1431 #[tokio::test]
1369 async fn folder_link_lists_and_serves_children() {1432 async fn folder_link_lists_and_serves_children() {
1370 let app = TestApp::build().await;1433 let app = TestApp::build().await;
@@ -2520,7 +2583,7 @@ async fn settings_panels_nest_inside_the_stage() {
2520 assert_eq!(page.status, StatusCode::OK, "{}", page.text());2583 assert_eq!(page.status, StatusCode::OK, "{}", page.text());
2521 let body = page.text();2584 let body = page.text();
2522 let stage = body2585 let stage = body
2523- .find("<main class=\"settings-stage\">")2586+ .find("<main class=\"settings-stage")
2524 .expect("no settings-stage");2587 .expect("no settings-stage");
2525 let close = body.find("</main>").expect("no main close");2588 let close = body.find("</main>").expect("no main close");
2526 for marker in ["panel-head", "member-table", "name=\"ui\""] {2589 for marker in ["panel-head", "member-table", "name=\"ui\""] {
style/main.scssmodified+97 -9
@@ -4661,22 +4661,19 @@ input[type="radio"] {
4661 // the house panel, chip, quiet and user-menu rules above do the rest.4661 // the house panel, chip, quiet and user-menu rules above do the rest.
4662 4662
4663 // A row never wraps: the name takes the slack as an ellipsis, every detail4663 // A row never wraps: the name takes the slack as an ellipsis, every detail
4664-// token and action holds its column. The name span in trash and public rows4664+// token and action holds its column. Trash and public names wear
4665-// is `.member-name`, which carries no geometry of its own — inside a row it4665+// `.member-name dep-title`; shared and drive names nest `.dep-title` inside
4666-// borrows the dep-title shape (flex, ellipsis, and the old-house `.dep-title`4666+// the link — the descendant selector covers both shapes, and the old-house
4667-// geometry it also wears in markup, so the ellipsis does not depend on this4667+// `.dep-title` geometry in markup holds the ellipsis even on its own.
4668-// block alone); the shared page wraps its linked names in `.dep-title`
4669-// directly.
4670-.dep-row { flex-wrap: nowrap; }
4671-
4672 .dep-row > .member-name,4668 .dep-row > .member-name,
4673-.dep-row > .dep-title {4669+.dep-row .dep-title {
4674 flex: 1;4670 flex: 1;
4675 min-width: 0;4671 min-width: 0;
4676 overflow: hidden;4672 overflow: hidden;
4677 text-overflow: ellipsis;4673 text-overflow: ellipsis;
4678 white-space: nowrap;4674 white-space: nowrap;
4679 }4675 }
4676+.dep-row { flex-wrap: nowrap; }
4680 4677
4681 // Detail tokens never break mid-value ('6.1 KiB' stays whole): the name's4678 // Detail tokens never break mid-value ('6.1 KiB' stays whole): the name's
4682 // ellipsis absorbs the pressure instead.4679 // ellipsis absorbs the pressure instead.
@@ -4746,3 +4743,94 @@ input[type="radio"] {
4746 .table-pan {4743 .table-pan {
4747 overflow-x: auto;4744 overflow-x: auto;
4748 }4745 }
4746+
4747+// -- drive round-3: single-border toolbar, menu drop-up, upload cancel -----
4748+//
4749+// The Sort/Kind/dir filterbar forms nest their controls inside the bordered
4750+// `.field-box`: the dd-enhanced trigger, the native select beside it, and
4751+// the →/↑ submit buttons. Each nested box of its own reads as a doubled or
4752+// overlapping control, so nested chrome is stripped and the box stays the
4753+// one border. Shared rules, so /trash and /shared (the identical
4754+// `.field-box-sort` pattern) inherit the fix with no per-page markup.
4755+//
4756+// A nested submit never draws its own box: borderless, transparent, and
4757+// stretched to the box height so its label sits where the box's text sits.
4758+.field-box .quiet {
4759+ border: none;
4760+ background: transparent;
4761+ height: auto;
4762+ align-self: stretch;
4763+ padding: 0 2px;
4764+}
4765+// A search submit keeps its label whole: exempt from the collapsed nested
4766+// padding above, never shrunk, never wrapped — the box stays its only
4767+// border, the button only its text width back.
4768+.field-box-search .quiet {
4769+ flex: none;
4770+ padding: 0 10px;
4771+ white-space: nowrap;
4772+}
4773+
4774+// The enhanced trigger is already chromeless through the class it clones
4775+// off its select (`.status-select` carries no border or background); this
4776+// pins that for any skin that buttons up a bare trigger, so the trigger
4777+// sits flush inside the field box instead of framing itself twice.
4778+.field-box .dd-trigger {
4779+ border: none;
4780+ background: transparent;
4781+}
4782+
4783+// The native select behind an enhanced trigger never takes space: the
4784+// element-qualified selector outranks any skin's bare `select` chrome
4785+// without resorting to `!important`.
4786+select.dd-native { display: none; }
4787+
4788+// A row Options menu near the viewport bottom opens upward instead of
4789+// spilling past it: the toggle-time script in `drive.rs` adds `menu-up`
4790+// when the downward panel would overflow, and this bottom-anchors the
4791+// house panel to its trigger. The qualified open selector outranks the
4792+// downward `[open]` rule above by specificity, not source order.
4793+.entry-options.menu-up[open] > .user-menu-panel {
4794+ top: auto;
4795+ bottom: 100%;
4796+ margin-bottom: 4px;
4797+}
4798+
4799+// The in-flight upload row's cancel control: the corner stack's dismiss
4800+// voice (24px ✕, danger on hover) as a row-local class, so progress rows
4801+// need no notice-card markup to borrow it.
4802+.upload-progress-cancel {
4803+ flex: none;
4804+ display: inline-flex;
4805+ align-items: center;
4806+ justify-content: center;
4807+ width: 24px;
4808+ height: 24px;
4809+ padding: 0;
4810+ border: none;
4811+ border-radius: var(--radius-sm);
4812+ background: transparent;
4813+ color: var(--muted-soft);
4814+ cursor: pointer;
4815+
4816+ &:hover { color: var(--danger); }
4817+}
4818+
4819+// -- share rows (ShareBuild) ------------------------------------------------------------
4820+// The share/people rows are `div.member-row` outside any table — the only
4821+// `.member-row` rule in the house lives under `.member-table` (the Everyone
4822+// register's own row borders), so these rows rendered as bare inline spans
4823+// and the name, address, expiry and access chip ran together ('NeverMay
4824+// download'). They get the row treatment without the card chrome: flex with
4825+// the house gap, wrapping under narrow pressure. `div` qualified so the
4826+// table's `tr.member-row` rows never match.
4827+div.member-row {
4828+ display: flex;
4829+ align-items: center;
4830+ gap: 4px 10px;
4831+ flex-wrap: wrap;
4832+ padding: 8px 0;
4833+}
4834+div.member-row + div.member-row {
4835+ border-top: 1px solid var(--border);
4836+}