Keep shared Rule files reachable, and say when a privacy change does not save.

This commit is contained in:
adilallo committed 2026-11-09 20:05:06 -07:00
1 parent b6795c1f18
commit 63ba21c614
9 files changed
+148 -16

No files matched your search

+1
View File
@@ -69,6 +69,7 @@ export const GET = apiRoute<RouteContext>(
idOrSlug: row.ruleId,
user,
viaShareSlug: visibility === RULE_VISIBILITY.shared_by_link,
lookup: "id",
requestPath: request.nextUrl.pathname,
});
allowed = resolved != null;
@@ -65,6 +65,7 @@ const ShareContainer = memo<ShareProps>((props) => {
const [inviteError, setInviteError] = useState<string | null>(null);
const [turnOnBusy, setTurnOnBusy] = useState(false);
const [linkCopied, setLinkCopied] = useState(false);
const [saveFailed, setSaveFailed] = useState(false);
useCreateModalA11y(isOpen, onClose, dialogRef);
@@ -76,6 +77,7 @@ const ShareContainer = memo<ShareProps>((props) => {
setInviteError(null);
setLinkCopied(false);
setTurnOnBusy(false);
setSaveFailed(false);
if (!previewSettings) setSettings(null);
return;
}
@@ -106,6 +108,7 @@ const ShareContainer = memo<ShareProps>((props) => {
setSettings(next);
setPhase("idle");
setCommunityAgreed(false);
setSaveFailed(false);
}, []);
const handleSelectValue = useCallback(
@@ -132,7 +135,11 @@ const ShareContainer = memo<ShareProps>((props) => {
}
void (async () => {
const res = await patchRuleShare(ruleId, "private");
if (res.ok) applySettings(res.share);
if (res.ok) {
applySettings(res.share);
return;
}
setSaveFailed(true);
})();
return;
}
@@ -146,6 +153,7 @@ const ShareContainer = memo<ShareProps>((props) => {
}
setPhase("confirm");
setCommunityAgreed(false);
setSaveFailed(false);
}
},
[applySettings, phase, ruleId, settings],
@@ -185,7 +193,11 @@ const ShareContainer = memo<ShareProps>((props) => {
return;
}
const res = await patchRuleShare(ruleId, "private");
if (res.ok) applySettings(res.share);
if (res.ok) {
applySettings(res.share);
return;
}
setSaveFailed(true);
}, [applySettings, ruleId, settings]);
const handleInvite = useCallback(async () => {
@@ -274,6 +286,7 @@ const ShareContainer = memo<ShareProps>((props) => {
turnOnDisabled
turnOnBusy={false}
showError={false}
showSaveError={false}
copyEnabled={false}
linkCopied={false}
onCopyLink={() => undefined}
@@ -327,6 +340,7 @@ const ShareContainer = memo<ShareProps>((props) => {
turnOnDisabled={!communityAgreed}
turnOnBusy={turnOnBusy}
showError={phase === "error"}
showSaveError={saveFailed}
copyEnabled={copyEnabled}
linkCopied={linkCopied}
onCopyLink={() => void handleCopyLink()}
@@ -44,6 +44,8 @@ export type ShareCopy = {
done: string;
errorTitle: string;
errorDescription: string;
saveErrorTitle: string;
saveErrorDescription: string;
closeDialogAriaLabel: string;
accessSelectAriaLabel: string;
};
@@ -79,6 +81,7 @@ export type ShareViewProps = {
turnOnDisabled: boolean;
turnOnBusy: boolean;
showError: boolean;
showSaveError: boolean;
copyEnabled: boolean;
linkCopied: boolean;
onCopyLink: () => void;
@@ -107,6 +107,7 @@ export const ShareView = memo(function ShareView({
turnOnDisabled,
turnOnBusy,
showError,
showSaveError,
copyEnabled,
linkCopied,
onCopyLink,
@@ -229,6 +230,19 @@ export const ShareView = memo(function ShareView({
{linkOn ? copy.anyoneWithLinkHint : copy.inviteOnlyHint}
</p>
) : null}
{showSaveError ? (
<Alert
type="banner"
status="danger"
size="s"
title={copy.saveErrorTitle}
description={copy.saveErrorDescription}
hasLeadingIcon
hasBodyText
hasTrailingIcon={false}
className="w-full"
/>
) : null}
</div>
{showLinkField ? (