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
5da8300a
Commit
5da8300a
authored
Jun 09, 2021
by
Vitaly Slobodin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply reviewer suggestions
parent
71e302cb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
60 deletions
+61
-60
ee/app/assets/javascripts/subscriptions/buy_minutes/components/checkout/billing_address.vue
...tions/buy_minutes/components/checkout/billing_address.vue
+48
-51
ee/app/assets/javascripts/subscriptions/buy_minutes/graphql/resolvers.js
...avascripts/subscriptions/buy_minutes/graphql/resolvers.js
+3
-3
ee/spec/frontend/subscriptions/buy_minutes/components/checkout/billing_address_spec.js
...s/buy_minutes/components/checkout/billing_address_spec.js
+10
-6
No files found.
ee/app/assets/javascripts/subscriptions/buy_minutes/components/checkout/billing_address.vue
View file @
5da8300a
...
@@ -2,10 +2,10 @@
...
@@ -2,10 +2,10 @@
import
{
GlFormGroup
,
GlFormInput
,
GlFormSelect
}
from
'
@gitlab/ui
'
;
import
{
GlFormGroup
,
GlFormInput
,
GlFormSelect
}
from
'
@gitlab/ui
'
;
import
{
isEmpty
}
from
'
lodash
'
;
import
{
isEmpty
}
from
'
lodash
'
;
import
{
STEPS
}
from
'
ee/subscriptions/constants
'
;
import
{
STEPS
}
from
'
ee/subscriptions/constants
'
;
import
UPDATE_STATE
from
'
ee/subscriptions/graphql/mutations/update_state.mutation.graphql
'
;
import
updateStateMutation
from
'
ee/subscriptions/graphql/mutations/update_state.mutation.graphql
'
;
import
COUNTRIES_QUERY
from
'
ee/subscriptions/graphql/queries/countries.query.graphql
'
;
import
countriesQuery
from
'
ee/subscriptions/graphql/queries/countries.query.graphql
'
;
import
STATE_QUERY
from
'
ee/subscriptions/graphql/queries/state.query.graphql
'
;
import
stateQuery
from
'
ee/subscriptions/graphql/queries/state.query.graphql
'
;
import
STATES_QUERY
from
'
ee/subscriptions/graphql/queries/states.query.graphql
'
;
import
statesQuery
from
'
ee/subscriptions/graphql/queries/states.query.graphql
'
;
import
Step
from
'
ee/vue_shared/purchase_flow/components/step.vue
'
;
import
Step
from
'
ee/vue_shared/purchase_flow/components/step.vue
'
;
import
{
GENERAL_ERROR_MESSAGE
}
from
'
ee/vue_shared/purchase_flow/constants
'
;
import
{
GENERAL_ERROR_MESSAGE
}
from
'
ee/vue_shared/purchase_flow/constants
'
;
import
createFlash
from
'
~/flash
'
;
import
createFlash
from
'
~/flash
'
;
...
@@ -24,45 +24,24 @@ export default {
...
@@ -24,45 +24,24 @@ export default {
},
},
data
()
{
data
()
{
return
{
return
{
country
:
null
,
countries
:
[],
address1
:
null
,
address2
:
null
,
city
:
null
,
state
:
null
,
zipCode
:
null
,
company
:
null
,
};
};
},
},
apollo
:
{
apollo
:
{
state
:
{
customer
:
{
query
:
STATE_QUERY
,
query
:
stateQuery
,
manual
:
true
,
result
({
data
,
loading
})
{
if
(
loading
)
{
return
;
}
const
{
customer
}
=
data
;
this
.
country
=
customer
.
country
;
this
.
address1
=
customer
.
address1
;
this
.
address2
=
customer
.
address2
;
this
.
city
=
customer
.
city
;
this
.
state
=
customer
.
state
;
this
.
zipCode
=
customer
.
zipCode
;
this
.
company
=
customer
.
company
;
},
},
},
countries
:
{
countries
:
{
query
:
COUNTRIES_QUERY
,
query
:
countriesQuery
,
},
},
states
:
{
states
:
{
query
:
STATES_QUERY
,
query
:
statesQuery
,
skip
()
{
skip
()
{
return
!
this
.
country
;
return
!
this
.
c
ustomer
.
c
ountry
;
},
},
variables
()
{
variables
()
{
return
{
return
{
countryId
:
this
.
country
,
countryId
:
this
.
c
ustomer
.
c
ountry
,
};
};
},
},
},
},
...
@@ -70,15 +49,15 @@ export default {
...
@@ -70,15 +49,15 @@ export default {
computed
:
{
computed
:
{
countryModel
:
{
countryModel
:
{
get
()
{
get
()
{
return
this
.
country
;
return
this
.
c
ustomer
.
c
ountry
;
},
},
set
(
country
)
{
set
(
country
)
{
this
.
updateState
({
customer
:
{
country
}
});
this
.
updateState
({
customer
:
{
country
,
state
:
null
}
});
},
},
},
},
streetAddressLine1Model
:
{
streetAddressLine1Model
:
{
get
()
{
get
()
{
return
this
.
address1
;
return
this
.
customer
.
address1
;
},
},
set
(
address1
)
{
set
(
address1
)
{
this
.
updateState
({
customer
:
{
address1
}
});
this
.
updateState
({
customer
:
{
address1
}
});
...
@@ -86,7 +65,7 @@ export default {
...
@@ -86,7 +65,7 @@ export default {
},
},
streetAddressLine2Model
:
{
streetAddressLine2Model
:
{
get
()
{
get
()
{
return
this
.
address2
;
return
this
.
customer
.
address2
;
},
},
set
(
address2
)
{
set
(
address2
)
{
this
.
updateState
({
customer
:
{
address2
}
});
this
.
updateState
({
customer
:
{
address2
}
});
...
@@ -94,7 +73,7 @@ export default {
...
@@ -94,7 +73,7 @@ export default {
},
},
cityModel
:
{
cityModel
:
{
get
()
{
get
()
{
return
this
.
city
;
return
this
.
c
ustomer
.
c
ity
;
},
},
set
(
city
)
{
set
(
city
)
{
this
.
updateState
({
customer
:
{
city
}
});
this
.
updateState
({
customer
:
{
city
}
});
...
@@ -102,7 +81,7 @@ export default {
...
@@ -102,7 +81,7 @@ export default {
},
},
countryStateModel
:
{
countryStateModel
:
{
get
()
{
get
()
{
return
this
.
state
;
return
this
.
customer
.
state
;
},
},
set
(
state
)
{
set
(
state
)
{
this
.
updateState
({
customer
:
{
state
}
});
this
.
updateState
({
customer
:
{
state
}
});
...
@@ -110,7 +89,7 @@ export default {
...
@@ -110,7 +89,7 @@ export default {
},
},
zipCodeModel
:
{
zipCodeModel
:
{
get
()
{
get
()
{
return
this
.
zipCode
;
return
this
.
customer
.
zipCode
;
},
},
set
(
zipCode
)
{
set
(
zipCode
)
{
this
.
updateState
({
customer
:
{
zipCode
}
});
this
.
updateState
({
customer
:
{
zipCode
}
});
...
@@ -118,10 +97,10 @@ export default {
...
@@ -118,10 +97,10 @@ export default {
},
},
isValid
()
{
isValid
()
{
return
(
return
(
!
isEmpty
(
this
.
country
)
&&
!
isEmpty
(
this
.
c
ustomer
.
c
ountry
)
&&
!
isEmpty
(
this
.
address1
)
&&
!
isEmpty
(
this
.
customer
.
address1
)
&&
!
isEmpty
(
this
.
city
)
&&
!
isEmpty
(
this
.
c
ustomer
.
c
ity
)
&&
!
isEmpty
(
this
.
zipCode
)
!
isEmpty
(
this
.
customer
.
zipCode
)
);
);
},
},
countryOptionsWithDefault
()
{
countryOptionsWithDefault
()
{
...
@@ -142,12 +121,19 @@ export default {
...
@@ -142,12 +121,19 @@ export default {
...
this
.
states
,
...
this
.
states
,
];
];
},
},
selectedStateName
()
{
if
(
!
this
.
customer
.
state
||
!
this
.
states
)
{
return
''
;
}
return
this
.
states
.
find
((
state
)
=>
state
.
id
===
this
.
customer
.
state
).
name
;
},
},
},
methods
:
{
methods
:
{
updateState
(
payload
)
{
updateState
(
payload
)
{
this
.
$apollo
this
.
$apollo
.
mutate
({
.
mutate
({
mutation
:
UPDATE_STATE
,
mutation
:
updateStateMutation
,
variables
:
{
variables
:
{
input
:
payload
,
input
:
payload
,
},
},
...
@@ -173,14 +159,19 @@ export default {
...
@@ -173,14 +159,19 @@ export default {
</
script
>
</
script
>
<
template
>
<
template
>
<step
<step
v-if=
"!$apollo.loading"
v-if=
"!$apollo.loading
.customer
"
:step-id=
"$options.stepId"
:step-id=
"$options.stepId"
:title=
"$options.i18n.stepTitle"
:title=
"$options.i18n.stepTitle"
:is-valid=
"isValid"
:is-valid=
"isValid"
:next-step-button-text=
"$options.i18n.nextStepButtonText"
:next-step-button-text=
"$options.i18n.nextStepButtonText"
>
>
<template
#body
>
<template
#body
>
<gl-form-group
:label=
"$options.i18n.countryLabel"
label-size=
"sm"
class=
"mb-3"
>
<gl-form-group
v-if=
"!$apollo.loading.countries"
:label=
"$options.i18n.countryLabel"
label-size=
"sm"
class=
"mb-3"
>
<gl-form-select
<gl-form-select
v-model=
"countryModel"
v-model=
"countryModel"
v-autofocusonshow
v-autofocusonshow
...
@@ -207,9 +198,13 @@ export default {
...
@@ -207,9 +198,13 @@ export default {
<gl-form-input
v-model=
"cityModel"
type=
"text"
data-qa-selector=
"city"
/>
<gl-form-input
v-model=
"cityModel"
type=
"text"
data-qa-selector=
"city"
/>
</gl-form-group>
</gl-form-group>
<div
class=
"combined d-flex"
>
<div
class=
"combined d-flex"
>
<gl-form-group
:label=
"$options.i18n.stateLabel"
label-size=
"sm"
class=
"mr-3 w-50"
>
<gl-form-group
v-if=
"!$apollo.loading.states && states"
:label=
"$options.i18n.stateLabel"
label-size=
"sm"
class=
"mr-3 w-50"
>
<gl-form-select
<gl-form-select
v-if=
"states"
v-model=
"countryStateModel"
v-model=
"countryStateModel"
:options=
"stateOptionsWithDefault"
:options=
"stateOptionsWithDefault"
value-field=
"id"
value-field=
"id"
...
@@ -223,9 +218,11 @@ export default {
...
@@ -223,9 +218,11 @@ export default {
</div>
</div>
</
template
>
</
template
>
<
template
#summary
>
<
template
#summary
>
<div
class=
"js-summary-line-1"
>
{{
address1
}}
</div>
<div
class=
"js-summary-line-1"
>
{{
customer
.
address1
}}
</div>
<div
class=
"js-summary-line-2"
>
{{
address2
}}
</div>
<div
class=
"js-summary-line-2"
>
{{
customer
.
address2
}}
</div>
<div
class=
"js-summary-line-3"
>
{{
city
}}
,
{{
country
}}
{{
state
}}
{{
zipCode
}}
</div>
<div
class=
"js-summary-line-3"
>
{{
customer
.
city
}}
,
{{
customer
.
country
}}
{{
selectedStateName
}}
{{
customer
.
zipCode
}}
</div>
</
template
>
</
template
>
</step>
</step>
</template>
</template>
ee/app/assets/javascripts/subscriptions/buy_minutes/graphql/resolvers.js
View file @
5da8300a
...
@@ -3,7 +3,7 @@ import { merge } from 'lodash';
...
@@ -3,7 +3,7 @@ import { merge } from 'lodash';
import
Api
from
'
ee/api
'
;
import
Api
from
'
ee/api
'
;
import
*
as
SubscriptionsApi
from
'
ee/api/subscriptions_api
'
;
import
*
as
SubscriptionsApi
from
'
ee/api/subscriptions_api
'
;
import
{
ERROR_FETCHING_COUNTRIES
,
ERROR_FETCHING_STATES
}
from
'
ee/subscriptions/constants
'
;
import
{
ERROR_FETCHING_COUNTRIES
,
ERROR_FETCHING_STATES
}
from
'
ee/subscriptions/constants
'
;
import
STATE_QUERY
from
'
ee/subscriptions/graphql/queries/state.query.graphql
'
;
import
stateQuery
from
'
ee/subscriptions/graphql/queries/state.query.graphql
'
;
import
createFlash
from
'
~/flash
'
;
import
createFlash
from
'
~/flash
'
;
// NOTE: These resolvers are temporary and will be removed in the future.
// NOTE: These resolvers are temporary and will be removed in the future.
...
@@ -38,13 +38,13 @@ export const resolvers = {
...
@@ -38,13 +38,13 @@ export const resolvers = {
return
SubscriptionsApi
.
createSubscription
(
groupId
,
customer
,
subscription
);
return
SubscriptionsApi
.
createSubscription
(
groupId
,
customer
,
subscription
);
},
},
updateState
:
(
_
,
{
input
},
{
cache
})
=>
{
updateState
:
(
_
,
{
input
},
{
cache
})
=>
{
const
oldState
=
cache
.
readQuery
({
query
:
STATE_QUERY
});
const
oldState
=
cache
.
readQuery
({
query
:
stateQuery
});
const
state
=
produce
(
oldState
,
(
draftState
)
=>
{
const
state
=
produce
(
oldState
,
(
draftState
)
=>
{
merge
(
draftState
,
input
);
merge
(
draftState
,
input
);
});
});
cache
.
writeQuery
({
query
:
STATE_QUERY
,
data
:
state
});
cache
.
writeQuery
({
query
:
stateQuery
,
data
:
state
});
},
},
},
},
};
};
ee/spec/frontend/subscriptions/buy_minutes/components/checkout/billing_address_spec.js
View file @
5da8300a
...
@@ -4,7 +4,7 @@ import VueApollo from 'vue-apollo';
...
@@ -4,7 +4,7 @@ import VueApollo from 'vue-apollo';
import
BillingAddress
from
'
ee/subscriptions/buy_minutes/components/checkout/billing_address.vue
'
;
import
BillingAddress
from
'
ee/subscriptions/buy_minutes/components/checkout/billing_address.vue
'
;
import
{
resolvers
}
from
'
ee/subscriptions/buy_minutes/graphql/resolvers
'
;
import
{
resolvers
}
from
'
ee/subscriptions/buy_minutes/graphql/resolvers
'
;
import
{
STEPS
}
from
'
ee/subscriptions/constants
'
;
import
{
STEPS
}
from
'
ee/subscriptions/constants
'
;
import
STATE_QUERY
from
'
ee/subscriptions/graphql/queries/state.query.graphql
'
;
import
stateQuery
from
'
ee/subscriptions/graphql/queries/state.query.graphql
'
;
import
Step
from
'
ee/vue_shared/purchase_flow/components/step.vue
'
;
import
Step
from
'
ee/vue_shared/purchase_flow/components/step.vue
'
;
import
{
stateData
as
initialStateData
}
from
'
ee_jest/subscriptions/buy_minutes/mock_data
'
;
import
{
stateData
as
initialStateData
}
from
'
ee_jest/subscriptions/buy_minutes/mock_data
'
;
import
{
createMockApolloProvider
}
from
'
ee_jest/vue_shared/purchase_flow/spec_helper
'
;
import
{
createMockApolloProvider
}
from
'
ee_jest/vue_shared/purchase_flow/spec_helper
'
;
...
@@ -18,7 +18,11 @@ describe('Billing Address', () => {
...
@@ -18,7 +18,11 @@ describe('Billing Address', () => {
const
apolloResolvers
=
{
const
apolloResolvers
=
{
Query
:
{
Query
:
{
countries
:
jest
.
fn
().
mockResolvedValue
([{
id
:
'
NL
'
,
name
:
'
Netherlands
'
}]),
countries
:
jest
.
fn
().
mockResolvedValue
([
{
id
:
'
NL
'
,
name
:
'
Netherlands
'
},
{
id
:
'
US
'
,
name
:
'
United States of America
'
},
]),
states
:
jest
.
fn
().
mockResolvedValue
([{
id
:
'
CA
'
,
name
:
'
California
'
}]),
},
},
};
};
...
@@ -28,7 +32,7 @@ describe('Billing Address', () => {
...
@@ -28,7 +32,7 @@ describe('Billing Address', () => {
...
apolloResolvers
,
...
apolloResolvers
,
});
});
apolloProvider
.
clients
.
defaultClient
.
cache
.
writeQuery
({
apolloProvider
.
clients
.
defaultClient
.
cache
.
writeQuery
({
query
:
STATE_QUERY
,
query
:
stateQuery
,
data
:
merge
({},
initialStateData
,
apolloLocalState
),
data
:
merge
({},
initialStateData
,
apolloLocalState
),
});
});
...
@@ -125,15 +129,15 @@ describe('Billing Address', () => {
...
@@ -125,15 +129,15 @@ describe('Billing Address', () => {
});
});
it
(
'
should show the entered address line 1
'
,
()
=>
{
it
(
'
should show the entered address line 1
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-summary-line-1
'
).
text
()).
to
Equal
(
'
address line 1
'
);
expect
(
wrapper
.
find
(
'
.js-summary-line-1
'
).
text
()).
to
Be
(
'
address line 1
'
);
});
});
it
(
'
should show the entered address line 2
'
,
()
=>
{
it
(
'
should show the entered address line 2
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-summary-line-2
'
).
text
()).
to
Equal
(
'
address line 2
'
);
expect
(
wrapper
.
find
(
'
.js-summary-line-2
'
).
text
()).
to
Be
(
'
address line 2
'
);
});
});
it
(
'
should show the entered address city, state and zip code
'
,
()
=>
{
it
(
'
should show the entered address city, state and zip code
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.js-summary-line-3
'
).
text
()).
to
Equal
(
'
city, US CA
zip
'
);
expect
(
wrapper
.
find
(
'
.js-summary-line-3
'
).
text
()).
to
Be
(
'
city, US California
zip
'
);
});
});
});
});
});
});
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