diff --git a/packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue b/packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue
index 2644cdc391c..fd396be7b1f 100644
--- a/packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue
+++ b/packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue
@@ -15,7 +15,7 @@
>('space')
const resource = inject[>('resource')
@@ -221,6 +226,36 @@ export default defineComponent({
)
}
+ const showQuickLinkPasswordModal = (params = {}) => {
+ const modal = {
+ variation: 'passive',
+ title: $gettext('Set password'),
+ cancelText: $gettext('Cancel'),
+ confirmText: $gettext('Set'),
+ hasInput: true,
+ inputDescription: $gettext('Passwords for links are required.'),
+ inputPasswordPolicy: passwordPolicyService.getPolicy(),
+ inputGeneratePasswordMethod: () => passwordPolicyService.generatePassword(),
+ inputLabel: $gettext('Password'),
+ inputType: 'password',
+ onInput: () => store.dispatch('setModalInputErrorMessage', ''),
+ onPasswordChallengeCompleted: () => store.dispatch('setModalConfirmButtonDisabled', false),
+ onPasswordChallengeFailed: () => store.dispatch('setModalConfirmButtonDisabled', true),
+ onCancel: () => store.dispatch('hideModal'),
+ onConfirm: async (newPassword: string) => {
+ await createLink({
+ resource: unref(resource),
+ space: unref(space),
+ ...params,
+ password: newPassword
+ })
+ return store.dispatch('hideModal')
+ }
+ }
+
+ return store.dispatch('createModal', modal)
+ }
+
return {
$store: store,
ability,
@@ -228,7 +263,7 @@ export default defineComponent({
resource,
incomingParentShare: inject('incomingParentShare'),
hasSpaces: useCapabilitySpacesEnabled(),
- hasShareJail: useCapabilityShareJailEnabled(),
+ hasShareJail,
hasPublicLinkEditing: useCapabilityFilesSharingPublicCanEdit(),
hasPublicLinkContribute: useCapabilityFilesSharingPublicCanContribute(),
hasPublicLinkAliasSupport: useCapabilityFilesSharingPublicAlias(),
@@ -241,10 +276,12 @@ export default defineComponent({
canCreatePublicLinks,
canDeleteReadOnlyPublicLinkPassword,
configurationManager,
- passwordPolicyService,
canCreateLinks,
canEditLink,
- expirationRules
+ expirationRules,
+ createLink,
+ showQuickLinkPasswordModal,
+ defaultLinkPermissions
}
},
computed: {
@@ -380,37 +417,12 @@ export default defineComponent({
)
},
- addNewLink() {
- this.checkLinkToCreate({
- link: {
- name: this.$gettext('Link'),
- permissions: getDefaultLinkPermissions({
- ability: this.ability,
- store: this.$store
- }).toString(),
- expiration: this.expirationRules.default,
- password: false
- }
- })
- },
-
- checkLinkToCreate({ link }) {
- const paramsToCreate = this.getParamsForLink(link)
-
- if (this.isPasswordEnforcedFor(link)) {
- showQuickLinkPasswordModal(
- {
- ...this.$language,
- store: this.$store,
- passwordPolicyService: this.passwordPolicyService
- },
- (newPassword) => {
- this.createLink({ params: { ...paramsToCreate, password: newPassword } })
- }
- )
- } else {
- this.createLink({ params: paramsToCreate })
+ addNewLink({ link }) {
+ if (this.isPasswordEnforcedFor({ permissions: this.defaultLinkPermissions })) {
+ return this.showQuickLinkPasswordModal(link)
}
+
+ return this.createLink({ resource: this.resource, space: this.space, ...link })
},
checkLinkToUpdate({ link }) {
@@ -424,16 +436,7 @@ export default defineComponent({
}
if (!link.password && !this.canDeletePublicLinkPassword(link)) {
- showQuickLinkPasswordModal(
- {
- ...this.$language,
- store: this.$store,
- passwordPolicyService: this.passwordPolicyService
- },
- (newPassword) => {
- this.updatePublicLink({ params: { ...params, password: newPassword } })
- }
- )
+ this.showQuickLinkPasswordModal(params)
} else {
this.updatePublicLink({ params })
}
@@ -490,38 +493,6 @@ export default defineComponent({
}
},
- async createLink({ params }) {
- let path = this.resource.path
- // sharing a share root from the share jail -> use resource name as path
- if (this.hasShareJail && path === '/') {
- path = `/${this.resource.name}`
- }
- try {
- await this.addLink({
- path,
- client: this.$client,
- storageId: this.resource.fileId || this.resource.id,
- params
- })
- this.hideModal()
- this.showMessage({
- title: this.$gettext('Link was created successfully')
- })
- } catch (e) {
- console.error(e)
-
- // Human-readable error message is provided, for example when password is on banned list
- if (e.statusCode === 400) {
- return this.setModalInputErrorMessage(this.$gettext(e.message))
- }
-
- this.showErrorMessage({
- title: this.$gettext('Failed to create link'),
- error: e
- })
- }
- },
-
async updatePublicLink({ params }) {
try {
await this.updateLink({
diff --git a/packages/web-app-files/src/components/SideBar/Shares/Links/CreateQuickLink.vue b/packages/web-app-files/src/components/SideBar/Shares/Links/CreateQuickLink.vue
index b045510bbed..7a15f5cef47 100644
--- a/packages/web-app-files/src/components/SideBar/Shares/Links/CreateQuickLink.vue
+++ b/packages/web-app-files/src/components/SideBar/Shares/Links/CreateQuickLink.vue
@@ -26,14 +26,10 @@
]