Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(control-ui): rp-011 disclose the surviving Editor shares before the write

M838c64d75110
diff --git a/control-ui/components/GfsGrantPanel.tsx b/control-ui/components/GfsGrantPanel.tsx
index 2c4c47025..ac1cd949c 100644
--- a/control-ui/components/GfsGrantPanel.tsx
+++ b/control-ui/components/GfsGrantPanel.tsx
@@ -750,6 +750,27 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme
.map(source => source.name)
if (writable.length === 0) {
if (row.direct && row.direct.grantId !== null) {
+ // Only this item's own grant can be rewritten, but the member also
+ // inherits Editor through share rows this panel cannot edit. The
+ // operator approves the change in the SAME confirmation every other
+ // role change uses, so the access those shares keep is disclosed
+ // BEFORE the write instead of only in the post-change feedback
+ // (RP-011). With nothing left granting Editor, the direct write
+ // needs no confirmation.
+ const residualEditorFolderNames =
+ nextRole === 'read' ? collectResidualEditorFolderNames(plan.shareOnlySources) : []
+ if (residualEditorFolderNames.length > 0) {
+ setParentUpdate({
+ row,
+ mode: 'change-role',
+ nextRole,
+ affected: [],
+ residualSources: plan.shareOnlySources,
+ skippedFolderNames,
+ residualEditorFolderNames,
+ })
+ return
+ }
await updateAccessRole(row.direct, nextRole, plan.shareOnlySources, skippedFolderNames)
return
}
diff --git a/control-ui/components/GfsInheritedAccessDialog/index.tsx b/control-ui/components/GfsInheritedAccessDialog/index.tsx
index ed973d7cb..a7d22fefb 100644
--- a/control-ui/components/GfsInheritedAccessDialog/index.tsx
+++ b/control-ui/components/GfsInheritedAccessDialog/index.tsx
@@ -61,10 +61,19 @@ export function GfsInheritedAccessDialog({
const isRemove = request.mode === 'remove'
const nextLabel = isRemove ? 'Remove' : request.nextRole ? ROLE_LABELS[request.nextRole] : ''
const confirmLabel = isRemove ? 'Remove' : 'Update role'
- const title = isRemove ? 'Remove from parent folder?' : 'Update role on parent folder?'
+ // A role change that touches no parent folder (only this item's own grant
+ // can be rewritten) must not promise a cascade that does not happen.
+ const touchesParentFolder = request.folders.length > 0
+ const title = isRemove
+ ? 'Remove from parent folder?'
+ : touchesParentFolder
+ ? 'Update role on parent folder?'
+ : 'Update role?'
const lead = isRemove
? `Removing ${request.memberLabel} from this item will also remove them from a parent folder.`
- : `Changing ${request.memberLabel}'s permissions on this item will also change permissions on a parent folder.`
+ : touchesParentFolder
+ ? `Changing ${request.memberLabel}'s permissions on this item will also change permissions on a parent folder.`
+ : `Changing ${request.memberLabel}'s permissions on this item changes this item's own access only.`
return (
<div
diff --git a/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx b/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx
index aea554a51..8346eb339 100644
--- a/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx
+++ b/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx
@@ -510,7 +510,10 @@ describe('GfsGrantPanel inherited access', () => {
await waitFor(() => expect(mockDeleteGfsShare).toHaveBeenCalledWith(FOLDER_SHARE_ID))
})
- it('discloses inherited Editor shares when only a direct grant can be changed', async () => {
+ // RP-011 — when only the direct grant can be rewritten, the access the
+ // member keeps through the shares this panel cannot edit is disclosed in a
+ // confirmation BEFORE the write, not only in the post-change feedback.
+ it('discloses inherited Editor shares before the direct grant is changed', async () => {
mockGetGfsGrants.mockImplementation(async resourceId => ({
items:
resourceId === FILE_ID
@@ -545,6 +548,20 @@ describe('GfsGrantPanel inherited access', () => {
const existing = await screen.findByRole('region', { name: 'People with access' })
const row = await within(existing).findByTestId(miguelRowTestId)
await chooseRole(row, 'Read')
+
+ // The confirmation opens BEFORE anything is written, and it names the
+ // Editor access the change does not remove.
+ const dialog = await screen.findByRole('alertdialog')
+ expect(
+ within(dialog).getByText(
+ 'Sharing entries on team-docs still grant Editor access. This change does not remove them.'
+ )
+ ).toBeTruthy()
+ expect(within(dialog).getByText(/changes this item's own access only/)).toBeTruthy()
+ expect(mockPutGfsGrant).not.toHaveBeenCalled()
+
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Update role' }))
+
await waitFor(() =>
expect(mockPutGfsGrant).toHaveBeenCalledWith({
drive: 'main',
@@ -555,6 +572,9 @@ describe('GfsGrantPanel inherited access', () => {
})
)
expect(mockPutGfsGrant).toHaveBeenCalledTimes(1)
+ // Nothing is revoked here: the item carries no sharing entry of its own,
+ // and the share-only ancestor's entry is not one this panel may rewrite.
+ // It survives and is disclosed in the outcome.
expect(mockDeleteGfsShare).not.toHaveBeenCalled()
expect(
await screen.findByText(
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 8fea81289..99dd39c39 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.745",
+ "version": "0.1.746",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.745",
+ "version": "0.1.746",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/frontend-components": "file:../packages/frontend-components",
diff --git a/control-ui/package.json b/control-ui/package.json
index bc2c54b6a..342a94f15 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.745",
+ "version": "0.1.746",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",