stages/consent: simplify permission rendering
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
2fa6cf855d
commit
da666871dd
|
@ -18,7 +18,7 @@ import PFTitle from "@patternfly/patternfly/components/Title/title.css";
|
||||||
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
||||||
import PFSpacing from "@patternfly/patternfly/utilities/Spacing/spacing.css";
|
import PFSpacing from "@patternfly/patternfly/utilities/Spacing/spacing.css";
|
||||||
|
|
||||||
import { ConsentChallenge, ConsentChallengeResponseRequest } from "@goauthentik/api";
|
import { ConsentChallenge, ConsentChallengeResponseRequest, Permission } from "@goauthentik/api";
|
||||||
|
|
||||||
@customElement("ak-stage-consent")
|
@customElement("ak-stage-consent")
|
||||||
export class ConsentStage extends BaseStage<ConsentChallenge, ConsentChallengeResponseRequest> {
|
export class ConsentStage extends BaseStage<ConsentChallenge, ConsentChallengeResponseRequest> {
|
||||||
|
@ -36,6 +36,14 @@ export class ConsentStage extends BaseStage<ConsentChallenge, ConsentChallengeRe
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderPermissions(perms: Permission[]): TemplateResult {
|
||||||
|
return html`${perms.map((permission) => {
|
||||||
|
return html`<li data-permission-code="${permission.id}">
|
||||||
|
${permission.name === "" ? permission.id : permission.name}
|
||||||
|
</li>`;
|
||||||
|
})}`;
|
||||||
|
}
|
||||||
|
|
||||||
renderNoPrevious(): TemplateResult {
|
renderNoPrevious(): TemplateResult {
|
||||||
return html`
|
return html`
|
||||||
<div class="pf-c-form__group">
|
<div class="pf-c-form__group">
|
||||||
|
@ -46,11 +54,7 @@ export class ConsentStage extends BaseStage<ConsentChallenge, ConsentChallengeRe
|
||||||
${t`Application requires following permissions:`}
|
${t`Application requires following permissions:`}
|
||||||
</p>
|
</p>
|
||||||
<ul class="pf-c-list" id="permmissions">
|
<ul class="pf-c-list" id="permmissions">
|
||||||
${this.challenge.permissions.map((permission) => {
|
${this.renderPermissions(this.challenge.permissions)}
|
||||||
return html`<li data-permission-code="${permission.id}">
|
|
||||||
${permission.name}
|
|
||||||
</li>`;
|
|
||||||
})}
|
|
||||||
</ul>
|
</ul>
|
||||||
`
|
`
|
||||||
: html``}
|
: html``}
|
||||||
|
@ -68,11 +72,7 @@ export class ConsentStage extends BaseStage<ConsentChallenge, ConsentChallengeRe
|
||||||
${t`Application already has access to the following permissions:`}
|
${t`Application already has access to the following permissions:`}
|
||||||
</p>
|
</p>
|
||||||
<ul class="pf-c-list" id="permmissions">
|
<ul class="pf-c-list" id="permmissions">
|
||||||
${this.challenge.permissions.map((permission) => {
|
${this.renderPermissions(this.challenge.permissions)}
|
||||||
return html`<li data-permission-code="${permission.id}">
|
|
||||||
${permission.name === "" ? permission.id : permission.name}
|
|
||||||
</li>`;
|
|
||||||
})}
|
|
||||||
</ul>
|
</ul>
|
||||||
`
|
`
|
||||||
: html``}
|
: html``}
|
||||||
|
@ -84,11 +84,7 @@ export class ConsentStage extends BaseStage<ConsentChallenge, ConsentChallengeRe
|
||||||
${t`Application requires following new permissions:`}
|
${t`Application requires following new permissions:`}
|
||||||
</strong>
|
</strong>
|
||||||
<ul class="pf-c-list" id="permmissions">
|
<ul class="pf-c-list" id="permmissions">
|
||||||
${this.challenge.additionalPermissions.map((permission) => {
|
${this.renderPermissions(this.challenge.additionalPermissions)}
|
||||||
return html`<li data-permission-code="${permission.id}">
|
|
||||||
${permission.name === "" ? permission.id : permission.name}
|
|
||||||
</li>`;
|
|
||||||
})}
|
|
||||||
</ul>
|
</ul>
|
||||||
`
|
`
|
||||||
: html``}
|
: html``}
|
||||||
|
|
Reference in New Issue