Skip to content

Commit 4814e47

Browse files
authored
Merge pull request #13296 from owncloud/feat/share-links-and-passswords
feat: share links and passwords in embed mode
2 parents f807d85 + fec0fea commit 4814e47

File tree

4 files changed

+55
-2
lines changed

4 files changed

+55
-2
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Enhancement: Embed mode share links with password
2+
3+
In embed mode, the "Copy link and password" button text has been changed to "Share link(s) and password(s)".
4+
When sharing links in embed mode, a new event `owncloud-embed:share-links` is now emitted that contains an array of objects with the link URL and optionally the password (when the "Share link(s) and password(s)" button is clicked).
5+
This allows parent applications to handle both the link and password programmatically.
6+
7+
DEPRECATION NOTICE: This deprecates the `owncloud-embed:share` event. The existing event continues to be emitted for backward compatibility.
8+
9+
https://github.com/owncloud/web/pull/13296

docs/embed-mode/_index.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ To maintain uniformity and ease of handling, each event encapsulates the same st
3535
| Name | Data | Description |
3636
| --- | --- | --- |
3737
| **owncloud-embed:select** | Resource[] | Gets emitted when user selects resources or location via the select action |
38-
| **owncloud-embed:share** | string[] | Gets emitted when user selects resources and shares them via the "Share links" action |
38+
| **owncloud-embed:share** | string[] | **DEPRECATED**: Gets emitted when user selects resources and shares them via the "Share links" action. Use `owncloud-embed:share-links` instead. |
39+
| **owncloud-embed:share-links** | Array<{ url: string; password?: string }> | Gets emitted when user selects resources and shares them via the "Share link(s)" or "Share link(s) and password(s)" action. Each object contains the link URL and optionally the password (when shared with password). |
3940
| **owncloud-embed:cancel** | null | Gets emitted when user attempts to close the embedded instance via "Cancel" action |
4041

4142
### Example
4243

44+
#### Selecting resources
45+
4346
```html
4447
<iframe src="https://my-owncloud-web-instance?embed=true"></iframe>
4548

@@ -58,6 +61,28 @@ To maintain uniformity and ease of handling, each event encapsulates the same st
5861
</script>
5962
```
6063
64+
#### Sharing links with password
65+
66+
```html
67+
<iframe src="https://my-owncloud-web-instance?embed=true"></iframe>
68+
69+
<script>
70+
function shareLinksEventHandler(event) {
71+
if (event.data?.name !== 'owncloud-embed:share-links') {
72+
return
73+
}
74+
75+
const links = event.data.data // Array<{ url: string; password?: string }>
76+
77+
links.forEach(link => console.log("Link", link.url, "Password", link.password))
78+
79+
doSomethingWithSharedLinks(links)
80+
}
81+
82+
window.addEventListener('message', shareLinksEventHandler)
83+
</script>
84+
```
85+
6186
## Location picker
6287
6388
By default, the Embed mode allows users to select resources. In certain cases (e.g. uploading a file), this needs to be changed to allow selecting a location. This can be achieved by running the embed mode with additional parameter `embed-target=location`. With this parameter, resource selection is disabled and the selected resources array always includes the current folder as the only item.

docs/releasing/deprecations.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The following features are deprecated and **will be removed** in the next major
1818

1919
| Component/Feature | Deprecated | Migration | Reference | Reasoning |
2020
|---|---|---|---|---|---|
21+
| `owncloud-embed:share` event | November 12, 2025 | Use `owncloud-embed:share-links` event instead | [PR #13296](https://github.com/owncloud/web/pull/13296) | New event provides structured data with both URL and optional password |
2122

2223
## Migration History
2324

packages/web-pkg/src/components/CreateLinkModal.vue

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
class="oc-modal-body-actions-confirm-password action-menu-item"
7272
appearance="raw"
7373
@click="$emit('confirm', { copyPassword: true })"
74-
>{{ $gettext('Copy link and password') }}
74+
>{{ confirmPasswordButtonText }}
7575
</oc-button>
7676
</li>
7777
</oc-list>
@@ -145,6 +145,14 @@ const confirmButtonText = computed(() => {
145145
return $gettext('Copy link')
146146
})
147147
148+
const confirmPasswordButtonText = computed(() => {
149+
if (unref(isEmbedEnabled)) {
150+
return $gettext('Share link(s) and password(s)')
151+
}
152+
153+
return $gettext('Copy link and password')
154+
})
155+
148156
const passwordInputKey = ref(uuidV4())
149157
const roleRefs = ref<Record<string, RoleRef>>({})
150158
@@ -211,10 +219,20 @@ const onConfirm = async (options: { copyPassword?: boolean } = {}) => {
211219
const failed = result.filter(({ status }) => status === 'rejected') as PromiseRejectedResult[]
212220
213221
if (succeeded.length && unref(isEmbedEnabled)) {
222+
// **DEPRECATED**: Always emit the share url for backwards compatibility
214223
postMessage<string[]>(
215224
'owncloud-embed:share',
216225
succeeded.map(({ value }) => value.webUrl)
217226
)
227+
228+
// Always emit new event with objects, include password only when copyPassword is enabled
229+
postMessage<Array<{ url: string; password?: string }>>(
230+
'owncloud-embed:share-links',
231+
succeeded.map(({ value }) => ({
232+
url: value.webUrl,
233+
...(options.copyPassword && { password: password.value })
234+
}))
235+
)
218236
}
219237
220238
const userFacingErrors: Error[] = []

0 commit comments

Comments
 (0)