aboutsummaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
Diffstat (limited to 'core/js')
-rw-r--r--core/js/login/grant.js19
-rw-r--r--core/js/mimetypelist.js129
-rw-r--r--core/js/tests/specHelper.js7
-rw-r--r--core/js/tests/specs/coreSpec.js87
-rw-r--r--core/js/tests/specs/l10nSpec.js63
5 files changed, 152 insertions, 153 deletions
diff --git a/core/js/login/grant.js b/core/js/login/grant.js
index a8c788397a8..c6134504421 100644
--- a/core/js/login/grant.js
+++ b/core/js/login/grant.js
@@ -2,11 +2,28 @@
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-document.querySelector('form').addEventListener('submit', function(e) {
+
+const form = document.querySelector('form')
+form.addEventListener('submit', function(event) {
const wrapper = document.getElementById('submit-wrapper')
if (wrapper === null) {
return
}
+
+ if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
+ // stop the event
+ event.preventDefault()
+ event.stopPropagation()
+
+ // handle password confirmation
+ OC.PasswordConfirmation.requirePasswordConfirmation(function () {
+ // when password is confirmed we submit the form
+ form.submit()
+ })
+
+ return false
+ }
+
Array.from(wrapper.getElementsByClassName('icon-confirm-white')).forEach(function(el) {
el.classList.remove('icon-confirm-white')
el.classList.add(OCA.Theming && OCA.Theming.inverted ? 'icon-loading-small' : 'icon-loading-small-dark')
diff --git a/core/js/mimetypelist.js b/core/js/mimetypelist.js
index ed861205cf0..eb937c440cc 100644
--- a/core/js/mimetypelist.js
+++ b/core/js/mimetypelist.js
@@ -81,7 +81,6 @@ OC.MimeTypeList={
"application/x-7z-compressed": "package/x-generic",
"application/x-bzip2": "package/x-generic",
"application/x-cbr": "text",
- "application/x-compressed": "package/x-generic",
"application/x-dcraw": "image",
"application/x-deb": "package/x-generic",
"application/x-fictionbook+xml": "text",
@@ -115,6 +114,7 @@ OC.MimeTypeList={
"text/x-h": "text/code",
"text/x-java-source": "text/code",
"text/x-ldif": "text/code",
+ "text/x-nfo": "text/code",
"text/x-python": "text/code",
"text/x-rst": "text",
"text/x-shellscript": "text/code",
@@ -151,5 +151,130 @@ OC.MimeTypeList={
"x-office-presentation",
"x-office-spreadsheet"
],
- themes: []
+ themes: [],
+ names: {'application/cmd': t('core', "Windows Command Script"),
+'application/epub+zip': t('core', "Electronic book document"),
+'application/font-sfnt': t('core', "TrueType Font Collection"),
+'application/font-woff': t('core', "Web Open Font Format"),
+'application/gpx+xml': t('core', "GPX geographic data"),
+'application/gzip': t('core', "Gzip archive"),
+'application/illustrator': t('core', "Adobe Illustrator document"),
+'application/java': t('core', "Java source code"),
+'application/javascript': t('core', "JavaScript source code"),
+'application/json': t('core', "JSON document"),
+'application/msaccess': t('core', "Microsoft Access database"),
+'application/msonenote': t('core', "Microsoft OneNote document"),
+'application/msword': t('core', "Microsoft Word document"),
+'application/octet-stream': t('core', "Unknown"),
+'application/pdf': t('core', "PDF document"),
+'application/postscript': t('core', "PostScript document"),
+'application/rss+xml': t('core', "RSS summary"),
+'application/vnd.android.package-archive': t('core', "Android package"),
+'application/vnd.google-earth.kml+xml': t('core', "KML geographic data"),
+'application/vnd.google-earth.kmz': t('core', "KML geographic compressed data"),
+'application/vnd.lotus-wordpro': t('core', "Lotus Word Pro document"),
+'application/vnd.ms-excel': t('core', "Excel spreadsheet"),
+'application/vnd.ms-excel.addin.macroEnabled.12': t('core', "Excel add-in"),
+'application/vnd.ms-excel.sheet.binary.macroEnabled.12': t('core', "Excel 2007 binary spreadsheet"),
+'application/vnd.ms-excel.sheet.macroEnabled.12': t('core', "Excel spreadsheet"),
+'application/vnd.ms-excel.template.macroEnabled.12': t('core', "Excel spreadsheet template"),
+'application/vnd.ms-outlook': t('core', "Outlook Message"),
+'application/vnd.ms-powerpoint': t('core', "PowerPoint presentation"),
+'application/vnd.ms-powerpoint.addin.macroEnabled.12': t('core', "PowerPoint add-in"),
+'application/vnd.ms-powerpoint.presentation.macroEnabled.12': t('core', "PowerPoint presentation"),
+'application/vnd.ms-powerpoint.slideshow.macroEnabled.12': t('core', "PowerPoint presentation"),
+'application/vnd.ms-powerpoint.template.macroEnabled.12': t('core', "PowerPoint presentation template"),
+'application/vnd.ms-word.document.macroEnabled.12': t('core', "Word document"),
+'application/vnd.oasis.opendocument.formula': t('core', "ODF formula"),
+'application/vnd.oasis.opendocument.graphics': t('core', "ODG drawing"),
+'application/vnd.oasis.opendocument.graphics-flat-xml': t('core', "ODG drawing (Flat XML)"),
+'application/vnd.oasis.opendocument.graphics-template': t('core', "ODG template"),
+'application/vnd.oasis.opendocument.presentation': t('core', "ODP presentation"),
+'application/vnd.oasis.opendocument.presentation-flat-xml': t('core', "ODP presentation (Flat XML)"),
+'application/vnd.oasis.opendocument.presentation-template': t('core', "ODP template"),
+'application/vnd.oasis.opendocument.spreadsheet': t('core', "ODS spreadsheet"),
+'application/vnd.oasis.opendocument.spreadsheet-flat-xml': t('core', "ODS spreadsheet (Flat XML)"),
+'application/vnd.oasis.opendocument.spreadsheet-template': t('core', "ODS template"),
+'application/vnd.oasis.opendocument.text': t('core', "ODT document"),
+'application/vnd.oasis.opendocument.text-flat-xml': t('core', "ODT document (Flat XML)"),
+'application/vnd.oasis.opendocument.text-template': t('core', "ODT template"),
+'application/vnd.openxmlformats-officedocument.presentationml.presentation': t('core', "PowerPoint 2007 presentation"),
+'application/vnd.openxmlformats-officedocument.presentationml.slideshow': t('core', "PowerPoint 2007 show"),
+'application/vnd.openxmlformats-officedocument.presentationml.template': t('core', "PowerPoint 2007 presentation template"),
+'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': t('core', "Excel 2007 spreadsheet"),
+'application/vnd.openxmlformats-officedocument.spreadsheetml.template': t('core', "Excel 2007 spreadsheet template"),
+'application/vnd.openxmlformats-officedocument.wordprocessingml.document': t('core', "Word 2007 document"),
+'application/vnd.openxmlformats-officedocument.wordprocessingml.template': t('core', "Word 2007 document template"),
+'application/vnd.visio': t('core', "Microsoft Visio document"),
+'application/vnd.wordperfect': t('core', "WordPerfect document"),
+'application/x-7z-compressed': t('core', "7-zip archive"),
+'application/x-blender': t('core', "Blender scene"),
+'application/x-bzip2': t('core', "Bzip2 archive"),
+'application/x-deb': t('core', "Debian package"),
+'application/x-fictionbook+xml': t('core', "FictionBook document"),
+'application/x-font': t('core', "Unknown font"),
+'application/x-krita': t('core', "Krita document"),
+'application/x-mobipocket-ebook': t('core', "Mobipocket e-book"),
+'application/x-msi': t('core', "Windows Installer package"),
+'application/x-perl': t('core', "Perl script"),
+'application/x-php': t('core', "PHP script"),
+'application/x-tar': t('core', "Tar archive"),
+'application/xml': t('core', "XML document"),
+'application/yaml': t('core', "YAML document"),
+'application/zip': t('core', "Zip archive"),
+'application/zstd': t('core', "Zstandard archive"),
+'audio/aac': t('core', "AAC audio"),
+'audio/flac': t('core', "FLAC audio"),
+'audio/mp4': t('core', "MPEG-4 audio"),
+'audio/mpeg': t('core', "MP3 audio"),
+'audio/ogg': t('core', "Ogg audio"),
+'audio/wav': t('core', "RIFF\/WAVe standard Audio"),
+'audio/webm': t('core', "WebM audio"),
+'audio/x-scpls': t('core', "MP3 ShoutCast playlist"),
+'image/bmp': t('core', "Windows BMP image"),
+'image/bpg': t('core', "Better Portable Graphics image"),
+'image/emf': t('core', "EMF image"),
+'image/gif': t('core', "GIF image"),
+'image/heic': t('core', "HEIC image"),
+'image/heif': t('core', "HEIF image"),
+'image/jp2': t('core', "JPEG-2000 JP2 image"),
+'image/jpeg': t('core', "JPEG image"),
+'image/png': t('core', "PNG image"),
+'image/svg+xml': t('core', "SVG image"),
+'image/tga': t('core', "Truevision Targa image"),
+'image/tiff': t('core', "TIFF image"),
+'image/webp': t('core', "WebP image"),
+'image/x-dcraw': t('core', "Digital raw image"),
+'image/x-icon': t('core', "Windows Icon"),
+'message/rfc822': t('core', "Email message"),
+'text/calendar': t('core', "VCS\/ICS calendar"),
+'text/css': t('core', "CSS stylesheet"),
+'text/csv': t('core', "CSV document"),
+'text/html': t('core', "HTML document"),
+'text/markdown': t('core', "Markdown document"),
+'text/org': t('core', "Org-mode file"),
+'text/plain': t('core', "Plain text document"),
+'text/rtf': t('core', "Rich Text document"),
+'text/vcard': t('core', "Electronic business card"),
+'text/x-c++src': t('core', "C++ source code"),
+'text/x-java-source': t('core', "Java source code"),
+'text/x-ldif': t('core', "LDIF address book"),
+'text/x-nfo': t('core', "NFO document"),
+'text/x-php': t('core', "PHP source"),
+'text/x-python': t('core', "Python script"),
+'text/x-rst': t('core', "ReStructuredText document"),
+'video/3gpp': t('core', "3GPP multimedia file"),
+'video/MP2T': t('core', "MPEG video"),
+'video/dv': t('core', "DV video"),
+'video/mp2t': t('core', "MPEG-2 transport stream"),
+'video/mp4': t('core', "MPEG-4 video"),
+'video/mpeg': t('core', "MPEG video"),
+'video/ogg': t('core', "Ogg video"),
+'video/quicktime': t('core', "QuickTime video"),
+'video/webm': t('core', "WebM video"),
+'video/x-flv': t('core', "Flash video"),
+'video/x-matroska': t('core', "Matroska video"),
+'video/x-ms-wmv': t('core', "Windows Media video"),
+'video/x-msvideo': t('core', "AVI video"),
+},
};
diff --git a/core/js/tests/specHelper.js b/core/js/tests/specHelper.js
index 8d121a2fb38..77958488df7 100644
--- a/core/js/tests/specHelper.js
+++ b/core/js/tests/specHelper.js
@@ -85,6 +85,9 @@ window._oc_appswebroots = {
"files": window.webroot + '/apps/files/',
"files_sharing": window.webroot + '/apps/files_sharing/'
};
+
+window.OC ??= {};
+
OC.config = {
session_lifetime: 600 * 1000,
session_keepalive: false,
@@ -111,6 +114,10 @@ window.Snap.prototype = {
window.isPhantom = /phantom/i.test(navigator.userAgent);
document.documentElement.lang = navigator.language;
+const el = document.createElement('input');
+el.id = 'initial-state-core-config';
+el.value = btoa(JSON.stringify(window.OC.config))
+document.body.append(el);
// global setup for all tests
(function setupTests() {
diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js
index 195b6dca99a..3cbd7623a47 100644
--- a/core/js/tests/specs/coreSpec.js
+++ b/core/js/tests/specs/coreSpec.js
@@ -119,93 +119,6 @@ describe('Core base tests', function() {
})).toEqual('number=123');
});
});
- describe('Session heartbeat', function() {
- var clock,
- oldConfig,
- counter;
-
- beforeEach(function() {
- clock = sinon.useFakeTimers();
- oldConfig = OC.config;
- counter = 0;
-
- fakeServer.autoRespond = true;
- fakeServer.autoRespondAfter = 0;
- fakeServer.respondWith(/\/csrftoken/, function(xhr) {
- counter++;
- xhr.respond(200, {'Content-Type': 'application/json'}, '{"token": "pgBEsb3MzTb1ZPd2mfDZbQ6/0j3OrXHMEZrghHcOkg8=:3khw5PSa+wKQVo4f26exFD3nplud9ECjJ8/Y5zk5/k4="}');
- });
- $(document).off('ajaxComplete'); // ignore previously registered heartbeats
- });
- afterEach(function() {
- clock.restore();
- /* jshint camelcase: false */
- OC.config = oldConfig;
- $(document).off('ajaxError');
- $(document).off('ajaxComplete');
- });
- it('sends heartbeat half the session lifetime when heartbeat enabled', function() {
- /* jshint camelcase: false */
- OC.config = {
- session_keepalive: true,
- session_lifetime: 300
- };
- window.initCore();
-
- expect(counter).toEqual(0);
-
- // less than half, still nothing
- clock.tick(100 * 1000);
- expect(counter).toEqual(0);
-
- // reach past half (160), one call
- clock.tick(55 * 1000);
- expect(counter).toEqual(1);
-
- // almost there to the next, still one
- clock.tick(140 * 1000);
- expect(counter).toEqual(1);
-
- // past it, second call
- clock.tick(20 * 1000);
- expect(counter).toEqual(2);
- });
- it('does not send heartbeat when heartbeat disabled', function() {
- /* jshint camelcase: false */
- OC.config = {
- session_keepalive: false,
- session_lifetime: 300
- };
- window.initCore();
-
- expect(counter).toEqual(0);
-
- clock.tick(1000000);
-
- // still nothing
- expect(counter).toEqual(0);
- });
- it('limits the heartbeat between one minute and one day', function() {
- /* jshint camelcase: false */
- var setIntervalStub = sinon.stub(window, 'setInterval');
- OC.config = {
- session_keepalive: true,
- session_lifetime: 5
- };
- window.initCore();
- expect(setIntervalStub.getCall(0).args[1]).toEqual(60 * 1000);
- setIntervalStub.reset();
-
- OC.config = {
- session_keepalive: true,
- session_lifetime: 48 * 3600
- };
- window.initCore();
- expect(setIntervalStub.getCall(0).args[1]).toEqual(24 * 3600 * 1000);
-
- setIntervalStub.restore();
- });
- });
describe('Parse query string', function() {
it('Parses query string from full URL', function() {
var query = OC.parseQueryString('http://localhost/stuff.php?q=a&b=x');
diff --git a/core/js/tests/specs/l10nSpec.js b/core/js/tests/specs/l10nSpec.js
index 03f7fd50796..bd93a13fe74 100644
--- a/core/js/tests/specs/l10nSpec.js
+++ b/core/js/tests/specs/l10nSpec.js
@@ -110,67 +110,4 @@ describe('OC.L10N tests', function() {
checkPlurals();
});
});
- describe('async loading of translations', function() {
- afterEach(() => {
- document.documentElement.removeAttribute('data-locale')
- })
- it('loads bundle for given app and calls callback', function(done) {
- document.documentElement.setAttribute('data-locale', 'zh_CN')
- var callbackStub = sinon.stub();
- var promiseStub = sinon.stub();
- var loading = OC.L10N.load(TEST_APP, callbackStub);
- expect(callbackStub.notCalled).toEqual(true);
- var req = fakeServer.requests[0];
-
- console.warn('fff-', window.OC.appswebroots)
- loading
- .then(promiseStub)
- .then(function() {
- expect(fakeServer.requests.length).toEqual(1);
- expect(req.url).toEqual(
- OC.getRootPath() + '/apps3/' + TEST_APP + '/l10n/zh_CN.json'
- );
-
- expect(callbackStub.calledOnce).toEqual(true);
- expect(promiseStub.calledOnce).toEqual(true);
- expect(t(TEST_APP, 'Hello world!')).toEqual('你好世界!');
- })
- .then(done)
- .catch(e => expect(e).toBe('No error expected!'));
-
- expect(promiseStub.notCalled).toEqual(true);
- req.respond(
- 200,
- { 'Content-Type': 'application/json' },
- JSON.stringify({
- translations: {'Hello world!': '你好世界!'},
- pluralForm: 'nplurals=2; plural=(n != 1);'
- })
- );
- });
- it('calls callback if translation already available', function(done) {
- var callbackStub = sinon.stub();
- spyOn(console, 'warn');
- OC.L10N.register(TEST_APP, {
- 'Hello world!': 'Hallo Welt!'
- });
- OC.L10N.load(TEST_APP, callbackStub)
- .then(function() {
- expect(callbackStub.calledOnce).toEqual(true);
- expect(fakeServer.requests.length).toEqual(0);
- })
- .then(done);
-
- });
- it('calls callback if locale is en', function(done) {
- var callbackStub = sinon.stub();
- OC.L10N.load(TEST_APP, callbackStub)
- .then(function() {
- expect(callbackStub.calledOnce).toEqual(true);
- expect(fakeServer.requests.length).toEqual(0);
- })
- .then(done)
- .catch(done);
- });
- });
});