Skip to content

Commit cacffec

Browse files
feat: update newfilemenu.js for rich-workspace
Signed-off-by: Luka Trovic <[email protected]>
1 parent 3bfc5a4 commit cacffec

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

apps/files/js/newfilemenu.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,18 @@
8181
if (action === 'upload') {
8282
OC.hideMenus();
8383
} else {
84-
event.preventDefault();
85-
this.$el.find('.menuitem.active').removeClass('active');
86-
$target.addClass('active');
87-
this._promptFileName($target);
84+
var actionItem = _.filter(this._menuItems, function(item) {
85+
return item.id === action
86+
}).pop();
87+
if (typeof actionItem.useInput === 'undefined' || actionItem.useInput === true) {
88+
event.preventDefault();
89+
this.$el.find('.menuitem.active').removeClass('active');
90+
$target.addClass('active');
91+
this._promptFileName($target);
92+
} else {
93+
actionItem.actionHandler();
94+
OC.hideMenus();
95+
}
8896
}
8997
},
9098

@@ -198,8 +206,10 @@
198206
templateName: actionSpec.templateName,
199207
iconClass: actionSpec.iconClass,
200208
fileType: actionSpec.fileType,
209+
useInput: actionSpec.useInput,
201210
actionHandler: actionSpec.actionHandler,
202-
checkFilename: actionSpec.checkFilename
211+
checkFilename: actionSpec.checkFilename,
212+
shouldShow: actionSpec.shouldShow,
203213
});
204214
},
205215

@@ -220,10 +230,11 @@
220230
* Renders the menu with the currently set items
221231
*/
222232
render: function() {
233+
const menuItems = this._menuItems.filter(item => !item.shouldShow || (item.shouldShow instanceof Function && item.shouldShow() === true))
223234
this.$el.html(this.template({
224235
uploadMaxHumanFileSize: 'TODO',
225236
uploadLabel: t('files', 'Upload file'),
226-
items: this._menuItems
237+
items: menuItems
227238
}));
228239

229240
// Trigger upload action also with keyboard navigation on enter

0 commit comments

Comments
 (0)