Skip to content

Commit 73375c7

Browse files
feat: update newfilemenu.js for rich-workspace
Signed-off-by: Luka Trovic <luka@nextcloud.com>
1 parent d607047 commit 73375c7

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

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

@@ -202,8 +210,10 @@
202210
templateName: actionSpec.templateName,
203211
iconClass: actionSpec.iconClass,
204212
fileType: actionSpec.fileType,
213+
useInput: actionSpec.useInput,
205214
actionHandler: actionSpec.actionHandler,
206-
checkFilename: actionSpec.checkFilename
215+
checkFilename: actionSpec.checkFilename,
216+
shouldShow: actionSpec.shouldShow,
207217
});
208218
},
209219

@@ -224,10 +234,11 @@
224234
* Renders the menu with the currently set items
225235
*/
226236
render: function() {
237+
const menuItems = this._menuItems.filter(item => !item.shouldShow || (item.shouldShow instanceof Function && item.shouldShow() === true))
227238
this.$el.html(this.template({
228239
uploadMaxHumanFileSize: 'TODO',
229240
uploadLabel: t('files', 'Upload file'),
230-
items: this._menuItems
241+
items: menuItems
231242
}));
232243

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

0 commit comments

Comments
 (0)