Skip to content

Commit

Permalink
fix(LabelEditor): show admin-only checkbox to project admins
Browse files Browse the repository at this point in the history
  • Loading branch information
miles-grant-ibigroup committed Aug 16, 2021
1 parent c6bffda commit db2101c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
11 changes: 3 additions & 8 deletions lib/manager/components/LabelEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@ class LabelEditor extends React.Component<Props, State> {
}
}

userIsAdmin = (user: ManagerUserState) => {
const {permissions} = user
if (!permissions) return false
else return permissions.isApplicationAdmin() || permissions.canAdministerAnOrganization()
}

_onFormChange = ({target}: {target: HTMLInputElement}) => {
const {checked, name, value: targetValue, type} = target

Expand Down Expand Up @@ -146,7 +140,8 @@ class LabelEditor extends React.Component<Props, State> {

render () {
const { newLabel, validation } = this.state
const { user } = this.props
const { user, projectId } = this.props
const isProjectAdmin = user && user.permissions && user.permissions.isProjectAdmin(projectId)

return (
<Form onChange={(e) => this._onFormChange(e)}>
Expand Down Expand Up @@ -186,7 +181,7 @@ class LabelEditor extends React.Component<Props, State> {
<FormControl.Feedback />
</FormGroup>
</Col>
{this.userIsAdmin(user) && (
{isProjectAdmin && (
<Col xs={9}>
<Checkbox
checked={newLabel.adminOnly}
Expand Down
2 changes: 1 addition & 1 deletion lib/manager/components/LabelEditorModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class LabelEditorModal extends React.Component<
<LabelEditor
label={label}
onDone={this.close}
projectId={projectId}
projectId={projectId || label.projectId}
/>
</Body>
</Modal>
Expand Down
2 changes: 1 addition & 1 deletion lib/manager/components/LabelPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class LabelPanel extends Component<Props> {
const { labels, id: projectId } = project

const projectAdmin =
user && user.permissions && user.permissions.isProjectAdmin(project.id)
user && user.permissions && user.permissions.isProjectAdmin(projectId)

let labelBody = (
<div className='noLabelsMessage'>
Expand Down

0 comments on commit db2101c

Please # to comment.