aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2023-01-04 12:12:12 +0100
committerJohn Molakvoæ <skjnldsv@protonmail.com>2023-01-04 16:46:17 +0100
commit62497323edd2d12f8fcef4170658102e5d51b61b (patch)
tree1a1dcf7daa0c271d8b5d6053fa69a46370ec67c6 /apps
parent811ba0bd3be3862dbd13167695b7fc15988bbd0c (diff)
downloadnextcloud-server-62497323edd2d12f8fcef4170658102e5d51b61b.tar.gz
nextcloud-server-62497323edd2d12f8fcef4170658102e5d51b61b.zip
feat(files): Add clipboard copy to webdav url in files settings
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/files/src/views/Settings.vue39
1 files changed, 36 insertions, 3 deletions
diff --git a/apps/files/src/views/Settings.vue b/apps/files/src/views/Settings.vue
index 2b2e14fd8fc..9a63fea4924 100644
--- a/apps/files/src/views/Settings.vue
+++ b/apps/files/src/views/Settings.vue
@@ -47,7 +47,19 @@
<!-- Webdav URL-->
<NcAppSettingsSection id="webdav" :title="t('files', 'Webdav')">
- <NcInputField type="text" readonly="readonly" :value="webdavUrl" />
+ <NcInputField id="webdav-url-input"
+ :show-trailing-button="true"
+ :success="webdavUrlCopied"
+ :trailing-button-label="t('files', 'Copy to clipboard')"
+ :value="webdavUrl"
+ readonly="readonly"
+ type="url"
+ @focus="$event.target.select()"
+ @trailing-button-click="copyCloudId">
+ <template #trailing-button-icon>
+ <Clipboard :size="20" />
+ </template>
+ </NcInputField>
<em>
<a :href="webdavDocs" target="_blank" rel="noreferrer noopener">
{{ t('files', 'Use this address to access your Files via WebDAV') }} ↗
@@ -61,15 +73,17 @@
import NcAppSettingsDialog from '@nextcloud/vue/dist/Components/NcAppSettingsDialog.js'
import NcAppSettingsSection from '@nextcloud/vue/dist/Components/NcAppSettingsSection.js'
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
+import Clipboard from 'vue-material-design-icons/Clipboard.vue'
import NcInputField from '@nextcloud/vue/dist/Components/NcInputField'
import Setting from '../components/Setting.vue'
+import { emit } from '@nextcloud/event-bus'
import { generateRemoteUrl, generateUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'
import { loadState } from '@nextcloud/initial-state'
-import { emit } from '@nextcloud/event-bus'
-import axios from '@nextcloud/axios'
+import { showError, showSuccess } from '@nextcloud/dialogs'
import { translate } from '@nextcloud/l10n'
+import axios from '@nextcloud/axios'
const userConfig = loadState('files', 'config', {
show_hidden: false,
@@ -79,6 +93,7 @@ const userConfig = loadState('files', 'config', {
export default {
name: 'Settings',
components: {
+ Clipboard,
NcAppSettingsDialog,
NcAppSettingsSection,
NcCheckboxRadioSwitch,
@@ -104,6 +119,7 @@ export default {
// Webdav infos
webdavUrl: generateRemoteUrl('dav/files/' + encodeURIComponent(getCurrentUser()?.uid)),
webdavDocs: 'https://docs.nextcloud.com/server/stable/go.php?to=user-webdav',
+ webdavUrlCopied: false,
}
},
@@ -129,6 +145,23 @@ export default {
})
},
+ async copyCloudId() {
+ document.querySelector('input#webdav-url-input').select()
+
+ if (!navigator.clipboard) {
+ // Clipboard API not available
+ showError(t('files', 'Clipboard is not available'))
+ return
+ }
+
+ await navigator.clipboard.writeText(this.webdavUrl)
+ this.webdavUrlCopied = true
+ showSuccess(t('files', 'Webdav URL copied to clipboard'))
+ setTimeout(() => {
+ this.webdavUrlCopied = false
+ }, 5000)
+ },
+
t: translate,
},
}