Skip to content

Commit

Permalink
Do not render badges section if user doesn't have privileges
Browse files Browse the repository at this point in the history
  • Loading branch information
vgeorge committed Apr 11, 2022
1 parent 2c60733 commit 5b3e0f0
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pages/organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,26 +188,26 @@ export default class Organization extends Component {
async getBadges () {
try {
const { id: orgId } = this.props

const badges = await apiClient.get(`/organizations/${orgId}/badges`)
this.setState({
badges
})
} catch (e) {
console.error(e)
this.setState({
error: e,
team: null,
loading: false
})
if (e.statusCode === 401) {
console.log("User doesn't have access to organization badges.")
} else {
console.error(e)
}
}
}

renderBadges () {
const { id: orgId } = this.props
const columns = [{ key: 'name' }, { key: 'color' }]

return (
// Do not render section if badges list cannot be fetched. This might happen
// on network error but also when the user doesn't have privileges.
return this.state.badges ? (
<SectionWrapper>
<Section>
<div className='section-actions'>
Expand Down Expand Up @@ -244,7 +244,7 @@ export default class Organization extends Component {
} />
)}
</SectionWrapper>
)
) : null
}

renderMembers (memberRows) {
Expand Down

0 comments on commit 5b3e0f0

Please sign in to comment.