Commit b4235a09 authored by Dhiraj Bodicherla's avatar Dhiraj Bodicherla

Update unit formatter

Update units formatter from IEC to metric
parent 4ac46452
<script>
import { GlAlert } from '@gitlab/ui';
import { __ } from '~/locale';
import { numberToHumanSize } from '~/lib/utils/number_utils';
import { n__, __ } from '~/locale';
import { getFormatter, SUPPORTED_FORMATS } from '~/lib/utils/unit_format';
import { usageRatioToThresholdLevel } from '../usage_thresholds';
import { ALERT_THRESHOLD, ERROR_THRESHOLD, WARNING_THRESHOLD } from '../constants';
......@@ -46,7 +46,7 @@ export default {
},
alertTitle() {
if (!this.hasPurchasedStorage() && this.containsLockedProjects) {
return __('This namespace contains locked projects');
return __('UsageQuota|This namespace contains locked projects');
}
return `${this.excessStoragePercentageLeft}% of purchased storage is available`;
},
......@@ -73,10 +73,12 @@ export default {
projectsLockedText() {
if (this.repositorySizeExcessProjectCount === 0) {
return '';
} else if (this.repositorySizeExcessProjectCount === 1) {
return __(`${this.repositorySizeExcessProjectCount} project`);
}
return __(`${this.repositorySizeExcessProjectCount} projects`);
return `${this.repositorySizeExcessProjectCount} ${n__(
'project',
'projects',
this.repositorySizeExcessProjectCount,
)}`;
},
},
methods: {
......@@ -84,7 +86,8 @@ export default {
return this.additionalPurchasedStorageSize > 0;
},
formatSize(size) {
return numberToHumanSize(size);
const formatter = getFormatter(SUPPORTED_FORMATS.decimalBytes);
return formatter(size);
},
hasPurchasedStorageText() {
if (this.thresholdLevel === ERROR_THRESHOLD) {
......
......@@ -2,10 +2,11 @@ import { shallowMount } from '@vue/test-utils';
import StorageInlineAlert from 'ee/storage_counter/components/storage_inline_alert.vue';
import { GlAlert } from '@gitlab/ui';
const THIRTEEN_GB_IN_BYTES = 1.3e10;
const TEN_GB_IN_BYTES = 1e10;
const FIVE_GB_IN_BYTES = 5e9;
const THREE_GB_IN_BYTES = 3e9;
const GB_IN_BYTES = 1_000_000_000;
const THIRTEEN_GB_IN_BYTES = 13 * GB_IN_BYTES;
const TEN_GB_IN_BYTES = 10 * GB_IN_BYTES;
const FIVE_GB_IN_BYTES = 5 * GB_IN_BYTES;
const THREE_GB_IN_BYTES = 3 * GB_IN_BYTES;
describe('StorageInlineAlert', () => {
let wrapper;
......@@ -53,10 +54,8 @@ describe('StorageInlineAlert', () => {
});
it('renders human readable repositoryFreeLimit', () => {
// Note how we get a less good looking 9.31 GiB number
// Will be fixed in https://gitlab.com/gitlab-org/gitlab/-/issues/263284
expect(findAlert().text()).toBe(
'You have reached the free storage limit of 9.31 GiB on 1 project. To unlock them, please purchase additional storage.',
'You have reached the free storage limit of 10GB on 1 project. To unlock them, please purchase additional storage.',
);
});
});
......@@ -80,7 +79,7 @@ describe('StorageInlineAlert', () => {
it('renders text explaining storage', () => {
expect(findAlert().text()).toBe(
'When you purchase additional storage, we automatically unlock projects that were locked when you reached the 9.31 GiB limit.',
'When you purchase additional storage, we automatically unlock projects that were locked when you reached the 10GB limit.',
);
});
});
......
......@@ -8,8 +8,6 @@ msgid ""
msgstr ""
"Project-Id-Version: gitlab 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-10-07 20:01+0000\n"
"PO-Revision-Date: 2020-10-07 20:01+0000\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
......@@ -26630,9 +26628,6 @@ msgstr ""
msgid "This merge request was merged. To apply this suggestion, edit this file directly."
msgstr ""
msgid "This namespace contains locked projects"
msgstr ""
msgid "This namespace has already been taken! Please choose another one."
msgstr ""
......@@ -28098,6 +28093,9 @@ msgstr ""
msgid "UsageQuota|Storage"
msgstr ""
msgid "UsageQuota|This namespace contains locked projects"
msgstr ""
msgid "UsageQuota|This namespace has no projects which use shared runners"
msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment