From db2101cd90cc3074eb5d87b24d12d5fd35061e58 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Mon, 16 Aug 2021 16:28:55 +0200 Subject: [PATCH] fix(LabelEditor): show admin-only checkbox to project admins --- lib/manager/components/LabelEditor.js | 11 +++-------- lib/manager/components/LabelEditorModal.js | 2 +- lib/manager/components/LabelPanel.js | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/manager/components/LabelEditor.js b/lib/manager/components/LabelEditor.js index 06d72ee52..22bb21996 100644 --- a/lib/manager/components/LabelEditor.js +++ b/lib/manager/components/LabelEditor.js @@ -69,12 +69,6 @@ class LabelEditor extends React.Component { } } - 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 @@ -146,7 +140,8 @@ class LabelEditor extends React.Component { 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 (
this._onFormChange(e)}> @@ -186,7 +181,7 @@ class LabelEditor extends React.Component { - {this.userIsAdmin(user) && ( + {isProjectAdmin && ( diff --git a/lib/manager/components/LabelPanel.js b/lib/manager/components/LabelPanel.js index 93c758032..e5c198d4f 100644 --- a/lib/manager/components/LabelPanel.js +++ b/lib/manager/components/LabelPanel.js @@ -29,7 +29,7 @@ export default class LabelPanel extends Component { const { labels, id: projectId } = project const projectAdmin = - user && user.permissions && user.permissions.isProjectAdmin(project.id) + user && user.permissions && user.permissions.isProjectAdmin(projectId) let labelBody = (