diff --git a/packages/nc-gui/components/project/appStore/appInstall.vue b/packages/nc-gui/components/project/appStore/appInstall.vue index 50d0dd7bc5..2f0e77eb2d 100644 --- a/packages/nc-gui/components/project/appStore/appInstall.vue +++ b/packages/nc-gui/components/project/appStore/appInstall.vue @@ -66,10 +66,12 @@
{{ action.label }}
@@ -91,7 +93,8 @@ export default { settings: null, pluginId: null, title: null, - valid: null + valid: null, + testing: false }), methods: { simpleAnim() { @@ -146,17 +149,23 @@ export default { }, async testSettings() { + this.testing = true; try { - await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcPluginTest', { + const res = await this.$store.dispatch('sqlMgr/ActSqlOp', [null, 'xcPluginTest', { input: this.settings, id: this.pluginId, category: this.plugin.category, title: this.plugin.title }]); - this.$toast.success('Successfully tested plugin settings').goAway(3000) + if (res) { + this.$toast.success('Successfully tested plugin settings').goAway(3000) + } else { + this.$toast.info('Invalid credentials').goAway(3000) + } } catch (e) { - this.$toast.error(e.message).goAway(3000); + this.$toast[e.message === 'Not implemented' ? 'info' : 'error'](e.message).goAway(3000); } + this.testing = false; }, async doAction(action) { switch (action.key) { @@ -246,7 +255,5 @@ tbody tr:nth-of-type(odd) { background-color: transparent; } -.form-input-label { - padding-bottom: 16px; -} + diff --git a/packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts b/packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts index 31618e3b4c..f86f15dc6f 100644 --- a/packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts +++ b/packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts @@ -2854,17 +2854,13 @@ export default class NcMetaMgr { protected async xcPluginTest(req, args): Promise { try { switch (args.args.category) { - // case 'Storage': - // const storageIns = StorageFactory.createNewInstance(args.args, args.args.input); - // await storageIns.init(); - // await storageIns?.test(); - // break; case 'Email': const emailIns = EmailFactory.createNewInstance(args.args, args.args.input) await emailIns.init(); await emailIns?.test(req.user?.email) break; default: + return this.pluginMgr.test(args.args) break; } return true; diff --git a/packages/nocodb/src/lib/noco/plugins/NcPluginMgr.ts b/packages/nocodb/src/lib/noco/plugins/NcPluginMgr.ts index 953ee11761..73eb087abf 100644 --- a/packages/nocodb/src/lib/noco/plugins/NcPluginMgr.ts +++ b/packages/nocodb/src/lib/noco/plugins/NcPluginMgr.ts @@ -99,7 +99,7 @@ class NcPluginMgr { try { await tempPlugin.init(pluginConfig?.input); - }catch (e){ + } catch (e) { console.log(`Plugin(${plugin?.title}) initialization failed : ${e.message}`) } } @@ -132,6 +132,19 @@ class NcPluginMgr { } + public async test(args: any): Promise { + switch (args.category) { + case 'Storage': + const plugin = defaultPlugins.find(pluginConfig => pluginConfig?.title === args.title); + const tempPlugin = new plugin.builder(this.app, plugin); + await tempPlugin.init(args?.input); + return tempPlugin?.getAdapter()?.test?.(); + break; + default: + throw new Error('Not implemented'); + } + } + } export default NcPluginMgr; diff --git a/packages/nocodb/src/plugins/backblaze/Backblaze.ts b/packages/nocodb/src/plugins/backblaze/Backblaze.ts index ab3d86226f..23d4b8d53b 100644 --- a/packages/nocodb/src/plugins/backblaze/Backblaze.ts +++ b/packages/nocodb/src/plugins/backblaze/Backblaze.ts @@ -81,7 +81,7 @@ export default class Backblaze implements IStorageAdapter { const tempFile = path.join(process.cwd(), 'temp.txt'); const createStream = fs.createWriteStream(tempFile); createStream.end(); - await this.fileCreate('/test.txt', { + await this.fileCreate('/nc-test-file.txt', { path: tempFile, mimetype: '', originalname: 'temp.txt', diff --git a/packages/nocodb/src/plugins/gcs/Gcs.ts b/packages/nocodb/src/plugins/gcs/Gcs.ts index 3658088470..74f4e0a51e 100644 --- a/packages/nocodb/src/plugins/gcs/Gcs.ts +++ b/packages/nocodb/src/plugins/gcs/Gcs.ts @@ -82,7 +82,7 @@ export default class Gcs implements IStorageAdapter { const tempFile = path.join(process.cwd(), 'temp.txt'); const createStream = fs.createWriteStream(tempFile); createStream.end(); - await this.fileCreate('/test.txt', { + await this.fileCreate('/nc-test-file.txt', { path: tempFile, mimetype: '', originalname: 'temp.txt', diff --git a/packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts b/packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts index e995afd45a..4266f5d469 100644 --- a/packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts +++ b/packages/nocodb/src/plugins/linode/LinodeObjectStorage.ts @@ -79,7 +79,7 @@ export default class LinodeObjectStorage implements IStorageAdapter { const tempFile = path.join(process.cwd(), 'temp.txt'); const createStream = fs.createWriteStream(tempFile); createStream.end(); - await this.fileCreate('/test.txt', { + await this.fileCreate('/nc-test-file.txt', { path: tempFile, mimetype: '', originalname: 'temp.txt', diff --git a/packages/nocodb/src/plugins/mino/Minio.ts b/packages/nocodb/src/plugins/mino/Minio.ts index 206cfe2432..6ec589cd78 100644 --- a/packages/nocodb/src/plugins/mino/Minio.ts +++ b/packages/nocodb/src/plugins/mino/Minio.ts @@ -71,7 +71,7 @@ export default class Minio implements IStorageAdapter { const tempFile = path.join(process.cwd(), 'temp.txt'); const createStream = fs.createWriteStream(tempFile); createStream.end(); - await this.fileCreate('/test.txt', { + await this.fileCreate('/nc-test-file.txt', { path: tempFile, mimetype: '', originalname: 'temp.txt', diff --git a/packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts b/packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts index 248a39c9c7..05b82fbacf 100644 --- a/packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts +++ b/packages/nocodb/src/plugins/ovhCloud/OvhCloud.ts @@ -81,7 +81,7 @@ export default class OvhCloud implements IStorageAdapter { const tempFile = path.join(process.cwd(), 'temp.txt'); const createStream = fs.createWriteStream(tempFile); createStream.end(); - await this.fileCreate('/test.txt', { + await this.fileCreate('/nc-test-file.txt', { path: tempFile, mimetype: '', originalname: 'temp.txt', diff --git a/packages/nocodb/src/plugins/s3/S3.ts b/packages/nocodb/src/plugins/s3/S3.ts index b1fa2979f0..ae44ad20a6 100644 --- a/packages/nocodb/src/plugins/s3/S3.ts +++ b/packages/nocodb/src/plugins/s3/S3.ts @@ -87,7 +87,7 @@ export default class S3 implements IStorageAdapter { const tempFile = path.join(process.cwd(), 'temp.txt'); const createStream = fs.createWriteStream(tempFile); createStream.end(); - await this.fileCreate('/test.txt', { + await this.fileCreate('/nc-test-file.txt', { path: tempFile, mimetype: '', originalname: 'temp.txt', diff --git a/packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts b/packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts index 99b1dca9e0..e3297e1eed 100644 --- a/packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts +++ b/packages/nocodb/src/plugins/scaleway/ScalewayObjectStorage.ts @@ -79,7 +79,7 @@ export default class ScalewayObjectStorage implements IStorageAdapter { const tempFile = path.join(process.cwd(), 'temp.txt'); const createStream = fs.createWriteStream(tempFile); createStream.end(); - await this.fileCreate('/test.txt', { + await this.fileCreate('/nc-test-file.txt', { path: tempFile, mimetype: '', originalname: 'temp.txt', diff --git a/packages/nocodb/src/plugins/spaces/Spaces.ts b/packages/nocodb/src/plugins/spaces/Spaces.ts index c5866c1c6d..4a1ef7c517 100644 --- a/packages/nocodb/src/plugins/spaces/Spaces.ts +++ b/packages/nocodb/src/plugins/spaces/Spaces.ts @@ -88,7 +88,7 @@ export default class Spaces implements IStorageAdapter { const tempFile = path.join(process.cwd(), 'temp.txt'); const createStream = fs.createWriteStream(tempFile); createStream.end(); - await this.fileCreate('/test.txt', { + await this.fileCreate('/nc-test-file.txt', { path: tempFile, mimetype: '', originalname: 'temp.txt', diff --git a/packages/nocodb/src/plugins/upcloud/UpoCloud.ts b/packages/nocodb/src/plugins/upcloud/UpoCloud.ts index 2a5a3c6aaa..3981de7a2b 100644 --- a/packages/nocodb/src/plugins/upcloud/UpoCloud.ts +++ b/packages/nocodb/src/plugins/upcloud/UpoCloud.ts @@ -81,7 +81,7 @@ export default class UpoCloud implements IStorageAdapter { const tempFile = path.join(process.cwd(), 'temp.txt'); const createStream = fs.createWriteStream(tempFile); createStream.end(); - await this.fileCreate('/test.txt', { + await this.fileCreate('/nc-test-file.txt', { path: tempFile, mimetype: '', originalname: 'temp.txt', diff --git a/packages/nocodb/src/plugins/vultr/Vultr.ts b/packages/nocodb/src/plugins/vultr/Vultr.ts index 842199a4a2..3dc9421c6f 100644 --- a/packages/nocodb/src/plugins/vultr/Vultr.ts +++ b/packages/nocodb/src/plugins/vultr/Vultr.ts @@ -81,7 +81,7 @@ export default class Vultr implements IStorageAdapter { const tempFile = path.join(process.cwd(), 'temp.txt'); const createStream = fs.createWriteStream(tempFile); createStream.end(); - await this.fileCreate('/test.txt', { + await this.fileCreate('/nc-test-file.txt', { path: tempFile, mimetype: '', originalname: 'temp.txt',