Commit 5127f962 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'vs-update-doc-links-in-usage-quotas' into 'master'

Update doc links in usage quotas

See merge request gitlab-org/gitlab!53279
parents 371eb8d1 6022eca3
<script> <script>
import { GlButton, GlSprintf } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import { helpPagePath } from '~/helpers/help_page_helper';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { formatUsageSize } from '../utils'; import { formatUsageSize } from '../utils';
import UsageStatisticsCard from './usage_statistics_card.vue'; import UsageStatisticsCard from './usage_statistics_card.vue';
...@@ -7,7 +8,6 @@ import UsageStatisticsCard from './usage_statistics_card.vue'; ...@@ -7,7 +8,6 @@ import UsageStatisticsCard from './usage_statistics_card.vue';
export default { export default {
components: { components: {
GlButton, GlButton,
GlSprintf,
UsageStatisticsCard, UsageStatisticsCard,
}, },
props: { props: {
...@@ -32,6 +32,10 @@ export default { ...@@ -32,6 +32,10 @@ export default {
footerNote: s__( footerNote: s__(
'UsageQuota|This is the total amount of storage used across your projects within this namespace.', 'UsageQuota|This is the total amount of storage used across your projects within this namespace.',
), ),
link: {
text: s__('UsageQuota|Learn more about usage quotas'),
url: helpPagePath('user/usage_quotas'),
},
}; };
}, },
excessUsage() { excessUsage() {
...@@ -41,6 +45,10 @@ export default { ...@@ -41,6 +45,10 @@ export default {
footerNote: s__( footerNote: s__(
'UsageQuota|This is the total amount of storage used by projects above the free %{actualRepositorySizeLimit} storage limit.', 'UsageQuota|This is the total amount of storage used by projects above the free %{actualRepositorySizeLimit} storage limit.',
), ),
link: {
text: s__('UsageQuota|Learn more about excess storage usage'),
url: helpPagePath('user/usage_quotas', { anchor: 'excess-storage-usage' }),
},
}; };
}, },
purchasedUsage() { purchasedUsage() {
...@@ -87,34 +95,22 @@ export default { ...@@ -87,34 +95,22 @@ export default {
<template> <template>
<div class="gl-display-flex gl-sm-flex-direction-column"> <div class="gl-display-flex gl-sm-flex-direction-column">
<usage-statistics-card <usage-statistics-card
data-testid="totalUsage" data-testid="total-usage"
:usage="totalUsage.usage" :usage="totalUsage.usage"
: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="excess-usage"
: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
v-if="purchasedUsage" v-if="purchasedUsage"
data-testid="purchasedUsage" data-testid="purchased-usage"
:usage="purchasedUsage.usage" :usage="purchasedUsage.usage"
:usage-total="purchasedUsage.usageTotal" :usage-total="purchasedUsage.usageTotal"
:link="purchasedUsage.link" :link="purchasedUsage.link"
......
...@@ -62,7 +62,7 @@ export default { ...@@ -62,7 +62,7 @@ export default {
</p> </p>
<p <p
class="gl-mb-0 gl-text-gray-900 gl-font-sm gl-white-space-normal" class="gl-mb-0 gl-text-gray-900 gl-font-sm gl-white-space-normal"
data-testid="statisticsCardFooter" data-testid="statistics-card-footer"
> >
<slot v-bind="{ link }" name="footer"> <slot v-bind="{ link }" name="footer">
<gl-link target="_blank" :href="link.url"> <gl-link target="_blank" :href="link.url">
......
---
title: Replace text with links on Usage Quota page
merge_request: 53279
author:
type: added
import { GlButton, GlSprintf } from '@gitlab/ui'; import { GlButton, GlLink, GlSprintf } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
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';
...@@ -21,12 +21,15 @@ describe('Usage Statistics component', () => { ...@@ -21,12 +21,15 @@ describe('Usage Statistics component', () => {
stubs: { stubs: {
UsageStatisticsCard, UsageStatisticsCard,
GlSprintf, GlSprintf,
GlLink,
}, },
}); });
}; };
const getStatisticsCards = () => wrapper.findAll(UsageStatisticsCard); const getStatisticsCards = () => wrapper.findAll(UsageStatisticsCard);
const getStatisticsCard = (testId) => wrapper.find(`[data-testid="${testId}"]`); const getStatisticsCard = (testId) => wrapper.find(`[data-testid="${testId}"]`);
const findGlLinkInCard = (cardName) =>
getStatisticsCard(cardName).find('[data-testid="statistics-card-footer"]').find(GlLink);
describe('with purchaseStorageUrl passed', () => { describe('with purchaseStorageUrl passed', () => {
beforeEach(() => { beforeEach(() => {
...@@ -43,24 +46,20 @@ describe('Usage Statistics component', () => { ...@@ -43,24 +46,20 @@ describe('Usage Statistics component', () => {
expect(getStatisticsCards()).toHaveLength(3); expect(getStatisticsCards()).toHaveLength(3);
}); });
it('renders text in total usage card footer', () => { it('renders URL in total usage card footer', () => {
expect( const url = findGlLinkInCard('total-usage');
getStatisticsCard('totalUsage').find('[data-testid="statisticsCardFooter"]').text(),
).toMatchInterpolatedText( expect(url.attributes('href')).toBe('/help/user/usage_quotas');
'This is the total amount of storage used across your projects within this namespace.',
);
}); });
it('renders text in excess usage card footer', () => { it('renders URL in excess usage card footer', () => {
expect( const url = findGlLinkInCard('excess-usage');
getStatisticsCard('excessUsage').find('[data-testid="statisticsCardFooter"]').text(),
).toMatchInterpolatedText( expect(url.attributes('href')).toBe('/help/user/usage_quotas#excess-storage-usage');
'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', () => { it('renders button in purchased usage card footer', () => {
expect(getStatisticsCard('purchasedUsage').find(GlButton).exists()).toBe(true); expect(getStatisticsCard('purchased-usage').find(GlButton).exists()).toBe(true);
}); });
}); });
...@@ -70,8 +69,13 @@ describe('Usage Statistics component', () => { ...@@ -70,8 +69,13 @@ describe('Usage Statistics component', () => {
purchaseStorageUrl: null, purchaseStorageUrl: null,
}); });
}); });
afterEach(() => {
wrapper.destroy();
});
it('does not render purchased usage card if purchaseStorageUrl is not provided', () => { it('does not render purchased usage card if purchaseStorageUrl is not provided', () => {
expect(getStatisticsCard('purchasedUsage').exists()).toBe(false); expect(getStatisticsCard('purchased-usage').exists()).toBe(false);
}); });
}); });
}); });
...@@ -31413,6 +31413,12 @@ msgstr "" ...@@ -31413,6 +31413,12 @@ 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 ""
......
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