Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/components/access-control-modal/AccessControlModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ export default class AccessControlModal extends DialogComponent<void> {
},
role: grant.role,
initialRole: grant.role,
initialScope: grant.scope,
initialScope: undefined,
scope: grant.scope ?? 'folder+contents',
subjectLabel: grant.label,
subjects: [{
Expand Down Expand Up @@ -744,7 +744,7 @@ export default class AccessControlModal extends DialogComponent<void> {
},
role,
initialRole: 'No Access',
initialScope: grant.scope,
initialScope: undefined,
Comment thread
SharonStrats marked this conversation as resolved.
Resolved
scope: grant.scope ?? 'folder+contents',
subjectLabel: grant.label,
subjects: [{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export default class AccessControlSharedAccess extends WebComponent {

private renderGrantRoleOptions () {
return ACCESS_ROLES.map(role => html`
<solid-ui-combobox-option value=${role}>${role === 'No Access' ? 'Remove' : role}</solid-ui-combobox-option>
<solid-ui-combobox-option value=${role}>${role}</solid-ui-combobox-option>
`)
}

Expand Down
4 changes: 3 additions & 1 deletion src/components/access-control-modal/accessGrantDrafts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ export function getAccessGrantViewModels (drafts: AccessGrantDraft[]): AccessGra
export function getChangedAccessGrants (drafts: AccessGrantDraft[]): ChangedAccessGrant[] {
return getAccessGrantViewModels(drafts)
.filter(({ role, initialRole, scope, initialScope, subjects }) =>
(role !== initialRole || scope !== initialScope) && subjects.length > 0)
!(role === 'No Access' && initialRole === 'No Access') &&
(role !== initialRole || scope !== initialScope) &&
subjects.length > 0)
.map(({ authorization, subjects, role, scope, initialScope }) => ({
authorization,
subjects,
Expand Down
6 changes: 3 additions & 3 deletions test/components/access-control-modal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ describe('AccessControlModal submit', () => {
document.body.removeChild(element)
})

it('shows remove for no access in grant rows', async () => {
it('shows no access for revoking a grant in shared access rows', async () => {
const element = document.createElement('solid-ui-access-control-modal') as any
element.accessGrants = [{
agent: ['https://alice.example.com/profile/card.ttl#me'],
Expand All @@ -1002,8 +1002,8 @@ describe('AccessControlModal submit', () => {
const grantRoleSelect = sharedAccess.shadowRoot.querySelector('solid-ui-combobox.access-grants-role--editable')
const grantOptions = [...grantRoleSelect.querySelectorAll('solid-ui-combobox-option')].map((option: Element) => option.textContent?.trim())

expect(grantOptions).toContain('Remove')
expect(grantOptions).not.toContain('No Access')
expect(grantOptions).toContain('No Access')
expect(grantOptions).not.toContain('Remove')

document.body.removeChild(element)
})
Expand Down
21 changes: 21 additions & 0 deletions test/components/access-control-modal/accessGrantDrafts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,25 @@ describe('access-control grant drafts', () => {
role: 'Editor'
}])
})

it('ignores a staged grant returned to No Access', () => {
const stagedGrant = {
id: 'agent:https://alice.example/profile#me',
authorization: {
agent: ['https://alice.example/profile#me'],
agentGroup: [],
agentClass: [],
origin: [],
mode: [] as AccessMode[]
},
role: 'No Access' as const,
initialRole: 'No Access' as const,
initialScope: undefined,
scope: 'folder' as const,
subjectLabel: 'Alice',
subjects: [{ type: 'agent' as const, iri: 'https://alice.example/profile#me' }]
}

expect(getChangedAccessGrants([stagedGrant])).toEqual([])
})
})
40 changes: 40 additions & 0 deletions test/components/access-control-modal/buildAccessChanges.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,44 @@ describe('buildAccessChanges', () => {
}
])
})

it('keeps separate changes for the same subject when their scopes differ', () => {
const subject = { type: 'agent' as const, iri: 'https://alice.example/profile#me' }

expect(buildAccessChanges({
pendingAccessGrants: [],
generalAccessChanges: [],
changedAccessGrants: [
{
authorization: { agent: [subject.iri], agentGroup: [], agentClass: [], origin: [], mode: ['Read'] as AccessMode[] },
subjects: [subject],
role: 'Viewer',
scope: 'folder',
initialScope: 'folder+contents'
},
{
authorization: { agent: [subject.iri], agentGroup: [], agentClass: [], origin: [], mode: ['Read'] as AccessMode[] },
subjects: [subject],
role: 'Editor',
scope: 'contents',
initialScope: undefined
}
]
})).toEqual([
{
subject,
role: 'Viewer',
label: 'profile',
scope: 'folder',
previousScope: 'folder+contents'
},
{
subject,
role: 'Editor',
label: 'profile',
scope: 'contents',
previousScope: undefined
}
])
})
})
Loading