History

fix(settings): preserve removed checkout scope

Julius Marminge committed 2 months ago

Commit 1fa2aae1 parent 7f965c02 files · +30 −11Browse files

Unified · Split

2 files
  1. apps/web/src/components/settings/ProjectSettingsPanel.tsx +2 −11
  2. apps/web/src/components/settings/settingsScope.test.ts +28 −0
apps/web/src/components/settings/ProjectSettingsPanel.tsx+2−11
@@ -869,23 +869,14 @@ function ProjectDetail({ · 868 unmodified lines
869869 draftStore.clearProjectDraftThreadId(projectRef);
870870 }
871871
872− if (isWholeGroup) {
873− if (hasOtherMembers) {
874− void navigate({
875− to: "/settings/projects",
876− search: { project: group.projectKey, machine: undefined },
877− replace: true,
878− });
879− } else {
880− void navigate({ to: "/", replace: true });
881− }
872+ if (isWholeGroup && !hasOtherMembers) {
873+ void navigate({ to: "/", replace: true });
882874 }
883875 },
884876 [
885877 deleteProject,
886878 group.displayName,
887879 group.memberProjects.length,
888− group.projectKey,
889880 hasOtherMembers,
890881 navigate,
891882 reportFailure,
apps/web/src/components/settings/settingsScope.test.ts+28−0
@@ -171,6 +171,34 @@ describe("settings scope resolution", () => { · 170 unmodified lines
171171 });
172172 });
173173
174+ it("leaves a removed checkout unavailable while sibling checkouts remain", () => {
175+ const search = {
176+ project: "t3code",
177+ machine: laptopId,
178+ checkout: first.physicalProjectKey,
179+ };
180+ expect(resolveSettingsScope(search, groups, environments)).toMatchObject({
181+ kind: "checkout",
182+ members: [first],
183+ });
184+ expect(
185+ resolveSettingsScope(search, [group("t3code", [second, third])], environments),
186+ ).toMatchObject({ kind: "unavailable", members: [], environmentIds: [] });
187+ });
188+
189+ it("does not select another environment after removing a project's last local checkout", () => {
190+ const search = { project: "t3code", machine: laptopId };
191+ expect(resolveSettingsScope(search, groups, environments)).toMatchObject({
192+ kind: "project",
193+ members: [first, second],
194+ });
195+ expect(resolveSettingsScope(search, [group("t3code", [third])], environments)).toMatchObject({
196+ kind: "unavailable",
197+ members: [],
198+ environmentIds: [],
199+ });
200+ });
201+
174202 it("rejects a cached checkout whose environment was removed", () => {
175203 expect(
176204 resolveSettingsScope(

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t