diff --git a/apps/files/src/actions/editLocallyAction.ts b/apps/files/src/actions/editLocallyAction.ts index 7e44927eba29a..5c796ef9afda7 100644 --- a/apps/files/src/actions/editLocallyAction.ts +++ b/apps/files/src/actions/editLocallyAction.ts @@ -9,9 +9,15 @@ import { FileAction, Permission, type Node } from '@nextcloud/files' import { showError } from '@nextcloud/dialogs' import { translate as t } from '@nextcloud/l10n' import axios from '@nextcloud/axios' - +import { spawnDialog } from '@nextcloud/dialogs' import LaptopSvg from '@mdi/svg/svg/laptop.svg?raw' +import ConfirmLocalEditModal from '../components/modals/ConfirmLocalEditModal.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 +33,27 @@ const openLocalClient = async function(path: string) { } } + +const showConfirmLocalEditModal = async function(path: string, fileName: string = '') { + spawnDialog( + ConfirmLocalEditModal, + { + name: t('richdocuments', 'Open file locally'), + description: t('richdocuments', '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('richdocuments', 'Retry to open locally'), + cancelButtonText: t('richdocuments', '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/modals/ConfirmLocalEditModal.vue b/apps/files/src/components/modals/ConfirmLocalEditModal.vue new file mode 100644 index 0000000000000..7f8116f5a1324 --- /dev/null +++ b/apps/files/src/components/modals/ConfirmLocalEditModal.vue @@ -0,0 +1,82 @@ + + + + + {{ name }} + {{ description }} + + close(false)"> + {{ cancelButtonText }} + + close(true)"> + {{ confirmButtonText }} + + + + + + + \ No newline at end of file
{{ description }}