Move concurrent build limit flow into a component
This commit is contained in:
parent
7817cd47e4
commit
868995bf09
37
app/components/limit-concurrent-builds.coffee
Normal file
37
app/components/limit-concurrent-builds.coffee
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
`import Ember from 'ember'`
|
||||||
|
|
||||||
|
LimitConcurrentBuildsComponent = Ember.Component.extend
|
||||||
|
description: (->
|
||||||
|
description = "Limit concurrent jobs"
|
||||||
|
if @get('enabled')
|
||||||
|
description += " "
|
||||||
|
description
|
||||||
|
).property('enabled')
|
||||||
|
|
||||||
|
|
||||||
|
actions:
|
||||||
|
toggle: ->
|
||||||
|
unless @get('enabled')
|
||||||
|
return if @get('value') == 0
|
||||||
|
return if @get('isSaving')
|
||||||
|
@set('isSaving', true)
|
||||||
|
|
||||||
|
savingFinished = =>
|
||||||
|
@set('isSaving', false)
|
||||||
|
|
||||||
|
@get('repo').saveSettings(maximum_number_of_builds: 0).then(savingFinished, savingFinished)
|
||||||
|
@set('value', 0)
|
||||||
|
|
||||||
|
limitChanged: ->
|
||||||
|
repo = @get('repo')
|
||||||
|
limit = parseInt(@get('value'))
|
||||||
|
if limit
|
||||||
|
@set('isSaving', true)
|
||||||
|
savingFinished = =>
|
||||||
|
@set('isSaving', false)
|
||||||
|
|
||||||
|
repo.saveSettings(maximum_number_of_builds: limit).
|
||||||
|
then(savingFinished, savingFinished)
|
||||||
|
|
||||||
|
|
||||||
|
`export default LimitConcurrentBuildsComponent`
|
|
@ -1,13 +1,6 @@
|
||||||
`import Ember from 'ember'`
|
`import Ember from 'ember'`
|
||||||
|
|
||||||
SettingsController = Ember.Controller.extend
|
SettingsController = Ember.Controller.extend
|
||||||
concurrentBuildsLimitDescription: (->
|
|
||||||
description = "Limit concurrent jobs"
|
|
||||||
if @get('concurrentBuildsLimit')
|
|
||||||
description += " "
|
|
||||||
description
|
|
||||||
).property('concurrentBuildsLimit')
|
|
||||||
|
|
||||||
envVars: Ember.computed.filterBy('model.envVars', 'isNew', false)
|
envVars: Ember.computed.filterBy('model.envVars', 'isNew', false)
|
||||||
|
|
||||||
actions:
|
actions:
|
||||||
|
@ -17,26 +10,4 @@ SettingsController = Ember.Controller.extend
|
||||||
sshKeyDeleted: ->
|
sshKeyDeleted: ->
|
||||||
@set('model.customSshKey', null)
|
@set('model.customSshKey', null)
|
||||||
|
|
||||||
concurrentBuildsLimitChanged: ->
|
|
||||||
unless @get('concurrentBuildsLimit')
|
|
||||||
return if @get('isSaving')
|
|
||||||
@set('isSaving', true)
|
|
||||||
|
|
||||||
savingFinished = =>
|
|
||||||
@set('isSaving', false)
|
|
||||||
|
|
||||||
@get('repo').saveSettings(maximum_number_of_builds: 0).then(savingFinished, savingFinished)
|
|
||||||
@set('model.settings.maximum_number_of_builds', 0)
|
|
||||||
|
|
||||||
concurrentBuildsLimitValueChanged: ->
|
|
||||||
repo = @get('repo')
|
|
||||||
concurrentBuildsLimit = parseInt(@get('model.settings.maximum_number_of_builds'))
|
|
||||||
if concurrentBuildsLimit
|
|
||||||
@set('isSaving', true)
|
|
||||||
savingFinished = =>
|
|
||||||
@set('isSaving', false)
|
|
||||||
|
|
||||||
repo.saveSettings(maximum_number_of_builds: concurrentBuildsLimit).
|
|
||||||
then(savingFinished, savingFinished)
|
|
||||||
|
|
||||||
`export default SettingsController`
|
`export default SettingsController`
|
||||||
|
|
7
app/templates/components/limit-concurrent-builds.hbs
Normal file
7
app/templates/components/limit-concurrent-builds.hbs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{{travis-switch active=enabled description=description action="toggle"}}
|
||||||
|
{{#if enabled}}
|
||||||
|
{{input pattern="/^[0-9]+$/" value=value on="key-up" action="limitChanged"}}
|
||||||
|
{{/if}}
|
||||||
|
{{#if isSaving}}
|
||||||
|
{{loading-indicator}}
|
||||||
|
{{/if}}
|
|
@ -5,15 +5,7 @@
|
||||||
|
|
||||||
<ul class="settings-list--columns">
|
<ul class="settings-list--columns">
|
||||||
<li>{{settings-switch active=model.settings.builds_only_with_travis_yml repo=repo description="Build only if .travis.yml is present" key="builds_only_with_travis_yml"}}</li>
|
<li>{{settings-switch active=model.settings.builds_only_with_travis_yml repo=repo description="Build only if .travis.yml is present" key="builds_only_with_travis_yml"}}</li>
|
||||||
<li>{{travis-switch active=concurrentBuildsLimit description=concurrentBuildsLimitDescription action="concurrentBuildsLimitChanged"}}
|
<li>{{limit-concurrent-builds value=model.settings.maximum_number_of_builds enabled=concurrentBuildsLimit repo=repo}}</li>
|
||||||
|
|
||||||
{{#if concurrentBuildsLimit}}
|
|
||||||
{{input pattern="/^[0-9]+$/" value=model.settings.maximum_number_of_builds on="key-up" action="concurrentBuildsLimitValueChanged" class="settings-concurrent"}}
|
|
||||||
{{/if}}
|
|
||||||
{{#if isSaving}}
|
|
||||||
{{loading-indicator inline=true}}
|
|
||||||
{{/if}}
|
|
||||||
</li>
|
|
||||||
<li>{{settings-switch active=model.settings.build_pushes repo=repo description="Build pushes" key="build_pushes"}}</li>
|
<li>{{settings-switch active=model.settings.build_pushes repo=repo description="Build pushes" key="build_pushes"}}</li>
|
||||||
<li>{{settings-switch active=model.settings.build_pull_requests repo=repo description="Build pull requests" key="build_pull_requests"}}</li>
|
<li>{{settings-switch active=model.settings.build_pull_requests repo=repo description="Build pull requests" key="build_pull_requests"}}</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user