mirror of
https://github.com/nextcloud/server.git
synced 2026-04-23 23:27:46 -04:00
fix: favorites colour, icon, unwanted eslint-disable, typing and preview
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
This commit is contained in:
parent
9b0e3a97cb
commit
19e2aaa5b4
15 changed files with 72 additions and 82 deletions
|
|
@ -286,7 +286,7 @@ export default Vue.extend({
|
|||
position: absolute;
|
||||
top: 4px;
|
||||
right: -8px;
|
||||
color: #ffcc00;
|
||||
color: #a08b00;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
*/
|
||||
import { File, Folder, parseWebdavPermissions } from '@nextcloud/files'
|
||||
import { generateRemoteUrl, generateUrl } from '@nextcloud/router'
|
||||
import { generateRemoteUrl } from '@nextcloud/router'
|
||||
import { getClient, rootPath } from './WebdavClient'
|
||||
import { getCurrentUser } from '@nextcloud/auth'
|
||||
import { getDavNameSpaces, getDavProperties, getDefaultPropfind } from './DavProperties'
|
||||
|
|
@ -49,7 +49,6 @@ const resultToNode = function(node: FileStat): File | Folder {
|
|||
const props = node.props as ResponseProps
|
||||
const permissions = parseWebdavPermissions(props?.permissions)
|
||||
const owner = getCurrentUser()?.uid as string
|
||||
const previewUrl = generateUrl('/core/preview?fileId={fileid}&x=32&y=32&forceIcon=0', props)
|
||||
|
||||
const nodeData = {
|
||||
id: props?.fileid as number || 0,
|
||||
|
|
@ -63,7 +62,7 @@ const resultToNode = function(node: FileStat): File | Folder {
|
|||
attributes: {
|
||||
...node,
|
||||
...props,
|
||||
previewUrl,
|
||||
hasPreview: props?.['has-preview'],
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
/* eslint-disable */
|
||||
/* eslint-disable no-use-before-define */
|
||||
import type { Folder, Node } from '@nextcloud/files'
|
||||
import isSvg from 'is-svg'
|
||||
|
||||
|
|
@ -39,8 +39,10 @@ export interface Column {
|
|||
render: (node: Node, view: Navigation) => HTMLElement
|
||||
/** Function used to sort Nodes between them */
|
||||
sort?: (nodeA: Node, nodeB: Node) => number
|
||||
/** Custom summary of the column to display at the end of the list.
|
||||
Will not be displayed if nothing is provided */
|
||||
/**
|
||||
* Custom summary of the column to display at the end of the list.
|
||||
* Will not be displayed if nothing is provided
|
||||
*/
|
||||
summary?: (node: Node[], view: Navigation) => string
|
||||
}
|
||||
|
||||
|
|
@ -64,8 +66,11 @@ export interface Navigation {
|
|||
icon: string
|
||||
/** The view order */
|
||||
order: number
|
||||
/** This view column(s). Name and actions are
|
||||
by default always included */
|
||||
|
||||
/**
|
||||
* This view column(s). Name and actions are
|
||||
* by default always included
|
||||
*/
|
||||
columns?: Column[]
|
||||
/** The empty view element to render your empty content into */
|
||||
emptyView?: (div: HTMLDivElement) => void
|
||||
|
|
@ -73,7 +78,9 @@ export interface Navigation {
|
|||
parent?: string
|
||||
/** This view is sticky (sent at the bottom) */
|
||||
sticky?: boolean
|
||||
/** This view has children and is expanded or not,
|
||||
|
||||
/**
|
||||
* This view has children and is expanded or not,
|
||||
* will be overridden by user config.
|
||||
*/
|
||||
expanded?: boolean
|
||||
|
|
@ -81,7 +88,7 @@ export interface Navigation {
|
|||
/**
|
||||
* Will be used as default if the user
|
||||
* haven't customized their sorting column
|
||||
* */
|
||||
*/
|
||||
defaultSortKey?: string
|
||||
|
||||
/**
|
||||
|
|
@ -90,8 +97,9 @@ export interface Navigation {
|
|||
* @deprecated It will be removed in a near future
|
||||
*/
|
||||
legacy?: boolean
|
||||
|
||||
/**
|
||||
* An icon class.
|
||||
* An icon class.
|
||||
* @deprecated It will be removed in a near future
|
||||
*/
|
||||
iconClass?: string
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
/* eslint-disable */
|
||||
import { defineStore } from 'pinia'
|
||||
import type { ActionsMenuStore } from '../types'
|
||||
|
||||
|
|
|
|||
|
|
@ -19,17 +19,15 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
/* eslint-disable */
|
||||
import type { Folder, Node } from '@nextcloud/files'
|
||||
import type { FilesStore, RootsStore, RootOptions, Service, FilesState } from '../types'
|
||||
import type { FilesStore, RootsStore, RootOptions, Service, FilesState, FileId } from '../types'
|
||||
|
||||
import { defineStore } from 'pinia'
|
||||
import { subscribe } from '@nextcloud/event-bus'
|
||||
import logger from '../logger'
|
||||
import type { FileId } from '../types'
|
||||
import Vue from 'vue'
|
||||
|
||||
export const useFilesStore = function() {
|
||||
export const useFilesStore = function(...args) {
|
||||
const store = defineStore('files', {
|
||||
state: (): FilesState => ({
|
||||
files: {} as FilesStore,
|
||||
|
|
@ -40,7 +38,7 @@ export const useFilesStore = function() {
|
|||
/**
|
||||
* Get a file or folder by id
|
||||
*/
|
||||
getNode: (state) => (id: FileId): Node|undefined => state.files[id],
|
||||
getNode: (state) => (id: FileId): Node|undefined => state.files[id],
|
||||
|
||||
/**
|
||||
* Get a list of files or folders by their IDs
|
||||
|
|
@ -52,7 +50,7 @@ export const useFilesStore = function() {
|
|||
/**
|
||||
* Get a file or folder by id
|
||||
*/
|
||||
getRoot: (state) => (service: Service): Folder|undefined => state.roots[service],
|
||||
getRoot: (state) => (service: Service): Folder|undefined => state.roots[service],
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
|
@ -67,7 +65,7 @@ export const useFilesStore = function() {
|
|||
return acc
|
||||
}, {} as FilesStore)
|
||||
|
||||
Vue.set(this, 'files', {...this.files, ...files})
|
||||
Vue.set(this, 'files', { ...this.files, ...files })
|
||||
},
|
||||
|
||||
deleteNodes(nodes: Node[]) {
|
||||
|
|
@ -85,10 +83,10 @@ export const useFilesStore = function() {
|
|||
onDeletedNode(node: Node) {
|
||||
this.deleteNodes([node])
|
||||
},
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
const fileStore = store(...arguments)
|
||||
const fileStore = store(...args)
|
||||
// Make sure we only register the listeners once
|
||||
if (!fileStore._initialized) {
|
||||
// subscribe('files:node:created', fileStore.onCreatedNode)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
/* eslint-disable */
|
||||
import { defineStore } from 'pinia'
|
||||
import Vue from 'vue'
|
||||
|
||||
|
|
@ -28,9 +27,9 @@ import Vue from 'vue'
|
|||
* special keys states. Useful for checking the
|
||||
* current status of a key when executing a method.
|
||||
*/
|
||||
export const useKeyboardStore = function() {
|
||||
export const useKeyboardStore = function(...args) {
|
||||
const store = defineStore('keyboard', {
|
||||
state: () => ({
|
||||
state: () => ({
|
||||
altKey: false,
|
||||
ctrlKey: false,
|
||||
metaKey: false,
|
||||
|
|
@ -47,10 +46,10 @@ export const useKeyboardStore = function() {
|
|||
Vue.set(this, 'metaKey', !!event.metaKey)
|
||||
Vue.set(this, 'shiftKey', !!event.shiftKey)
|
||||
},
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
const keyboardStore = store(...arguments)
|
||||
const keyboardStore = store(...args)
|
||||
// Make sure we only register the listeners once
|
||||
if (!keyboardStore._initialized) {
|
||||
window.addEventListener('keydown', keyboardStore.onEvent)
|
||||
|
|
|
|||
|
|
@ -19,18 +19,14 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
/* eslint-disable */
|
||||
import type { PathOptions, ServicesState } from '../types'
|
||||
|
||||
import type { FileId, PathsStore, PathOptions, ServicesState } from '../types'
|
||||
import { defineStore } from 'pinia'
|
||||
import { subscribe } from '@nextcloud/event-bus'
|
||||
import type { FileId, PathsStore } from '../types'
|
||||
import Vue from 'vue'
|
||||
|
||||
export const usePathsStore = function() {
|
||||
export const usePathsStore = function(...args) {
|
||||
const store = defineStore('paths', {
|
||||
state: () => ({
|
||||
paths: {} as ServicesState
|
||||
paths: {} as ServicesState,
|
||||
} as PathsStore),
|
||||
|
||||
getters: {
|
||||
|
|
@ -54,10 +50,10 @@ export const usePathsStore = function() {
|
|||
// Now we can set the provided path
|
||||
Vue.set(this.paths[payload.service], payload.path, payload.fileid)
|
||||
},
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
const pathsStore = store(...arguments)
|
||||
const pathsStore = store(...args)
|
||||
// Make sure we only register the listeners once
|
||||
if (!pathsStore._initialized) {
|
||||
// TODO: watch folders to update paths?
|
||||
|
|
|
|||
|
|
@ -19,13 +19,12 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
/* eslint-disable */
|
||||
import { defineStore } from 'pinia'
|
||||
import { subscribe } from '@nextcloud/event-bus'
|
||||
import type { Node } from '@nextcloud/files'
|
||||
import type { RenamingStore } from '../types'
|
||||
|
||||
export const useRenamingStore = function() {
|
||||
export const useRenamingStore = function(...args) {
|
||||
const store = defineStore('renaming', {
|
||||
state: () => ({
|
||||
renamingNode: undefined,
|
||||
|
|
@ -33,7 +32,7 @@ export const useRenamingStore = function() {
|
|||
} as RenamingStore),
|
||||
})
|
||||
|
||||
const renamingStore = store(...arguments)
|
||||
const renamingStore = store(...args)
|
||||
|
||||
// Make sure we only register the listeners once
|
||||
if (!renamingStore._initialized) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
/* eslint-disable */
|
||||
import { defineStore } from 'pinia'
|
||||
import Vue from 'vue'
|
||||
import { FileId, SelectionStore } from '../types'
|
||||
|
|
@ -55,6 +54,6 @@ export const useSelectionStore = defineStore('selection', {
|
|||
Vue.set(this, 'selected', [])
|
||||
Vue.set(this, 'lastSelection', [])
|
||||
Vue.set(this, 'lastSelectedIndex', null)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -19,14 +19,13 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
/* eslint-disable */
|
||||
import { loadState } from '@nextcloud/initial-state'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
import { defineStore } from 'pinia'
|
||||
import Vue from 'vue'
|
||||
import axios from '@nextcloud/axios'
|
||||
import type { UserConfig, UserConfigStore } from '../types'
|
||||
import { defineStore } from 'pinia'
|
||||
import { emit, subscribe } from '@nextcloud/event-bus'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
import { loadState } from '@nextcloud/initial-state'
|
||||
import axios from '@nextcloud/axios'
|
||||
import Vue from 'vue'
|
||||
|
||||
const userConfig = loadState('files', 'config', {
|
||||
show_hidden: false,
|
||||
|
|
@ -34,7 +33,7 @@ const userConfig = loadState('files', 'config', {
|
|||
sort_favorites_first: true,
|
||||
}) as UserConfig
|
||||
|
||||
export const useUserConfigStore = function() {
|
||||
export const useUserConfigStore = function(...args) {
|
||||
const store = defineStore('userconfig', {
|
||||
state: () => ({
|
||||
userConfig,
|
||||
|
|
@ -57,11 +56,11 @@ export const useUserConfigStore = function() {
|
|||
})
|
||||
|
||||
emit('files:config:updated', { key, value })
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const userConfigStore = store(...arguments)
|
||||
const userConfigStore = store(...args)
|
||||
|
||||
// Make sure we only register the listeners once
|
||||
if (!userConfigStore._initialized) {
|
||||
|
|
@ -73,4 +72,3 @@ export const useUserConfigStore = function() {
|
|||
|
||||
return userConfigStore
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
/* eslint-disable */
|
||||
import { defineStore } from 'pinia'
|
||||
import { emit, subscribe } from '@nextcloud/event-bus'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
|
|
@ -27,12 +26,11 @@ import { loadState } from '@nextcloud/initial-state'
|
|||
import axios from '@nextcloud/axios'
|
||||
import Vue from 'vue'
|
||||
|
||||
import type { ViewConfigs, ViewConfigStore, ViewId } from '../types'
|
||||
import type { ViewConfig } from '../types'
|
||||
import type { ViewConfigs, ViewConfigStore, ViewId, ViewConfig } from '../types'
|
||||
|
||||
const viewConfig = loadState('files', 'viewConfigs', {}) as ViewConfigs
|
||||
|
||||
export const useViewConfigStore = function() {
|
||||
export const useViewConfigStore = function(...args) {
|
||||
const store = defineStore('viewconfig', {
|
||||
state: () => ({
|
||||
viewConfig,
|
||||
|
|
@ -69,26 +67,26 @@ export const useViewConfigStore = function() {
|
|||
* The key param must be a valid key of a File object
|
||||
* If not found, will be searched within the File attributes
|
||||
*/
|
||||
setSortingBy(key: string = 'basename', view: string = 'files') {
|
||||
setSortingBy(key = 'basename', view = 'files') {
|
||||
// Save new config
|
||||
this.update(view, 'sorting_mode', key)
|
||||
this.update(view, 'sorting_direction', 'asc')
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Toggle the sorting direction
|
||||
*/
|
||||
toggleSortingDirection(view: string = 'files') {
|
||||
const config = this.getConfig(view) || { 'sorting_direction': 'asc' }
|
||||
toggleSortingDirection(view = 'files') {
|
||||
const config = this.getConfig(view) || { sorting_direction: 'asc' }
|
||||
const newDirection = config.sorting_direction === 'asc' ? 'desc' : 'asc'
|
||||
|
||||
|
||||
// Save new config
|
||||
this.update(view, 'sorting_direction', newDirection)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const viewConfigStore = store(...arguments)
|
||||
const viewConfigStore = store(...args)
|
||||
|
||||
// Make sure we only register the listeners once
|
||||
if (!viewConfigStore._initialized) {
|
||||
|
|
@ -100,4 +98,3 @@ export const useViewConfigStore = function() {
|
|||
|
||||
return viewConfigStore
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
/* eslint-disable */
|
||||
import type { Folder } from '@nextcloud/files'
|
||||
import type { Node } from '@nextcloud/files'
|
||||
import type { Folder, Node } from '@nextcloud/files'
|
||||
|
||||
// Global definitions
|
||||
export type Service = string
|
||||
|
|
@ -29,11 +27,6 @@ export type FileId = number
|
|||
export type ViewId = string
|
||||
|
||||
// Files store
|
||||
export type FilesState = {
|
||||
files: FilesStore,
|
||||
roots: RootsStore,
|
||||
}
|
||||
|
||||
export type FilesStore = {
|
||||
[fileid: FileId]: Node
|
||||
}
|
||||
|
|
@ -42,20 +35,25 @@ export type RootsStore = {
|
|||
[service: Service]: Folder
|
||||
}
|
||||
|
||||
export type FilesState = {
|
||||
files: FilesStore,
|
||||
roots: RootsStore,
|
||||
}
|
||||
|
||||
export interface RootOptions {
|
||||
root: Folder
|
||||
service: Service
|
||||
}
|
||||
|
||||
// Paths store
|
||||
export type ServicesState = {
|
||||
[service: Service]: PathConfig
|
||||
}
|
||||
|
||||
export type PathConfig = {
|
||||
[path: string]: number
|
||||
}
|
||||
|
||||
export type ServicesState = {
|
||||
[service: Service]: PathConfig
|
||||
}
|
||||
|
||||
export type PathsStore = {
|
||||
paths: ServicesState
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ export const generateIdFromPath = function(path: string): string {
|
|||
|
||||
export default () => {
|
||||
// Load state in function for mock testing purposes
|
||||
const favoriteFolders = loadState('files', 'favoriteFolders', []) as string[]
|
||||
const favoriteFolders = loadState<string[]>('files', 'favoriteFolders', [])
|
||||
const favoriteFoldersViews = favoriteFolders.map((folder, index) => generateFolderView(folder, index))
|
||||
|
||||
const Navigation = window.OCP.Files.Navigation as NavigationService
|
||||
|
|
|
|||
4
dist/files-main.js
vendored
4
dist/files-main.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files-main.js.map
vendored
2
dist/files-main.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue