Skip to content

Commit

Permalink
Partial update for publink links
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAndBear committed Oct 14, 2024
1 parent a16fc35 commit 03d5fe1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ import {
useConfigStore,
useResourcesStore,
useLinkTypes,
useCanShare
useCanShare,
UpdateLinkOptions
} from '@ownclouders/web-pkg'
import { shareViaLinkHelp, shareViaIndirectLinkHelp } from '../../../helpers/contextualHelpers'
import { isSpaceResource, LinkShare } from '@ownclouders/web-client'
Expand Down Expand Up @@ -185,23 +186,18 @@ export default defineComponent({
const handleLinkUpdate = async ({
linkShare,
password = undefined
options
}: {
linkShare: LinkShare
password?: string
options: UpdateLinkOptions['options']
}) => {
try {
await updateLink({
clientService,
space: unref(space),
resource: unref(resource),
linkShare,
options: {
displayName: linkShare.displayName,
type: linkShare.type,
expirationDateTime: linkShare.expirationDateTime,
...(password !== undefined && { password })
}
options
})
showMessage({ title: $gettext('Link was updated successfully') })
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ export default defineComponent({
}),
onConfirm: (expirationDateTime: DateTime) => {
emit('updateLink', {
linkShare: { ...props.linkShare, expirationDateTime }
linkShare: { ...props.linkShare },
options: { expirationDateTime }
})
}
})
Expand Down Expand Up @@ -184,8 +185,7 @@ export default defineComponent({
},
onConfirm: (displayName: string) => {
const linkShare = props.linkShare
linkShare.displayName = displayName
emit('updateLink', { linkShare })
emit('updateLink', { linkShare, options: { displayName } })
}
})
}
Expand Down Expand Up @@ -220,7 +220,8 @@ export default defineComponent({
icon: 'calendar-close',
method: () => {
emit('updateLink', {
linkShare: { ...props.linkShare, expirationDateTime: null }
linkShare: { ...props.linkShare },
options: { expirationDateTime: null }
})
unref(editPublicLinkDropdown).hide()
}
Expand All @@ -247,7 +248,8 @@ export default defineComponent({
id: 'remove-password',
title: $gettext('Remove password'),
icon: 'lock-unlock',
method: () => emit('updateLink', { linkShare: props.linkShare, password: '' })
method: () =>
emit('updateLink', { linkShare: props.linkShare, options: { password: '' } })
})
}
}
Expand Down Expand Up @@ -280,6 +282,7 @@ export default defineComponent({
width: 100%;
justify-content: flex-start;
}
&-delete {
margin-top: var(--oc-space-small) !important;
border-top: 1px solid var(--oc-color-border) !important;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,19 @@ export default defineComponent({
const updateSelectedType = (type: SharingLinkType) => {
currentLinkType.value = type
const linkShare = props.linkShare
linkShare.type = type
const needsNoPw =
type === SharingLinkType.Internal ||
(unref(canDeleteReadOnlyPublicLinkPassword) && type === SharingLinkType.View)
if (!linkShare.hasPassword && !needsNoPw && props.isPasswordEnforced) {
showPasswordModal(() => emit('updateLink', { linkShare: { ...linkShare, type } }))
showPasswordModal(() =>
emit('updateLink', { linkShare: { ...linkShare }, options: { type } })
)
return
}
emit('updateLink', { linkShare })
emit('updateLink', { linkShare, options: { type } })
}
const showPasswordModal = (callbackFn: () => void = undefined) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ export const useSharesStore = defineStore('shares', () => {
'@libre.graph.displayName': options.displayName
})
},
expirationDateTime: options.expirationDateTime
...(Object.hasOwn(options, 'expirationDateTime') && {
expirationDateTime: options.expirationDateTime
})
} satisfies Permission

link = await client.updatePermission<LinkShare>(space.id, resource.id, linkShare.id, payload)
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 03d5fe1

Please sign in to comment.