From 0a70544cd93c02e0ec5c2571400b5d00ed97c456 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?=
Date: Thu, 1 Nov 2018 14:55:32 +0100
Subject: [PATCH] Password policy fix and menu open on first share
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: John Molakvoæ (skjnldsv)
---
...kshareview_popover_menu_pending.handlebars | 2 +-
core/js/sharedialoglinkshareview.js | 27 +++++++++++++++++--
core/js/sharetemplates.js | 4 ++-
3 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/core/js/share/sharedialoglinkshareview_popover_menu_pending.handlebars b/core/js/share/sharedialoglinkshareview_popover_menu_pending.handlebars
index f789d7ae80..787f50c6c1 100644
--- a/core/js/share/sharedialoglinkshareview_popover_menu_pending.handlebars
+++ b/core/js/share/sharedialoglinkshareview_popover_menu_pending.handlebars
@@ -10,7 +10,7 @@
diff --git a/core/js/sharedialoglinkshareview.js b/core/js/sharedialoglinkshareview.js
index 53ad88984a..4ea8c0fa15 100644
--- a/core/js/sharedialoglinkshareview.js
+++ b/core/js/sharedialoglinkshareview.js
@@ -189,6 +189,8 @@
shareData.password = this.password
}
+ var newShareId = false;
+
// We need a password before the share creation
if (isPasswordEnforced && !this.showPending && this.password === '') {
this.showPending = shareId;
@@ -196,18 +198,32 @@
$li.find('#enforcedPassText').focus();
} else {
// else, we have a password or it is not enforced
- this.model.saveLinkShare(shareData, {
+ $.when(this.model.saveLinkShare(shareData, {
success: function() {
$loading.addClass('hidden');
$li.find('.icon').removeClass('hidden');
self.render();
+ // open the menu by default
+ // we can only do that after the render
+ if (newShareId) {
+ var shares = self.$el.find('li[data-share-id]');
+ var $newShare = self.$el.find('li[data-share-id="'+newShareId+'"]');
+ // only open the menu by default if this is the first share
+ if ($newShare && shares.length === 1) {
+ $menu = $newShare.find('.popovermenu');
+ OC.showMenu(null, $menu);
+ }
+ }
},
error: function() {
OC.Notification.showTemporary(t('core', 'Unable to create a link share'));
$loading.addClass('hidden');
$li.find('.icon').removeClass('hidden');
}
- })
+ })).then(function(response) {
+ // resolve before success
+ newShareId = response.ocs.data.id
+ });
}
},
@@ -515,6 +531,12 @@
this.$el.find('.datepicker').datepicker({dateFormat : 'dd-mm-yy'});
+ var minPasswordLength = 4
+ // password policy?
+ if(oc_capabilities.password_policy && oc_capabilities.password_policy.minLength) {
+ minPasswordLength = oc_capabilities.password_policy.minLength;
+ }
+
var popoverBase = {
social: social,
urlLabel: t('core', 'Link'),
@@ -550,6 +572,7 @@
isPasswordEnforced: isPasswordEnforced,
enforcedPasswordLabel: t('core', 'Password protection for links is mandatory'),
passwordPlaceholder: passwordPlaceholderInitial,
+ minPasswordLength: minPasswordLength,
};
var pendingPopoverMenu = this.pendingPopoverMenuTemplate(_.extend({}, pendingPopover))
diff --git a/core/js/sharetemplates.js b/core/js/sharetemplates.js
index 37ca778402..bd9886e6af 100644
--- a/core/js/sharetemplates.js
+++ b/core/js/sharetemplates.js
@@ -250,7 +250,9 @@ templates['sharedialoglinkshareview_popover_menu_pending'] = template({"1":funct
+ alias4(((helper = (helper = helpers.enforcedPasswordLabel || (depth0 != null ? depth0.enforcedPasswordLabel : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"enforcedPasswordLabel","hash":{},"data":data}) : helper)))
+ "
\n \n \n \n";
+ + "\" autocomplete=\"enforcedPassText\" minlength=\""
+ + alias4(((helper = (helper = helpers.minPasswordLength || (depth0 != null ? depth0.minPasswordLength : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"minPasswordLength","hash":{},"data":data}) : helper)))
+ + "\" />\n \n \n \n \n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var stack1;