@crowdin/app-project-module 0.10.0 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -571,7 +571,7 @@ const configuration = {
571
571
  description: 'Sample App description',
572
572
  dbFolder: __dirname,
573
573
  imagePath: __dirname + '/' + 'logo.png',
574
- reports: {
574
+ reports: { //can be editorPanels, projectMenu, tools
575
575
  fileName: 'reports.html', //optional, only needed if file is not index.html
576
576
  uiPath: __dirname + '/' + 'public' // folder where UI of the module is located (js, html, css files)
577
577
  },
@@ -16,6 +16,10 @@ function handle(config, integration) {
16
16
  if (integration.checkConnection) {
17
17
  yield integration.checkConnection(req.body.credentials);
18
18
  }
19
+ const existing = yield (0, storage_1.getIntegrationCredentials)(req.crowdinContext.clientId);
20
+ if (!!existing) {
21
+ yield (0, storage_1.deleteIntegrationCredentials)(req.crowdinContext.clientId);
22
+ }
19
23
  yield (0, storage_1.saveIntegrationCredentials)(req.crowdinContext.clientId, (0, util_1.encryptData)(config.clientSecret, JSON.stringify(req.body.credentials)), req.crowdinContext.crowdinId);
20
24
  res.status(204).end();
21
25
  }));
@@ -250,7 +250,7 @@ export interface FormField {
250
250
  helpText?: string;
251
251
  helpTextHtml?: string;
252
252
  label: string;
253
- type?: 'text' | 'password';
253
+ type?: 'text' | 'password' | 'checkbox';
254
254
  }
255
255
  export declare type TreeItem = File | Folder;
256
256
  export interface File {
package/out/util/index.js CHANGED
@@ -59,10 +59,17 @@ function handleError(err, req, res) {
59
59
  res.redirect('/');
60
60
  return;
61
61
  }
62
- res.status(code).send({
63
- message: err.message ? err.message : JSON.stringify(err),
64
- code,
65
- });
62
+ let message;
63
+ if (typeof err === 'string') {
64
+ message = err;
65
+ }
66
+ else if (err.message) {
67
+ message = err.message;
68
+ }
69
+ else {
70
+ message = JSON.stringify(err);
71
+ }
72
+ res.status(code).send({ message, code });
66
73
  });
67
74
  }
68
75
  function runAsyncWrapper(callback) {
@@ -12,20 +12,36 @@
12
12
  {{else}}
13
13
  <div class="inputs">
14
14
  {{#each loginFields}}
15
- <crowdin-input
16
- id="{{key}}"
17
- label="{{label}}"
18
- {{#if helpText}}
19
- help-text="{{helpText}}"
20
- {{/if}}
21
- {{#if helpTextHtml}}
22
- help-text-html="{{helpTextHtml}}"
23
- {{/if}}
24
- {{#if type}}
25
- type="{{type}}"
26
- {{/if}}
27
- value="">
28
- </crowdin-input>
15
+ {{#ifeq type "checkbox"}}
16
+ <crowdin-checkbox
17
+ id="{{key}}"
18
+ label="{{label}}"
19
+ value="false"
20
+ use-switch
21
+ {{#if helpText}}
22
+ help-text="{{helpText}}"
23
+ {{/if}}
24
+ {{#if helpTextHtml}}
25
+ help-text-html="{{helpTextHtml}}"
26
+ {{/if}}
27
+ >
28
+ </crowdin-checkbox>
29
+ {{else}}
30
+ <crowdin-input
31
+ id="{{key}}"
32
+ label="{{label}}"
33
+ {{#if helpText}}
34
+ help-text="{{helpText}}"
35
+ {{/if}}
36
+ {{#if helpTextHtml}}
37
+ help-text-html="{{helpTextHtml}}"
38
+ {{/if}}
39
+ {{#if type}}
40
+ type="{{type}}"
41
+ {{/if}}
42
+ value="">
43
+ </crowdin-input>
44
+ {{/ifeq}}
29
45
  {{/each}}
30
46
  </div>
31
47
  {{/if}}
@@ -63,7 +79,11 @@
63
79
  function integrationLogin(oauthCredentials) {
64
80
  const credentials = oauthCredentials || {
65
81
  {{#each loginFields}}
66
- '{{key}}': document.querySelector('#{{key}}').getAttribute('value'),
82
+ {{#ifeq type "checkbox"}}
83
+ '{{key}}': !!document.querySelector('#{{key}}').checked,
84
+ {{else}}
85
+ '{{key}}': document.querySelector('#{{key}}').getAttribute('value'),
86
+ {{/ifeq}}
67
87
  {{/each}}
68
88
  };
69
89
  checkOrigin()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "Module that generates for you all common endpoints for serving standalone Crowdin App",
5
5
  "main": "out/index.js",
6
6
  "types": "out/index.d.ts",