aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/src
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2023-07-28 14:52:30 +0200
committerJohn Molakvoæ <skjnldsv@protonmail.com>2023-08-02 09:57:27 +0200
commit87b1719c88240d7ae230e5e6ad30c47e100701bd (patch)
treea328054f57ff87500594da226a85ed2cad106e0e /apps/files_external/src
parent6ec35e3799974afdfa04fe43585f613534465610 (diff)
downloadnextcloud-server-87b1719c88240d7ae230e5e6ad30c47e100701bd.tar.gz
nextcloud-server-87b1719c88240d7ae230e5e6ad30c47e100701bd.zip
feat(files): migrate recent view
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_external/src')
-rw-r--r--apps/files_external/src/actions/enterCredentialsAction.spec.ts22
-rw-r--r--apps/files_external/src/css/fileEntryStatus.scss10
-rw-r--r--apps/files_external/src/services/externalStorage.ts2
-rw-r--r--apps/files_external/src/utils/externalStorageUtils.spec.ts91
4 files changed, 118 insertions, 7 deletions
diff --git a/apps/files_external/src/actions/enterCredentialsAction.spec.ts b/apps/files_external/src/actions/enterCredentialsAction.spec.ts
index db796b773c8..29e1fe31f02 100644
--- a/apps/files_external/src/actions/enterCredentialsAction.spec.ts
+++ b/apps/files_external/src/actions/enterCredentialsAction.spec.ts
@@ -110,12 +110,27 @@ describe('Enter credentials action enabled tests', () => {
},
})
- const notAStorage = new Folder({
+ const missingConfig = new Folder({
id: 1,
source: 'https://cloud.domain.com/remote.php/dav/files/admin/Foo/',
owner: 'admin',
root: '/files/admin',
permissions: Permission.ALL,
+ attributes: {
+ scope: 'system',
+ backend: 'SFTP',
+ config: {
+ } as StorageConfig,
+ },
+ })
+
+ const notAStorage = new File({
+ id: 1,
+ source: 'https://cloud.domain.com/remote.php/dav/files/admin/Foo/test.txt',
+ mime: 'text/plain',
+ owner: 'admin',
+ root: '/files/admin',
+ permissions: Permission.ALL,
})
test('Disabled with on success storage', () => {
@@ -138,6 +153,11 @@ describe('Enter credentials action enabled tests', () => {
expect(action.enabled!([globalAuthUserStorage], view)).toBe(true)
})
+ test('Disabled for missing config', () => {
+ expect(action.enabled).toBeDefined()
+ expect(action.enabled!([missingConfig], view)).toBe(false)
+ })
+
test('Disabled for normal nodes', () => {
expect(action.enabled).toBeDefined()
expect(action.enabled!([notAStorage], view)).toBe(false)
diff --git a/apps/files_external/src/css/fileEntryStatus.scss b/apps/files_external/src/css/fileEntryStatus.scss
index 1e36cccdb6f..d7b5063bceb 100644
--- a/apps/files_external/src/css/fileEntryStatus.scss
+++ b/apps/files_external/src/css/fileEntryStatus.scss
@@ -1,9 +1,9 @@
.files-list__row-status {
display: flex;
- width: 44px;
- justify-content: center;
- align-items: center;
- height: 100%;
+ width: 44px;
+ justify-content: center;
+ align-items: center;
+ height: 100%;
svg {
width: 24px;
@@ -33,4 +33,4 @@
&--warning {
background: var(--color-warning);
}
-} \ No newline at end of file
+}
diff --git a/apps/files_external/src/services/externalStorage.ts b/apps/files_external/src/services/externalStorage.ts
index 5683dbea53a..c84ad6bcc5b 100644
--- a/apps/files_external/src/services/externalStorage.ts
+++ b/apps/files_external/src/services/externalStorage.ts
@@ -35,7 +35,7 @@ export const rootPath = `/files/${getCurrentUser()?.uid}`
export type StorageConfig = {
applicableUsers?: string[]
- applicableGroups?: string[]
+ applicableGroups?: string[]
authMechanism: string
backend: string
backendOptions: Record<string, string>
diff --git a/apps/files_external/src/utils/externalStorageUtils.spec.ts b/apps/files_external/src/utils/externalStorageUtils.spec.ts
new file mode 100644
index 00000000000..dc901544a98
--- /dev/null
+++ b/apps/files_external/src/utils/externalStorageUtils.spec.ts
@@ -0,0 +1,91 @@
+/**
+ * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @author John Molakvoæ <skjnldsv@protonmail.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, Folder, Permission } from '@nextcloud/files'
+import { isNodeExternalStorage } from './externalStorageUtils'
+import { expect } from '@jest/globals'
+
+describe('Is node an external storage', () => {
+ test('A Folder with a backend and a valid scope is an external storage', () => {
+ const folder = new Folder({
+ id: 1,
+ source: 'https://cloud.domain.com/remote.php/dav/files/admin/Foo/',
+ owner: 'admin',
+ permissions: Permission.ALL,
+ attributes: {
+ scope: 'personal',
+ backend: 'SFTP',
+ },
+ })
+ expect(isNodeExternalStorage(folder)).toBe(true)
+ })
+
+ test('a File is not a valid storage', () => {
+ const file = new File({
+ id: 1,
+ source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt',
+ owner: 'admin',
+ mime: 'text/plain',
+ permissions: Permission.ALL,
+ })
+ expect(isNodeExternalStorage(file)).toBe(false)
+ })
+
+ test('A Folder without a backend is not a storage', () => {
+ const folder = new Folder({
+ id: 1,
+ source: 'https://cloud.domain.com/remote.php/dav/files/admin/Foo/',
+ owner: 'admin',
+ permissions: Permission.ALL,
+ attributes: {
+ scope: 'personal',
+ },
+ })
+ expect(isNodeExternalStorage(folder)).toBe(false)
+ })
+
+ test('A Folder without a scope is not a storage', () => {
+ const folder = new Folder({
+ id: 1,
+ source: 'https://cloud.domain.com/remote.php/dav/files/admin/Foo/',
+ owner: 'admin',
+ permissions: Permission.ALL,
+ attributes: {
+ backend: 'SFTP',
+ },
+ })
+ expect(isNodeExternalStorage(folder)).toBe(false)
+ })
+
+ test('A Folder with an invalid scope is not a storage', () => {
+ const folder = new Folder({
+ id: 1,
+ source: 'https://cloud.domain.com/remote.php/dav/files/admin/Foo/',
+ owner: 'admin',
+ permissions: Permission.ALL,
+ attributes: {
+ scope: 'null',
+ backend: 'SFTP',
+ },
+ })
+ expect(isNodeExternalStorage(folder)).toBe(false)
+ })
+})