Browse Source

refactor: handle plugin test

re #827

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/847/head
Pranav C 3 years ago
parent
commit
eaa4c34d68
  1. 23
      packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts
  2. 12
      packages/nocodb/src/lib/noco/plugins/NcPluginMgr.ts
  3. 3
      packages/nocodb/src/lib/noco/plugins/adapters/email/EmailFactory.ts

23
packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts

@ -30,8 +30,6 @@ import Noco from '../Noco';
import { GqlApiBuilder } from '../gql/GqlApiBuilder';
import NcPluginMgr from '../plugins/NcPluginMgr';
import XcCache from '../plugins/adapters/cache/XcCache';
import EmailFactory from '../plugins/adapters/email/EmailFactory';
// import Twilio from '../plugins/adapters/twilio/Twilio';
import { RestApiBuilder } from '../rest/RestApiBuilder';
import RestAuthCtrl from '../rest/RestAuthCtrlEE';
import { packageVersion } from 'nc-help';
@ -4859,27 +4857,8 @@ export default class NcMetaMgr {
});
}
protected async xcPluginTest(req, args): Promise<any> {
try {
switch (args.args.category) {
case 'Email':
{
const emailIns = EmailFactory.createNewInstance(
args.args,
args.args.input
);
await emailIns.init();
await emailIns?.test(req.user?.email);
}
break;
default:
protected async xcPluginTest(_req, args): Promise<any> {
return this.pluginMgr.test(args.args);
break;
}
return true;
} catch (e) {
throw e;
}
}
protected async xcPluginCreate(_args): Promise<any> {}

12
packages/nocodb/src/lib/noco/plugins/NcPluginMgr.ts

@ -149,8 +149,18 @@ class NcPluginMgr {
return tempPlugin?.getAdapter()?.test?.();
}
break;
case 'Email':
{
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');
throw new Error('Test not implemented');
}
}
}

3
packages/nocodb/src/lib/noco/plugins/adapters/email/EmailFactory.ts

@ -27,9 +27,8 @@ export default class EmailFactory {
break;
case 'SES':
return new SES(input);
break;
default:
return null;
throw new Error('Test not implemented');
break;
}
}

Loading…
Cancel
Save