-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move quickActions into own file and pass store into context
- Loading branch information
Showing
4 changed files
with
57 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import moment from 'moment' | ||
import copyToClipboard from 'copy-to-clipboard' | ||
|
||
// just a dummy function to trick gettext tools | ||
function $gettext(msg) { | ||
return msg | ||
} | ||
|
||
function createPublicLink(ctx) { | ||
// FIXME: Translate name | ||
const params = { name: 'Quick action link' } | ||
const capabilities = ctx.store.state.user.capabilities | ||
const expirationDate = capabilities.files_sharing.public.expire_date | ||
|
||
if (expirationDate.enabled) { | ||
params.expireDate = moment() | ||
.add(parseInt(expirationDate.days, 10), 'days') | ||
.endOf('day') | ||
.toISOString() | ||
} | ||
|
||
return new Promise((resolve, reject) => { | ||
ctx.client.shares | ||
.shareFileWithLink(ctx.item.path, params) | ||
.then(res => { | ||
copyToClipboard(res.shareInfo.url) | ||
ctx.store.dispatch('showMessage', { | ||
title: $gettext('Public link created'), | ||
desc: $gettext( | ||
'Public link has been successfully created and copied into your clipboard.' | ||
), | ||
status: 'success' | ||
}) | ||
resolve() | ||
}) | ||
.catch(e => { | ||
reject(e) | ||
}) | ||
}) | ||
} | ||
|
||
export default { | ||
publicLink: { | ||
id: 'public-link', | ||
label: $gettext('Create and copy public link'), | ||
icon: 'link', | ||
handler: createPublicLink | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Enhancement: Load and display quick actions | ||
|
||
We've added an extension point into files apps for quick actions. | ||
By creating and exporting object called quickActions, developers can define an action which will be then displayed in the files list. | ||
By creating and exporting an object called quickActions, developers can define an action which will be then displayed in the files list. | ||
|
||
https://github.com/owncloud/phoenix/pull/3573 |