feat(auth): separate source control write permissions (#9787)
Co-authored-by: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
28ce9d1c17
commit
2eda8ac6a3
59 files changed
+3628
-315
No files matched your search
@@ -7,18 +7,24 @@ import {
|
||||
squashAtomCommandFailure,
|
||||
} from "@t3tools/client-runtime/state/runtime";
|
||||
import { canSnooze, effectiveSnoozed } from "@t3tools/client-runtime/state/thread-settled";
|
||||
import type { ScopedThreadRef, ThreadId } from "@t3tools/contracts";
|
||||
import {
|
||||
AuthOrchestrationOperateScope,
|
||||
type ScopedThreadRef,
|
||||
type ThreadId,
|
||||
} from "@t3tools/contracts";
|
||||
import { useRouter } from "@tanstack/react-router";
|
||||
import { useCallback, useMemo } from "react";
|
||||
|
||||
import { resolveSnoozePresets } from "../components/Sidebar.snooze";
|
||||
import {
|
||||
buildThreadActionMenuItems,
|
||||
threadActionRequiresOperate,
|
||||
type ThreadActionMenuId,
|
||||
} from "../components/threadActionMenu.logic";
|
||||
import { stackedThreadToast, toastManager } from "../components/ui/toast";
|
||||
import { threadEnvironment } from "../state/threads";
|
||||
import { useAtomCommand } from "../state/use-atom-command";
|
||||
import { useOrchestrationCommand } from "../state/use-orchestration-command";
|
||||
import { readEnvironmentScope } from "../state/session";
|
||||
import {
|
||||
readEnvironmentSupportsAutoSettleOptOut,
|
||||
readEnvironmentSupportsPinning,
|
||||
@@ -94,7 +100,7 @@ export function useThreadActionMenu(input: {
|
||||
deleteThread,
|
||||
markThreadUnread,
|
||||
} = useThreadActions();
|
||||
const updateThreadMetadata = useAtomCommand(threadEnvironment.updateMetadata, {
|
||||
const updateThreadMetadata = useOrchestrationCommand(threadEnvironment.updateMetadata, {
|
||||
reportFailure: false,
|
||||
});
|
||||
const handleNewThread = useNewThreadHandler();
|
||||
@@ -142,6 +148,7 @@ export function useThreadActionMenu(input: {
|
||||
const isRegeneratingTitle = thread.titleRegeneration != null;
|
||||
const snoozePresets = resolveSnoozePresets(now, timestampFormat);
|
||||
const items = buildThreadActionMenuItems({
|
||||
canOperate: readEnvironmentScope(threadRef.environmentId, AuthOrchestrationOperateScope),
|
||||
branch: thread.branch ?? null,
|
||||
projectFilter: null,
|
||||
isPinned: thread.pinnedAt != null,
|
||||
@@ -157,6 +164,16 @@ export function useThreadActionMenu(input: {
|
||||
const clicked = await settlePromise(() => api.contextMenu.show(items, position));
|
||||
if (clicked._tag === "Failure" || clicked.value === null) return;
|
||||
const action: ThreadActionMenuId = clicked.value;
|
||||
if (
|
||||
threadActionRequiresOperate(action) &&
|
||||
!readEnvironmentScope(threadRef.environmentId, AuthOrchestrationOperateScope)
|
||||
) {
|
||||
failureToast(
|
||||
"Thread action unavailable",
|
||||
new Error("This connection cannot change threads."),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (action.startsWith("snooze:")) {
|
||||
const preset =
|
||||
action === "snooze:custom"
|
||||
|
||||
Reference in new issue
Block a user