fix: not show scopes if keys empty or not exist (#1975)

This commit is contained in:
AlexVarchuk 2022-05-03 11:25:46 +03:00 committed by GitHub
parent 0fa08faab1
commit 4e793f07a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,6 +23,7 @@ export interface OAuthFlowProps {
export class OAuthFlow extends React.PureComponent<OAuthFlowProps> { export class OAuthFlow extends React.PureComponent<OAuthFlowProps> {
render() { render() {
const { type, flow } = this.props; const { type, flow } = this.props;
const scopesNames = Object.keys(flow?.scopes || {});
return ( return (
<tr> <tr>
<th> {type} OAuth Flow </th> <th> {type} OAuth Flow </th>
@ -45,16 +46,21 @@ export class OAuthFlow extends React.PureComponent<OAuthFlowProps> {
{flow!.refreshUrl} {flow!.refreshUrl}
</div> </div>
)} )}
{!!scopesNames.length && (
<>
<div> <div>
<strong> Scopes: </strong> <strong> Scopes: </strong>
</div> </div>
<ul> <ul>
{Object.keys(flow!.scopes || {}).map(scope => ( {scopesNames.map(scope => (
<li key={scope}> <li key={scope}>
<code>{scope}</code> - <Markdown inline={true} source={flow!.scopes[scope] || ''} /> <code>{scope}</code> -{' '}
<Markdown inline={true} source={flow!.scopes[scope] || ''} />
</li> </li>
))} ))}
</ul> </ul>
</>
)}
</td> </td>
</tr> </tr>
); );