Skip to content
This repository has been archived by the owner on Nov 6, 2018. It is now read-only.

Commit

Permalink
feat: edit settings for the highest precedence subject (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismwendt committed Sep 28, 2018
1 parent b875c08 commit 8f9e7a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
5 changes: 1 addition & 4 deletions src/extensions/ExtensionConfigureButtonDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,7 @@ export class ExtensionConfigureButtonDropdown<
{this.props.children}
</DropdownToggle>
<DropdownMenu>
<DropdownItem header={true}>
User settings ({subjectLabel(this.props.subject.subject)}
):
</DropdownItem>
<DropdownItem header={true}>{subjectLabel(this.props.subject.subject)} settings:</DropdownItem>
<ExtensionConfigureDropdownItem
extension={this.props.extension}
subject={this.props.subject}
Expand Down
16 changes: 9 additions & 7 deletions src/extensions/ExtensionPrimaryActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ export class ExtensionPrimaryActionButton<
return null
}

// Only operate on the current user's extension configuration, for simplicity.
const userSubject = this.props.configurationCascade.subjects.find(
({ subject }) => subject.__typename === 'User'
)
if (!userSubject || !userSubject.subject.viewerCanAdminister) {
// Only operate on the highest precedence settings, for simplicity.
const subjects = this.props.configurationCascade.subjects
if (subjects.length === 0) {
return null
}
const highestPrecedenceSubject = subjects[subjects.length - 1]
if (!highestPrecedenceSubject || !highestPrecedenceSubject.subject.viewerCanAdminister) {
return null
}

Expand All @@ -57,7 +59,7 @@ export class ExtensionPrimaryActionButton<
return (
<ExtensionAddButton
extension={this.props.extension}
subject={userSubject}
subject={highestPrecedenceSubject}
confirm={this.confirm}
onUpdate={this.props.onUpdate}
className={`btn ${this.props.className || ''} ${this.props.addClassName || ''}`}
Expand All @@ -71,7 +73,7 @@ export class ExtensionPrimaryActionButton<
<div className="btn-group" role="group" aria-label="Extension configuration actions">
<ExtensionConfigureButtonDropdown
extension={this.props.extension}
subject={userSubject}
subject={highestPrecedenceSubject}
configurationCascade={this.props.configurationCascade}
confirm={this.confirm}
onUpdate={this.props.onUpdate}
Expand Down

0 comments on commit 8f9e7a3

Please sign in to comment.