mirror of
https://github.com/flarum/framework.git
synced 2024-11-22 12:31:41 +08:00
chore: hide developer tokens section in if there is nothing to display or create (#3753)
This commit is contained in:
parent
b7498d6cb1
commit
661b9d7d9a
|
@ -51,17 +51,27 @@ export default class UserSecurityPage<CustomAttrs extends IUserPageAttrs = IUser
|
|||
settingsItems() {
|
||||
const items = new ItemList<Mithril.Children>();
|
||||
|
||||
['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,
|
||||
<FieldSet className={`UserSecurityPage-${section}`} label={app.translator.trans(`core.forum.security.${sectionLocale}_heading`)}>
|
||||
{this[sectionName]().toArray()}
|
||||
'developerTokens',
|
||||
<FieldSet className="UserSecurityPage-developerTokens" label={app.translator.trans(`core.forum.security.developer_tokens_heading`)}>
|
||||
{this.developerTokensItems().toArray()}
|
||||
</FieldSet>
|
||||
);
|
||||
});
|
||||
} else if (!this.state.hasLoadedTokens()) {
|
||||
items.add('developerTokens', <LoadingIndicator />);
|
||||
}
|
||||
|
||||
items.add(
|
||||
'sessions',
|
||||
<FieldSet className="UserSecurityPage-sessions" label={app.translator.trans(`core.forum.security.sessions_heading`)}>
|
||||
{this.sessionsItems().toArray()}
|
||||
</FieldSet>
|
||||
);
|
||||
|
||||
if (this.user!.id() === app.session.user!.id()) {
|
||||
items.add(
|
||||
|
|
Loading…
Reference in New Issue
Block a user