Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/usage_quotas/storage/utils.js')
-rw-r--r--app/assets/javascripts/usage_quotas/storage/utils.js52
1 files changed, 15 insertions, 37 deletions
diff --git a/app/assets/javascripts/usage_quotas/storage/utils.js b/app/assets/javascripts/usage_quotas/storage/utils.js
index 0460cd0a9b2..445c3efc9e6 100644
--- a/app/assets/javascripts/usage_quotas/storage/utils.js
+++ b/app/assets/javascripts/usage_quotas/storage/utils.js
@@ -1,54 +1,32 @@
-import { numberToHumanSize } from '~/lib/utils/number_utils';
-import { PROJECT_STORAGE_TYPES } from './constants';
-
+/**
+ * Populates an array of storage types with usage value and other details
+ *
+ * @param {Array} selectedStorageTypes selected storage types that will be populated
+ * @param {Object} projectStatistics object of storage values, with storage type as keys
+ * @param {Object} statisticsDetailsPaths object of storage detail paths, with storage type as keys
+ * @param {Object} helpLinks object of help paths, with storage type as keys
+ * @returns {Array}
+ */
export const getStorageTypesFromProjectStatistics = (
+ selectedStorageTypes,
projectStatistics,
- helpLinks = {},
statisticsDetailsPaths = {},
+ helpLinks = {},
) =>
- PROJECT_STORAGE_TYPES.reduce((types, currentType) => {
+ selectedStorageTypes.reduce((types, currentType) => {
const helpPath = helpLinks[currentType.id];
const value = projectStatistics[`${currentType.id}Size`];
const detailsPath = statisticsDetailsPaths[currentType.id];
return types.concat({
- storageType: {
- ...currentType,
- helpPath,
- detailsPath,
- },
+ ...currentType,
+ helpPath,
+ detailsPath,
value,
});
}, []);
/**
- * This method parses the results from `getProjectStorageStatistics` call.
- *
- * @param {Object} data graphql result
- * @returns {Object}
- */
-export const parseGetProjectStorageResults = (data, helpLinks) => {
- const projectStatistics = data?.project?.statistics;
- if (!projectStatistics) {
- return {};
- }
- const { storageSize } = projectStatistics;
- const storageTypes = getStorageTypesFromProjectStatistics(
- projectStatistics,
- helpLinks,
- data?.project?.statisticsDetailsPaths,
- );
-
- return {
- storage: {
- totalUsage: numberToHumanSize(storageSize, 1),
- storageTypes,
- },
- statistics: projectStatistics,
- };
-};
-
-/**
* Creates a sorting function to sort storage types by usage in the graph and in the table
*
* @param {string} storageUsageKey key storing value of storage usage