diff --git a/cypress/e2e/column-text-link.cy.js b/cypress/e2e/column-text-link.cy.js index c3022f3f8..5d11f9e02 100644 --- a/cypress/e2e/column-text-link.cy.js +++ b/cypress/e2e/column-text-link.cy.js @@ -37,8 +37,7 @@ describe('Test column text-link', () => { cy.loadTable('Test text-link') cy.get('.NcTable').contains('Create row').click({ force: true }) - cy.get('.modal__content .slot input').first().type('https://nextcloud.com').tick(500) - cy.get('.icon-label-container .labels').contains('https://nextcloud.com').click() + cy.get('.modal__content .slot input').first().type('https://nextcloud.com') cy.intercept({ method: 'GET', url: '**/search/providers/files/*' }).as('filesResults') cy.get('.modal__content .slot input').eq(1).type('pdf').tick(500) @@ -58,8 +57,7 @@ describe('Test column text-link', () => { cy.loadTable('Test text-link') cy.get('.NcTable tr td button').click({ force: true }) - cy.get('.modal__content .slot input').first().clear().type('https://github.com').tick(500) - cy.get('[data-cy*="github"]').click() + cy.get('.modal__content .slot input').first().clear().type('https://github.com') cy.get('.modal__content .slot input').eq(1).type('photo-test').tick(500) cy.get('[data-cy*="photo-test"]').first().click() diff --git a/cypress/support/commands.js b/cypress/support/commands.js index a6cee5b23..eb67e7048 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -156,7 +156,9 @@ Cypress.Commands.add('createTextLinkColumn', (title, ressourceProvider, isFirstC cy.get('.typeSelection span').contains('Url', { matchCase: false }).click() cy.get('.typeSelection span').contains('Files').click() // TODO is the contacts search provider deactivated by default beginning with nc28 - // cy.get('.typeSelection span label').contains('Contacts').click() + if (['stable27'].includes(Cypress.env('ncVersion'))) { + cy.get('.typeSelection span').contains('Contacts').click() + } ressourceProvider.forEach(provider => cy.get('.typeSelection span').contains(provider, { matchCase: false }).click(), diff --git a/src/modules/sidebar/sections/SidebarIntegration.vue b/src/modules/sidebar/sections/SidebarIntegration.vue index 60d09644b..387c4a473 100644 --- a/src/modules/sidebar/sections/SidebarIntegration.vue +++ b/src/modules/sidebar/sections/SidebarIntegration.vue @@ -48,9 +48,10 @@ import { mapGetters, mapState } from 'vuex' import { generateUrl } from '@nextcloud/router' import permissionsMixin from '../../../shared/components/ncTable/mixins/permissionsMixin.js' +import copyToClipboard from '../../../shared/mixins/copyToClipboard.js' + import NcInputField from '@nextcloud/vue/dist/Components/NcInputField.js' import ContentCopy from 'vue-material-design-icons/ContentCopy.vue' -import { showError, showSuccess } from '@nextcloud/dialogs' export default { components: { @@ -58,7 +59,7 @@ export default { ContentCopy, }, - mixins: [permissionsMixin], + mixins: [permissionsMixin, copyToClipboard], data() { return { @@ -80,22 +81,7 @@ export default { }, methods: { copyUrl() { - if (navigator?.clipboard) { - navigator.clipboard.writeText(this.apiEndpointUrl).then(function() { - showSuccess(t('files', 'Integration URL copied to clipboard')) - }, function(err) { - showError(t('files', 'Clipboard is not available')) - console.error('Async: Could not copy text: ', err) - }) - } else { - try { - document.querySelector('input#urlTextField').select() - document.execCommand('copy') - showSuccess(t('files', 'Integration URL copied to clipboard')) - } catch (e) { - showError(t('files', 'Clipboard is not available')) - } - } + this.copyToClipboard(this.apiEndpointUrl, false) }, }, } diff --git a/src/shared/components/ncTable/partials/rowTypePartials/TextLinkForm.vue b/src/shared/components/ncTable/partials/rowTypePartials/TextLinkForm.vue index a5284cfcb..86b7a786d 100644 --- a/src/shared/components/ncTable/partials/rowTypePartials/TextLinkForm.vue +++ b/src/shared/components/ncTable/partials/rowTypePartials/TextLinkForm.vue @@ -10,8 +10,9 @@ {{ t('tables', 'You can not insert any links in this field. Please configure at least one link provider in the column configuration.') }} -
- + + + + + + + +
+ + diff --git a/src/shared/mixins/copyToClipboard.js b/src/shared/mixins/copyToClipboard.js new file mode 100644 index 000000000..41e129b6e --- /dev/null +++ b/src/shared/mixins/copyToClipboard.js @@ -0,0 +1,30 @@ +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { showError, showSuccess } from '@nextcloud/dialogs' + +export default { + methods: { + async copyToClipboard(content, silent = true) { + try { + if (navigator?.clipboard) { + await navigator.clipboard.writeText(content) + } else { + throw new Error('Clipboard is not available') + } + + if (!silent) { + showSuccess(t('files', 'Copied to clipboard.')) + } + return true + } catch (e) { + console.error('Error copying to clipboard', e) + if (!silent) { + showError(t('files', 'Clipboard is not available')) + } + } + }, + }, +}