Skip to content
代码片段 群组 项目
提交 bbce1313 编辑于 作者: Ammar Alakkad's avatar Ammar Alakkad 提交者: Alexander Turinske
浏览文件

Update storage purchase messages

Also removes the warning thresold

Changelog: changed
EE: true
上级 7135f3ca
No related branches found
No related tags found
无相关合并请求
<script> <script>
import { GlAlert } from '@gitlab/ui'; import { GlAlert } from '@gitlab/ui';
import { n__, s__, sprintf } from '~/locale'; import { n__, s__, sprintf } from '~/locale';
import { ALERT_THRESHOLD, ERROR_THRESHOLD, WARNING_THRESHOLD } from '../constants'; import { ALERT_THRESHOLD, ERROR_THRESHOLD } from '../constants';
import { formatUsageSize, usageRatioToThresholdLevel } from '../utils'; import { formatUsageSize, usageRatioToThresholdLevel } from '../utils';
export default { export default {
i18n: { i18n: {
lockedWithNoPurchasedStorageTitle: s__('UsageQuota|This namespace contains locked projects'),
lockedWithNoPurchasedStorageText: s__( lockedWithNoPurchasedStorageText: s__(
'UsageQuota|You have reached the free storage limit of %{actualRepositorySizeLimit} on %{projectsLockedText}. To unlock them, purchase additional storage.', 'UsageQuota|You have reached the free storage limit on %{projectsLockedText}. To unlock them, purchase additional storage.',
), ),
storageUsageText: s__('UsageQuota|%{percentageLeft} of purchased storage is available'),
lockedWithPurchaseText: s__( lockedWithPurchaseText: s__(
'UsageQuota|You have consumed all of your additional storage. Purchase more to unlock your projects over the free %{actualRepositorySizeLimit} limit.', 'UsageQuota|You have consumed all of your additional storage. Purchase more to unlock projects over the limit.',
), ),
warningWithPurchaseText: s__( warningWithPurchaseText: s__(
'UsageQuota|Your purchased storage is running low. To avoid locked projects, purchase more storage.', 'UsageQuota|Your purchased storage is running low. To avoid locked projects, purchase more storage.',
), ),
infoWithPurchaseText: s__( infoWithPurchaseText: s__(
'UsageQuota|When you purchase additional storage, we automatically unlock projects that were locked when you reached the %{actualRepositorySizeLimit} limit.', 'UsageQuota|When you purchase additional storage, we automatically unlock projects that were locked if the storage limit was reached.',
), ),
}, },
components: { components: {
...@@ -59,14 +57,6 @@ export default { ...@@ -59,14 +57,6 @@ export default {
? this.hasPurchasedStorageText() ? this.hasPurchasedStorageText()
: this.hasNotPurchasedStorageText(); : this.hasNotPurchasedStorageText();
}, },
alertTitle() {
if (!this.hasPurchasedStorage() && this.containsLockedProjects) {
return this.$options.i18n.lockedWithNoPurchasedStorageTitle;
}
return sprintf(this.$options.i18n.storageUsageText, {
percentageLeft: `${this.excessStoragePercentageLeft}%`,
});
},
excessStorageRatio() { excessStorageRatio() {
return this.totalRepositorySizeExcess / this.additionalPurchasedStorageSize; return this.totalRepositorySizeExcess / this.additionalPurchasedStorageSize;
}, },
...@@ -82,8 +72,6 @@ export default { ...@@ -82,8 +72,6 @@ export default {
thresholdLevelToAlertVariant() { thresholdLevelToAlertVariant() {
if (this.thresholdLevel === ERROR_THRESHOLD || this.thresholdLevel === ALERT_THRESHOLD) { if (this.thresholdLevel === ERROR_THRESHOLD || this.thresholdLevel === ALERT_THRESHOLD) {
return 'danger'; return 'danger';
} else if (this.thresholdLevel === WARNING_THRESHOLD) {
return 'warning';
} }
return 'info'; return 'info';
}, },
...@@ -107,23 +95,15 @@ export default { ...@@ -107,23 +95,15 @@ export default {
}, },
hasPurchasedStorageText() { hasPurchasedStorageText() {
if (this.thresholdLevel === ERROR_THRESHOLD) { if (this.thresholdLevel === ERROR_THRESHOLD) {
return sprintf(this.$options.i18n.lockedWithPurchaseText, { return this.$options.i18n.lockedWithPurchaseText;
actualRepositorySizeLimit: this.formatSize(this.actualRepositorySizeLimit), } else if (this.thresholdLevel === ALERT_THRESHOLD) {
});
} else if (
this.thresholdLevel === WARNING_THRESHOLD ||
this.thresholdLevel === ALERT_THRESHOLD
) {
return this.$options.i18n.warningWithPurchaseText; return this.$options.i18n.warningWithPurchaseText;
} }
return sprintf(this.$options.i18n.infoWithPurchaseText, { return this.$options.i18n.infoWithPurchaseText;
actualRepositorySizeLimit: this.formatSize(this.actualRepositorySizeLimit),
});
}, },
hasNotPurchasedStorageText() { hasNotPurchasedStorageText() {
if (this.thresholdLevel === ERROR_THRESHOLD) { if (this.thresholdLevel === ERROR_THRESHOLD) {
return sprintf(this.$options.i18n.lockedWithNoPurchasedStorageText, { return sprintf(this.$options.i18n.lockedWithNoPurchasedStorageText, {
actualRepositorySizeLimit: this.formatSize(this.actualRepositorySizeLimit),
projectsLockedText: this.projectsLockedText, projectsLockedText: this.projectsLockedText,
}); });
} }
...@@ -138,7 +118,6 @@ export default { ...@@ -138,7 +118,6 @@ export default {
class="gl-mt-5" class="gl-mt-5"
:variant="thresholdLevelToAlertVariant" :variant="thresholdLevelToAlertVariant"
:dismissible="false" :dismissible="false"
:title="alertTitle"
> >
{{ alertText }} {{ alertText }}
</gl-alert> </gl-alert>
......
...@@ -81,14 +81,12 @@ export const SKELETON_LOADER_ROWS = 5; ...@@ -81,14 +81,12 @@ export const SKELETON_LOADER_ROWS = 5;
export const NONE_THRESHOLD = 'none'; export const NONE_THRESHOLD = 'none';
export const INFO_THRESHOLD = 'info'; export const INFO_THRESHOLD = 'info';
export const WARNING_THRESHOLD = 'warning';
export const ALERT_THRESHOLD = 'alert'; export const ALERT_THRESHOLD = 'alert';
export const ERROR_THRESHOLD = 'error'; export const ERROR_THRESHOLD = 'error';
export const STORAGE_USAGE_THRESHOLDS = { export const STORAGE_USAGE_THRESHOLDS = {
[NONE_THRESHOLD]: 0.0, [NONE_THRESHOLD]: 0.0,
[INFO_THRESHOLD]: 0.5, [INFO_THRESHOLD]: 0.5,
[WARNING_THRESHOLD]: 0.75,
[ALERT_THRESHOLD]: 0.95, [ALERT_THRESHOLD]: 0.95,
[ERROR_THRESHOLD]: 1.0, [ERROR_THRESHOLD]: 1.0,
}; };
......
...@@ -52,7 +52,7 @@ describe('StorageInlineAlert', () => { ...@@ -52,7 +52,7 @@ describe('StorageInlineAlert', () => {
const alert = findAlert(); const alert = findAlert();
expect(alert.props('variant')).toBe('danger'); expect(alert.props('variant')).toBe('danger');
expect(alert.text()).toBe( expect(alert.text()).toBe(
'You have reached the free storage limit of 10.0GiB on 1 project. To unlock them, purchase additional storage.', 'You have reached the free storage limit on 1 project. To unlock them, purchase additional storage.',
); );
}); });
}); });
...@@ -73,7 +73,7 @@ describe('StorageInlineAlert', () => { ...@@ -73,7 +73,7 @@ describe('StorageInlineAlert', () => {
const alert = findAlert(); const alert = findAlert();
expect(alert.props('variant')).toBe('info'); expect(alert.props('variant')).toBe('info');
expect(alert.text()).toBe( expect(alert.text()).toBe(
'When you purchase additional storage, we automatically unlock projects that were locked when you reached the 10.0GiB limit.', 'When you purchase additional storage, we automatically unlock projects that were locked if the storage limit was reached.',
); );
}); });
}); });
...@@ -94,28 +94,7 @@ describe('StorageInlineAlert', () => { ...@@ -94,28 +94,7 @@ describe('StorageInlineAlert', () => {
const alert = findAlert(); const alert = findAlert();
expect(alert.props('variant')).toBe('danger'); expect(alert.props('variant')).toBe('danger');
expect(alert.text()).toBe( expect(alert.text()).toBe(
'You have consumed all of your additional storage. Purchase more to unlock your projects over the free 10.0GiB limit.', 'You have consumed all of your additional storage. Purchase more to unlock projects over the limit.',
);
});
});
describe('excess storage below purchase limit in warning threshold', () => {
beforeEach(() => {
mountComponent({
containsLockedProjects: false,
repositorySizeExcessProjectCount: 0,
totalRepositorySizeExcess: TEN_GB_IN_BYTES,
totalRepositorySize: THIRTEEN_GB_IN_BYTES,
additionalPurchasedStorageSize: THIRTEEN_GB_IN_BYTES,
actualRepositorySizeLimit: TEN_GB_IN_BYTES,
});
});
it('renders warning alert with correct message', () => {
const alert = findAlert();
expect(alert.props('variant')).toBe('warning');
expect(alert.text()).toBe(
'Your purchased storage is running low. To avoid locked projects, purchase more storage.',
); );
}); });
}); });
......
...@@ -90,7 +90,7 @@ describe('UsageThreshold', () => { ...@@ -90,7 +90,7 @@ describe('UsageThreshold', () => {
${0} | ${'none'} ${0} | ${'none'}
${0.4} | ${'none'} ${0.4} | ${'none'}
${0.5} | ${'info'} ${0.5} | ${'info'}
${0.9} | ${'warning'} ${0.9} | ${'info'}
${0.99} | ${'alert'} ${0.99} | ${'alert'}
${1} | ${'error'} ${1} | ${'error'}
${1.5} | ${'error'} ${1.5} | ${'error'}
......
...@@ -44212,9 +44212,6 @@ msgstr "" ...@@ -44212,9 +44212,6 @@ msgstr ""
msgid "UsageQuota|%{linkTitle} help link" msgid "UsageQuota|%{linkTitle} help link"
msgstr "" msgstr ""
   
msgid "UsageQuota|%{percentageLeft} of purchased storage is available"
msgstr ""
msgid "UsageQuota|%{storage_limit_link_start}A namespace storage limit%{link_end} will soon be enforced for the %{strong_start}%{namespace_name}%{strong_end} namespace. %{extra_message}" msgid "UsageQuota|%{storage_limit_link_start}A namespace storage limit%{link_end} will soon be enforced for the %{strong_start}%{namespace_name}%{strong_end} namespace. %{extra_message}"
msgstr "" msgstr ""
   
...@@ -44386,9 +44383,6 @@ msgstr "" ...@@ -44386,9 +44383,6 @@ msgstr ""
msgid "UsageQuota|This is the total amount of storage used by projects above the free %{actualRepositorySizeLimit} storage limit." msgid "UsageQuota|This is the total amount of storage used by projects above the free %{actualRepositorySizeLimit} storage limit."
msgstr "" msgstr ""
   
msgid "UsageQuota|This namespace contains locked projects"
msgstr ""
msgid "UsageQuota|This namespace has no projects which used shared runners in the current period" msgid "UsageQuota|This namespace has no projects which used shared runners in the current period"
msgstr "" msgstr ""
   
...@@ -44434,7 +44428,7 @@ msgstr "" ...@@ -44434,7 +44428,7 @@ msgstr ""
msgid "UsageQuota|User settings &gt; Usage quotas" msgid "UsageQuota|User settings &gt; Usage quotas"
msgstr "" msgstr ""
   
msgid "UsageQuota|When you purchase additional storage, we automatically unlock projects that were locked when you reached the %{actualRepositorySizeLimit} limit." msgid "UsageQuota|When you purchase additional storage, we automatically unlock projects that were locked if the storage limit was reached."
msgstr "" msgstr ""
   
msgid "UsageQuota|Wiki" msgid "UsageQuota|Wiki"
...@@ -44443,10 +44437,10 @@ msgstr "" ...@@ -44443,10 +44437,10 @@ msgstr ""
msgid "UsageQuota|Wiki content." msgid "UsageQuota|Wiki content."
msgstr "" msgstr ""
   
msgid "UsageQuota|You have consumed all of your additional storage. Purchase more to unlock your projects over the free %{actualRepositorySizeLimit} limit." msgid "UsageQuota|You have consumed all of your additional storage. Purchase more to unlock projects over the limit."
msgstr "" msgstr ""
   
msgid "UsageQuota|You have reached the free storage limit of %{actualRepositorySizeLimit} on %{projectsLockedText}. To unlock them, purchase additional storage." msgid "UsageQuota|You have reached the free storage limit on %{projectsLockedText}. To unlock them, purchase additional storage."
msgstr "" msgstr ""
   
msgid "UsageQuota|You used: %{usage} %{limit}" msgid "UsageQuota|You used: %{usage} %{limit}"
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册