diff --git a/apps/files/src/actions/editLocallyAction.ts b/apps/files/src/actions/editLocallyAction.ts index 7e44927eba29a..62632aae51887 100644 --- a/apps/files/src/actions/editLocallyAction.ts +++ b/apps/files/src/actions/editLocallyAction.ts @@ -6,12 +6,17 @@ import { encodePath } from '@nextcloud/paths' import { generateOcsUrl } from '@nextcloud/router' import { getCurrentUser } from '@nextcloud/auth' import { FileAction, Permission, type Node } from '@nextcloud/files' -import { showError } from '@nextcloud/dialogs' +import { showError, spawnDialog } from '@nextcloud/dialogs' import { translate as t } from '@nextcloud/l10n' import axios from '@nextcloud/axios' - import LaptopSvg from '@mdi/svg/svg/laptop.svg?raw' +import ConfirmLocalEditDialog from '../components/dialogs/ConfirmLocalEditDialog.vue' + +var openingLocally: Boolean = false +const startOpenLocalProcess = async function (path: string) { + showConfirmLocalEditModal(path) +} const openLocalClient = async function(path: string) { const link = generateOcsUrl('apps/files/api/v1') + '/openlocaleditor?format=json' @@ -27,6 +32,27 @@ const openLocalClient = async function(path: string) { } } + +const showConfirmLocalEditModal = async function(path: string, fileName: string = '') { + spawnDialog( + ConfirmLocalEditDialog, + { + name: t('files', 'Open file locally'), + description: t('files', 'The file should now open locally. If you don\'t see this happening, make sure that the desktop client is installed on your system.'), + confirmButtonText: t('files', 'Retry to open locally'), + cancelButtonText: t('files', 'Continue editing online'), + }, + (decision) => { + if (!decision) { + window.OCA.Viewer.open({ path: fileName }) + return + } + openingLocally = true + openLocalClient + }, + ) +} + export const action = new FileAction({ id: 'edit-locally', displayName: () => t('files', 'Edit locally'), diff --git a/apps/files/src/components/FileEntry/FileEntryActions.vue b/apps/files/src/components/FileEntry/FileEntryActions.vue index 3df4289b1a001..4019e8cb9e18b 100644 --- a/apps/files/src/components/FileEntry/FileEntryActions.vue +++ b/apps/files/src/components/FileEntry/FileEntryActions.vue @@ -262,6 +262,7 @@ export default defineComponent({ }, async onActionClick(action, isSubmenu = false) { + debugger // Skip click on loading if (this.isLoading || this.loading !== '') { return diff --git a/apps/files/src/components/dialogs/ConfirmLocalEditDialog.vue b/apps/files/src/components/dialogs/ConfirmLocalEditDialog.vue new file mode 100644 index 0000000000000..7e42b16f02f2b --- /dev/null +++ b/apps/files/src/components/dialogs/ConfirmLocalEditDialog.vue @@ -0,0 +1,55 @@ + + + + Last response: {{ lastResponse }} + + +
Last response: {{ lastResponse }}