@crowdin/app-project-module 1.8.1 → 1.10.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/out/middlewares/crowdin-client.js +5 -5
- package/out/middlewares/integration-access-denied.d.ts +1 -1
- package/out/middlewares/integration-access-denied.js +2 -35
- package/out/middlewares/ui-module.js +3 -3
- package/out/modules/custom-mt/index.js +2 -1
- package/out/modules/file-processing/handlers/file-download.js +2 -1
- package/out/modules/file-processing/handlers/pre-post-process.js +2 -1
- package/out/modules/file-processing/handlers/translations-alignment.js +2 -1
- package/out/modules/file-processing/index.js +3 -2
- package/out/modules/file-processing/util/folder.d.ts +1 -0
- package/out/modules/file-processing/util/folder.js +13 -0
- package/out/modules/install.js +7 -7
- package/out/modules/integration/handlers/integration-logout.js +2 -35
- package/out/modules/integration/handlers/job-list.js +4 -1
- package/out/modules/integration/handlers/oauth-login.js +2 -2
- package/out/modules/integration/handlers/settings-save.js +56 -41
- package/out/modules/integration/handlers/sync-settings-save.js +57 -3
- package/out/modules/integration/types.d.ts +7 -0
- package/out/modules/integration/util/cron.js +7 -40
- package/out/modules/integration/util/defaults.js +2 -35
- package/out/modules/integration/util/files.js +19 -7
- package/out/modules/integration/util/job.d.ts +4 -3
- package/out/modules/integration/util/job.js +8 -40
- package/out/modules/integration/util/types.d.ts +4 -2
- package/out/modules/integration/util/types.js +2 -0
- package/out/modules/integration/util/webhooks.d.ts +1 -1
- package/out/modules/integration/util/webhooks.js +7 -7
- package/out/static/ui/form.bundle.js +99 -44
- package/out/static/ui/form.bundle.js.map +1 -1
- package/out/static/ui/main.bundle.js +94 -3
- package/out/static/ui/main.bundle.js.map +1 -1
- package/out/types.d.ts +45 -1
- package/out/types.js +11 -1
- package/out/util/app-functions/crowdin.d.ts +104 -0
- package/out/util/app-functions/crowdin.js +245 -0
- package/out/util/app-functions/token.d.ts +71 -0
- package/out/util/app-functions/token.js +192 -0
- package/out/util/connection.js +11 -12
- package/out/util/credentials-masker.js +2 -2
- package/out/util/index.js +2 -2
- package/out/util/subscription.js +3 -3
- package/package.json +26 -2
|
@@ -566,6 +566,7 @@
|
|
|
566
566
|
updateTargetLanguages: 'updateTargetLanguages',
|
|
567
567
|
integrationSyncSettingsSave: 'integrationSyncSettingsSave',
|
|
568
568
|
crowdinSyncSettingsSave: 'crowdinSyncSettingsSave',
|
|
569
|
+
integrationSettingsSave: 'integrationSettingsSave',
|
|
569
570
|
};
|
|
570
571
|
const JOB_STATUS = {
|
|
571
572
|
created: 'created',
|
|
@@ -574,7 +575,7 @@
|
|
|
574
575
|
canceled: 'canceled',
|
|
575
576
|
finished: 'finished',
|
|
576
577
|
};
|
|
577
|
-
const silentJobs = [JOB_TYPE.
|
|
578
|
+
const silentJobs = [JOB_TYPE.integrationSettingsSave];
|
|
578
579
|
const appComponent = reactExports.useRef(null);
|
|
579
580
|
const subscriptionModal = reactExports.useRef(null);
|
|
580
581
|
const languageModal = reactExports.useRef(null);
|
|
@@ -949,11 +950,65 @@
|
|
|
949
950
|
}
|
|
950
951
|
});
|
|
951
952
|
}
|
|
953
|
+
function isScheduleDisabled(currentConfig = config.current) {
|
|
954
|
+
var _a;
|
|
955
|
+
return String((_a = currentConfig === null || currentConfig === void 0 ? void 0 : currentConfig.schedule) !== null && _a !== void 0 ? _a : '0') === '0';
|
|
956
|
+
}
|
|
957
|
+
async function applyAutoSyncPausedMarkers(provider, syncSettingsFiles = []) {
|
|
958
|
+
var _a, _b, _c, _d;
|
|
959
|
+
const isDisabled = isScheduleDisabled();
|
|
960
|
+
const configuredIds = new Set((Array.isArray(syncSettingsFiles) ? syncSettingsFiles : []).map((item) => `${item.id}`));
|
|
961
|
+
const getChangedItems = (tree = []) => tree
|
|
962
|
+
.map((item) => {
|
|
963
|
+
const nextScheduleDisabled = Boolean(item.schedule) && isDisabled && configuredIds.has(`${item.id}`);
|
|
964
|
+
const currentScheduleDisabled = Boolean(item.scheduleDisabled);
|
|
965
|
+
if (currentScheduleDisabled === nextScheduleDisabled) {
|
|
966
|
+
return null;
|
|
967
|
+
}
|
|
968
|
+
return {
|
|
969
|
+
...item,
|
|
970
|
+
scheduleDisabled: nextScheduleDisabled,
|
|
971
|
+
};
|
|
972
|
+
})
|
|
973
|
+
.filter(Boolean);
|
|
974
|
+
if (provider === 'crowdin') {
|
|
975
|
+
const changedItems = getChangedItems(crowdinData.current || []);
|
|
976
|
+
if (changedItems.length) {
|
|
977
|
+
const changedById = new Map(changedItems.map((item) => [`${item.id}`, item]));
|
|
978
|
+
crowdinData.current = (crowdinData.current || []).map((item) => changedById.get(`${item.id}`) || item);
|
|
979
|
+
(_a = appComponent.current) === null || _a === void 0 ? void 0 : _a.updateCrowdinFileData(changedItems);
|
|
980
|
+
}
|
|
981
|
+
return;
|
|
982
|
+
}
|
|
983
|
+
const integrationData = await ((_c = (_b = appComponent.current) === null || _b === void 0 ? void 0 : _b.getIntegrationFilesData) === null || _c === void 0 ? void 0 : _c.call(_b));
|
|
984
|
+
if (Array.isArray(integrationData)) {
|
|
985
|
+
const changedItems = getChangedItems(integrationData);
|
|
986
|
+
if (changedItems.length) {
|
|
987
|
+
(_d = appComponent.current) === null || _d === void 0 ? void 0 : _d.updateIntegrationFileData(changedItems);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
async function fetchSyncSettingsFiles(provider) {
|
|
992
|
+
const restParams = await checkOrigin();
|
|
993
|
+
const res = await fetch(`/api/sync-settings/${provider}` + restParams).then(checkResponse);
|
|
994
|
+
return Array.isArray(res) ? res : [];
|
|
995
|
+
}
|
|
996
|
+
async function refreshAutoSyncPausedIndicatorsAndWarning() {
|
|
997
|
+
const [crowdinSyncSettings, integrationSyncSettings] = await Promise.all([
|
|
998
|
+
fetchSyncSettingsFiles('crowdin'),
|
|
999
|
+
fetchSyncSettingsFiles('integration'),
|
|
1000
|
+
]);
|
|
1001
|
+
await applyAutoSyncPausedMarkers('crowdin', crowdinSyncSettings);
|
|
1002
|
+
await applyAutoSyncPausedMarkers('integration', integrationSyncSettings);
|
|
1003
|
+
if (isScheduleDisabled() && (crowdinSyncSettings.length || integrationSyncSettings.length)) {
|
|
1004
|
+
showToast('Auto Sync is configured for some files, but sync schedule is disabled in app settings.');
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
952
1007
|
function getSyncSettings(provider) {
|
|
953
1008
|
checkOrigin()
|
|
954
1009
|
.then((restParams) => fetch(`/api/sync-settings/${provider}` + restParams))
|
|
955
1010
|
.then(checkResponse)
|
|
956
|
-
.then((res) => {
|
|
1011
|
+
.then(async (res) => {
|
|
957
1012
|
if (provider === 'crowdin') {
|
|
958
1013
|
if (syncNewElements === null || syncNewElements === void 0 ? void 0 : syncNewElements.crowdin) {
|
|
959
1014
|
appComponent.current.setCrowdinScheduleSync(res, true, true);
|
|
@@ -970,6 +1025,7 @@
|
|
|
970
1025
|
appComponent.current.setIntegrationScheduleSync(res);
|
|
971
1026
|
}
|
|
972
1027
|
}
|
|
1028
|
+
await applyAutoSyncPausedMarkers(provider, res);
|
|
973
1029
|
})
|
|
974
1030
|
.catch((e) => catchRejection(e, "Can't fetch file progress"));
|
|
975
1031
|
}
|
|
@@ -1708,6 +1764,8 @@
|
|
|
1708
1764
|
});
|
|
1709
1765
|
});
|
|
1710
1766
|
let isValidationError = false;
|
|
1767
|
+
let isSettingsSaveJobPending = false;
|
|
1768
|
+
let isSettingsSaveFailed = false;
|
|
1711
1769
|
settingsSaveBtn.setAttribute('disabled', true);
|
|
1712
1770
|
checkOrigin()
|
|
1713
1771
|
.then((restParams) => fetch('api/settings' + restParams, {
|
|
@@ -1716,9 +1774,39 @@
|
|
|
1716
1774
|
body: JSON.stringify({ config: configReq }),
|
|
1717
1775
|
}))
|
|
1718
1776
|
.then(checkResponse)
|
|
1719
|
-
.then(() => {
|
|
1777
|
+
.then((res) => {
|
|
1778
|
+
if (res === null || res === void 0 ? void 0 : res.jobId) {
|
|
1779
|
+
isSettingsSaveJobPending = true;
|
|
1780
|
+
checkJob({
|
|
1781
|
+
jobId: res.jobId,
|
|
1782
|
+
jobType: JOB_TYPE.integrationSettingsSave,
|
|
1783
|
+
onSuccess: () => {
|
|
1784
|
+
showToast('Settings successfully saved');
|
|
1785
|
+
config.current = configReq;
|
|
1786
|
+
refreshAutoSyncPausedIndicatorsAndWarning().catch((e) => catchRejection(e, "Can't fetch sync settings warning"));
|
|
1787
|
+
},
|
|
1788
|
+
onError: () => {
|
|
1789
|
+
isSettingsSaveFailed = true;
|
|
1790
|
+
showToast("Can't save settings");
|
|
1791
|
+
},
|
|
1792
|
+
onFinally: () => {
|
|
1793
|
+
unsetLoader('#settings-modal');
|
|
1794
|
+
settingsSaveBtn.removeAttribute('disabled');
|
|
1795
|
+
if (!isValidationError && !isSettingsSaveFailed) {
|
|
1796
|
+
const settingsModal = document.getElementById('settings-modal');
|
|
1797
|
+
closeModal(settingsModal);
|
|
1798
|
+
if (reloadOnConfigSave) {
|
|
1799
|
+
getIntegrationData({ hardReload: true });
|
|
1800
|
+
getCrowdinData();
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
},
|
|
1804
|
+
});
|
|
1805
|
+
return;
|
|
1806
|
+
}
|
|
1720
1807
|
showToast('Settings successfully saved');
|
|
1721
1808
|
config.current = configReq;
|
|
1809
|
+
refreshAutoSyncPausedIndicatorsAndWarning().catch((e) => catchRejection(e, "Can't fetch sync settings warning"));
|
|
1722
1810
|
})
|
|
1723
1811
|
.catch((e) => {
|
|
1724
1812
|
var _a, _b, _c, _d;
|
|
@@ -1739,6 +1827,9 @@
|
|
|
1739
1827
|
catchRejection(e, "Can't save settings");
|
|
1740
1828
|
})
|
|
1741
1829
|
.finally(() => {
|
|
1830
|
+
if (isSettingsSaveJobPending) {
|
|
1831
|
+
return;
|
|
1832
|
+
}
|
|
1742
1833
|
unsetLoader('#settings-modal');
|
|
1743
1834
|
settingsSaveBtn.removeAttribute('disabled');
|
|
1744
1835
|
if (!isValidationError) {
|