@crowdin/app-project-module 0.18.2 → 0.19.0
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 +3 -1
- package/out/handlers/integration-data.js +2 -1
- package/out/handlers/main.js +2 -0
- package/out/models/index.d.ts +9 -1
- package/out/views/main.handlebars +23 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -87,7 +87,9 @@ const configuration = {
|
|
|
87
87
|
crowdin: true,
|
|
88
88
|
integration: true,
|
|
89
89
|
},
|
|
90
|
-
|
|
90
|
+
integrationOneLevelFetching: true, //turn on request when opening a directory and pass its id
|
|
91
|
+
integrationSearchListener: true, //turn on search listener and pass search string
|
|
92
|
+
getIntegrationFiles: async (credentials, appSettings, parentId, search) => {
|
|
91
93
|
//here you need to fetch files/objects from integration
|
|
92
94
|
return [
|
|
93
95
|
{
|
|
@@ -12,8 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
const util_1 = require("../util");
|
|
13
13
|
function handle(config, integration) {
|
|
14
14
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const { parent_id: parentId, search } = req.query;
|
|
15
16
|
(0, util_1.log)('Recieved request to get integration data', config.logger);
|
|
16
|
-
const files = yield integration.getIntegrationFiles(req.integrationCredentials, req.integrationSettings);
|
|
17
|
+
const files = yield integration.getIntegrationFiles(req.integrationCredentials, req.integrationSettings, parentId, search);
|
|
17
18
|
(0, util_1.log)(`Integration data response ${JSON.stringify(files, null, 2)}`, config.logger);
|
|
18
19
|
res.send(files);
|
|
19
20
|
}), config.onError);
|
package/out/handlers/main.js
CHANGED
|
@@ -56,6 +56,8 @@ function handle(config, integration) {
|
|
|
56
56
|
options.infoModal = integration.infoModal;
|
|
57
57
|
options.withCronSync = integration.withCronSync;
|
|
58
58
|
options.withWebhookSync = integration.withWebhookSync;
|
|
59
|
+
options.integrationOneLevelFetching = integration.integrationOneLevelFetching;
|
|
60
|
+
options.integrationSearchListener = integration.integrationSearchListener;
|
|
59
61
|
options.checkSubscription = !(0, connection_1.isAppFree)(config);
|
|
60
62
|
(0, util_1.log)(`Routing user to ${view} view`, config.logger);
|
|
61
63
|
return res.render(view, options);
|
package/out/models/index.d.ts
CHANGED
|
@@ -152,7 +152,7 @@ export interface IntegrationLogic {
|
|
|
152
152
|
/**
|
|
153
153
|
* function to get data from integration
|
|
154
154
|
*/
|
|
155
|
-
getIntegrationFiles: (apiCredentials: any, config?: any) => Promise<TreeItem[]>;
|
|
155
|
+
getIntegrationFiles: (apiCredentials: any, config?: any, parentId?: any, search?: any) => Promise<TreeItem[]>;
|
|
156
156
|
/**
|
|
157
157
|
* function to update crowdin files (e.g. pull integration data to crowdin source files)
|
|
158
158
|
*/
|
|
@@ -188,6 +188,14 @@ export interface IntegrationLogic {
|
|
|
188
188
|
crowdin: boolean;
|
|
189
189
|
integration: boolean;
|
|
190
190
|
};
|
|
191
|
+
/**
|
|
192
|
+
* Enable integration folder open event
|
|
193
|
+
*/
|
|
194
|
+
integrationOneLevelFetching?: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Enable integration search event
|
|
197
|
+
*/
|
|
198
|
+
integrationSearchListener?: boolean;
|
|
191
199
|
}
|
|
192
200
|
export declare type ConfigurationModalEntity = ConfigurationField | ConfigurationDelimeter;
|
|
193
201
|
export interface ConfigurationField {
|
|
@@ -34,6 +34,12 @@
|
|
|
34
34
|
{{#if withCronSync.integration}}
|
|
35
35
|
integration-schedule="true"
|
|
36
36
|
{{/if}}
|
|
37
|
+
{{#if integrationOneLevelFetching}}
|
|
38
|
+
integration-one-level-fetching="true"
|
|
39
|
+
{{/if}}
|
|
40
|
+
{{#if integrationSearchListener}}
|
|
41
|
+
allow-filter-change-listener="true"
|
|
42
|
+
{{/if}}
|
|
37
43
|
integration-name="{{name}}"
|
|
38
44
|
integration-logo="logo.png"
|
|
39
45
|
>
|
|
@@ -136,10 +142,19 @@
|
|
|
136
142
|
if (event.detail.componentId === 'crowdin-files' && event.detail.isOpen && event.detail.type === '1') {
|
|
137
143
|
getFileProgress(event.detail.id);
|
|
138
144
|
}
|
|
145
|
+
{{#if integrationOneLevelFetching}}
|
|
146
|
+
if (event.detail.componentId === 'integration-files' && event.detail.isOpen) {
|
|
147
|
+
getIntegrationData(event.detail.id);
|
|
148
|
+
}
|
|
149
|
+
{{/if}}
|
|
139
150
|
});
|
|
140
151
|
document.body.addEventListener('uploadFilesToCrowdin', uploadFilesToCrowdin);
|
|
141
152
|
document.body.addEventListener('uploadFilesToIntegration', uploadFilesToIntegration);
|
|
142
|
-
|
|
153
|
+
{{#if integrationSearchListener}}
|
|
154
|
+
document.body.addEventListener("integrationFilterChange", (event) => {
|
|
155
|
+
getIntegrationData(0, event.detail);
|
|
156
|
+
})
|
|
157
|
+
{{/if}}
|
|
143
158
|
const appComponent = document.querySelector('crowdin-simple-integration');
|
|
144
159
|
const subscriptionModal = document.getElementById('subscription-modal');
|
|
145
160
|
|
|
@@ -197,10 +212,10 @@
|
|
|
197
212
|
.finally(() => (appComponent.setAttribute('is-crowdin-loading', false)));
|
|
198
213
|
}
|
|
199
214
|
|
|
200
|
-
function getIntegrationData() {
|
|
215
|
+
function getIntegrationData(parentId = null, search = '') {
|
|
201
216
|
appComponent.setAttribute('is-integration-loading', true);
|
|
202
217
|
checkOrigin()
|
|
203
|
-
.then(restParams => fetch(
|
|
218
|
+
.then(restParams => fetch(`api/integration/data${restParams}&parent_id=${parentId}&search=${search}`))
|
|
204
219
|
.then(checkResponse)
|
|
205
220
|
.then((res) => {
|
|
206
221
|
const tree = res.map(e => {
|
|
@@ -217,7 +232,11 @@
|
|
|
217
232
|
}
|
|
218
233
|
return item;
|
|
219
234
|
});
|
|
220
|
-
appComponent.
|
|
235
|
+
appComponent.pushIntegrationFilesData(tree);
|
|
236
|
+
if (search) {
|
|
237
|
+
const openIds = res.filter(e => !e.type).map(e => e.id);
|
|
238
|
+
appComponent.setIntegrationOpenedFolders(openIds);
|
|
239
|
+
}
|
|
221
240
|
})
|
|
222
241
|
{{#if withCronSync}}
|
|
223
242
|
.then(() => getSyncSettings('integration'))
|
package/package.json
CHANGED