]> source.dussan.org Git - nextcloud-server.git/commitdiff
Show pending popover menu when password is enabled by default
authorDaniel Calviño Sánchez <danxuliu@gmail.com>
Tue, 9 May 2023 23:54:32 +0000 (01:54 +0200)
committerChristopher Ng <chrng8@gmail.com>
Tue, 13 Jun 2023 22:08:45 +0000 (15:08 -0700)
When "Enforce password protection" is enabled in the sharing settings a
popover menu is shown to set a password before the share is created. On
the other hand, when "Always ask for a password" was enabled in the
sharing settings and a new link share was created the share was
immediately created with a default password; the user was not able to
specify a password (nor create the share without password).

The component template already provided the needed elements to also ask
for the password without enforcing it, but the popover menu was not
shown due to "enableLinkPasswordByDefault" being missing in "if"
conditions.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
(cherry picked from commit d4631921b4f4ab2832bc6698def47aa16d60c621)

apps/files_sharing/src/components/SharingEntryLink.vue

index a81cfcffb5d5e8941c354decdd08e37005b4595c..0b6cdaeb4a64185230220fdb0442f8432cef688d 100644 (file)
@@ -47,7 +47,7 @@
                </NcActions>
 
                <!-- pending actions -->
-               <NcActions v-if="!pending && (pendingEnforcedPassword || pendingExpirationDate)"
+               <NcActions v-if="!pending && (pendingPassword || pendingEnforcedPassword || pendingExpirationDate)"
                        class="sharing-entry__actions"
                        :aria-label="actionsTooltip"
                        menu-align="right"
@@ -67,7 +67,7 @@
                        <NcActionText v-if="pendingEnforcedPassword" icon="icon-password">
                                {{ t('files_sharing', 'Password protection (enforced)') }}
                        </NcActionText>
-                       <NcActionCheckbox v-else-if="config.enableLinkPasswordByDefault"
+                       <NcActionCheckbox v-else-if="pendingPassword"
                                :checked.sync="isPasswordProtected"
                                :disabled="config.enforcePasswordForPublicLink || saving"
                                class="share-link-password-checkbox"
@@ -515,6 +515,9 @@ export default {
                 *
                 * @return {boolean}
                 */
+               pendingPassword() {
+                       return this.config.enableLinkPasswordByDefault && this.share && !this.share.id
+               },
                pendingEnforcedPassword() {
                        return this.config.enforcePasswordForPublicLink && this.share && !this.share.id
                },
@@ -612,12 +615,9 @@ export default {
                                // expiration is the share object key, not expireDate
                                shareDefaults.expiration = this.formatDateToString(this.config.defaultExpirationDate)
                        }
-                       if (this.config.enableLinkPasswordByDefault) {
-                               shareDefaults.password = await GeneratePassword()
-                       }
 
                        // do not push yet if we need a password or an expiration date: show pending menu
-                       if (this.config.enforcePasswordForPublicLink || this.config.isDefaultExpireDateEnforced) {
+                       if (this.config.enableLinkPasswordByDefault || this.config.enforcePasswordForPublicLink || this.config.isDefaultExpireDateEnforced) {
                                this.pending = true
 
                                // if a share already exists, pushing it
@@ -640,8 +640,8 @@ export default {
                                }
 
                                // ELSE, show the pending popovermenu
-                               // if password enforced, pre-fill with random one
-                               if (this.config.enforcePasswordForPublicLink) {
+                               // if password default or enforced, pre-fill with random one
+                               if (this.config.enableLinkPasswordByDefault || this.config.enforcePasswordForPublicLink) {
                                        shareDefaults.password = await GeneratePassword()
                                }