web/admin: only allow policies to be bound to sources as users/groups cannot be checked
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
@ -25,6 +25,9 @@ export class BoundPoliciesList extends Table<PolicyBinding> {
|
||||
@property()
|
||||
target?: string;
|
||||
|
||||
@property({type: Boolean})
|
||||
policyOnly = false;
|
||||
|
||||
apiEndpoint(page: number): Promise<AKResponse<PolicyBinding>> {
|
||||
return new PoliciesApi(DEFAULT_CONFIG).policiesBindingsList({
|
||||
target: this.target || "",
|
||||
@ -125,7 +128,7 @@ export class BoundPoliciesList extends Table<PolicyBinding> {
|
||||
<span slot="header">
|
||||
${t`Update Binding`}
|
||||
</span>
|
||||
<ak-policy-binding-form slot="form" .binding=${item} targetPk=${ifDefined(this.target)}>
|
||||
<ak-policy-binding-form slot="form" .binding=${item} targetPk=${ifDefined(this.target)} ?policyOnly=${this.policyOnly}>
|
||||
</ak-policy-binding-form>
|
||||
<button slot="trigger" class="pf-c-button pf-m-secondary">
|
||||
${t`Edit Binding`}
|
||||
@ -159,7 +162,7 @@ export class BoundPoliciesList extends Table<PolicyBinding> {
|
||||
<span slot="header">
|
||||
${t`Create Binding`}
|
||||
</span>
|
||||
<ak-policy-binding-form slot="form" targetPk=${ifDefined(this.target)}>
|
||||
<ak-policy-binding-form slot="form" targetPk=${ifDefined(this.target)} ?policyOnly=${this.policyOnly}>
|
||||
</ak-policy-binding-form>
|
||||
<button slot="trigger" class="pf-c-button pf-m-primary">
|
||||
${t`Create Binding`}
|
||||
@ -208,7 +211,7 @@ export class BoundPoliciesList extends Table<PolicyBinding> {
|
||||
<span slot="header">
|
||||
${t`Create Binding`}
|
||||
</span>
|
||||
<ak-policy-binding-form slot="form" targetPk=${ifDefined(this.target)}>
|
||||
<ak-policy-binding-form slot="form" targetPk=${ifDefined(this.target)} ?policyOnly=${this.policyOnly}>
|
||||
</ak-policy-binding-form>
|
||||
<button slot="trigger" class="pf-c-button pf-m-secondary">
|
||||
${t`Create Binding`}
|
||||
|
||||
@ -44,6 +44,9 @@ export class PolicyBindingForm extends Form<PolicyBinding> {
|
||||
@property({type: Number})
|
||||
policyGroupUser: target = target.policy;
|
||||
|
||||
@property({type: Boolean})
|
||||
policyOnly = false;
|
||||
|
||||
getSuccessMessage(): string {
|
||||
if (this.binding) {
|
||||
return t`Successfully updated binding.`;
|
||||
@ -60,10 +63,6 @@ export class PolicyBindingForm extends Form<PolicyBinding> {
|
||||
`);
|
||||
}
|
||||
|
||||
async customValidate(form: PolicyBinding): Promise<PolicyBinding> {
|
||||
return form;
|
||||
}
|
||||
|
||||
send = (data: PolicyBinding): Promise<PolicyBinding> => {
|
||||
if (this.binding) {
|
||||
return new PoliciesApi(DEFAULT_CONFIG).policiesBindingsUpdate({
|
||||
@ -105,34 +104,49 @@ export class PolicyBindingForm extends Form<PolicyBinding> {
|
||||
});
|
||||
}
|
||||
|
||||
renderModeSelector(): TemplateResult {
|
||||
console.log(this.policyOnly);
|
||||
if (this.policyOnly) {
|
||||
this.policyGroupUser = target.policy;
|
||||
return html`
|
||||
<div class="pf-c-toggle-group__item">
|
||||
<button class="pf-c-toggle-group__button pf-m-selected" type="button">
|
||||
<span class="pf-c-toggle-group__text">${t`Policy`}</span>
|
||||
</button>
|
||||
</div>`;
|
||||
}
|
||||
return html`
|
||||
<div class="pf-c-toggle-group__item">
|
||||
<button class="pf-c-toggle-group__button ${this.policyGroupUser === target.policy ? "pf-m-selected": ""}" type="button" @click=${() => {
|
||||
this.policyGroupUser = target.policy;
|
||||
}}>
|
||||
<span class="pf-c-toggle-group__text">${t`Policy`}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="pf-c-divider pf-m-vertical" role="separator"></div>
|
||||
<div class="pf-c-toggle-group__item">
|
||||
<button class="pf-c-toggle-group__button ${this.policyGroupUser === target.group ? "pf-m-selected" : ""}" type="button" @click=${() => {
|
||||
this.policyGroupUser = target.group;
|
||||
}}>
|
||||
<span class="pf-c-toggle-group__text">${t`Group`}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="pf-c-divider pf-m-vertical" role="separator"></div>
|
||||
<div class="pf-c-toggle-group__item">
|
||||
<button class="pf-c-toggle-group__button ${this.policyGroupUser === target.user ? "pf-m-selected" : ""}" type="button" @click=${() => {
|
||||
this.policyGroupUser = target.user;
|
||||
}}>
|
||||
<span class="pf-c-toggle-group__text">${t`User`}</span>
|
||||
</button>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
renderForm(): TemplateResult {
|
||||
return html`<form class="pf-c-form pf-m-horizontal">
|
||||
<div class="pf-c-card pf-m-selectable pf-m-selected">
|
||||
<div class="pf-c-card__body">
|
||||
<div class="pf-c-toggle-group">
|
||||
<div class="pf-c-toggle-group__item">
|
||||
<button class="pf-c-toggle-group__button ${this.policyGroupUser === target.policy ? "pf-m-selected": ""}" type="button" @click=${() => {
|
||||
this.policyGroupUser = target.policy;
|
||||
}}>
|
||||
<span class="pf-c-toggle-group__text">${t`Policy`}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="pf-c-divider pf-m-vertical" role="separator"></div>
|
||||
<div class="pf-c-toggle-group__item">
|
||||
<button class="pf-c-toggle-group__button ${this.policyGroupUser === target.group ? "pf-m-selected" : ""}" type="button" @click=${() => {
|
||||
this.policyGroupUser = target.group;
|
||||
}}>
|
||||
<span class="pf-c-toggle-group__text">${t`Group`}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="pf-c-divider pf-m-vertical" role="separator"></div>
|
||||
<div class="pf-c-toggle-group__item">
|
||||
<button class="pf-c-toggle-group__button ${this.policyGroupUser === target.user ? "pf-m-selected" : ""}" type="button" @click=${() => {
|
||||
this.policyGroupUser = target.user;
|
||||
}}>
|
||||
<span class="pf-c-toggle-group__text">${t`User`}</span>
|
||||
</button>
|
||||
</div>
|
||||
${this.renderModeSelector()}
|
||||
</div>
|
||||
</div>
|
||||
<div class="pf-c-card__footer">
|
||||
|
||||
Reference in New Issue
Block a user