From 661b9d7d9a2c00ade9737cc3f4d903383b3ca1e4 Mon Sep 17 00:00:00 2001 From: Robert Korulczyk Date: Sun, 12 Mar 2023 12:37:49 +0100 Subject: [PATCH] chore: hide developer tokens section in if there is nothing to display or create (#3753) --- .../src/forum/components/UserSecurityPage.tsx | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/framework/core/js/src/forum/components/UserSecurityPage.tsx b/framework/core/js/src/forum/components/UserSecurityPage.tsx index d0fdac8aa..bb32f9f31 100644 --- a/framework/core/js/src/forum/components/UserSecurityPage.tsx +++ b/framework/core/js/src/forum/components/UserSecurityPage.tsx @@ -51,17 +51,27 @@ export default class UserSecurityPage(); - ['developerTokens', 'sessions'].forEach((section) => { - const sectionName = `${section}Items` as 'developerTokensItems' | 'sessionsItems'; - const sectionLocale = camelCaseToSnakeCase(section); - + if ( + app.forum.attribute('canCreateAccessToken') || + app.forum.attribute('canModerateAccessTokens') || + (this.state.hasLoadedTokens() && this.state.getDeveloperTokens()?.length) + ) { items.add( - section, -
- {this[sectionName]().toArray()} + 'developerTokens', +
+ {this.developerTokensItems().toArray()}
); - }); + } else if (!this.state.hasLoadedTokens()) { + items.add('developerTokens', ); + } + + items.add( + 'sessions', +
+ {this.sessionsItems().toArray()} +
+ ); if (this.user!.id() === app.session.user!.id()) { items.add(