Merge pull request #21225 from nextcloud/techdebt/humanfilesize-getcanonicallocale-package

Move humanFileSize and OC.getCanonicalLocale to npm packages
pull/21246/head
Roeland Jago Douma 5 years ago committed by GitHub
commit 81f83d3c1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      apps/files/js/dist/files-app-settings.js
  2. 14
      apps/files/js/dist/personal-settings.js
  3. 2
      apps/files/js/dist/personal-settings.js.map
  4. 16
      apps/files/js/dist/sidebar.js
  5. 2
      apps/files/js/dist/sidebar.js.map
  6. 2
      apps/files_sharing/js/dist/additionalScripts.js
  7. 48
      apps/files_sharing/js/dist/files_sharing_tab.js
  8. 2
      apps/files_sharing/js/dist/files_sharing_tab.js.map
  9. 4
      apps/files_sharing/js/dist/personal-settings.js
  10. 2
      apps/files_sharing/js/dist/personal-settings.js.map
  11. 22
      apps/settings/js/vue-0.js
  12. 2
      apps/settings/js/vue-0.js.map
  13. 4
      apps/settings/js/vue-5.js
  14. 2
      apps/settings/js/vue-5.js.map
  15. 8
      apps/settings/js/vue-6.js
  16. 2
      apps/settings/js/vue-6.js.map
  17. 4
      apps/settings/js/vue-7.js
  18. 2
      apps/settings/js/vue-7.js.map
  19. 6
      apps/settings/js/vue-8.js
  20. 2
      apps/settings/js/vue-8.js.map
  21. 24
      apps/settings/js/vue-settings-admin-security.js
  22. 2
      apps/settings/js/vue-settings-admin-security.js.map
  23. 10
      apps/settings/js/vue-settings-apps-users-management.js
  24. 2
      apps/settings/js/vue-settings-apps-users-management.js.map
  25. 24
      apps/settings/js/vue-settings-personal-security.js
  26. 2
      apps/settings/js/vue-settings-personal-security.js.map
  27. 16
      apps/settings/js/vue-settings-personal-webauthn.js
  28. 2
      apps/settings/js/vue-settings-personal-webauthn.js.map
  29. 16
      apps/updatenotification/js/updatenotification.js
  30. 2
      apps/updatenotification/js/updatenotification.js.map
  31. 30
      apps/workflowengine/js/workflowengine.js
  32. 2
      apps/workflowengine/js/workflowengine.js.map
  33. 6
      core/js/dist/files_client.js
  34. 2
      core/js/dist/files_client.js.map
  35. 2
      core/js/dist/files_fileinfo.js
  36. 2
      core/js/dist/files_fileinfo.js.map
  37. 2
      core/js/dist/files_iedavclient.js
  38. 2
      core/js/dist/files_iedavclient.js.map
  39. 18
      core/js/dist/install.js
  40. 2
      core/js/dist/install.js.map
  41. 67
      core/js/dist/login.js
  42. 2
      core/js/dist/login.js.map
  43. 83
      core/js/dist/main.js
  44. 2
      core/js/dist/main.js.map
  45. 59
      core/js/dist/maintenance.js
  46. 2
      core/js/dist/maintenance.js.map
  47. 4
      core/js/dist/recommendedapps.js
  48. 2
      core/js/dist/recommendedapps.js.map
  49. 88
      core/js/tests/specs/coreSpec.js
  50. 6
      core/src/OC/index.js
  51. 10
      core/src/OC/l10n.js
  52. 5
      core/src/OC/util.js
  53. 51
      core/src/Util/human-file-size.js
  54. 15
      package-lock.json
  55. 3
      package.json

@ -1,4 +1,4 @@
!function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/js/",n(n.s=400)}({10:function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},136:function(t,e,n){(function(t){var r=void 0!==t&&t||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new o(i.call(setTimeout,r,arguments),clearTimeout)},e.setInterval=function(){return new o(i.call(setInterval,r,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(r,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},n(137),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n(10))},137:function(t,e,n){(function(t,e){!function(t,n){"use strict";if(!t.setImmediate){var r,i,o,a,s,c=1,u={},l=!1,f=t.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(t);d=d&&d.setTimeout?d:t,"[object process]"==={}.toString.call(t.process)?r=function(t){e.nextTick((function(){v(t)}))}:!function(){if(t.postMessage&&!t.importScripts){var e=!0,n=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=n,e}}()?t.MessageChannel?((o=new MessageChannel).port1.onmessage=function(t){v(t.data)},r=function(t){o.port2.postMessage(t)}):f&&"onreadystatechange"in f.createElement("script")?(i=f.documentElement,r=function(t){var e=f.createElement("script");e.onreadystatechange=function(){v(t),e.onreadystatechange=null,i.removeChild(e),e=null},i.appendChild(e)}):r=function(t){setTimeout(v,0,t)}:(a="setImmediate$"+Math.random()+"$",s=function(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(a)&&v(+e.data.slice(a.length))},t.addEventListener?t.addEventListener("message",s,!1):t.attachEvent("onmessage",s),r=function(e){t.postMessage(a+e,"*")}),d.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n<e.length;n++)e[n]=arguments[n+1];var i={callback:t,args:e};return u[c]=i,r(c),c++},d.clearImmediate=p}function p(t){delete u[t]}function v(t){if(l)setTimeout(v,0,t);else{var e=u[t];if(e){l=!0;try{!function(t){var e=t.callback,n=t.args;switch(n.length){case 0:e();break;case 1:e(n[0]);break;case 2:e(n[0],n[1]);break;case 3:e(n[0],n[1],n[2]);break;default:e.apply(void 0,n)}}(e)}finally{p(t),l=!1}}}}}("undefined"==typeof self?void 0===t?this:t:self)}).call(this,n(10),n(43))},19:function(t,e,n){"use strict";function r(t,e,n,r,i,o,a,s){var c,u="function"==typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=n,u._compiled=!0),r&&(u.functional=!0),o&&(u._scopeId="data-v-"+o),a?(c=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),i&&i.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(a)},u._ssrRegister=c):i&&(c=s?function(){i.call(this,(u.functional?this.parent:this).$root.$options.shadowRoot)}:i),c)if(u.functional){u._injectStyles=c;var l=u.render;u.render=function(t,e){return c.call(e),l(t,e)}}else{var f=u.beforeCreate;u.beforeCreate=f?[].concat(f,c):[c]}return{exports:t,options:u}}n.d(e,"a",(function(){return r}))},20:function(t,e,n){"use strict";n.r(e),function(t,n){
!function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/js/",n(n.s=400)}({10:function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},136:function(t,e,n){(function(t){var r=void 0!==t&&t||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(t,e){this._id=t,this._clearFn=e}e.setTimeout=function(){return new o(i.call(setTimeout,r,arguments),clearTimeout)},e.setInterval=function(){return new o(i.call(setInterval,r,arguments),clearInterval)},e.clearTimeout=e.clearInterval=function(t){t&&t.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(r,this._id)},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout((function(){t._onTimeout&&t._onTimeout()}),e))},n(137),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n(10))},137:function(t,e,n){(function(t,e){!function(t,n){"use strict";if(!t.setImmediate){var r,i,o,a,s,c=1,u={},l=!1,f=t.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(t);d=d&&d.setTimeout?d:t,"[object process]"==={}.toString.call(t.process)?r=function(t){e.nextTick((function(){v(t)}))}:!function(){if(t.postMessage&&!t.importScripts){var e=!0,n=t.onmessage;return t.onmessage=function(){e=!1},t.postMessage("","*"),t.onmessage=n,e}}()?t.MessageChannel?((o=new MessageChannel).port1.onmessage=function(t){v(t.data)},r=function(t){o.port2.postMessage(t)}):f&&"onreadystatechange"in f.createElement("script")?(i=f.documentElement,r=function(t){var e=f.createElement("script");e.onreadystatechange=function(){v(t),e.onreadystatechange=null,i.removeChild(e),e=null},i.appendChild(e)}):r=function(t){setTimeout(v,0,t)}:(a="setImmediate$"+Math.random()+"$",s=function(e){e.source===t&&"string"==typeof e.data&&0===e.data.indexOf(a)&&v(+e.data.slice(a.length))},t.addEventListener?t.addEventListener("message",s,!1):t.attachEvent("onmessage",s),r=function(e){t.postMessage(a+e,"*")}),d.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n<e.length;n++)e[n]=arguments[n+1];var i={callback:t,args:e};return u[c]=i,r(c),c++},d.clearImmediate=p}function p(t){delete u[t]}function v(t){if(l)setTimeout(v,0,t);else{var e=u[t];if(e){l=!0;try{!function(t){var e=t.callback,n=t.args;switch(n.length){case 0:e();break;case 1:e(n[0]);break;case 2:e(n[0],n[1]);break;case 3:e(n[0],n[1],n[2]);break;default:e.apply(void 0,n)}}(e)}finally{p(t),l=!1}}}}}("undefined"==typeof self?void 0===t?this:t:self)}).call(this,n(10),n(44))},19:function(t,e,n){"use strict";function r(t,e,n,r,i,o,a,s){var c,u="function"==typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=n,u._compiled=!0),r&&(u.functional=!0),o&&(u._scopeId="data-v-"+o),a?(c=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),i&&i.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(a)},u._ssrRegister=c):i&&(c=s?function(){i.call(this,(u.functional?this.parent:this).$root.$options.shadowRoot)}:i),c)if(u.functional){u._injectStyles=c;var l=u.render;u.render=function(t,e){return c.call(e),l(t,e)}}else{var f=u.beforeCreate;u.beforeCreate=f?[].concat(f,c):[c]}return{exports:t,options:u}}n.d(e,"a",(function(){return r}))},20:function(t,e,n){"use strict";n.r(e),function(t,n){
/*!
* Vue.js v2.6.11
* (c) 2014-2019 Evan You
@ -71,5 +71,5 @@ var c=function(){function t(){!function(t,e){if(!(t instanceof e))throw new Type
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
i.default.prototype.t=t,window.OCA.Files||(window.OCA.Files={}),Object.assign(window.OCA.Files,{Settings:new c}),Object.assign(window.OCA.Files.Settings,{Setting:g}),window.addEventListener("DOMContentLoaded",(function(){new i.default({el:"#files-app-settings",render:function(t){return t(p)}});var t=document.getElementById("app-settings-header");t&&t.addEventListener("click",(function(t){var e=t.currentTarget.children[0].classList.contains("opened");OCA.Files.Settings.settings.forEach((function(t){return e?t.close():t.open()}))}))}))},43:function(t,e){var n,r,i=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(t){n=o}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(t){r=a}}();var c,u=[],l=!1,f=-1;function d(){l&&c&&(l=!1,c.length?u=c.concat(u):f=-1,u.length&&p())}function p(){if(!l){var t=s(d);l=!0;for(var e=u.length;e;){for(c=u,u=[];++f<e;)c&&c[f].run();f=-1,e=u.length}c=null,l=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function v(t,e){this.fun=t,this.array=e}function h(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];u.push(new v(t,e)),1!==u.length||l||s(p)},v.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=h,i.addListener=h,i.once=h,i.off=h,i.removeListener=h,i.removeAllListeners=h,i.emit=h,i.prependListener=h,i.prependOnceListener=h,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}}});
i.default.prototype.t=t,window.OCA.Files||(window.OCA.Files={}),Object.assign(window.OCA.Files,{Settings:new c}),Object.assign(window.OCA.Files.Settings,{Setting:g}),window.addEventListener("DOMContentLoaded",(function(){new i.default({el:"#files-app-settings",render:function(t){return t(p)}});var t=document.getElementById("app-settings-header");t&&t.addEventListener("click",(function(t){var e=t.currentTarget.children[0].classList.contains("opened");OCA.Files.Settings.settings.forEach((function(t){return e?t.close():t.open()}))}))}))},44:function(t,e){var n,r,i=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(t){n=o}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(t){r=a}}();var c,u=[],l=!1,f=-1;function d(){l&&c&&(l=!1,c.length?u=c.concat(u):f=-1,u.length&&p())}function p(){if(!l){var t=s(d);l=!0;for(var e=u.length;e;){for(c=u,u=[];++f<e;)c&&c[f].run();f=-1,e=u.length}c=null,l=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function v(t,e){this.fun=t,this.array=e}function h(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];u.push(new v(t,e)),1!==u.length||l||s(p)},v.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=h,i.addListener=h,i.once=h,i.off=h,i.removeListener=h,i.removeAllListeners=h,i.emit=h,i.prependListener=h,i.prependOnceListener=h,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}}});
//# sourceMappingURL=files-app-settings.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -55,29 +55,6 @@ describe('Core base tests', function() {
expect(OC.filePath('files', 'ajax', 'test.php')).toEqual('http://localhost/index.php/apps/files/ajax/test.php');
});
});
describe('getCanonicalLocale', function() {
var oldLocale;
beforeEach(function() {
oldLocale = $('html').data('locale')
});
afterEach(function() {
$('html').data('locale', oldLocale)
});
it("Returns primary locales as is", function() {
$('html').data('locale', 'de')
expect(OC.getCanonicalLocale()).toEqual('de');
$('html').data('locale', 'zu')
expect(OC.getCanonicalLocale()).toEqual('zu');
});
it("Returns extended locales with hyphens", function() {
$('html').data('locale', 'az_Cyrl_AZ')
expect(OC.getCanonicalLocale()).toEqual('az-Cyrl-AZ');
$('html').data('locale', 'de_DE')
expect(OC.getCanonicalLocale()).toEqual('de-DE');
});
});
describe('Link functions', function() {
var TESTAPP = 'testapp';
var TESTAPP_ROOT = OC.getRootPath() + '/appsx/testapp';
@ -364,71 +341,6 @@ describe('Core base tests', function() {
});
});
describe('Util', function() {
var locale;
var localeStub;
beforeEach(function() {
locale = OC.getCanonicalLocale();
localeStub = sinon.stub(OC, 'getCanonicalLocale');
localeStub.returns(locale);
});
afterEach(function() {
localeStub.restore();
});
describe('humanFileSize', function() {
// cit() will skip tests if toLocaleString() is not supported.
// See https://github.com/ariya/phantomjs/issues/12581
//
// Please run these tests in Chrome/Firefox manually.
var cit = 4.2.toLocaleString("de") !== "4,2" ? xit : it;
it('renders file sizes with the correct unit', function() {
var data = [
[0, '0 B'],
["0", '0 B'],
["A", 'NaN B'],
[125, '125 B'],
[128000, '125 KB'],
[128000000, '122.1 MB'],
[128000000000, '119.2 GB'],
[128000000000000, '116.4 TB']
];
for (var i = 0; i < data.length; i++) {
expect(OC.Util.humanFileSize(data[i][0])).toEqual(data[i][1]);
}
});
it('renders file sizes with the correct unit for small sizes', function() {
var data = [
[0, '0 KB'],
[125, '< 1 KB'],
[128000, '125 KB'],
[128000000, '122.1 MB'],
[128000000000, '119.2 GB'],
[128000000000000, '116.4 TB']
];
for (var i = 0; i < data.length; i++) {
expect(OC.Util.humanFileSize(data[i][0], true)).toEqual(data[i][1]);
}
});
cit('renders file sizes with the correct locale', function() {
localeStub.returns("de");
var data = [
[0, '0 B'],
["0", '0 B'],
["A", 'NaN B'],
[125, '125 B'],
[128000, '125 KB'],
[128000000, '122,1 MB'],
[128000000000, '119,2 GB'],
[128000000000000, '116,4 TB']
];
for (var i = 0; i < data.length; i++) {
expect(OC.Util.humanFileSize(data[i][0])).toEqual(data[i][1]);
}
});
});
describe('computerFileSize', function() {
it('correctly parses file sizes from a human readable formated string', function() {
var data = [

@ -79,10 +79,12 @@ import {
} from './menu'
import { isUserAdmin } from './admin'
import L10N, {
getCanonicalLocale,
getLanguage,
getLocale,
} from './l10n'
import {
getCanonicalLocale,
} from '@nextcloud/l10n'
import {
generateUrl,
@ -223,7 +225,7 @@ export default {
getProtocol,
/**
* L10n
* @deprecated 20.0.0 use `getCanonicalLocale` from https://www.npmjs.com/package/@nextcloud/l10n
*/
getCanonicalLocale,
getLocale,

@ -323,16 +323,6 @@ const L10n = {
export default L10n
/**
* Returns the user's locale as a BCP 47 compliant language tag
*
* @returns {String} locale string
*/
export const getCanonicalLocale = () => {
const locale = getLocale()
return typeof locale === 'string' ? locale.replace(/_/g, '-') : locale
}
/**
* Returns the user's locale
*

@ -24,7 +24,7 @@ import moment from 'moment'
import History from './util-history'
import OC from './index'
import humanFileSize from '../Util/human-file-size'
import { formatFileSize as humanFileSize } from '@nextcloud/files'
function chunkify(t) {
// Adapted from http://my.opera.com/GreyWyvern/blog/show.dml/1671288
@ -58,6 +58,9 @@ export default {
History,
/**
* @deprecated use https://nextcloud.github.io/nextcloud-files/modules/_humanfilesize_.html#formatfilesize
*/
humanFileSize,
/**

@ -1,51 +0,0 @@
/*
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Returns a human readable file size
* @param {number} size Size in bytes
* @param {boolean} skipSmallSizes return '< 1 kB' for small files
* @returns {string}
*/
export default function humanFileSize(size, skipSmallSizes) {
const humanList = ['B', 'KB', 'MB', 'GB', 'TB']
// Calculate Log with base 1024: size = 1024 ** order
let order = size > 0 ? Math.floor(Math.log(size) / Math.log(1024)) : 0
// Stay in range of the byte sizes that are defined
order = Math.min(humanList.length - 1, order)
const readableFormat = humanList[order]
let relativeSize = (size / Math.pow(1024, order)).toFixed(1)
if (skipSmallSizes === true && order === 0) {
if (relativeSize !== '0.0') {
return '< 1 KB'
} else {
return '0 KB'
}
}
if (order < 2) {
relativeSize = parseFloat(relativeSize).toFixed(0)
} else if (relativeSize.substr(relativeSize.length - 2, 2) === '.0') {
relativeSize = relativeSize.substr(0, relativeSize.length - 2)
} else {
relativeSize = parseFloat(relativeSize).toLocaleString(OC.getCanonicalLocale())
}
return relativeSize + ' ' + readableFormat
}

15
package-lock.json generated

@ -3214,6 +3214,15 @@
}
}
},
"@nextcloud/files": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@nextcloud/files/-/files-1.1.0.tgz",
"integrity": "sha512-wBtgtE3cSII5dNBOSIbkEHlroOGHS34CI7P20ye/9RYBY3TuKakhw5loT68wEOXa29Sp7GZsdWOuzxoRlsF2GA==",
"requires": {
"@nextcloud/l10n": "^1.3.0",
"core-js": "^3.6.4"
}
},
"@nextcloud/initial-state": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@nextcloud/initial-state/-/initial-state-1.1.2.tgz",
@ -3223,9 +3232,9 @@
}
},
"@nextcloud/l10n": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/@nextcloud/l10n/-/l10n-1.2.3.tgz",
"integrity": "sha512-bd/bp/pk24Sl/Fjj3KJhDsGhc5EI1tIs34+sl4eaBNrj7SHl79K9bAzarxtABx6LSXn6pl6K/YYkKCidqPzuDQ==",
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@nextcloud/l10n/-/l10n-1.3.0.tgz",
"integrity": "sha512-hGk3ag9TU4cb0+ld/wziEsE+CWaS7Rpj6Y6dPv0QVfnqQ7jFCKQ62VHnuk8pFQHkmKMg3HGxkHuojumbukm42w==",
"requires": {
"core-js": "^3.6.4",
"node-gettext": "^3.0.0"

@ -31,8 +31,9 @@
"@nextcloud/capabilities": "^1.0.2",
"@nextcloud/dialogs": "^1.3.1",
"@nextcloud/event-bus": "^1.1.4",
"@nextcloud/files": "^1.1.0",
"@nextcloud/initial-state": "^1.1.2",
"@nextcloud/l10n": "^1.2.3",
"@nextcloud/l10n": "^1.3.0",
"@nextcloud/logger": "^1.1.2",
"@nextcloud/password-confirmation": "^1.0.1",
"@nextcloud/paths": "^1.1.2",

Loading…
Cancel
Save