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
869 draftStore.clearProjectDraftThreadId(projectRef);869 draftStore.clearProjectDraftThreadId(projectRef);
870 }870 }
871 871
872 if (isWholeGroup) {872 if (isWholeGroup && !hasOtherMembers) {
873 if (hasOtherMembers) {873 void navigate({ to: "/", replace: true });
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 }
882 }874 }
883 },875 },
884 [876 [
885 deleteProject,877 deleteProject,
886 group.displayName,878 group.displayName,
887 group.memberProjects.length,879 group.memberProjects.length,
888 group.projectKey,
889 hasOtherMembers,880 hasOtherMembers,
890 navigate,881 navigate,
891 reportFailure,882 reportFailure,
apps/web/src/components/settings/settingsScope.test.ts+28−0
@@ -171,6 +171,34 @@ describe("settings scope resolution", () => { · 170 unmodified lines
171 });171 });
172 });172 });
173 173
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
174 it("rejects a cached checkout whose environment was removed", () => {202 it("rejects a cached checkout whose environment was removed", () => {
175 expect(203 expect(
176 resolveSettingsScope(204 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