From 9a3b556e6e2bcc260f477e0124279bae2db0f26a Mon Sep 17 00:00:00 2001 From: Richard Hallett Date: Fri, 3 Jun 2022 11:09:17 +0200 Subject: [PATCH] Only allow staff to add/edit the analytics url --- app/abilities/repository.js | 8 ++++++++ app/templates/providers/show/repositories/new.hbs | 4 ++-- app/templates/repositories/show/edit.hbs | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/abilities/repository.js b/app/abilities/repository.js index 4a23a6090..b365f967d 100644 --- a/app/abilities/repository.js +++ b/app/abilities/repository.js @@ -143,5 +143,13 @@ export default Ability.extend({ default: return false; } + }), + canSetAnalyticsUrl: computed('currentUser.role_id', function () { + switch (this.get('currentUser.role_id')) { + case 'staff_admin': + return true; + default: + return false; + } }) }); diff --git a/app/templates/providers/show/repositories/new.hbs b/app/templates/providers/show/repositories/new.hbs index 2f83b08df..1584a5ab1 100644 --- a/app/templates/providers/show/repositories/new.hbs +++ b/app/templates/providers/show/repositories/new.hbs @@ -111,9 +111,9 @@ {{/if}} - {{!-- {{#if (show-analytics)}} --}} + {{#if (can "setAnalyticsUrl repository" model)}} - {{!-- {{/if}} --}} + {{/if}} diff --git a/app/templates/repositories/show/edit.hbs b/app/templates/repositories/show/edit.hbs index e2a93c00c..77150e079 100644 --- a/app/templates/repositories/show/edit.hbs +++ b/app/templates/repositories/show/edit.hbs @@ -111,9 +111,9 @@ {{/if}} - {{!-- {{#if (show-analytics)}} --}} + {{#if (can "setAnalyticsUrl repository" model)}} - {{!-- {{/if}} --}} + {{/if}} {{#if (can "create repository" model)}}