Skip to content

Commit

Permalink
Extract enforce-password modal incl. closing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalwengerter committed May 23, 2022
1 parent e7011b7 commit a60dff0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ export default defineComponent({
if (this.isPasswordEnforcedFor(link)) {
showQuickLinkPasswordModal({ store: this.$store }, async (newPassword) => {
this.hideModal()
this.createLink({ params: { ...paramsToCreate, password: newPassword }, onError })
})
} else {
Expand All @@ -387,7 +386,6 @@ export default defineComponent({
if (!link.password && this.isPasswordEnforcedFor(link)) {
showQuickLinkPasswordModal({ store: this.$store }, async (newPassword) => {
this.hideModal()
this.updatePublicLink({ params: { ...params, password: newPassword }, onSuccess })
})
} else {
Expand Down
19 changes: 11 additions & 8 deletions packages/web-app-files/src/quickActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,17 @@ export function showQuickLinkPasswordModal(ctx, onConfirm) {
inputLabel: $gettext('Password'),
onCancel: () => ctx.store.dispatch('hideModal'),
inputDescription: $gettext('Passwords for links are required.'),
onConfirm: (password) => onConfirm(password),
onConfirm: async (password) => {
if (!password || password.trim() === '') {
ctx.store.dispatch('showMessage', {
title: $gettext('Password cannot be empty'),
status: 'danger'
})
} else {
await ctx.store.dispatch('hideModal')
onConfirm(password)
}
},
onInput: (password) => {
if (password.trim() === '') {
return ctx.store.dispatch('setModalInputErrorMessage', $gettext('Password cannot be empty'))
Expand Down Expand Up @@ -61,13 +71,6 @@ export default {

if (passwordEnforced) {
return showQuickLinkPasswordModal(ctx, async (password) => {
if (!password || password.trim() === '') {
return ctx.store.dispatch('showMessage', {
title: $gettext('Password cannot be empty'),
status: 'danger'
})
}
ctx.store.dispatch('hideModal')
await createQuicklink({ ...ctx, resource: ctx.item, password })
await ctx.store.dispatch('Files/sidebar/openWithPanel', 'sharing-item')
})
Expand Down

0 comments on commit a60dff0

Please sign in to comment.