summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/useFolderTrust.ts
diff options
context:
space:
mode:
authorshrutip90 <[email protected]>2025-08-08 11:02:27 -0700
committerGitHub <[email protected]>2025-08-08 18:02:27 +0000
commit34b5dc7f289dc9af0a87d3a795e681d2415da3c9 (patch)
tree9f4b52a13c26a27ccd0eed28715362ee2ded0b65 /packages/cli/src/ui/hooks/useFolderTrust.ts
parent3af4913ef3f00de71744de551a568aa713a3beec (diff)
Add FolderTrustDialog that shows on launch and enables folderTrust setting (#5815)
Diffstat (limited to 'packages/cli/src/ui/hooks/useFolderTrust.ts')
-rw-r--r--packages/cli/src/ui/hooks/useFolderTrust.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/packages/cli/src/ui/hooks/useFolderTrust.ts b/packages/cli/src/ui/hooks/useFolderTrust.ts
new file mode 100644
index 00000000..90a69132
--- /dev/null
+++ b/packages/cli/src/ui/hooks/useFolderTrust.ts
@@ -0,0 +1,31 @@
+/**
+ * @license
+ * Copyright 2025 Google LLC
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import { useState, useCallback } from 'react';
+import { LoadedSettings, SettingScope } from '../../config/settings.js';
+import { FolderTrustChoice } from '../components/FolderTrustDialog.js';
+
+export const useFolderTrust = (settings: LoadedSettings) => {
+ const [isFolderTrustDialogOpen, setIsFolderTrustDialogOpen] = useState(
+ !!settings.merged.folderTrustFeature &&
+ // TODO: Update to avoid showing dialog for folders that are trusted.
+ settings.merged.folderTrust === undefined,
+ );
+
+ const handleFolderTrustSelect = useCallback(
+ (_choice: FolderTrustChoice) => {
+ // TODO: Store folderPath in the trusted folders config file based on the choice.
+ settings.setValue(SettingScope.User, 'folderTrust', true);
+ setIsFolderTrustDialogOpen(false);
+ },
+ [settings],
+ );
+
+ return {
+ isFolderTrustDialogOpen,
+ handleFolderTrustSelect,
+ };
+};