add general settings functionality
This commit is contained in:
parent
dd4580f151
commit
e7aa74872d
|
@ -4,23 +4,18 @@ SettingsSwitchComponent = Ember.Component.extend
|
||||||
|
|
||||||
tagName: 'a'
|
tagName: 'a'
|
||||||
classNames: ['switch']
|
classNames: ['switch']
|
||||||
classNameBindings: ['_active:active']
|
classNameBindings: ['active']
|
||||||
|
|
||||||
# TODO: how to handle overriding properties to
|
|
||||||
# avoid naming it _action?
|
|
||||||
_active: (->
|
|
||||||
@get('target.active') || @get('active')
|
|
||||||
).property('target.active', 'active')
|
|
||||||
|
|
||||||
click: ->
|
click: ->
|
||||||
target = @get('target')
|
return if @get('isSaving')
|
||||||
if @get('toggleAutomatically') != 'false'
|
@set('isSaving', true)
|
||||||
if target
|
@toggleProperty('active')
|
||||||
@set('target.active', !@get('target.active'))
|
setting = {}
|
||||||
else
|
setting[@get('key')] = @get('active')
|
||||||
@set('active', !@get('active'))
|
@get('repo').saveSettings(setting).then =>
|
||||||
# allow for bindings to propagate
|
@set('isSaving', false)
|
||||||
Ember.run.next this, ->
|
, =>
|
||||||
@sendAction('action', target)
|
@set('isSaving', false)
|
||||||
|
Travis.flash(error: 'There was an error while saving settings. Please try again.')
|
||||||
|
|
||||||
`export default SettingsSwitchComponent`
|
`export default SettingsSwitchComponent`
|
||||||
|
|
|
@ -29,6 +29,7 @@ Route = TravisRoute.extend
|
||||||
|
|
||||||
model: () ->
|
model: () ->
|
||||||
return Ember.RSVP.hash({
|
return Ember.RSVP.hash({
|
||||||
|
settings: @modelFor('repo').fetchSettings(),
|
||||||
envVars: this.fetchEnvVars(),
|
envVars: this.fetchEnvVars(),
|
||||||
sshKey: this.fetchSshKey(),
|
sshKey: this.fetchSshKey(),
|
||||||
customSshKey: this.fetchCustomSshKey()
|
customSshKey: this.fetchCustomSshKey()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
%tooltip
|
%tooltip
|
||||||
&:hover
|
&:hover .tooltip-bubble,
|
||||||
.tooltip-bubble
|
&:hover + .tooltip-bubble
|
||||||
transform: translateY(0)
|
transform: translateY(0)
|
||||||
opacity: 1
|
opacity: 1
|
||||||
|
|
||||||
|
|
|
@ -6,4 +6,7 @@
|
||||||
OFF
|
OFF
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<span class="label">Some label text</span>
|
<span class="label">{{description}}</span>
|
||||||
|
{{#if isSaving}}
|
||||||
|
{{loading-indicator}}
|
||||||
|
{{/if}}
|
|
@ -4,12 +4,12 @@
|
||||||
<h2 class="small-title">General Settings</h2>
|
<h2 class="small-title">General Settings</h2>
|
||||||
|
|
||||||
<ul class="settings-list--columns">
|
<ul class="settings-list--columns">
|
||||||
<li>{{settings-switch}}</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>
|
<li>
|
||||||
<div class="settings-input"><input type="text" pattern="/^[0-9]+$/" value="4"></div><span class="label">Concurrent jobs</span>
|
<div class="settings-input"><input type="text" pattern="/^[0-9]+$/" value="4"></div><span class="label">Concurrent jobs</span>
|
||||||
</li>
|
</li>
|
||||||
<li>{{settings-switch}}</li>
|
<li>{{settings-switch active=model.settings.build_pushes repo=repo description="Build pushes" key="build_pushes"}}</li>
|
||||||
<li>{{settings-switch}}</li>
|
<li>{{settings-switch active=model.settings.build_pull_requests repo=repo description="Build pull requests" key="build_pull_requests"}}</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -53,10 +53,10 @@ test('it deletes a custom key', function(assert) {
|
||||||
|
|
||||||
this.set('key', key);
|
this.set('key', key);
|
||||||
this.render(hbs`{{ssh-key key=key sshKeyDeleted="sshKeyDeleted"}}`);
|
this.render(hbs`{{ssh-key key=key sshKeyDeleted="sshKeyDeleted"}}`);
|
||||||
this.on('sshKeyDeleted', function() {})
|
this.on('sshKeyDeleted', function() {});
|
||||||
|
|
||||||
this.$('.ssh-key-action a').click();
|
this.$('.ssh-key-action a').click();
|
||||||
|
|
||||||
assert.ok(key.get('isDeleted'), 'key should be deleted')
|
assert.ok(key.get('isDeleted'), 'key should be deleted');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user