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

namespace_storage_app.vue « components « storage « usage_quotas « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1594e125da3565a0ae8102d3803e9d3e11055908 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<script>
import { GlAlert, GlKeysetPagination } from '@gitlab/ui';
import StorageUsageStatistics from 'ee_else_ce/usage_quotas/storage/components/storage_usage_statistics.vue';
import SearchAndSortBar from '~/usage_quotas/components/search_and_sort_bar/search_and_sort_bar.vue';
import DependencyProxyUsage from './dependency_proxy_usage.vue';
import ContainerRegistryUsage from './container_registry_usage.vue';
import ProjectList from './project_list.vue';

export default {
  name: 'NamespaceStorageApp',
  components: {
    GlAlert,
    GlKeysetPagination,
    StorageUsageStatistics,
    DependencyProxyUsage,
    ContainerRegistryUsage,
    SearchAndSortBar,
    ProjectList,
  },
  inject: ['userNamespace', 'namespaceId', 'helpLinks', 'defaultPerPage'],
  props: {
    namespaceLoadingError: {
      type: Boolean,
      required: false,
      default: false,
    },
    projectsLoadingError: {
      type: Boolean,
      required: false,
      default: false,
    },
    isNamespaceStorageStatisticsLoading: {
      type: Boolean,
      required: false,
      default: false,
    },
    isNamespaceProjectsLoading: {
      type: Boolean,
      required: false,
      default: false,
    },
    namespace: {
      type: Object,
      required: false,
      default: () => ({}),
    },
    projects: {
      type: Object,
      required: false,
      default: () => ({}),
    },
    initialSortBy: {
      type: String,
      required: false,
      default: 'storage',
    },
  },
  computed: {
    usedStorage() {
      return (
        // This is the coefficient adjusted forked repo size, only used in EE
        this.namespace.rootStorageStatistics?.costFactoredStorageSize ??
        // This is the actual storage size value, used in CE or when the above is disabled
        this.namespace.rootStorageStatistics?.storageSize
      );
    },
    dependencyProxyTotalSize() {
      return this.namespace.rootStorageStatistics?.dependencyProxySize ?? 0;
    },
    containerRegistrySize() {
      return this.namespace.rootStorageStatistics?.containerRegistrySize ?? 0;
    },
    containerRegistrySizeIsEstimated() {
      return this.namespace.rootStorageStatistics?.containerRegistrySizeIsEstimated ?? false;
    },
    projectList() {
      return this.projects?.nodes ?? [];
    },
    pageInfo() {
      return this.projects?.pageInfo;
    },
    showPagination() {
      return Boolean(this.pageInfo?.hasPreviousPage || this.pageInfo?.hasNextPage);
    },
  },
  methods: {
    onPrev(before) {
      if (this.pageInfo?.hasPreviousPage) {
        this.$emit('fetch-more-projects', { before, last: this.defaultPerPage, first: undefined });
      }
    },
    onNext(after) {
      if (this.pageInfo?.hasNextPage) {
        this.$emit('fetch-more-projects', { after, first: this.defaultPerPage });
      }
    },
  },
};
</script>
<template>
  <div>
    <gl-alert
      v-if="namespaceLoadingError || projectsLoadingError"
      variant="danger"
      :dismissible="false"
      class="gl-mt-4"
    >
      {{
        s__(
          'UsageQuota|An error occured while loading the storage usage details. Please refresh the page to try again.',
        )
      }}
    </gl-alert>
    <storage-usage-statistics
      :additional-purchased-storage-size="namespace.additionalPurchasedStorageSize"
      :used-storage="usedStorage"
      :loading="isNamespaceStorageStatisticsLoading"
    />
    <h3 data-testid="breakdown-subtitle">
      {{ s__('UsageQuota|Storage usage breakdown') }}
    </h3>
    <dependency-proxy-usage
      v-if="!userNamespace"
      :dependency-proxy-total-size="dependencyProxyTotalSize"
      :loading="isNamespaceStorageStatisticsLoading"
    />
    <container-registry-usage
      :container-registry-size="containerRegistrySize"
      :container-registry-size-is-estimated="containerRegistrySizeIsEstimated"
      :loading="isNamespaceStorageStatisticsLoading"
    />

    <section class="gl-mt-5">
      <div class="gl-bg-gray-10 gl-p-5 gl-display-flex">
        <search-and-sort-bar
          :namespace="namespaceId"
          :search-input-placeholder="__('Search')"
          @onFilter="
            (searchTerm) => {
              $emit('search', searchTerm);
            }
          "
        />
      </div>
      <project-list
        :projects="projectList"
        :is-loading="isNamespaceProjectsLoading"
        :help-links="helpLinks"
        :sort-by="initialSortBy"
        :sort-desc="true"
        @sortChanged="
          ($event) => {
            $emit('sort-changed', $event);
          }
        "
      />
      <div class="gl-display-flex gl-justify-content-center gl-mt-5">
        <gl-keyset-pagination
          v-if="showPagination"
          v-bind="pageInfo"
          @prev="onPrev"
          @next="onNext"
        />
      </div>
    </section>
  </div>
</template>