diff --git a/app/abilities/species.js b/app/abilities/species.js
deleted file mode 100644
index 7900607..0000000
--- a/app/abilities/species.js
+++ /dev/null
@@ -1,17 +0,0 @@
-import { Ability } from 'ember-can';
-
-export default Ability.extend({
- // Only admins and writers can create a new species
- canAdd: function() {
- let role = this.get('session.currentUser.role');
- return (role === 'W') || (role === 'A');
- }.property('session.currentUser.role'),
-
- // Only admins and the person who created can edit
- canEdit: function() {
- let role = this.get('session.currentUser.role');
- let id = this.get('session.currentUser.id');
- let author = this.get('model.createdBy');
- return (role === 'W' && (+id === author)) || (role === 'A');
- }.property('session.currentUser.role', 'session.currentUser.id', 'model.createdBy')
-});
diff --git a/app/abilities/strain.js b/app/abilities/strain.js
deleted file mode 100644
index ba12463..0000000
--- a/app/abilities/strain.js
+++ /dev/null
@@ -1,17 +0,0 @@
-import { Ability } from 'ember-can';
-
-export default Ability.extend({
- // Only admins and writers can create a new strain
- canAdd: function() {
- let role = this.get('session.currentUser.role');
- return (role === 'W') || (role === 'A');
- }.property('session.currentUser.role'),
-
- // Only admins and the person who created can edit
- canEdit: function() {
- let role = this.get('session.currentUser.role');
- let id = this.get('session.currentUser.id');
- let author = this.get('model.createdBy');
- return (role === 'W' && (+id === author)) || (role === 'A');
- }.property('session.currentUser.role', 'session.currentUser.id', 'model.createdBy')
-});
diff --git a/app/pods/components/add-button/component.js b/app/pods/components/add-button/component.js
new file mode 100644
index 0000000..857bde3
--- /dev/null
+++ b/app/pods/components/add-button/component.js
@@ -0,0 +1,8 @@
+import Ember from 'ember';
+
+export default Ember.Component.extend({
+ canAdd: function() {
+ let role = this.get('session.currentUser.role');
+ return (role === 'W') || (role === 'A');
+ }.property('session.currentUser.role')
+});
diff --git a/app/pods/components/add-button/template.hbs b/app/pods/components/add-button/template.hbs
new file mode 100644
index 0000000..43dfc1f
--- /dev/null
+++ b/app/pods/components/add-button/template.hbs
@@ -0,0 +1,5 @@
+{{#if canAdd}}
+ {{#link-to link class="button-gray smaller"}}
+ {{label}}
+ {{/link-to}}
+{{/if}}
diff --git a/app/pods/components/species-details/component.js b/app/pods/components/species-details/component.js
index 58afb31..2950361 100644
--- a/app/pods/components/species-details/component.js
+++ b/app/pods/components/species-details/component.js
@@ -3,6 +3,14 @@ import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['grid-1'],
isEditing: false,
+
+ canEdit: function() {
+ let role = this.get('session.currentUser.role');
+ let id = this.get('session.currentUser.id');
+ let author = this.get('species.createdBy');
+ return (role === 'W' && (+id === author)) || (role === 'A');
+ }.property('session.currentUser.role', 'session.currentUser.id', 'species.createdBy'),
+
actions: {
save: function() {
this.sendAction('save');
diff --git a/app/pods/components/species-details/template.hbs b/app/pods/components/species-details/template.hbs
index ee6d571..d868809 100644
--- a/app/pods/components/species-details/template.hbs
+++ b/app/pods/components/species-details/template.hbs
@@ -21,16 +21,9 @@
{{strain.strainName}}
{{/link-to}}
{{/each}}
- {{#if (can "edit species" species)}}
- {{#if species.isNew}}
- PENDING SAVE
- {{else}}
-
- {{#link-to 'strains.new' class="button-gray smaller"}}
- Add Strain
- {{/link-to}}
- {{/if}}
- {{/if}}
+ {{#unless species.isNew}}
+ {{add-button label="Add Strain" link="strains.new"}}
+ {{/unless}}