Skip to content

Commit

Permalink
Dynamic menus are now computed properties
Browse files Browse the repository at this point in the history
  • Loading branch information
noirbizarre committed Mar 27, 2017
1 parent e69e490 commit ba6c3f2
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 70 deletions.
52 changes: 26 additions & 26 deletions js/views/dataset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,32 +79,8 @@ import ReuseList from 'components/reuse/list.vue';
import SmallBox from 'components/containers/small-box.vue';
export default {
name: 'DatasetView',
mixins: [DatasetFilters],
data: function() {
var actions = [{
label: this._('Edit'),
icon: 'edit',
method: this.edit
}, {
label: this._('Transfer'),
icon: 'send',
method: this.transfer_request
}, {
label: this._('Delete'),
icon: 'trash',
method: this.confirm_delete
}];
if (this.$root.me.is_admin) {
actions.push({divider: true});
actions.push({
label: this._('Badges'),
icon: 'bookmark',
method: this.setBadges
});
}
data() {
return {
dataset: new Dataset({mask: '*'}),
metrics: new Metrics({query: {
Expand All @@ -116,7 +92,6 @@ export default {
issues: new Issues({query: {sort: '-created', page_size: 10}, mask: IssueList.MASK}),
discussions: new Discussions({query: {sort: '-created', page_size: 10}, mask: DiscussionList.MASK}),
communities: new CommunityResources({query: {sort: '-created_at', page_size: 10}, mask: CommunityList.MASK}),
actions: actions,
badges: [],
y: [{
id: 'views',
Expand All @@ -136,6 +111,31 @@ export default {
};
},
computed: {
actions() {
const actions = [{
label: this._('Edit'),
icon: 'edit',
method: this.edit
}, {
label: this._('Transfer'),
icon: 'send',
method: this.transfer_request
}, {
label: this._('Delete'),
icon: 'trash',
method: this.confirm_delete
}];
if (this.$root.me.is_admin) {
actions.push({divider: true});
actions.push({
label: this._('Badges'),
icon: 'bookmark',
method: this.setBadges
});
}
return actions;
},
boxes() {
if (!this.dataset.metrics) {
return [];
Expand Down
41 changes: 21 additions & 20 deletions js/views/organization.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,6 @@ import ReuseList from 'components/reuse/list.vue';
export default {
name: 'OrganizationView',
data() {
let actions = [{
label: this._('Edit'),
icon: 'edit',
method: this.edit
}, {
label: this._('Delete'),
icon: 'trash',
method: this.confirm_delete
}];
if (this.$root.me.is_admin) {
actions.push({divider: true});
actions.push({
label: this._('Badges'),
icon: 'bookmark',
method: this.setBadges
});
}
return {
org: new Organization(),
metrics: new Metrics({query: {
Expand Down Expand Up @@ -115,7 +96,6 @@ export default {
}),
communities: new CommunityResources({query: {sort: '-created_at', page_size: 10}}),
followers: new Followers({ns: 'organizations', query: {page_size: 10}}),
actions: actions,
badges: [],
charts: {
traffic: {
Expand Down Expand Up @@ -147,6 +127,27 @@ export default {
};
},
computed: {
actions() {
const actions = [{
label: this._('Edit'),
icon: 'edit',
method: this.edit
}, {
label: this._('Delete'),
icon: 'trash',
method: this.confirm_delete
}];
if (this.$root.me.is_admin) {
actions.push({divider: true});
actions.push({
label: this._('Badges'),
icon: 'bookmark',
method: this.setBadges
});
}
return actions;
},
boxes() {
if (!this.org.metrics) {
return [];
Expand Down
49 changes: 25 additions & 24 deletions js/views/reuse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,6 @@ const MASK = `datasets{${mask(DatasetCards.MASK)}},*`;
export default {
components: {SmallBox, Chart, ReuseDetails, FollowerList, DiscussionList, IssueList, DatasetCards, Layout},
data() {
const actions = [{
label: this._('Edit'),
icon: 'edit',
method: this.edit
}, {
label: this._('Transfer'),
icon: 'send',
method: this.transfer_request
}, {
label: this._('Delete'),
icon: 'trash',
method: this.confirm_delete
}];
if (this.$root.me.is_admin) {
actions.push({divider: true});
actions.push({
label: this._('Badges'),
icon: 'bookmark',
method: this.setBadges
});
}
return {
reuse: new Reuse({mask: MASK}),
metrics: new Metrics({query: {
Expand All @@ -86,7 +63,6 @@ export default {
followers: new Followers({ns: 'reuses', query: {page_size: 10}}),
issues: new Issues({query: {sort: '-created', page_size: 10}, mask: IssueList.MASK}),
discussions: new Discussions({query: {sort: '-created', page_size: 10}, mask: DiscussionList.MASK}),
actions: actions,
badges: [],
y: [{
id: 'views',
Expand All @@ -98,6 +74,31 @@ export default {
};
},
computed: {
actions() {
const actions = [{
label: this._('Edit'),
icon: 'edit',
method: this.edit
}, {
label: this._('Transfer'),
icon: 'send',
method: this.transfer_request
}, {
label: this._('Delete'),
icon: 'trash',
method: this.confirm_delete
}];
if (this.$root.me.is_admin) {
actions.push({divider: true});
actions.push({
label: this._('Badges'),
icon: 'bookmark',
method: this.setBadges
});
}
return actions;
},
boxes() {
if (!this.reuse.metrics) {
return [];
Expand Down

0 comments on commit ba6c3f2

Please sign in to comment.