Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
02058f29
Commit
02058f29
authored
Oct 16, 2020
by
Ragnar Hardarson
Committed by
Vitaly Slobodin
Oct 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrate StorageInlineAlert with graphql response
The endpoint now responds with actual data. Let us use this data.
parent
d7d09608
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
18 deletions
+45
-18
ee/app/assets/javascripts/storage_counter/components/app.vue
ee/app/assets/javascripts/storage_counter/components/app.vue
+16
-0
ee/app/assets/javascripts/storage_counter/components/storage_inline_alert.vue
...ripts/storage_counter/components/storage_inline_alert.vue
+6
-8
ee/spec/frontend/storage_counter/components/app_spec.js
ee/spec/frontend/storage_counter/components/app_spec.js
+10
-3
ee/spec/frontend/storage_counter/components/storage_inline_alert_spec.js
...d/storage_counter/components/storage_inline_alert_spec.js
+7
-7
ee/spec/frontend/storage_counter/mock_data.js
ee/spec/frontend/storage_counter/mock_data.js
+6
-0
No files found.
ee/app/assets/javascripts/storage_counter/components/app.vue
View file @
02058f29
...
...
@@ -4,6 +4,7 @@ import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import
ProjectsTable
from
'
./projects_table.vue
'
;
import
UsageGraph
from
'
./usage_graph.vue
'
;
import
UsageStatistics
from
'
./usage_statistics.vue
'
;
import
StorageInlineAlert
from
'
./storage_inline_alert.vue
'
;
import
query
from
'
../queries/storage.query.graphql
'
;
import
TemporaryStorageIncreaseModal
from
'
./temporary_storage_increase_modal.vue
'
;
import
{
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
...
...
@@ -17,6 +18,7 @@ export default {
GlButton
,
GlSprintf
,
GlIcon
,
StorageInlineAlert
,
UsageGraph
,
UsageStatistics
,
TemporaryStorageIncreaseModal
,
...
...
@@ -72,6 +74,7 @@ export default {
isAdditionalStorageFlagEnabled
()
{
return
this
.
glFeatures
.
additionalRepoStorageByNamespace
;
},
formattedNamespaceLimit
()
{
return
formatUsageSize
(
this
.
namespace
.
limit
);
},
...
...
@@ -86,12 +89,25 @@ export default {
additionalPurchasedStorageSize
:
this
.
namespace
.
additionalPurchasedStorageSize
,
};
},
shouldShowStorageInlineAlert
()
{
return
this
.
isAdditionalStorageFlagEnabled
&&
!
this
.
$apollo
.
queries
.
namespace
.
loading
;
},
},
modalId
:
'
temporary-increase-storage-modal
'
,
};
</
script
>
<
template
>
<div>
<storage-inline-alert
v-if=
"shouldShowStorageInlineAlert"
:contains-locked-projects=
"namespace.containsLockedProjects"
:repository-size-excess-project-count=
"namespace.repositorySizeExcessProjectCount"
:total-repository-size-excess=
"namespace.totalRepositorySizeExcess"
:total-repository-size=
"namespace.totalRepositorySize"
:additional-purchased-storage-size=
"namespace.additionalPurchasedStorageSize"
:actual-repository-size-limit=
"namespace.actualRepositorySizeLimit"
/>
<div
v-if=
"isAdditionalStorageFlagEnabled && storageStatistics"
>
<usage-statistics
:root-storage-statistics=
"storageStatistics"
/>
</div>
...
...
ee/app/assets/javascripts/storage_counter/components/storage_inline_alert.vue
View file @
02058f29
<
script
>
import
{
GlAlert
}
from
'
@gitlab/ui
'
;
import
{
n__
,
__
}
from
'
~/locale
'
;
import
{
getFormatter
,
SUPPORTED_FORMATS
}
from
'
~/lib/utils/unit_format
'
;
import
{
usageRatioToThresholdLevel
}
from
'
../utils
'
;
import
{
formatUsageSize
,
usageRatioToThresholdLevel
}
from
'
../utils
'
;
import
{
ALERT_THRESHOLD
,
ERROR_THRESHOLD
,
WARNING_THRESHOLD
}
from
'
../constants
'
;
export
default
{
...
...
@@ -30,7 +29,7 @@ export default {
type
:
Number
,
required
:
true
,
},
repositoryFree
SizeLimit
:
{
actualRepository
SizeLimit
:
{
type
:
Number
,
required
:
true
,
},
...
...
@@ -86,14 +85,13 @@ export default {
return
this
.
additionalPurchasedStorageSize
>
0
;
},
formatSize
(
size
)
{
const
formatter
=
getFormatter
(
SUPPORTED_FORMATS
.
decimalBytes
);
return
formatter
(
size
);
return
formatUsageSize
(
size
);
},
hasPurchasedStorageText
()
{
if
(
this
.
thresholdLevel
===
ERROR_THRESHOLD
)
{
return
__
(
`You have consumed all of your additional storage, please purchase more to unlock your projects over the free
${
this
.
formatSize
(
this
.
repositoryFree
SizeLimit
,
this
.
actualRepository
SizeLimit
,
)}
limit`
,
);
}
else
if
(
...
...
@@ -106,7 +104,7 @@ export default {
}
return
__
(
`When you purchase additional storage, we automatically unlock projects that were locked when you reached the
${
this
.
formatSize
(
this
.
repositoryFree
SizeLimit
,
this
.
actualRepository
SizeLimit
,
)}
limit.`
,
);
},
...
...
@@ -114,7 +112,7 @@ export default {
if
(
this
.
thresholdLevel
===
ERROR_THRESHOLD
)
{
return
__
(
`You have reached the free storage limit of
${
this
.
formatSize
(
this
.
repositoryFree
SizeLimit
,
this
.
actualRepository
SizeLimit
,
)}
on
${
this
.
projectsLockedText
}
. To unlock them, please purchase additional storage.`
,
);
}
...
...
ee/spec/frontend/storage_counter/components/app_spec.js
View file @
02058f29
import
{
mount
}
from
'
@vue/test-utils
'
;
import
StorageApp
from
'
ee/storage_counter/components/app.vue
'
;
import
Project
from
'
ee/storage_counter/components/project.vue
'
;
import
StorageInlineAlert
from
'
ee/storage_counter/components/storage_inline_alert.vue
'
;
import
UsageGraph
from
'
ee/storage_counter/components/usage_graph.vue
'
;
import
UsageStatistics
from
'
ee/storage_counter/components/usage_statistics.vue
'
;
import
TemporaryStorageIncreaseModal
from
'
ee/storage_counter/components/temporary_storage_increase_modal.vue
'
;
...
...
@@ -19,11 +20,13 @@ describe('Storage counter app', () => {
wrapper
.
find
(
"
[data-testid='temporary-storage-increase-button']
"
);
const
findUsageGraph
=
()
=>
wrapper
.
find
(
UsageGraph
);
const
findUsageStatistics
=
()
=>
wrapper
.
find
(
UsageStatistics
);
const
findStorageInlineAlert
=
()
=>
wrapper
.
find
(
StorageInlineAlert
);
const
createComponent
=
({
props
=
{},
loading
=
false
,
additionalRepoStorageByNamespace
=
false
,
namespace
=
{},
}
=
{})
=>
{
const
$apollo
=
{
queries
:
{
...
...
@@ -44,6 +47,11 @@ describe('Storage counter app', () => {
additionalRepoStorageByNamespace
,
},
},
data
()
{
return
{
namespace
,
};
},
});
};
...
...
@@ -109,14 +117,12 @@ describe('Storage counter app', () => {
expect
(
findUsageGraph
().
exists
()).
toBe
(
true
);
expect
(
findUsageStatistics
().
exists
()).
toBe
(
false
);
expect
(
findStorageInlineAlert
().
exists
()).
toBe
(
false
);
});
it
(
'
usage_statistics component is rendered when flag is true
'
,
async
()
=>
{
createComponent
({
additionalRepoStorageByNamespace
:
true
,
});
wrapper
.
setData
({
namespace
:
withRootStorageStatistics
,
});
...
...
@@ -124,6 +130,7 @@ describe('Storage counter app', () => {
expect
(
findUsageStatistics
().
exists
()).
toBe
(
true
);
expect
(
findUsageGraph
().
exists
()).
toBe
(
false
);
expect
(
findStorageInlineAlert
().
exists
()).
toBe
(
true
);
});
});
...
...
ee/spec/frontend/storage_counter/components/storage_inline_alert_spec.js
View file @
02058f29
...
...
@@ -2,7 +2,7 @@ import { shallowMount } from '@vue/test-utils';
import
StorageInlineAlert
from
'
ee/storage_counter/components/storage_inline_alert.vue
'
;
import
{
GlAlert
}
from
'
@gitlab/ui
'
;
const
GB_IN_BYTES
=
1
_0
00
_000_000
;
const
GB_IN_BYTES
=
1
_0
74
_000_000
;
const
THIRTEEN_GB_IN_BYTES
=
13
*
GB_IN_BYTES
;
const
TEN_GB_IN_BYTES
=
10
*
GB_IN_BYTES
;
const
FIVE_GB_IN_BYTES
=
5
*
GB_IN_BYTES
;
...
...
@@ -27,7 +27,7 @@ describe('StorageInlineAlert', () => {
totalRepositorySizeExcess
:
0
,
totalRepositorySize
:
FIVE_GB_IN_BYTES
,
additionalPurchasedStorageSize
:
0
,
repositoryFree
SizeLimit
:
TEN_GB_IN_BYTES
,
actualRepository
SizeLimit
:
TEN_GB_IN_BYTES
,
});
});
...
...
@@ -44,7 +44,7 @@ describe('StorageInlineAlert', () => {
totalRepositorySizeExcess
:
THREE_GB_IN_BYTES
,
totalRepositorySize
:
THIRTEEN_GB_IN_BYTES
,
additionalPurchasedStorageSize
:
0
,
repositoryFree
SizeLimit
:
TEN_GB_IN_BYTES
,
actualRepository
SizeLimit
:
TEN_GB_IN_BYTES
,
});
});
...
...
@@ -55,7 +55,7 @@ describe('StorageInlineAlert', () => {
it
(
'
renders human readable repositoryFreeLimit
'
,
()
=>
{
expect
(
findAlert
().
text
()).
toBe
(
'
You have reached the free storage limit of 10
G
B on 1 project. To unlock them, please purchase additional storage.
'
,
'
You have reached the free storage limit of 10
.0Gi
B on 1 project. To unlock them, please purchase additional storage.
'
,
);
});
});
...
...
@@ -68,7 +68,7 @@ describe('StorageInlineAlert', () => {
totalRepositorySizeExcess
:
THREE_GB_IN_BYTES
,
totalRepositorySize
:
THIRTEEN_GB_IN_BYTES
,
additionalPurchasedStorageSize
:
FIVE_GB_IN_BYTES
,
repositoryFree
SizeLimit
:
TEN_GB_IN_BYTES
,
actualRepository
SizeLimit
:
TEN_GB_IN_BYTES
,
});
});
...
...
@@ -79,7 +79,7 @@ describe('StorageInlineAlert', () => {
it
(
'
renders text explaining storage
'
,
()
=>
{
expect
(
findAlert
().
text
()).
toBe
(
'
When you purchase additional storage, we automatically unlock projects that were locked when you reached the 10
G
B limit.
'
,
'
When you purchase additional storage, we automatically unlock projects that were locked when you reached the 10
.0Gi
B limit.
'
,
);
});
});
...
...
@@ -92,7 +92,7 @@ describe('StorageInlineAlert', () => {
totalRepositorySizeExcess
:
THREE_GB_IN_BYTES
,
totalRepositorySize
:
THIRTEEN_GB_IN_BYTES
,
additionalPurchasedStorageSize
:
THREE_GB_IN_BYTES
,
repositoryFree
SizeLimit
:
TEN_GB_IN_BYTES
,
actualRepository
SizeLimit
:
TEN_GB_IN_BYTES
,
});
});
...
...
ee/spec/frontend/storage_counter/mock_data.js
View file @
02058f29
...
...
@@ -68,6 +68,12 @@ export const withRootStorageStatistics = {
projects
,
limit
:
10000000
,
totalUsage
:
129334601
,
containsLockedProjects
:
true
,
repositorySizeExcessProjectCount
:
1
,
totalRepositorySizeExcess
:
2321
,
totalRepositorySize
:
1002321
,
additionalPurchasedStorageSize
:
321
,
actualRepositorySizeLimit
:
1002321
,
rootStorageStatistics
:
{
storageSize
:
129334601
,
repositorySize
:
46012030
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment