Add warning message when importing unstable x2t doc in drive

https://github.com/cryptpad/cryptpad/issues/1883
This commit is contained in:
Wolfgang Ginolas 2025-05-05 10:17:36 +02:00
parent ef094326c9
commit 3e2d8c3aa2
4 changed files with 31 additions and 10 deletions

View File

@ -867,6 +867,12 @@ const factory = (NaclUtil) => {
};
/* End of code copied from saferphore */
Util.requirePromise = function(modulePath){
return new Promise((resolve) => {
require([modulePath], resolve);
});
}
return Util;
};

View File

@ -1652,15 +1652,15 @@ define([
if (($(e.target).offset().top + $(e.target).height()) > ($(window).height()-$menu.height())) {
if ( $(e.target).offset().top < $menu.height()) {
menuPositionTop = 0;
} else {
menuPositionTop = ($(e.target).offset().top - $menu.height());
}
menuPositionTop = ($(e.target).offset().top - $menu.height());
}
} else {
menuPositionTop = $(e.target).offset().top + $(e.target).outerHeight();
}
if (($(e.target).offset().left + $(e.target).width()) < $menu.width()) {
menuPositionLeft = $(e.target).offset().left;
menuPositionLeft = $(e.target).offset().left;
} else {
menuPositionLeft = $(e.target).offset().left - ($menu.width() - $(e.target).width()) + 10;
}
@ -4841,7 +4841,7 @@ define([
});
};
var openInApp = function (paths, app) {
var openInApp = async function (paths, app) {
var p = paths[0];
var el = manager.find(p.path);
var path = currentPath;
@ -4854,6 +4854,13 @@ define([
password: _metadata.password,
channel: _metadata.channel,
};
const ext = _simpleData.title.split('.').pop();
const brokenFormats = await Util.requirePromise('/common/onlyoffice/broken-formats.js');
if (brokenFormats.brokenImportFormats.includes(ext)) {
await UI.alertPromise(Messages.oo_unstableMigrationWarning);
}
openIn(app, path, APP.team, _simpleData);
};
@ -5642,4 +5649,3 @@ define([
logError: logError
};
});

View File

@ -0,0 +1,9 @@
// SPDX-FileCopyrightText: 2023 XWiki CryptPad Team <contact@cryptpad.org> and contributors
//
// SPDX-License-Identifier: AGPL-3.0-or-later
define({
brokenExportFormats: ['odt', 'odp'],
brokenImportFormats: ['odp'],
});

View File

@ -63,8 +63,6 @@ define([
var PENDING_TIMEOUT = 30000;
const HISTORY_KEEPER_INDEX_USER = 1;
const READ_ONLY_INDEX_USER = 2;
const BROKEN_EXPORT_FORMATS = ['odt', 'odp'];
const BROKEN_IMPORT_FORMATS = ['odp'];
//var READONLY_REFRESH_TO = 15000;
var debug = function (x, type) {
@ -2241,7 +2239,8 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
return;
}
if (BROKEN_EXPORT_FORMATS.includes(ext)) {
const brokenFormats = await Util.requirePromise('/common/onlyoffice/broken-formats.js');
if (brokenFormats.brokenExportFormats.includes(ext)) {
await UI.alertPromise(Messages.oo_unstableMigrationWarning);
}
@ -2367,7 +2366,8 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
debug("Filename");
debug(filename);
if (BROKEN_IMPORT_FORMATS.includes(ext)) {
const brokenFormats = await Util.requirePromise('/common/onlyoffice/broken-formats.js');
if (brokenFormats.brokenImportFormats.includes(ext)) {
await UI.alertPromise(Messages.oo_unstableMigrationWarning);
}