Skip to content

Commit 8f96c30

Browse files
committed
fix(projects): hide cached Projects once the projects flag is off
1 parent 019d1bb commit 8f96c30

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

‎apps/sim/ee/access-control/components/project-issue-restrictions.test.tsx‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ afterEach(() => {
4949
act(() => root.unmount())
5050
client.clear()
5151
container.remove()
52-
vi.unstubAllGlobals()
5352
})
5453

5554
async function render(projects: boolean) {
@@ -86,4 +85,14 @@ describe('ProjectIssueRestrictions', () => {
8685
expect(requests.some((url) => url.startsWith('/api/projects?'))).toBe(true)
8786
expect(container.querySelector('#project-issues-project-1')).not.toBeNull()
8887
})
88+
89+
it('hides Projects loaded before the projects flag turned off', async () => {
90+
await render(true)
91+
act(() => root.unmount())
92+
root = createRoot(container)
93+
requests = []
94+
await render(false)
95+
expect(requests).toEqual([])
96+
expect(container.querySelector('#project-issues-project-1')).toBeNull()
97+
})
8998
})

‎apps/sim/ee/access-control/components/project-issue-restrictions.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function ProjectIssueRestrictions({
2020
onChange,
2121
}: ProjectIssueRestrictionsProps) {
2222
const projects = useProjects(organizationId)
23-
if (projects.isPending) return null
23+
if (!projects.isEnabled || projects.isPending) return null
2424
const choices = projects.data?.pages.flatMap((page) => page.projects) ?? []
2525
if (!projects.error && choices.length === 0) return null
2626
const selected = new Set(value)

0 commit comments

Comments
 (0)