From 5b3e0f00ea194c4bcb71fb729deb7c8347417742 Mon Sep 17 00:00:00 2001 From: Vitor George Date: Mon, 11 Apr 2022 09:11:05 +0100 Subject: [PATCH] Do not render badges section if user doesn't have privileges --- pages/organization.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pages/organization.js b/pages/organization.js index 5afd4afe..0283195a 100644 --- a/pages/organization.js +++ b/pages/organization.js @@ -188,18 +188,16 @@ 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) + } } } @@ -207,7 +205,9 @@ export default class Organization extends Component { 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 ? (
@@ -244,7 +244,7 @@ export default class Organization extends Component { } /> )} - ) + ) : null } renderMembers (memberRows) {