From 2c6b4b9c6a437b13d3026f6d672505208325fa72 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 2 Feb 2017 18:40:39 +0100 Subject: [PATCH] Hide disabled applications from the context menu in drive --- customize.dist/application_config.js | 2 +- customize.dist/main.js | 1 + www/common/toolbar.js | 5 +++-- www/drive/main.js | 7 +++++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/customize.dist/application_config.js b/customize.dist/application_config.js index 0e067331e..e391134eb 100644 --- a/customize.dist/application_config.js +++ b/customize.dist/application_config.js @@ -4,7 +4,7 @@ define(function() { /* Select the buttons displayed on the main page to create new collaborative sessions * Existing types : pad, code, poll, slide */ - config.availablePadTypes = ['pad', 'code', 'slide', 'poll']; + config.availablePadTypes = ['drive', 'pad', 'code', 'slide', 'poll']; /* Cryptpad apps use a common API to display notifications to users * by default, notifications are hidden after 5 seconds diff --git a/customize.dist/main.js b/customize.dist/main.js index e05096074..ba0626853 100644 --- a/customize.dist/main.js +++ b/customize.dist/main.js @@ -54,6 +54,7 @@ define([ var $parent = $('#buttons'); var options = []; Config.availablePadTypes.forEach(function (el) { + if (el === 'drive') { return; } options.push({ tag: 'a', attributes: { diff --git a/www/common/toolbar.js b/www/common/toolbar.js index 49e796d64..fcc45a438 100644 --- a/www/common/toolbar.js +++ b/www/common/toolbar.js @@ -1,7 +1,8 @@ define([ '/customize/messages.js', + '/customize/application_config.js', '/bower_components/jquery/dist/jquery.min.js' -], function (Messages) { +], function (Messages, Config) { var $ = window.jQuery; var Bar = { @@ -349,7 +350,7 @@ define([ if (config.displayed.indexOf('newpad') !== -1) { var pads_options = []; - ['drive', 'pad', 'code', 'slide', 'poll'].forEach(function (p) { + Config.availablePadTypes.forEach(function (p) { pads_options.push({ tag: 'a', attributes: { diff --git a/www/drive/main.js b/www/drive/main.js index ad8852028..3f145f4fe 100644 --- a/www/drive/main.js +++ b/www/drive/main.js @@ -452,6 +452,12 @@ define([ $menu.find('a.own').parent('li').hide(); } + $menu.find('[data-type]').each(function (idx, el) { + if (AppConfig.availablePadTypes.indexOf($(el).attr('data-type')) === -1) { + $(el).hide(); + } + }); + $menu.css({ display: "block", left: e.pageX, @@ -893,6 +899,7 @@ define([ options.push({tag: 'hr'}); } AppConfig.availablePadTypes.forEach(function (type) { + if (type === 'drive') { return; } var path = filesOp.isPathInTrash(currentPath) ? '' : '/#?path=' + encodeURIComponent(currentPath); var attributes = { 'class': 'newdoc',