@crowdin/app-project-module 0.71.1 → 0.71.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.
|
@@ -147,7 +147,7 @@ function applyIntegrationModuleDefaults(config, integration) {
|
|
|
147
147
|
fields = yield getUserSettings(projectId, crowdinClient, integrationCredentials);
|
|
148
148
|
}
|
|
149
149
|
const defaultSettings = [];
|
|
150
|
-
const mangers = yield getManagers(
|
|
150
|
+
const mangers = yield getManagers(crowdinClient, projectId, integrationCredentials.ownerId);
|
|
151
151
|
if (mangers.length) {
|
|
152
152
|
defaultSettings.push({
|
|
153
153
|
key: 'managers',
|
|
@@ -320,17 +320,30 @@ function getOAuthLoginFormId(clientId) {
|
|
|
320
320
|
return `oauth_form_${clientId}`;
|
|
321
321
|
}
|
|
322
322
|
exports.getOAuthLoginFormId = getOAuthLoginFormId;
|
|
323
|
-
function getManagers(
|
|
323
|
+
function getManagers(client, projectId, ownerId) {
|
|
324
324
|
return __awaiter(this, void 0, void 0, function* () {
|
|
325
325
|
const managers = [];
|
|
326
326
|
if (client.organization) {
|
|
327
|
-
|
|
328
|
-
|
|
327
|
+
try {
|
|
328
|
+
const admins = (yield client.usersApi.withFetchAll().listUsers()).data.filter((user) => user.data.isAdmin);
|
|
329
|
+
managers.push(...admins.map((admin) => admin.data));
|
|
330
|
+
}
|
|
331
|
+
catch (e) {
|
|
332
|
+
console.error('Failed to get organization users', e);
|
|
333
|
+
}
|
|
329
334
|
}
|
|
330
|
-
const projectMembers = (yield client.usersApi.listProjectMembers(projectId)).data.filter((user) => 'role' in user.data ? ['owner', 'manager'].includes(user.data.role) : user.data.isManager);
|
|
335
|
+
const projectMembers = (yield client.usersApi.withFetchAll().listProjectMembers(projectId)).data.filter((user) => 'role' in user.data ? ['owner', 'manager'].includes(user.data.role) : user.data.isManager);
|
|
331
336
|
managers.push(...projectMembers.map((members) => members.data));
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
337
|
+
const uniqueManagers = new Map();
|
|
338
|
+
managers.forEach((manager) => {
|
|
339
|
+
if (manager.id !== ownerId && !uniqueManagers.has(manager.id)) {
|
|
340
|
+
uniqueManagers.set(manager.id, manager);
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
return Array.from(uniqueManagers.values()).sort((a, b) => {
|
|
344
|
+
const aValue = a.firstName || a.username || '';
|
|
345
|
+
const bValue = b.firstName || b.username || '';
|
|
346
|
+
return aValue.localeCompare(bValue);
|
|
347
|
+
});
|
|
335
348
|
});
|
|
336
349
|
}
|
package/package.json
CHANGED