Skip to content

Commit

Permalink
feat: migrate FileAction from server
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Aug 18, 2023
1 parent 6e4690d commit 302f696
Show file tree
Hide file tree
Showing 50 changed files with 71 additions and 294 deletions.
3 changes: 1 addition & 2 deletions apps/files/src/actions/deleteAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
*/
import { action } from './deleteAction'
import { expect } from '@jest/globals'
import { File, Folder, Permission, View } from '@nextcloud/files'
import { FileAction } from '../services/FileAction'
import { File, Folder, Permission, View, FileAction } from '@nextcloud/files'
import * as eventBus from '@nextcloud/event-bus'
import axios from '@nextcloud/axios'
import logger from '../logger'
Expand Down
3 changes: 1 addition & 2 deletions apps/files/src/actions/deleteAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
*
*/
import { emit } from '@nextcloud/event-bus'
import { Permission, Node, View } from '@nextcloud/files'
import { Permission, Node, View, registerFileAction, FileAction } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import axios from '@nextcloud/axios'
import TrashCanSvg from '@mdi/svg/svg/trash-can.svg?raw'

import { registerFileAction, FileAction } from '../services/FileAction'
import logger from '../logger.js'

export const action = new FileAction({
Expand Down
3 changes: 1 addition & 2 deletions apps/files/src/actions/downloadAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
*/
import { action } from './downloadAction'
import { expect } from '@jest/globals'
import { File, Folder, Permission, View } from '@nextcloud/files'
import { FileAction } from '../services/FileAction'
import { File, Folder, Permission, View, FileAction } from '@nextcloud/files'

const view = {
id: 'files',
Expand Down
6 changes: 2 additions & 4 deletions apps/files/src/actions/downloadAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import { Permission, Node, FileType, View } from '@nextcloud/files'
import { generateUrl } from '@nextcloud/router'
import { registerFileAction, FileAction, Permission, Node, FileType, View } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import ArrowDownSvg from '@mdi/svg/svg/arrow-down.svg?raw'

import { registerFileAction, FileAction } from '../services/FileAction'
import { generateUrl } from '@nextcloud/router'

const triggerDownload = function(url: string) {
const hiddenElement = document.createElement('a')
hiddenElement.download = ''
Expand Down
3 changes: 1 addition & 2 deletions apps/files/src/actions/editLocallyAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
*/
import { action } from './editLocallyAction'
import { expect } from '@jest/globals'
import { File, Permission, View } from '@nextcloud/files'
import { FileAction } from '../services/FileAction'
import { File, Permission, View, FileAction } from '@nextcloud/files'
import * as ncDialogs from '@nextcloud/dialogs'
import axios from '@nextcloud/axios'

Expand Down
11 changes: 5 additions & 6 deletions apps/files/src/actions/editLocallyAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@
*
*/
import { encodePath } from '@nextcloud/paths'
import { Permission, type Node } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import axios from '@nextcloud/axios'
import LaptopSvg from '@mdi/svg/svg/laptop.svg?raw'

import { generateOcsUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'
import { registerFileAction, FileAction, DefaultType } from '../services/FileAction'
import { registerFileAction, 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 LaptopSvg from '@mdi/svg/svg/laptop.svg?raw'

const openLocalClient = async function(path: string) {
const link = generateOcsUrl('apps/files/api/v1') + '/openlocaleditor?format=json'
Expand Down
3 changes: 1 addition & 2 deletions apps/files/src/actions/favoriteAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
*/
import { action } from './favoriteAction'
import { expect } from '@jest/globals'
import { File, Permission, View } from '@nextcloud/files'
import { FileAction } from '../services/FileAction'
import { File, Permission, View, FileAction } from '@nextcloud/files'
import * as eventBus from '@nextcloud/event-bus'
import * as favoriteAction from './favoriteAction'
import axios from '@nextcloud/axios'
Expand Down
3 changes: 1 addition & 2 deletions apps/files/src/actions/favoriteAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
*/
import { emit } from '@nextcloud/event-bus'
import { generateUrl } from '@nextcloud/router'
import { Permission, type Node, View } from '@nextcloud/files'
import { Permission, type Node, View, registerFileAction, FileAction } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import axios from '@nextcloud/axios'
import Vue from 'vue'

import StarOutlineSvg from '@mdi/svg/svg/star-outline.svg?raw'
import StarSvg from '@mdi/svg/svg/star.svg?raw'

import { registerFileAction, FileAction } from '../services/FileAction'
import logger from '../logger.js'

// If any of the nodes is not favorited, we display the favorite action.
Expand Down
3 changes: 1 addition & 2 deletions apps/files/src/actions/openFolderAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
*
*/
import { expect } from '@jest/globals'
import { File, Folder, Node, Permission, View } from '@nextcloud/files'
import { File, Folder, Node, Permission, View, DefaultType, FileAction } from '@nextcloud/files'

import { action } from './openFolderAction'
import { DefaultType, FileAction } from '../services/FileAction'

const view = {
id: 'files',
Expand Down
6 changes: 2 additions & 4 deletions apps/files/src/actions/openFolderAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import { Permission, Node, FileType, View } from '@nextcloud/files'
import { join } from 'path'
import { Permission, Node, FileType, View, registerFileAction, FileAction, DefaultType } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import FolderSvg from '@mdi/svg/svg/folder.svg?raw'

import { join } from 'path'
import { registerFileAction, FileAction, DefaultType } from '../services/FileAction'

export const action = new FileAction({
id: 'open-folder',
displayName(files: Node[]) {
Expand Down
3 changes: 1 addition & 2 deletions apps/files/src/actions/openInFilesAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
*/
import { action } from './openInFilesAction'
import { expect } from '@jest/globals'
import { File, Folder, Permission, View } from '@nextcloud/files'
import { DefaultType, FileAction } from '../../../files/src/services/FileAction'
import { File, Folder, Permission, View, DefaultType, FileAction } from '@nextcloud/files'

const view = {
id: 'files',
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/actions/openInFilesAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import { translate as t } from '@nextcloud/l10n'
import { FileType, type Node } from '@nextcloud/files'

import { registerFileAction, FileAction, DefaultType } from '../../../files/src/services/FileAction'
import { registerFileAction, FileAction, DefaultType } from '@nextcloud/files'

/**
* TODO: Move away from a redirect and handle
Expand Down
3 changes: 1 addition & 2 deletions apps/files/src/actions/renameAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
*/
import { action } from './renameAction'
import { expect } from '@jest/globals'
import { File, Permission, View } from '@nextcloud/files'
import { FileAction } from '../services/FileAction'
import { File, Permission, View, FileAction } from '@nextcloud/files'
import * as eventBus from '@nextcloud/event-bus'

const view = {
Expand Down
6 changes: 2 additions & 4 deletions apps/files/src/actions/renameAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import { Permission, type Node } from '@nextcloud/files'
import { emit } from '@nextcloud/event-bus'
import { Permission, type Node, registerFileAction, FileAction } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import PencilSvg from '@mdi/svg/svg/pencil.svg?raw'

import { emit } from '@nextcloud/event-bus'
import { registerFileAction, FileAction } from '../services/FileAction'

export const ACTION_DETAILS = 'details'

export const action = new FileAction({
Expand Down
3 changes: 1 addition & 2 deletions apps/files/src/actions/sidebarAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
*
*/
import { expect } from '@jest/globals'
import { File, Permission, View } from '@nextcloud/files'
import { File, Permission, View, FileAction } from '@nextcloud/files'

import { action } from './sidebarAction'
import { FileAction } from '../services/FileAction'
import logger from '../logger'

const view = {
Expand Down
3 changes: 1 addition & 2 deletions apps/files/src/actions/sidebarAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import { Permission, type Node, View } from '@nextcloud/files'
import { Permission, type Node, View, registerFileAction, FileAction } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import InformationSvg from '@mdi/svg/svg/information-variant.svg?raw'

import { registerFileAction, FileAction } from '../services/FileAction'
import logger from '../logger.js'

export const ACTION_DETAILS = 'details'
Expand Down
3 changes: 1 addition & 2 deletions apps/files/src/actions/viewInFolderAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
*/
import { action } from './viewInFolderAction'
import { expect } from '@jest/globals'
import { File, Folder, Node, Permission, View } from '@nextcloud/files'
import { FileAction } from '../services/FileAction'
import { File, Folder, Node, Permission, View, FileAction } from '@nextcloud/files'

const view = {
id: 'files',
Expand Down
4 changes: 1 addition & 3 deletions apps/files/src/actions/viewInFolderAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import { Node, FileType, Permission, View } from '@nextcloud/files'
import { Node, FileType, Permission, View, registerFileAction, FileAction } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import FolderMoveSvg from '@mdi/svg/svg/folder-move.svg?raw'

import { registerFileAction, FileAction } from '../services/FileAction'

export const action = new FileAction({
id: 'view-in-folder',
displayName() {
Expand Down
3 changes: 1 addition & 2 deletions apps/files/src/components/FileEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ import { CancelablePromise } from 'cancelable-promise'
import { debounce } from 'debounce'
import { emit } from '@nextcloud/event-bus'
import { extname } from 'path'
import { formatFileSize, Permission } from '@nextcloud/files'
import { generateUrl } from '@nextcloud/router'
import { getFileActions, DefaultType, formatFileSize, Permission } from '@nextcloud/files'
import { showError, showSuccess } from '@nextcloud/dialogs'
import { translate } from '@nextcloud/l10n'
import { vOnClickOutside } from '@vueuse/components'
Expand All @@ -187,7 +187,6 @@ import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'
import Vue from 'vue'
import { ACTION_DETAILS } from '../actions/sidebarAction.ts'
import { getFileActions, DefaultType } from '../services/FileAction.ts'
import { hashCode } from '../utils/hashUtils.ts'
import { isCachedPreview } from '../services/PreviewService.ts'
import { useActionsMenuStore } from '../store/actionsmenu.ts'
Expand Down
3 changes: 1 addition & 2 deletions apps/files/src/components/FilesListFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@
</template>

<script lang="ts">
import { formatFileSize } from '@nextcloud/files'
import { translate } from '@nextcloud/l10n'
import { formatFileSize, translate } from '@nextcloud/l10n'
import Vue from 'vue'

import { useFilesStore } from '../store/files.ts'
Expand Down
3 changes: 1 addition & 2 deletions apps/files/src/components/FilesListHeaderActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import Vue from 'vue'
import { getFileActions } from '../services/FileAction.ts'
import { useActionsMenuStore } from '../store/actionsmenu.ts'
import { getFileActions, useActionsMenuStore } from '../store/actionsmenu.ts'
import { useFilesStore } from '../store/files.ts'
import { useSelectionStore } from '../store/selection.ts'
import filesListWidthMixin from '../mixins/filesListWidth.ts'
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/components/FilesListTableHeaderActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
</template>

<script lang="ts">
import { getFileActions } from '@nextcloud/files'
import { showError, showSuccess } from '@nextcloud/dialogs'
import { translate } from '@nextcloud/l10n'
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import Vue from 'vue'
import { getFileActions } from '../services/FileAction.ts'
import { useActionsMenuStore } from '../store/actionsmenu.ts'
import { useFilesStore } from '../store/files.ts'
import { useSelectionStore } from '../store/selection.ts'
Expand Down
4 changes: 2 additions & 2 deletions apps/files/src/components/NavigationQuota.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
</template>

<script>
import { debounce, throttle } from 'throttle-debounce'
import { formatFileSize } from '@nextcloud/files'
import { generateUrl } from '@nextcloud/router'
import { loadState } from '@nextcloud/initial-state'
import { showError } from '@nextcloud/dialogs'
import { debounce, throttle } from 'throttle-debounce'
import { subscribe } from '@nextcloud/event-bus'
import { translate } from '@nextcloud/l10n'
import axios from '@nextcloud/axios'
import ChartPie from 'vue-material-design-icons/ChartPie.vue'
import NcAppNavigationItem from '@nextcloud/vue/dist/Components/NcAppNavigationItem.js'
import NcProgressBar from '@nextcloud/vue/dist/Components/NcProgressBar.js'
import logger from '../logger.js'
import { subscribe } from '@nextcloud/event-bus'
export default {
name: 'NavigationQuota',
Expand Down
3 changes: 1 addition & 2 deletions apps/files/src/components/VirtualList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
</template>

<script lang="ts">
import { File, Folder } from '@nextcloud/files'
import { debounce } from 'debounce'
import { File, Folder, debounce } from 'debounce'
import Vue from 'vue'
import logger from '../logger.js'
Expand Down
1 change: 0 additions & 1 deletion apps/files/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import './actions/openInFilesAction.js'
import './actions/renameAction'
import './actions/sidebarAction'
import './actions/viewInFolderAction'
import './newMenu/newFolder'

import Vue from 'vue'
import { createPinia, PiniaVuePlugin } from 'pinia'
Expand Down
8 changes: 5 additions & 3 deletions apps/files/src/services/Favorites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import type { ContentsWithRoot } from '@nextcloud/files'
import type { FileStat, ResponseDataDetailed, DAVResultResponseProps } from 'webdav'

import { File, Folder, davParsePermissions } from '@nextcloud/files'
import { generateRemoteUrl } from '@nextcloud/router'
import { getClient, rootPath } from './WebdavClient'
import { getCurrentUser } from '@nextcloud/auth'

import { getClient, rootPath } from './WebdavClient'
import { getDavNameSpaces, getDavProperties, getDefaultPropfind } from './DavProperties'
import type { ContentsWithRoot } from './Navigation'
import type { FileStat, ResponseDataDetailed, DAVResultResponseProps } from 'webdav'

const client = getClient()

Expand Down
Loading

0 comments on commit 302f696

Please sign in to comment.