Commit 7b86ecc0 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch 'usage-quotas-statistics-hide-docs-links' into 'master'

Remove usage statistics docs links

See merge request gitlab-org/gitlab!45856
parents 1bcebe7f 5f36182d
...@@ -85,6 +85,7 @@ export default { ...@@ -85,6 +85,7 @@ export default {
return { return {
totalRepositorySize: this.namespace.totalRepositorySize, totalRepositorySize: this.namespace.totalRepositorySize,
actualRepositorySizeLimit: this.namespace.actualRepositorySizeLimit,
totalRepositorySizeExcess: this.namespace.totalRepositorySizeExcess, totalRepositorySizeExcess: this.namespace.totalRepositorySizeExcess,
additionalPurchasedStorageSize: this.namespace.additionalPurchasedStorageSize, additionalPurchasedStorageSize: this.namespace.additionalPurchasedStorageSize,
}; };
......
<script> <script>
import { GlButton } from '@gitlab/ui'; import { GlButton, GlSprintf } from '@gitlab/ui';
import UsageStatisticsCard from './usage_statistics_card.vue'; import UsageStatisticsCard from './usage_statistics_card.vue';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { formatUsageSize } from '../utils'; import { formatUsageSize } from '../utils';
...@@ -7,6 +7,7 @@ import { formatUsageSize } from '../utils'; ...@@ -7,6 +7,7 @@ import { formatUsageSize } from '../utils';
export default { export default {
components: { components: {
GlButton, GlButton,
GlSprintf,
UsageStatisticsCard, UsageStatisticsCard,
}, },
props: { props: {
...@@ -16,24 +17,25 @@ export default { ...@@ -16,24 +17,25 @@ export default {
}, },
}, },
computed: { computed: {
formattedActualRepoSizeLimit() {
return formatUsageSize(this.rootStorageStatistics.actualRepositorySizeLimit);
},
totalUsage() { totalUsage() {
return { return {
usage: this.formatSize(this.rootStorageStatistics.totalRepositorySize), usage: this.formatSizeAndSplit(this.rootStorageStatistics.totalRepositorySize),
description: s__('UsageQuota|Total namespace storage used'), description: s__('UsageQuota|Total namespace storage used'),
link: { footerNote: s__(
text: s__('UsageQuota|Learn more about usage quotas'), 'UsageQuota|This is the total amount of storage used across your projects within this namespace.',
url: '#', ),
},
}; };
}, },
excessUsage() { excessUsage() {
return { return {
usage: this.formatSize(this.rootStorageStatistics.totalRepositorySizeExcess), usage: this.formatSizeAndSplit(this.rootStorageStatistics.totalRepositorySizeExcess),
description: s__('UsageQuota|Total excess storage used'), description: s__('UsageQuota|Total excess storage used'),
link: { footerNote: s__(
text: s__('UsageQuota|Learn more about excess storage usage'), 'UsageQuota|This is the total amount of storage used by projects above the free %{actualRepositorySizeLimit} storage limit.',
url: '#', ),
},
}; };
}, },
purchasedUsage() { purchasedUsage() {
...@@ -42,10 +44,10 @@ export default { ...@@ -42,10 +44,10 @@ export default {
additionalPurchasedStorageSize, additionalPurchasedStorageSize,
} = this.rootStorageStatistics; } = this.rootStorageStatistics;
return { return {
usage: this.formatSize( usage: this.formatSizeAndSplit(
Math.max(0, additionalPurchasedStorageSize - totalRepositorySizeExcess), Math.max(0, additionalPurchasedStorageSize - totalRepositorySizeExcess),
), ),
usageTotal: this.formatSize(additionalPurchasedStorageSize), usageTotal: this.formatSizeAndSplit(additionalPurchasedStorageSize),
description: s__('UsageQuota|Purchased storage available'), description: s__('UsageQuota|Purchased storage available'),
link: { link: {
text: s__('UsageQuota|Purchase more storage'), text: s__('UsageQuota|Purchase more storage'),
...@@ -65,7 +67,7 @@ export default { ...@@ -65,7 +67,7 @@ export default {
* @params {Number} size size in bytes * @params {Number} size size in bytes
* @returns {Object} value and unit of formatted size * @returns {Object} value and unit of formatted size
*/ */
formatSize(size) { formatSizeAndSplit(size) {
const formattedSize = formatUsageSize(size); const formattedSize = formatUsageSize(size);
return { return {
value: formattedSize.slice(0, -3), value: formattedSize.slice(0, -3),
...@@ -83,14 +85,26 @@ export default { ...@@ -83,14 +85,26 @@ export default {
:link="totalUsage.link" :link="totalUsage.link"
:description="totalUsage.description" :description="totalUsage.description"
css-class="gl-mr-4" css-class="gl-mr-4"
/> >
<template #footer="{}">
{{ totalUsage.footerNote }}
</template>
</usage-statistics-card>
<usage-statistics-card <usage-statistics-card
data-testid="excessUsage" data-testid="excessUsage"
:usage="excessUsage.usage" :usage="excessUsage.usage"
:link="excessUsage.link" :link="excessUsage.link"
:description="excessUsage.description" :description="excessUsage.description"
css-class="gl-mx-4" css-class="gl-mx-4"
/> >
<template #footer="{}">
<gl-sprintf :message="excessUsage.footerNote">
<template #actualRepositorySizeLimit>
{{ formattedActualRepoSizeLimit }}
</template>
</gl-sprintf>
</template>
</usage-statistics-card>
<usage-statistics-card <usage-statistics-card
data-testid="purchasedUsage" data-testid="purchasedUsage"
:usage="purchasedUsage.usage" :usage="purchasedUsage.usage"
...@@ -99,7 +113,7 @@ export default { ...@@ -99,7 +113,7 @@ export default {
:description="purchasedUsage.description" :description="purchasedUsage.description"
css-class="gl-ml-4" css-class="gl-ml-4"
> >
<template #link="{link}"> <template #footer="{link}">
<gl-button <gl-button
target="_blank" target="_blank"
:href="link.url" :href="link.url"
......
...@@ -60,8 +60,11 @@ export default { ...@@ -60,8 +60,11 @@ export default {
<p class="gl-border-b-2 gl-border-b-solid gl-border-b-gray-100 gl-font-weight-bold gl-pb-3"> <p class="gl-border-b-2 gl-border-b-solid gl-border-b-gray-100 gl-font-weight-bold gl-pb-3">
{{ description }} {{ description }}
</p> </p>
<p class="gl-mb-0"> <p
<slot v-bind="{ link }" name="link"> class="gl-mb-0 gl-text-gray-900 gl-font-sm gl-white-space-normal"
data-testid="statisticsCardFooter"
>
<slot v-bind="{ link }" name="footer">
<gl-link target="_blank" :href="link.url"> <gl-link target="_blank" :href="link.url">
<span class="text-truncate">{{ link.text }}</span> <span class="text-truncate">{{ link.text }}</span>
<gl-icon name="external-link" class="gl-ml-2 gl-flex-shrink-0 gl-text-black-normal" /> <gl-icon name="external-link" class="gl-ml-2 gl-flex-shrink-0 gl-text-black-normal" />
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlButton, GlLink } from '@gitlab/ui'; import { GlButton, GlSprintf } from '@gitlab/ui';
import UsageStatistics from 'ee/storage_counter/components/usage_statistics.vue'; import UsageStatistics from 'ee/storage_counter/components/usage_statistics.vue';
import UsageStatisticsCard from 'ee/storage_counter/components/usage_statistics_card.vue'; import UsageStatisticsCard from 'ee/storage_counter/components/usage_statistics_card.vue';
import { withRootStorageStatistics } from '../mock_data'; import { withRootStorageStatistics } from '../mock_data';
...@@ -10,11 +10,16 @@ describe('Usage Statistics component', () => { ...@@ -10,11 +10,16 @@ describe('Usage Statistics component', () => {
const createComponent = () => { const createComponent = () => {
wrapper = shallowMount(UsageStatistics, { wrapper = shallowMount(UsageStatistics, {
propsData: { propsData: {
rootStorageStatistics: withRootStorageStatistics.rootStorageStatistics, rootStorageStatistics: {
totalRepositorySize: withRootStorageStatistics.totalRepositorySize,
actualRepositorySizeLimit: withRootStorageStatistics.actualRepositorySizeLimit,
totalRepositorySizeExcess: withRootStorageStatistics.totalRepositorySizeExcess,
additionalPurchasedStorageSize: withRootStorageStatistics.additionalPurchasedStorageSize,
},
}, },
stubs: { stubs: {
UsageStatisticsCard, UsageStatisticsCard,
GlLink, GlSprintf,
}, },
}); });
}; };
...@@ -34,15 +39,30 @@ describe('Usage Statistics component', () => { ...@@ -34,15 +39,30 @@ describe('Usage Statistics component', () => {
expect(getStatisticsCards()).toHaveLength(3); expect(getStatisticsCards()).toHaveLength(3);
}); });
it.each` it('renders text in total usage card footer', () => {
cardName | componentName | componentType
${'totalUsage'} | ${'GlLink'} | ${GlLink}
${'excessUsage'} | ${'GlLink'} | ${GlLink}
${'purchasedUsage'} | ${'GlButton'} | ${GlButton}
`('renders $componentName in $cardName', ({ cardName, componentType }) => {
expect( expect(
getStatisticsCard(cardName) getStatisticsCard('totalUsage')
.find(componentType) .find('[data-testid="statisticsCardFooter"]')
.text(),
).toMatchInterpolatedText(
'This is the total amount of storage used across your projects within this namespace.',
);
});
it('renders text in excess usage card footer', () => {
expect(
getStatisticsCard('excessUsage')
.find('[data-testid="statisticsCardFooter"]')
.text(),
).toMatchInterpolatedText(
'This is the total amount of storage used by projects above the free 978.8KiB storage limit.',
);
});
it('renders button in purchased usage card footer', () => {
expect(
getStatisticsCard('purchasedUsage')
.find(GlButton)
.exists(), .exists(),
).toBe(true); ).toBe(true);
}); });
......
...@@ -28629,12 +28629,6 @@ msgstr "" ...@@ -28629,12 +28629,6 @@ msgstr ""
msgid "UsageQuota|LFS Storage" msgid "UsageQuota|LFS Storage"
msgstr "" msgstr ""
msgid "UsageQuota|Learn more about excess storage usage"
msgstr ""
msgid "UsageQuota|Learn more about usage quotas"
msgstr ""
msgid "UsageQuota|Packages" msgid "UsageQuota|Packages"
msgstr "" msgstr ""
...@@ -28659,6 +28653,12 @@ msgstr "" ...@@ -28659,6 +28653,12 @@ msgstr ""
msgid "UsageQuota|Storage" msgid "UsageQuota|Storage"
msgstr "" msgstr ""
msgid "UsageQuota|This is the total amount of storage used across your projects within this namespace."
msgstr ""
msgid "UsageQuota|This is the total amount of storage used by projects above the free %{actualRepositorySizeLimit} storage limit."
msgstr ""
msgid "UsageQuota|This namespace contains locked projects" msgid "UsageQuota|This namespace contains locked projects"
msgstr "" 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