Skip to content

Commit

Permalink
Merge pull request #43211 from nextcloud/feature/person-files-view/42…
Browse files Browse the repository at this point in the history
…919/base-draft
  • Loading branch information
skjnldsv authored Feb 15, 2024
2 parents 299e5fd + 0fa226e commit 4bc1701
Show file tree
Hide file tree
Showing 79 changed files with 212 additions and 121 deletions.
2 changes: 2 additions & 0 deletions apps/files/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { registerTemplateEntries } from './newMenu/newFromTemplate.ts'

import registerFavoritesView from './views/favorites'
import registerRecentView from './views/recent'
import registerPersonalFilesView from './views/personal-files'
import registerFilesView from './views/files'
import registerPreviewServiceWorker from './services/ServiceWorker.js'

Expand Down Expand Up @@ -64,6 +65,7 @@ registerTemplateEntries()
registerFavoritesView()
registerFilesView()
registerRecentView()
registerPersonalFilesView()

// Register preview service worker
registerPreviewServiceWorker()
Expand Down
12 changes: 2 additions & 10 deletions apps/files/src/services/Favorites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,14 @@
import type { ContentsWithRoot } from '@nextcloud/files'
import type { FileStat, ResponseDataDetailed } from 'webdav'

import { Folder, getDavNameSpaces, getDavProperties, davGetDefaultPropfind } from '@nextcloud/files'
import { Folder, davGetDefaultPropfind, davGetFavoritesReport } from '@nextcloud/files'

import { getClient } from './WebdavClient'
import { resultToNode } from './Files'

const client = getClient()

const reportPayload = `<?xml version="1.0"?>
<oc:filter-files ${getDavNameSpaces()}>
<d:prop>
${getDavProperties()}
</d:prop>
<oc:filter-rules>
<oc:favorite>1</oc:favorite>
</oc:filter-rules>
</oc:filter-files>`
const reportPayload = davGetFavoritesReport()

export const getContents = async (path = '/'): Promise<ContentsWithRoot> => {
const propfindPayload = davGetDefaultPropfind()
Expand Down
54 changes: 54 additions & 0 deletions apps/files/src/services/PersonalFiles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* @copyright Copyright (c) 2024 Eduardo Morales <emoral435@gmail.com>
*
* @author Eduardo Morales <emoral435@gmail.com>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import { File, type ContentsWithRoot } from '@nextcloud/files'
import { getCurrentUser } from '@nextcloud/auth';

import { getContents as getFiles } from './Files';

const currUserID = getCurrentUser()?.uid

/**
* NOTE MOVE TO @nextcloud/files
* @brief filters each file/folder on its shared status
* A personal file is considered a file that has all of the following properties:
* a.) the current user owns
* b.) the file is not shared with anyone
* c.) the file is not a group folder
* @param {FileStat} node that contains
* @return {Boolean}
*/
export const personalFile = function(node: File): Boolean {
const isNotShared = currUserID ? node.owner === currUserID : true
&& node.attributes['mount-type'] !== 'group'
&& node.attributes['mount-type'] !== 'shared'
return isNotShared
}

export const getContents = (path: string = "/"): Promise<ContentsWithRoot> => {
// get all the files from the current path as a cancellable promise
// then filter the files that the user does not own, or has shared / is a group folder
return getFiles(path)
.then(c => {
c.contents = c.contents.filter(personalFile) as File[]
return c
})
}
2 changes: 1 addition & 1 deletion apps/files/src/views/favorites.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('Favorites view definition', () => {
expect(favoritesView?.name).toBe('Favorites')
expect(favoritesView?.caption).toBeDefined()
expect(favoritesView?.icon).toBe('<svg>SvgMock</svg>')
expect(favoritesView?.order).toBe(5)
expect(favoritesView?.order).toBe(15)
expect(favoritesView?.columns).toStrictEqual([])
expect(favoritesView?.getContents).toBeDefined()
})
Expand Down
2 changes: 1 addition & 1 deletion apps/files/src/views/favorites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default () => {
emptyCaption: t('files', 'Files and folders you mark as favorite will show up here'),

icon: StarSvg,
order: 5,
order: 15,

columns: [],

Expand Down
43 changes: 43 additions & 0 deletions apps/files/src/views/personal-files.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @copyright Copyright (c) 2024 Eduardo Morales <emoral435@gmail.com>
*
* @author Eduardo Morales <emoral435@gmail.com>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import { translate as t } from '@nextcloud/l10n'
import { View, getNavigation } from '@nextcloud/files'

import { getContents } from '../services/PersonalFiles'
import AccountIcon from '@mdi/svg/svg/account.svg?raw'

export default () => {
const Navigation = getNavigation()
Navigation.register(new View({
id: 'personal',
name: t('files', 'Personal Files'),
caption: t('files', 'List of your files and folders that are not shared.'),

emptyTitle: t('files', 'No personal files found'),
emptyCaption: t('files', 'Files that are not shared will show up here.'),

icon: AccountIcon,
order: 5,

getContents,
}))
}
2 changes: 1 addition & 1 deletion apps/files/src/views/recent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default () => {
emptyCaption: t('files', 'Files and folders you recently modified will show up here.'),

icon: HistorySvg,
order: 2,
order: 10,

defaultSortKey: 'mtime',

Expand Down
4 changes: 2 additions & 2 deletions dist/6512-6512.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/6512-6512.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/comments-comments-app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/comments-comments-app.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/comments-comments-tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/comments-comments-tab.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-legacy-unified-search.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-legacy-unified-search.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-login.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-profile.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-profile.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/dav-settings-personal-availability.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/dav-settings-personal-availability.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/federatedfilesharing-vue-settings-admin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/federatedfilesharing-vue-settings-admin.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 4bc1701

Please sign in to comment.