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
bdecacbd
Commit
bdecacbd
authored
Nov 25, 2021
by
Diana Zubova
Committed by
Vitaly Slobodin
Nov 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reroute storage to GitLab flow
parent
e8ed8549
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
124 additions
and
40 deletions
+124
-40
ee/app/assets/javascripts/storage_counter/components/app.vue
ee/app/assets/javascripts/storage_counter/components/app.vue
+0
-1
ee/app/assets/javascripts/storage_counter/components/usage_statistics.vue
...vascripts/storage_counter/components/usage_statistics.vue
+4
-1
ee/app/controllers/groups/usage_quotas_controller.rb
ee/app/controllers/groups/usage_quotas_controller.rb
+4
-0
ee/app/helpers/ee/namespaces_helper.rb
ee/app/helpers/ee/namespaces_helper.rb
+13
-3
ee/app/views/groups/usage_quotas/index.html.haml
ee/app/views/groups/usage_quotas/index.html.haml
+1
-1
ee/app/views/shared/_namespace_storage_limit_alert.html.haml
ee/app/views/shared/_namespace_storage_limit_alert.html.haml
+1
-1
ee/spec/frontend/storage_counter/components/usage_statistics_spec.js
...ntend/storage_counter/components/usage_statistics_spec.js
+40
-12
ee/spec/helpers/ee/namespaces_helper_spec.rb
ee/spec/helpers/ee/namespaces_helper_spec.rb
+61
-21
No files found.
ee/app/assets/javascripts/storage_counter/components/app.vue
View file @
bdecacbd
...
...
@@ -90,7 +90,6 @@ export default {
isAdditionalStorageFlagEnabled
()
{
return
this
.
glFeatures
.
additionalRepoStorageByNamespace
;
},
formattedNamespaceLimit
()
{
return
formatUsageSize
(
this
.
namespace
.
limit
);
},
...
...
ee/app/assets/javascripts/storage_counter/components/usage_statistics.vue
View file @
bdecacbd
<
script
>
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
glFeatureFlagsMixin
from
'
~/vue_shared/mixins/gl_feature_flags_mixin
'
;
import
{
helpPagePath
}
from
'
~/helpers/help_page_helper
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
formatUsageSize
}
from
'
../utils
'
;
...
...
@@ -10,6 +11,7 @@ export default {
GlButton
,
UsageStatisticsCard
,
},
mixins
:
[
glFeatureFlagsMixin
()],
props
:
{
rootStorageStatistics
:
{
required
:
true
,
...
...
@@ -66,6 +68,7 @@ export default {
link
:
{
text
:
s__
(
'
UsageQuota|Purchase more storage
'
),
url
:
this
.
purchaseStorageUrl
,
target
:
this
.
glFeatures
.
newRouteStoragePurchase
?
'
_self
'
:
'
_blank
'
,
},
}
:
null
;
...
...
@@ -119,7 +122,7 @@ export default {
>
<template
#footer
="
{ link }">
<gl-button
target=
"_blank
"
:target=
"link.target
"
:href=
"link.url"
class=
"mb-0"
variant=
"confirm"
...
...
ee/app/controllers/groups/usage_quotas_controller.rb
View file @
bdecacbd
...
...
@@ -5,6 +5,10 @@ class Groups::UsageQuotasController < Groups::ApplicationController
before_action
:verify_usage_quotas_enabled!
before_action
:push_additional_repo_storage_by_namespace_feature
,
only: :index
before_action
do
push_frontend_feature_flag
(
:new_route_storage_purchase
,
@group
,
default_enabled: :yaml
)
end
layout
'group_settings'
feature_category
:purchase
...
...
ee/app/helpers/ee/namespaces_helper.rb
View file @
bdecacbd
...
...
@@ -40,19 +40,29 @@ module EE
end
def
buy_additional_minutes_path
(
namespace
)
return
EE
::
SUBSCRIPTIONS_MORE_MINUTES_URL
if
use_customers_dot_path?
(
namespace
)
return
EE
::
SUBSCRIPTIONS_MORE_MINUTES_URL
if
use_customers_dot_
for_minutes_
path?
(
namespace
)
buy_minutes_subscriptions_path
(
selected_group:
namespace
.
id
)
end
def
buy_additional_minutes_target
(
namespace
)
use_customers_dot_path?
(
namespace
)
?
'_blank'
:
'_self'
use_customers_dot_for_minutes_path?
(
namespace
)
?
'_blank'
:
'_self'
end
def
buy_storage_path
(
namespace
)
return
EE
::
SUBSCRIPTIONS_MORE_STORAGE_URL
if
use_customers_dot_for_storage_path?
(
namespace
)
buy_storage_subscriptions_path
(
selected_group:
namespace
.
id
)
end
private
def
use_customers_dot_path?
(
namespace
)
def
use_customers_dot_
for_minutes_
path?
(
namespace
)
namespace
.
user_namespace?
||
::
Feature
.
disabled?
(
:new_route_ci_minutes_purchase
,
namespace
,
default_enabled: :yaml
)
end
def
use_customers_dot_for_storage_path?
(
namespace
)
namespace
.
user_namespace?
||
::
Feature
.
disabled?
(
:new_route_storage_purchase
,
namespace
,
default_enabled: :yaml
)
end
end
end
ee/app/views/groups/usage_quotas/index.html.haml
View file @
bdecacbd
-
page_title
s_
(
"UsageQuota|Usage"
)
-
url_to_purchase_storage
=
purchase_storage_url
if
purchase_storage_link_enabled?
(
@group
)
-
url_to_purchase_storage
=
buy_storage_path
(
@group
)
if
purchase_storage_link_enabled?
(
@group
)
-
if
show_product_purchase_success_alert?
=
render
'product_purchase_success_alert'
,
product_name:
params
[
:purchased_product
]
...
...
ee/app/views/shared/_namespace_storage_limit_alert.html.haml
View file @
bdecacbd
...
...
@@ -10,7 +10,7 @@
-
root_namespace
=
payload
[
:root_namespace
]
-
style
=
namespace_storage_alert_style
(
alert_level
)
-
icon
=
namespace_storage_alert_icon
(
alert_level
)
-
purchase_link
=
purchase_storage_url
if
purchase_storage_link_enabled?
(
namespace
)
-
purchase_link
=
buy_storage_path
(
namespace
)
if
purchase_storage_link_enabled?
(
namespace
)
-
usage_link
=
usage_quotas_path
(
root_namespace
,
anchor:
'storage-quota-tab'
)
-
show_storage_banner_actions
=
purchase_link
||
usage_link
...
...
ee/spec/frontend/storage_counter/components/usage_statistics_spec.js
View file @
bdecacbd
...
...
@@ -7,7 +7,7 @@ import { withRootStorageStatistics } from '../mock_data';
describe
(
'
Usage Statistics component
'
,
()
=>
{
let
wrapper
;
const
createComponent
=
(
props
=
{})
=>
{
const
createComponent
=
(
{
props
=
{},
newRouteStoragePurchase
=
false
}
=
{})
=>
{
wrapper
=
shallowMount
(
UsageStatistics
,
{
propsData
:
{
rootStorageStatistics
:
{
...
...
@@ -18,6 +18,11 @@ describe('Usage Statistics component', () => {
},
...
props
,
},
provide
:
{
glFeatures
:
{
newRouteStoragePurchase
,
},
},
stubs
:
{
UsageStatisticsCard
,
GlSprintf
,
...
...
@@ -26,20 +31,42 @@ describe('Usage Statistics component', () => {
});
};
afterEach
(()
=>
{
wrapper
.
destroy
();
});
const
getStatisticsCards
=
()
=>
wrapper
.
findAll
(
UsageStatisticsCard
);
const
getStatisticsCard
=
(
testId
)
=>
wrapper
.
find
(
`[data-testid="
${
testId
}
"]`
);
const
findGlLinkInCard
=
(
cardName
)
=>
getStatisticsCard
(
cardName
).
find
(
'
[data-testid="statistics-card-footer"]
'
).
find
(
GlLink
);
const
findPurchasedUsageButton
=
()
=>
getStatisticsCard
(
'
purchased-usage
'
).
findComponent
(
GlButton
);
describe
(
'
with purchaseStorageUrl passed
'
,
()
=>
{
describe
(
'
with purchaseStorageUrl passed
and newRouteStoragePurchase flag enabled
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
purchaseStorageUrl
:
'
some-fancy-url
'
,
props
:
{
purchaseStorageUrl
:
'
some-fancy-url
'
,
},
newRouteStoragePurchase
:
true
,
});
});
afterEach
(()
=>
{
wrapper
.
destroy
();
it
(
'
renders button in purchased usage card footer with correct link
'
,
()
=>
{
expect
(
findPurchasedUsageButton
().
attributes
()).
toMatchObject
({
href
:
'
some-fancy-url
'
,
target
:
'
_self
'
,
});
});
});
describe
(
'
with purchaseStorageUrl passed
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
props
:
{
purchaseStorageUrl
:
'
some-fancy-url
'
,
},
});
});
it
(
'
renders three statistics cards
'
,
()
=>
{
...
...
@@ -58,22 +85,23 @@ describe('Usage Statistics component', () => {
expect
(
url
.
attributes
(
'
href
'
)).
toBe
(
'
/help/user/usage_quotas#excess-storage-usage
'
);
});
it
(
'
renders button in purchased usage card footer
'
,
()
=>
{
expect
(
getStatisticsCard
(
'
purchased-usage
'
).
find
(
GlButton
).
exists
()).
toBe
(
true
);
it
(
'
renders button in purchased usage card footer with correct link
'
,
()
=>
{
expect
(
findPurchasedUsageButton
().
attributes
()).
toMatchObject
({
href
:
'
some-fancy-url
'
,
target
:
'
_blank
'
,
});
});
});
describe
(
'
with no purchaseStorageUrl
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
purchaseStorageUrl
:
null
,
props
:
{
purchaseStorageUrl
:
null
,
},
});
});
afterEach
(()
=>
{
wrapper
.
destroy
();
});
it
(
'
does not render purchased usage card if purchaseStorageUrl is not provided
'
,
()
=>
{
expect
(
getStatisticsCard
(
'
purchased-usage
'
).
exists
()).
toBe
(
false
);
});
...
...
ee/spec/helpers/ee/namespaces_helper_spec.rb
View file @
bdecacbd
...
...
@@ -175,7 +175,9 @@ RSpec.describe EE::NamespacesHelper do
describe
'#buy_additional_minutes_path'
do
subject
{
helper
.
buy_additional_minutes_path
(
namespace
)
}
let_it_be
(
:namespace
)
{
create
(
:group
)
}
let
(
:namespace
)
{
build_stubbed
(
:group
)
}
it
{
is_expected
.
to
eq
buy_minutes_subscriptions_path
(
selected_group:
namespace
.
id
)
}
context
'new_route_ci_minutes_purchase'
do
context
'when is disabled'
do
...
...
@@ -183,16 +185,11 @@ RSpec.describe EE::NamespacesHelper do
stub_feature_flags
(
new_route_ci_minutes_purchase:
false
)
end
it
{
is_expected
.
to
be
EE
::
SUBSCRIPTIONS_MORE_MINUTES_URL
}
it
{
is_expected
.
to
eq
EE
::
SUBSCRIPTIONS_MORE_MINUTES_URL
}
end
context
'when is enabled'
do
it
{
is_expected
.
to
eq
buy_minutes_subscriptions_path
(
selected_group:
namespace
.
id
)
}
end
context
'when is enabled only for a specific namespace'
do
let_it_be
(
:enabled_namespace
)
{
create
(
:group
)
}
let_it_be
(
:disabled_namespace
)
{
create
(
:group
)
}
context
'when new_route_ci_minutes_purchase is enabled only for a specific namespace'
do
let
(
:enabled_namespace
)
{
build_stubbed
(
:group
)
}
before
do
stub_feature_flags
(
new_route_ci_minutes_purchase:
false
)
...
...
@@ -200,7 +197,7 @@ RSpec.describe EE::NamespacesHelper do
end
it
'returns the default purchase path for the disabled namespace'
do
expect
(
helper
.
buy_additional_minutes_path
(
disabled_namespace
)).
to
be
EE
::
SUBSCRIPTIONS_MORE_MINUTES_URL
expect
(
helper
.
buy_additional_minutes_path
(
namespace
)).
to
eq
EE
::
SUBSCRIPTIONS_MORE_MINUTES_URL
end
it
'returns GitLab purchase path for the disabled namespace'
do
...
...
@@ -209,11 +206,55 @@ RSpec.describe EE::NamespacesHelper do
end
context
'when called for a personal namespace'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:personal_namespace
)
{
user
.
namespace
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:personal_namespace
)
{
build_stubbed
(
:user_namespace
)
}
it
'returns the default purchase'
do
expect
(
helper
.
buy_additional_minutes_path
(
personal_namespace
)).
to
eq
EE
::
SUBSCRIPTIONS_MORE_MINUTES_URL
end
end
end
end
describe
'#buy_storage_path'
do
subject
{
helper
.
buy_storage_path
(
namespace
)
}
let
(
:namespace
)
{
build_stubbed
(
:group
)
}
it
{
is_expected
.
to
eq
buy_storage_subscriptions_path
(
selected_group:
namespace
.
id
)
}
context
'new_route_storage_purchase'
do
context
'when is disabled'
do
before
do
stub_feature_flags
(
new_route_storage_purchase:
false
)
end
it
{
is_expected
.
to
eq
EE
::
SUBSCRIPTIONS_MORE_STORAGE_URL
}
end
context
'when new_route_storage_purchase is enabled only for a specific namespace'
do
let
(
:enabled_namespace
)
{
build_stubbed
(
:group
)
}
before
do
stub_feature_flags
(
new_route_storage_purchase:
false
)
stub_feature_flags
(
new_route_storage_purchase:
enabled_namespace
)
end
it
'returns the default purchase path for the disabled namespace'
do
expect
(
helper
.
buy_storage_path
(
namespace
)).
to
eq
EE
::
SUBSCRIPTIONS_MORE_STORAGE_URL
end
it
'returns GitLab purchase path for the disabled namespace'
do
expect
(
helper
.
buy_storage_path
(
enabled_namespace
)).
to
eq
buy_storage_subscriptions_path
(
selected_group:
enabled_namespace
.
id
)
end
end
context
'when called for a personal namespace'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:personal_namespace
)
{
build_stubbed
(
:user_namespace
)
}
it
'returns the default purchase'
do
expect
(
helper
.
buy_
additional_minutes_path
(
personal_namespace
)).
to
be
EE
::
SUBSCRIPTIONS_MORE_MINUTES
_URL
expect
(
helper
.
buy_
storage_path
(
personal_namespace
)).
to
eq
EE
::
SUBSCRIPTIONS_MORE_STORAGE
_URL
end
end
end
...
...
@@ -222,7 +263,7 @@ RSpec.describe EE::NamespacesHelper do
describe
'#buy_additional_minutes_target'
do
subject
{
helper
.
buy_additional_minutes_target
(
namespace
)
}
let
_it_be
(
:namespace
)
{
create
(
:group
)
}
let
(
:namespace
)
{
create
(
:group
)
}
context
'new_route_ci_minutes_purchase'
do
context
'when is disabled'
do
...
...
@@ -230,7 +271,7 @@ RSpec.describe EE::NamespacesHelper do
stub_feature_flags
(
new_route_ci_minutes_purchase:
false
)
end
it
{
is_expected
.
to
be
'_blank'
}
it
{
is_expected
.
to
eq
'_blank'
}
end
context
'when is enabled'
do
...
...
@@ -238,8 +279,7 @@ RSpec.describe EE::NamespacesHelper do
end
context
'when is enabled only for a specific namespace'
do
let_it_be
(
:enabled_namespace
)
{
create
(
:group
)
}
let_it_be
(
:disabled_namespace
)
{
create
(
:group
)
}
let
(
:enabled_namespace
)
{
build_stubbed
(
:group
)
}
before
do
stub_feature_flags
(
new_route_ci_minutes_purchase:
false
)
...
...
@@ -247,7 +287,7 @@ RSpec.describe EE::NamespacesHelper do
end
it
'returns _blank for the disabled namespace'
do
expect
(
helper
.
buy_additional_minutes_target
(
disabled_namespace
)).
to
be
'_blank'
expect
(
helper
.
buy_additional_minutes_target
(
namespace
)).
to
eq
'_blank'
end
it
'returns _self for the disabled namespace'
do
...
...
@@ -256,11 +296,11 @@ RSpec.describe EE::NamespacesHelper do
end
context
'when called for a personal namespace'
do
let
_it_be
(
:user
)
{
create
(
:user
)
}
let
_it_be
(
:personal_namespace
)
{
user
.
namespace
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:personal_namespace
)
{
build_stubbed
(
:user_namespace
)
}
it
'returns _blank'
do
expect
(
helper
.
buy_additional_minutes_target
(
personal_namespace
)).
to
be
'_blank'
expect
(
helper
.
buy_additional_minutes_target
(
personal_namespace
)).
to
eq
'_blank'
end
end
end
...
...
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