Skip to content

Commit

Permalink
implemented permission based restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodes committed Aug 18, 2024
1 parent c7136ce commit 5abd1fa
Show file tree
Hide file tree
Showing 24 changed files with 12,728 additions and 9,305 deletions.
2 changes: 1 addition & 1 deletion addon/components/webhook/details.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>

<div class="flex items-center section-header-actions">
<Button @icon="pencil" @text={{t "developers.component.webhook.details.update-details"}} @onClick={{this.onClickUpdateWebhook}} />
<Button @icon="pencil" @text={{t "developers.component.webhook.details.update-details"}} @onClick={{this.onClickUpdateWebhook}} @permission={{@permission}} />
</div>
</div>
<div class="text-sm content-panel-body">
Expand Down
16 changes: 16 additions & 0 deletions addon/components/webhook/details.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';

export default class WebhookDetailsComponent extends Component {
@service abilities;
@tracked permission;
@tracked doesntHavePermission = false;

constructor(owner, { permission }) {
super(...arguments);
this.permission = permission;
this.doesntHavePermission = permission && this.abilities.cannot(permission);
}

@action onClickUpdateWebhook() {
if (this.doesntHavePermission) {
return;
}

const { webhook, onClickUpdateWebhook } = this.args;

if (typeof onClickUpdateWebhook === 'function') {
Expand Down
Loading

0 comments on commit 5abd1fa

Please sign in to comment.