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
e58e0dcb
Commit
e58e0dcb
authored
Jul 23, 2020
by
Jake Burden
Committed by
Jose Ivan Vargas
Jul 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Decouple timezone dropdown component from deploy freeze"
parent
be4faf17
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
35 deletions
+45
-35
app/assets/javascripts/deploy_freeze/components/deploy_freeze_modal.vue
...ascripts/deploy_freeze/components/deploy_freeze_modal.vue
+11
-8
app/assets/javascripts/deploy_freeze/store/actions.js
app/assets/javascripts/deploy_freeze/store/actions.js
+1
-0
app/assets/javascripts/vue_shared/components/timezone_dropdown.vue
...s/javascripts/vue_shared/components/timezone_dropdown.vue
+10
-15
spec/frontend/deploy_freeze/components/deploy_freeze_modal_spec.js
...tend/deploy_freeze/components/deploy_freeze_modal_spec.js
+2
-2
spec/frontend/deploy_freeze/components/timezone_dropdown_spec.js
...ontend/deploy_freeze/components/timezone_dropdown_spec.js
+21
-10
No files found.
app/assets/javascripts/deploy_freeze/components/deploy_freeze_modal.vue
View file @
e58e0dcb
...
@@ -4,7 +4,7 @@ import { mapActions, mapState } from 'vuex';
...
@@ -4,7 +4,7 @@ import { mapActions, mapState } from 'vuex';
import
{
mapComputed
}
from
'
~/vuex_shared/bindings
'
;
import
{
mapComputed
}
from
'
~/vuex_shared/bindings
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
MODAL_ID
}
from
'
../constants
'
;
import
{
MODAL_ID
}
from
'
../constants
'
;
import
DeployFreezeTimezoneDropdown
from
'
./deploy_freeze_
timezone_dropdown.vue
'
;
import
TimezoneDropdown
from
'
~/vue_shared/components/
timezone_dropdown.vue
'
;
import
{
isValidCron
}
from
'
cron-validator
'
;
import
{
isValidCron
}
from
'
cron-validator
'
;
export
default
{
export
default
{
...
@@ -14,7 +14,7 @@ export default {
...
@@ -14,7 +14,7 @@ export default {
GlModal
,
GlModal
,
GlSprintf
,
GlSprintf
,
GlLink
,
GlLink
,
DeployFreeze
TimezoneDropdown
,
TimezoneDropdown
,
},
},
modalOptions
:
{
modalOptions
:
{
ref
:
'
modal
'
,
ref
:
'
modal
'
,
...
@@ -39,7 +39,6 @@ export default {
...
@@ -39,7 +39,6 @@ export default {
'
timezoneData
'
,
'
timezoneData
'
,
'
freezeStartCron
'
,
'
freezeStartCron
'
,
'
freezeEndCron
'
,
'
freezeEndCron
'
,
'
selectedTimezone
'
,
]),
]),
...
mapComputed
([
...
mapComputed
([
{
key
:
'
freezeStartCron
'
,
updateFn
:
'
setFreezeStartCron
'
},
{
key
:
'
freezeStartCron
'
,
updateFn
:
'
setFreezeStartCron
'
},
...
@@ -71,6 +70,14 @@ export default {
...
@@ -71,6 +70,14 @@ export default {
freezeEndCronState
()
{
freezeEndCronState
()
{
return
Boolean
(
!
this
.
freezeEndCron
||
isValidCron
(
this
.
freezeEndCron
));
return
Boolean
(
!
this
.
freezeEndCron
||
isValidCron
(
this
.
freezeEndCron
));
},
},
timezone
:
{
get
()
{
return
this
.
selectedTimezone
;
},
set
(
selectedTimezone
)
{
this
.
setSelectedTimezone
(
selectedTimezone
);
},
},
},
},
methods
:
{
methods
:
{
...
mapActions
([
'
addFreezePeriod
'
,
'
setSelectedTimezone
'
,
'
resetModal
'
]),
...
mapActions
([
'
addFreezePeriod
'
,
'
setSelectedTimezone
'
,
'
resetModal
'
]),
...
@@ -137,11 +144,7 @@ export default {
...
@@ -137,11 +144,7 @@ export default {
</gl-form-group>
</gl-form-group>
<gl-form-group
:label=
"__('Cron time zone')"
label-for=
"cron-time-zone-dropdown"
>
<gl-form-group
:label=
"__('Cron time zone')"
label-for=
"cron-time-zone-dropdown"
>
<deploy-freeze-timezone-dropdown
<timezone-dropdown
v-model=
"timezone"
:timezone-data=
"timezoneData"
/>
:timezone-data=
"timezoneData"
:value=
"selectedTimezone"
@
selectTimezone=
"setSelectedTimezone"
/>
</gl-form-group>
</gl-form-group>
</gl-modal>
</gl-modal>
</template>
</template>
app/assets/javascripts/deploy_freeze/store/actions.js
View file @
e58e0dcb
...
@@ -64,6 +64,7 @@ export const fetchFreezePeriods = ({ dispatch, state }) => {
...
@@ -64,6 +64,7 @@ export const fetchFreezePeriods = ({ dispatch, state }) => {
export
const
setSelectedTimezone
=
({
commit
},
timezone
)
=>
{
export
const
setSelectedTimezone
=
({
commit
},
timezone
)
=>
{
commit
(
types
.
SET_SELECTED_TIMEZONE
,
timezone
);
commit
(
types
.
SET_SELECTED_TIMEZONE
,
timezone
);
};
};
export
const
setFreezeStartCron
=
({
commit
},
{
freezeStartCron
})
=>
{
export
const
setFreezeStartCron
=
({
commit
},
{
freezeStartCron
})
=>
{
commit
(
types
.
SET_FREEZE_START_CRON
,
freezeStartCron
);
commit
(
types
.
SET_FREEZE_START_CRON
,
freezeStartCron
);
};
};
...
...
app/assets/javascripts/
deploy_freeze/components/deploy_freeze_
timezone_dropdown.vue
→
app/assets/javascripts/
vue_shared/components/
timezone_dropdown.vue
View file @
e58e0dcb
...
@@ -4,7 +4,7 @@ import { __ } from '~/locale';
...
@@ -4,7 +4,7 @@ import { __ } from '~/locale';
import
autofocusonshow
from
'
~/vue_shared/directives/autofocusonshow
'
;
import
autofocusonshow
from
'
~/vue_shared/directives/autofocusonshow
'
;
export
default
{
export
default
{
name
:
'
DeployFreeze
TimezoneDropdown
'
,
name
:
'
TimezoneDropdown
'
,
components
:
{
components
:
{
GlNewDropdown
,
GlNewDropdown
,
GlDropdownItem
,
GlDropdownItem
,
...
@@ -17,7 +17,7 @@ export default {
...
@@ -17,7 +17,7 @@ export default {
props
:
{
props
:
{
value
:
{
value
:
{
type
:
String
,
type
:
String
,
required
:
fals
e
,
required
:
tru
e
,
default
:
''
,
default
:
''
,
},
},
timezoneData
:
{
timezoneData
:
{
...
@@ -28,7 +28,7 @@ export default {
...
@@ -28,7 +28,7 @@ export default {
},
},
data
()
{
data
()
{
return
{
return
{
searchTerm
:
this
.
value
||
''
,
searchTerm
:
''
,
};
};
},
},
tranlations
:
{
tranlations
:
{
...
@@ -47,18 +47,13 @@ export default {
...
@@ -47,18 +47,13 @@ export default {
timezone
.
formattedTimezone
.
toLowerCase
().
includes
(
lowerCasedSearchTerm
),
timezone
.
formattedTimezone
.
toLowerCase
().
includes
(
lowerCasedSearchTerm
),
);
);
},
},
selectTimezoneLabel
()
{
select
ed
TimezoneLabel
()
{
return
this
.
value
||
__
(
'
Select timezone
'
);
return
this
.
value
||
__
(
'
Select timezone
'
);
},
},
},
},
watch
:
{
value
(
newVal
)
{
this
.
searchTerm
=
newVal
;
},
},
methods
:
{
methods
:
{
selectTimezone
(
selected
)
{
selectTimezone
(
selected
Timezone
)
{
this
.
$emit
(
'
selectTimezone
'
,
selected
);
this
.
$emit
(
'
input
'
,
selectedTimezone
);
this
.
searchTerm
=
''
;
this
.
searchTerm
=
''
;
},
},
isSelected
(
timezone
)
{
isSelected
(
timezone
)
{
...
@@ -81,9 +76,9 @@ export default {
...
@@ -81,9 +76,9 @@ export default {
<
template
>
<
template
>
<gl-new-dropdown
:text=
"value"
block
lazy
menu-class=
"gl-w-full!"
>
<gl-new-dropdown
:text=
"value"
block
lazy
menu-class=
"gl-w-full!"
>
<template
#button-content
>
<template
#button-content
>
<span
ref=
"buttonText"
class=
"gl-flex-grow-1"
:class=
"
{ 'gl-text-gray-500': !value }">
{{
<span
class=
"gl-flex-grow-1"
:class=
"
{ 'gl-text-gray-500': !value }">
selectTimezoneLabel
{{
selectedTimezoneLabel
}}
}}
</span>
</span>
<gl-icon
name=
"chevron-down"
/>
<gl-icon
name=
"chevron-down"
/>
</
template
>
</
template
>
...
@@ -100,7 +95,7 @@ export default {
...
@@ -100,7 +95,7 @@ export default {
/>
/>
{{ timezone.formattedTimezone }}
{{ timezone.formattedTimezone }}
</gl-dropdown-item>
</gl-dropdown-item>
<gl-dropdown-item
v-if=
"!filteredResults.length"
ref
=
"noMatchingResults"
>
<gl-dropdown-item
v-if=
"!filteredResults.length"
data-testid
=
"noMatchingResults"
>
{{ $options.tranlations.noResultsText }}
{{ $options.tranlations.noResultsText }}
</gl-dropdown-item>
</gl-dropdown-item>
</gl-new-dropdown>
</gl-new-dropdown>
...
...
spec/frontend/deploy_freeze/components/deploy_freeze_modal_spec.js
View file @
e58e0dcb
...
@@ -2,7 +2,7 @@ import Vuex from 'vuex';
...
@@ -2,7 +2,7 @@ import Vuex from 'vuex';
import
{
createLocalVue
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
createLocalVue
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlButton
,
GlModal
}
from
'
@gitlab/ui
'
;
import
{
GlButton
,
GlModal
}
from
'
@gitlab/ui
'
;
import
DeployFreezeModal
from
'
~/deploy_freeze/components/deploy_freeze_modal.vue
'
;
import
DeployFreezeModal
from
'
~/deploy_freeze/components/deploy_freeze_modal.vue
'
;
import
DeployFreezeTimezoneDropdown
from
'
~/deploy_freeze/components/deploy_freeze_
timezone_dropdown.vue
'
;
import
TimezoneDropdown
from
'
~/vue_shared/components/
timezone_dropdown.vue
'
;
import
createStore
from
'
~/deploy_freeze/store
'
;
import
createStore
from
'
~/deploy_freeze/store
'
;
import
{
mockDeployFreezePayload
,
mockTimezoneData
}
from
'
../mock_data
'
;
import
{
mockDeployFreezePayload
,
mockTimezoneData
}
from
'
../mock_data
'
;
...
@@ -41,7 +41,7 @@ describe('Deploy freeze modal', () => {
...
@@ -41,7 +41,7 @@ describe('Deploy freeze modal', () => {
wrapper
.
find
(
'
#deploy-freeze-start
'
).
trigger
(
'
input
'
);
wrapper
.
find
(
'
#deploy-freeze-start
'
).
trigger
(
'
input
'
);
wrapper
.
find
(
'
#deploy-freeze-end
'
).
trigger
(
'
input
'
);
wrapper
.
find
(
'
#deploy-freeze-end
'
).
trigger
(
'
input
'
);
wrapper
.
find
(
DeployFreeze
TimezoneDropdown
).
trigger
(
'
input
'
);
wrapper
.
find
(
TimezoneDropdown
).
trigger
(
'
input
'
);
};
};
afterEach
(()
=>
{
afterEach
(()
=>
{
...
...
spec/frontend/deploy_freeze/components/
deploy_freeze_
timezone_dropdown_spec.js
→
spec/frontend/deploy_freeze/components/timezone_dropdown_spec.js
View file @
e58e0dcb
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
DeployFreezeTimezoneDropdown
from
'
~/deploy_freeze/components/deploy_freeze_
timezone_dropdown.vue
'
;
import
TimezoneDropdown
from
'
~/vue_shared/components/
timezone_dropdown.vue
'
;
import
{
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
createStore
from
'
~/deploy_freeze/store
'
;
import
createStore
from
'
~/deploy_freeze/store
'
;
import
{
mockTimezoneData
}
from
'
../mock_data
'
;
import
{
mockTimezoneData
}
from
'
../mock_data
'
;
import
{
GlDropdownItem
}
from
'
@gitlab/ui
'
;
import
{
GlDropdownItem
,
GlNewDropdown
}
from
'
@gitlab/ui
'
;
const
localVue
=
createLocalVue
();
const
localVue
=
createLocalVue
();
localVue
.
use
(
Vuex
);
localVue
.
use
(
Vuex
);
...
@@ -13,20 +13,21 @@ describe('Deploy freeze timezone dropdown', () => {
...
@@ -13,20 +13,21 @@ describe('Deploy freeze timezone dropdown', () => {
let
wrapper
;
let
wrapper
;
let
store
;
let
store
;
const
createComponent
=
term
=>
{
const
createComponent
=
(
searchTerm
,
selectedTimezone
)
=>
{
store
=
createStore
({
store
=
createStore
({
projectId
:
'
8
'
,
projectId
:
'
8
'
,
timezoneData
:
mockTimezoneData
,
timezoneData
:
mockTimezoneData
,
});
});
store
.
state
.
timezoneData
=
mockTimezoneData
;
wrapper
=
shallowMount
(
TimezoneDropdown
,
{
wrapper
=
shallowMount
(
DeployFreezeTimezoneDropdown
,
{
store
,
store
,
localVue
,
localVue
,
propsData
:
{
propsData
:
{
value
:
term
,
value
:
selectedTimezone
,
timezoneData
:
mockTimezoneData
,
timezoneData
:
mockTimezoneData
,
},
},
});
});
wrapper
.
setData
({
searchTerm
});
};
};
const
findAllDropdownItems
=
()
=>
wrapper
.
findAll
(
GlDropdownItem
);
const
findAllDropdownItems
=
()
=>
wrapper
.
findAll
(
GlDropdownItem
);
...
@@ -37,7 +38,7 @@ describe('Deploy freeze timezone dropdown', () => {
...
@@ -37,7 +38,7 @@ describe('Deploy freeze timezone dropdown', () => {
wrapper
=
null
;
wrapper
=
null
;
});
});
describe
(
'
No
enviroment
s found
'
,
()
=>
{
describe
(
'
No
time zone
s found
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
createComponent
(
'
UTC timezone
'
);
createComponent
(
'
UTC timezone
'
);
});
});
...
@@ -68,13 +69,13 @@ describe('Deploy freeze timezone dropdown', () => {
...
@@ -68,13 +69,13 @@ describe('Deploy freeze timezone dropdown', () => {
});
});
it
(
'
should not display empty results message
'
,
()
=>
{
it
(
'
should not display empty results message
'
,
()
=>
{
expect
(
wrapper
.
find
(
{
ref
:
'
noMatchingResults
'
}
).
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
'
[data-testid="noMatchingResults"]
'
).
exists
()).
toBe
(
false
);
});
});
describe
(
'
Custom events
'
,
()
=>
{
describe
(
'
Custom events
'
,
()
=>
{
it
(
'
should emit
selectTimezone if an environment
is clicked
'
,
()
=>
{
it
(
'
should emit
input if a time zone
is clicked
'
,
()
=>
{
findDropdownItemByIndex
(
0
).
vm
.
$emit
(
'
click
'
);
findDropdownItemByIndex
(
0
).
vm
.
$emit
(
'
click
'
);
expect
(
wrapper
.
emitted
(
'
selectTimezone
'
)).
toEqual
([
expect
(
wrapper
.
emitted
(
'
input
'
)).
toEqual
([
[
[
{
{
formattedTimezone
:
'
[UTC -8] Alaska
'
,
formattedTimezone
:
'
[UTC -8] Alaska
'
,
...
@@ -85,4 +86,14 @@ describe('Deploy freeze timezone dropdown', () => {
...
@@ -85,4 +86,14 @@ describe('Deploy freeze timezone dropdown', () => {
});
});
});
});
});
});
describe
(
'
Selected time zone
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
(
''
,
'
Alaska
'
);
});
it
(
'
renders selected time zone as dropdown label
'
,
()
=>
{
expect
(
wrapper
.
find
(
GlNewDropdown
).
vm
.
text
).
toBe
(
'
Alaska
'
);
});
});
});
});
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