Commit 44690d46 authored by Sheldon Led's avatar Sheldon Led Committed by Natalia Tepluhina

Move storage usage_graph component to new usage_quotas folder

parent e9c54058
/* eslint-disable @gitlab/require-i18n-strings */
import '@gitlab/ui/dist/utility_classes.css';
import UsageGraph from './usage_graph.vue';
export default {
component: UsageGraph,
title: 'vue_shared/components/storage_counter/usage_graph',
};
const Template = (args, { argTypes }) => ({
components: { UsageGraph },
props: Object.keys(argTypes),
template: '<usage-graph v-bind="$props" />',
});
export const Default = Template.bind({});
Default.argTypes = {
rootStorageStatistics: {
description: 'The statistics object with all its fields',
type: { name: 'object', required: true },
defaultValue: {
buildArtifactsSize: 400000,
pipelineArtifactsSize: 38000,
lfsObjectsSize: 4800000,
packagesSize: 3800000,
repositorySize: 39000000,
snippetsSize: 2000112,
storageSize: 39930000,
uploadsSize: 7000,
wikiSize: 300000,
},
},
limit: {
description:
'When a limit is set, users will see how much of their storage usage (limit) is used. In case the limit is 0 or the current usage exceeds the limit, it just renders the distribution',
defaultValue: 0,
},
};
...@@ -8,7 +8,6 @@ import { ...@@ -8,7 +8,6 @@ import {
GlKeysetPagination, GlKeysetPagination,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { parseBoolean } from '~/lib/utils/common_utils'; import { parseBoolean } from '~/lib/utils/common_utils';
import UsageGraph from '~/vue_shared/components/storage_counter/usage_graph.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { PROJECTS_PER_PAGE } from '../constants'; import { PROJECTS_PER_PAGE } from '../constants';
import query from '../queries/namespace_storage.query.graphql'; import query from '../queries/namespace_storage.query.graphql';
...@@ -16,6 +15,7 @@ import { formatUsageSize, parseGetStorageResults } from '../utils'; ...@@ -16,6 +15,7 @@ import { formatUsageSize, parseGetStorageResults } from '../utils';
import ProjectList from './project_list.vue'; import ProjectList from './project_list.vue';
import StorageInlineAlert from './storage_inline_alert.vue'; import StorageInlineAlert from './storage_inline_alert.vue';
import TemporaryStorageIncreaseModal from './temporary_storage_increase_modal.vue'; import TemporaryStorageIncreaseModal from './temporary_storage_increase_modal.vue';
import UsageGraph from './usage_graph.vue';
import UsageStatistics from './usage_statistics.vue'; import UsageStatistics from './usage_statistics.vue';
export default { export default {
......
<script> <script>
import { GlAlert, GlLink, GlLoadingIcon } from '@gitlab/ui'; import { GlAlert, GlLink, GlLoadingIcon } from '@gitlab/ui';
import { sprintf } from '~/locale'; import { sprintf } from '~/locale';
import UsageGraph from '~/vue_shared/components/storage_counter/usage_graph.vue';
import { import {
ERROR_MESSAGE, ERROR_MESSAGE,
LEARN_MORE_LABEL, LEARN_MORE_LABEL,
...@@ -13,6 +12,7 @@ import { ...@@ -13,6 +12,7 @@ import {
} from '../constants'; } from '../constants';
import getProjectStorageStatistics from '../queries/project_storage.query.graphql'; import getProjectStorageStatistics from '../queries/project_storage.query.graphql';
import { parseGetProjectStorageResults } from '../utils'; import { parseGetProjectStorageResults } from '../utils';
import UsageGraph from './usage_graph.vue';
import ProjectStorageDetail from './project_storage_detail.vue'; import ProjectStorageDetail from './project_storage_detail.vue';
export default { export default {
......
<script> <script>
import { GlIcon, GlTooltipDirective } from '@gitlab/ui'; import { GlIcon, GlTooltipDirective } from '@gitlab/ui';
import { numberToHumanSize } from '~/lib/utils/number_utils'; import { numberToHumanSize } from '~/lib/utils/number_utils';
import { s__ } from '~/locale'; import { PROJECT_STORAGE_TYPES } from '../constants';
export default { export default {
components: { components: {
...@@ -41,51 +41,62 @@ export default { ...@@ -41,51 +41,62 @@ export default {
return [ return [
{ {
name: s__('UsageQuota|Repositories'), id: 'repositorySize',
style: this.usageStyle(this.barRatio(repositorySize)), style: this.usageStyle(this.barRatio(repositorySize)),
class: 'gl-bg-data-viz-blue-500', class: 'gl-bg-data-viz-blue-500',
size: repositorySize, size: repositorySize,
}, },
{ {
name: s__('UsageQuota|LFS Objects'), id: 'lfsObjectsSize',
style: this.usageStyle(this.barRatio(lfsObjectsSize)), style: this.usageStyle(this.barRatio(lfsObjectsSize)),
class: 'gl-bg-data-viz-orange-600', class: 'gl-bg-data-viz-orange-600',
size: lfsObjectsSize, size: lfsObjectsSize,
}, },
{ {
name: s__('UsageQuota|Packages'), id: 'packagesSize',
style: this.usageStyle(this.barRatio(packagesSize)), style: this.usageStyle(this.barRatio(packagesSize)),
class: 'gl-bg-data-viz-aqua-500', class: 'gl-bg-data-viz-aqua-500',
size: packagesSize, size: packagesSize,
}, },
{ {
name: s__('UsageQuota|Artifacts'), id: 'buildArtifactsSize',
style: this.usageStyle(this.barRatio(artifactsSize)), style: this.usageStyle(this.barRatio(artifactsSize)),
class: 'gl-bg-data-viz-green-600', class: 'gl-bg-data-viz-green-600',
size: artifactsSize, size: artifactsSize,
tooltip: s__('UsageQuota|Artifacts is a sum of build and pipeline artifacts.'),
}, },
{ {
name: s__('UsageQuota|Wikis'), id: 'wikiSize',
style: this.usageStyle(this.barRatio(wikiSize)), style: this.usageStyle(this.barRatio(wikiSize)),
class: 'gl-bg-data-viz-magenta-500', class: 'gl-bg-data-viz-magenta-500',
size: wikiSize, size: wikiSize,
}, },
{ {
name: s__('UsageQuota|Snippets'), id: 'snippetsSize',
style: this.usageStyle(this.barRatio(snippetsSize)), style: this.usageStyle(this.barRatio(snippetsSize)),
class: 'gl-bg-data-viz-orange-800', class: 'gl-bg-data-viz-orange-800',
size: snippetsSize, size: snippetsSize,
}, },
{ {
name: s__('UsageQuota|Uploads'), id: 'uploadsSize',
style: this.usageStyle(this.barRatio(uploadsSize)), style: this.usageStyle(this.barRatio(uploadsSize)),
class: 'gl-bg-data-viz-aqua-700', class: 'gl-bg-data-viz-aqua-700',
size: uploadsSize, size: uploadsSize,
}, },
] ]
.filter((data) => data.size !== 0) .filter((data) => data.size !== 0)
.sort((a, b) => b.size - a.size); .sort((a, b) => b.size - a.size)
.map((storageType) => {
const storageTypeExtraData = PROJECT_STORAGE_TYPES.find(
(type) => storageType.id === type.id,
);
const { name, tooltip } = storageTypeExtraData || {};
return {
name,
tooltip,
...storageType,
};
});
}, },
}, },
methods: { methods: {
......
...@@ -22,6 +22,7 @@ export const PROJECT_STORAGE_TYPES = [ ...@@ -22,6 +22,7 @@ export const PROJECT_STORAGE_TYPES = [
'UsageQuota|Because of a known issue, the artifact total for some projects may be incorrect. For more details, read %{warningLinkStart}the epic%{warningLinkEnd}.', 'UsageQuota|Because of a known issue, the artifact total for some projects may be incorrect. For more details, read %{warningLinkStart}the epic%{warningLinkEnd}.',
), ),
warningLink: 'https://gitlab.com/groups/gitlab-org/-/epics/5380', warningLink: 'https://gitlab.com/groups/gitlab-org/-/epics/5380',
tooltip: s__('UsageQuota|Artifacts is a sum of build and pipeline artifacts.'),
}, },
{ {
id: 'lfsObjectsSize', id: 'lfsObjectsSize',
......
...@@ -5,9 +5,9 @@ import ProjectList from 'ee/usage_quotas/storage/components/project_list.vue'; ...@@ -5,9 +5,9 @@ import ProjectList from 'ee/usage_quotas/storage/components/project_list.vue';
import StorageInlineAlert from 'ee/usage_quotas/storage/components/storage_inline_alert.vue'; import StorageInlineAlert from 'ee/usage_quotas/storage/components/storage_inline_alert.vue';
import TemporaryStorageIncreaseModal from 'ee/usage_quotas/storage/components/temporary_storage_increase_modal.vue'; import TemporaryStorageIncreaseModal from 'ee/usage_quotas/storage/components/temporary_storage_increase_modal.vue';
import UsageStatistics from 'ee/usage_quotas/storage/components/usage_statistics.vue'; import UsageStatistics from 'ee/usage_quotas/storage/components/usage_statistics.vue';
import UsageGraph from 'ee/usage_quotas/storage/components/usage_graph.vue';
import { formatUsageSize } from 'ee/usage_quotas/storage/utils'; import { formatUsageSize } from 'ee/usage_quotas/storage/utils';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import UsageGraph from '~/vue_shared/components/storage_counter/usage_graph.vue';
import { namespaceData, withRootStorageStatistics } from '../mock_data'; import { namespaceData, withRootStorageStatistics } from '../mock_data';
const TEST_LIMIT = 1000; const TEST_LIMIT = 1000;
......
...@@ -5,9 +5,9 @@ import createMockApollo from 'helpers/mock_apollo_helper'; ...@@ -5,9 +5,9 @@ import createMockApollo from 'helpers/mock_apollo_helper';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import ProjectStorageApp from 'ee/usage_quotas/storage/components/project_storage_app.vue'; import ProjectStorageApp from 'ee/usage_quotas/storage/components/project_storage_app.vue';
import UsageGraph from 'ee/usage_quotas/storage/components/usage_graph.vue';
import { TOTAL_USAGE_DEFAULT_TEXT } from 'ee/usage_quotas/storage/constants'; import { TOTAL_USAGE_DEFAULT_TEXT } from 'ee/usage_quotas/storage/constants';
import getProjectStorageStatistics from 'ee/usage_quotas/storage/queries/project_storage.query.graphql'; import getProjectStorageStatistics from 'ee/usage_quotas/storage/queries/project_storage.query.graphql';
import UsageGraph from '~/vue_shared/components/storage_counter/usage_graph.vue';
import { import {
projectData, projectData,
mockGetProjectStorageStatisticsGraphQLResponse, mockGetProjectStorageStatisticsGraphQLResponse,
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { numberToHumanSize } from '~/lib/utils/number_utils'; import { numberToHumanSize } from '~/lib/utils/number_utils';
import UsageGraph from '~/vue_shared/components/storage_counter/usage_graph.vue'; import UsageGraph from 'ee/usage_quotas/storage/components/usage_graph.vue';
let data; let data;
let wrapper; let wrapper;
...@@ -56,15 +56,15 @@ describe('Storage Counter usage graph component', () => { ...@@ -56,15 +56,15 @@ describe('Storage Counter usage graph component', () => {
uploadsSize, uploadsSize,
} = data.rootStorageStatistics; } = data.rootStorageStatistics;
expect(types.at(0).text()).toMatchInterpolatedText(`Wikis ${numberToHumanSize(wikiSize)}`); expect(types.at(0).text()).toMatchInterpolatedText(`Wiki ${numberToHumanSize(wikiSize)}`);
expect(types.at(1).text()).toMatchInterpolatedText( expect(types.at(1).text()).toMatchInterpolatedText(
`Repositories ${numberToHumanSize(repositorySize)}`, `Repository ${numberToHumanSize(repositorySize)}`,
); );
expect(types.at(2).text()).toMatchInterpolatedText( expect(types.at(2).text()).toMatchInterpolatedText(
`Packages ${numberToHumanSize(packagesSize)}`, `Packages ${numberToHumanSize(packagesSize)}`,
); );
expect(types.at(3).text()).toMatchInterpolatedText( expect(types.at(3).text()).toMatchInterpolatedText(
`LFS Objects ${numberToHumanSize(lfsObjectsSize)}`, `LFS storage ${numberToHumanSize(lfsObjectsSize)}`,
); );
expect(types.at(4).text()).toMatchInterpolatedText( expect(types.at(4).text()).toMatchInterpolatedText(
`Snippets ${numberToHumanSize(snippetsSize)}`, `Snippets ${numberToHumanSize(snippetsSize)}`,
......
...@@ -37553,9 +37553,6 @@ msgstr "" ...@@ -37553,9 +37553,6 @@ msgstr ""
msgid "UsageQuota|Increase storage temporarily" msgid "UsageQuota|Increase storage temporarily"
msgstr "" msgstr ""
msgid "UsageQuota|LFS Objects"
msgstr ""
msgid "UsageQuota|LFS storage" msgid "UsageQuota|LFS storage"
msgstr "" msgstr ""
...@@ -37586,9 +37583,6 @@ msgstr "" ...@@ -37586,9 +37583,6 @@ msgstr ""
msgid "UsageQuota|Purchased storage available" msgid "UsageQuota|Purchased storage available"
msgstr "" msgstr ""
msgid "UsageQuota|Repositories"
msgstr ""
msgid "UsageQuota|Repository" msgid "UsageQuota|Repository"
msgstr "" msgstr ""
...@@ -37667,9 +37661,6 @@ msgstr "" ...@@ -37667,9 +37661,6 @@ msgstr ""
msgid "UsageQuota|Wiki content." msgid "UsageQuota|Wiki content."
msgstr "" msgstr ""
msgid "UsageQuota|Wikis"
msgstr ""
msgid "UsageQuota|You have consumed all of your additional storage, please purchase more to unlock your projects over the free %{actualRepositorySizeLimit} limit." msgid "UsageQuota|You have consumed all of your additional storage, please purchase more to unlock your projects over the free %{actualRepositorySizeLimit} limit."
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