diff --git a/src/features/project-trust/index.tsx b/src/features/project-trust/index.tsx
index 27d32d825..5d64e09ea 100644
--- a/src/features/project-trust/index.tsx
+++ b/src/features/project-trust/index.tsx
@@ -140,6 +140,14 @@ function TrustSettings() {
setError(String(e));
}
};
+ const trust = async (path: string) => {
+ try {
+ await call(commands.projectTrustSet(path, true, false));
+ await refresh();
+ } catch (e) {
+ setError(String(e));
+ }
+ };
const addLocation = async () => {
try {
const { open } = await import("@/platform/dialog");
@@ -169,6 +177,24 @@ function TrustSettings() {
))}
+ {decisions?.restricted.length ? (
+ <>
+
diff --git a/src/features/project-trust/trust.module.css b/src/features/project-trust/trust.module.css
index 88fef2ba5..4c9b5fcc5 100644
--- a/src/features/project-trust/trust.module.css
+++ b/src/features/project-trust/trust.module.css
@@ -58,9 +58,13 @@
justify-content: space-between;
gap: var(--space-3);
}
-.sectionHead h3 {
+.content h3 {
margin: 0;
}
+.content > h3,
+.sectionHead {
+ margin-top: var(--space-3);
+}
.hint {
color: var(--fg-secondary);
}
diff --git a/src/features/project-trust/trust.test.tsx b/src/features/project-trust/trust.test.tsx
index 9f8ada26b..b098c4ea9 100644
--- a/src/features/project-trust/trust.test.tsx
+++ b/src/features/project-trust/trust.test.tsx
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, expect, it, vi } from "vitest";
-import { act, fireEvent, render, screen } from "@testing-library/react";
+import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
import { confirmProjectTrust } from "@/platform/projectTrust";
import { executeAction } from "@/platform/actions";
import { emitLocalIdeEvent } from "@/platform/ipc";
@@ -165,6 +165,24 @@ it("adds a picked folder as a trusted location from settings", async () => {
expect(addLocation).toHaveBeenCalledTimes(1);
});
+it("lists restricted projects, which a trusted location doesn't cover, and trusts one from settings", async () => {
+ const Page = useSettingsPages.getState().pages.get("projectTrust")!.component!;
+ listDecisions.mockResolvedValue({
+ status: "ok",
+ data: { projects: [], locations: ["/projects"], restricted: ["/projects/app"] },
+ });
+ render(
);
+ expect(await screen.findByRole("heading", { name: "Restricted projects" })).toBeTruthy();
+ listDecisions.mockResolvedValue({
+ status: "ok",
+ data: { projects: ["/projects/app"], locations: ["/projects"], restricted: [] },
+ });
+ fireEvent.click(screen.getByRole("button", { name: "Trust" }));
+ await waitFor(() => expect(screen.queryByRole("heading", { name: "Restricted projects" })).toBeNull());
+ expect(decide).toHaveBeenCalledWith("/projects/app", true, false);
+ expect(screen.getByText("/projects/app")).toBeTruthy();
+});
+
it.each(["Trust Project", "Preview in Restricted Mode"])(
"keeps a local opening's trust decision on the client: %s",
async (button) => {
diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.json
index 2ad069bc8..9c38e2b93 100644
--- a/src/platform/locales/text/en.json
+++ b/src/platform/locales/text/en.json
@@ -2479,5 +2479,9 @@
"Align key-value pairs": "Align key-value pairs",
"Align consecutive assignments": "Align consecutive assignments",
"Lines up => in multi-line arrays and = in consecutive assignments after the language server or PHP-CS-Fixer formats the file; for a selection, only its lines.": "Lines up => in multi-line arrays and = in consecutive assignments after the language server or PHP-CS-Fixer formats the file; for a selection, only its lines.",
- "Are you sure you want to delete {name}?": "Are you sure you want to delete {name}?"
+ "Are you sure you want to delete {name}?": "Are you sure you want to delete {name}?",
+ "Every project inside a trusted location is trusted without asking, unless it is a restricted project.": "Every project inside a trusted location is trusted without asking, unless it is a restricted project.",
+ "Restricted projects": "Restricted projects",
+ "These projects open in Restricted Mode, even inside a trusted location.": "These projects open in Restricted Mode, even inside a trusted location.",
+ "Trust": "Trust"
}
diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json
index d99ff1075..ea1ded886 100644
--- a/src/platform/locales/text/zh.json
+++ b/src/platform/locales/text/zh.json
@@ -3793,7 +3793,6 @@
"(empty line)": "(空行)",
"Name cannot be empty": "名称不能为空",
"Every scope needs a name": "每个范围都需要名称",
- "Every project inside a trusted location is trusted without asking.": "受信任的位置内的每个项目都会被信任,不再询问。",
"Scopes": "范围",
"Add Scope": "添加范围",
"Remove Scope": "移除范围",
@@ -8854,5 +8853,9 @@
"Align key-value pairs": "对齐键值对",
"Align consecutive assignments": "对齐连续赋值",
"Lines up => in multi-line arrays and = in consecutive assignments after the language server or PHP-CS-Fixer formats the file; for a selection, only its lines.": "在语言服务器或 PHP-CS-Fixer 格式化文件后,对齐多行数组中的 => 和连续赋值语句中的 =;格式化选区时只对齐选中的行。",
- "Are you sure you want to delete {name}?": "确定要删除 {name} 吗?"
+ "Are you sure you want to delete {name}?": "确定要删除 {name} 吗?",
+ "Every project inside a trusted location is trusted without asking, unless it is a restricted project.": "受信任的位置内的每个项目都会被信任,不再询问;受限项目除外。",
+ "Restricted projects": "受限项目",
+ "These projects open in Restricted Mode, even inside a trusted location.": "这些项目即使位于受信任的位置内,也以受限模式打开。",
+ "Trust": "信任"
}