Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(evendrive): revoke file's direct shares on parent-role confirm (R1-H2)
M24bc7f4059d3
diff --git a/desktop-app/ui/src/pages/FilesPage.tsx b/desktop-app/ui/src/pages/FilesPage.tsxindex deaec7ed3..08c839f76 100644--- a/desktop-app/ui/src/pages/FilesPage.tsx+++ b/desktop-app/ui/src/pages/FilesPage.tsx@@ -618,9 +618,13 @@ export function FilesPage({ pushToast, pendingGfsUri, onPendingGfsUriHandled }:// everything inside; its superseded share rows are consolidated.await window.clerum.gfs.grant(source.resourceId, [subjectKey], bits, GFS_DRIVE_MAIN, true)for (const shareId of source.shareIds) await ctrl.revokeShare(shareId)- // The file's own direct grant is aligned so it cannot mask the role.- if (request.row.grant) {- await ctrl.grant([subjectKey], bits, request.row.grant.inherit)+ // The file's own direct rows are aligned so they cannot mask the+ // confirmed role: the grant upsert expresses the new role and every+ // direct file share for the member is revoked after it — a stale+ // editor share would otherwise keep the member an Editor.+ if (request.row.grant || request.row.shares.length > 0) {+ await ctrl.grant([subjectKey], bits, request.row.grant?.inherit ?? false)+ for (const share of request.row.shares) await ctrl.revokeShare(share.id)}pushToast?.(`${label} is now ${request.nextRole === 'editor' ? 'an Editor' : 'Read-only'} on ${source.name} and everything inside it`,diff --git a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsxindex b1fda1011..8bf7efa23 100644--- a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx+++ b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx@@ -1830,6 +1830,62 @@ describe('FilesPage', () => {await waitFor(() => expect(refreshInheritedAccess).toHaveBeenCalled())})+ // R1-H2 — a stale direct file share must not survive a confirmed parent+ // role change: the editor share would keep masking the confirmed downgrade+ // while the toast claims Read-only.+ it('revokes the file’s direct shares when a confirmed parent role change downgrades the member', async () => {+ installInheritedDirectoryMocks()+ const fileGrant = vi.fn(async () => undefined)+ const revokeShare = vi.fn(async () => undefined)+ const pushToast = vi.fn()+ hookMock.useGfsBrowserController.mockReturnValue(+ inheritedFileController({+ grants: [],+ shares: [+ {+ id: 'file-share-1',+ drive: 'main',+ resourceId: 'file-1',+ subject: { type: 'user', id: 'user-2' },+ permissions: ['read', 'write'],+ includeDescendants: false,+ },+ ],+ grant: fileGrant,+ revokeShare,+ })+ )++ renderFilesPage(pushToast)+ await openManageDialog('report.txt')+ const manageDialog = await screen.findByRole('dialog', { name: 'Share file report.txt' })+ // The direct share row is consumed by the deduped merged row.+ expect(within(manageDialog).queryByTestId('gfs-access-row-share-file-share-1')).toBeNull()+ const row = await within(manageDialog).findByTestId('gfs-access-row-inherited-user')++ await act(async () => {+ fireEvent.click(within(row).getByRole('button', { name: 'Access role for Test Two' }))+ })+ await act(async () => {+ fireEvent.click(screen.getByRole('option', { name: 'Read' }))+ })+ const confirmDialog = await screen.findByRole('alertdialog')+ await act(async () => {+ fireEvent.click(within(confirmDialog).getByRole('button', { name: 'Update role' }))+ })++ // The direct share is superseded by the aligned grant and revoked…+ await waitFor(() => expect(revokeShare).toHaveBeenCalledWith('file-share-1'))+ // …after the replacement grant expresses the confirmed role.+ await waitFor(() =>+ expect(fileGrant).toHaveBeenCalledWith(['user:user-2'], ['read', 'share'], false)+ )+ expect(pushToast).toHaveBeenCalledWith(+ 'Test Two is now Read-only on Team folder and everything inside it',+ 'success'+ )+ })+it('removes an inherited member from the parent folder after confirmation', async () => {installInheritedDirectoryMocks()const revokeGrant = vi.fn(async () => undefined)