First stab at hooks activation error message
This commit is contained in:
parent
62c1326bd0
commit
249003d2ff
17
app/components/hook-switch.coffee
Normal file
17
app/components/hook-switch.coffee
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
`import Ember from 'ember'`
|
||||||
|
|
||||||
|
HookSwitchComponent = Ember.Component.extend
|
||||||
|
tagName: 'a'
|
||||||
|
classNames: ['travis-switch', 'switch']
|
||||||
|
classNameBindings: ['active']
|
||||||
|
activeBinding: "hook.active"
|
||||||
|
|
||||||
|
click: ->
|
||||||
|
hook = @get('hook')
|
||||||
|
hook.toggle().then( (->), =>
|
||||||
|
@toggleProperty('hook.active')
|
||||||
|
@sendAction('onToggleError', hook)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
`export default HookSwitchComponent`
|
11
app/components/hooks-list-item.coffee
Normal file
11
app/components/hooks-list-item.coffee
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
`import Ember from 'ember'`
|
||||||
|
|
||||||
|
HooksListItemComponent = Ember.Component.extend
|
||||||
|
tagName: 'li'
|
||||||
|
classNames: ['row']
|
||||||
|
classNameBindings: ['hook.active:active']
|
||||||
|
actions:
|
||||||
|
handleToggleError: ->
|
||||||
|
@set("errorMessage", "There was an error")
|
||||||
|
|
||||||
|
`export default HooksListItemComponent`
|
|
@ -73,20 +73,7 @@
|
||||||
<div>
|
<div>
|
||||||
<ul class="profile-hooklist">
|
<ul class="profile-hooklist">
|
||||||
{{#each hook in hooks}}
|
{{#each hook in hooks}}
|
||||||
<li {{bind-attr class="hook.active:active :row"}}>
|
{{hooks-list-item hook=hook}}
|
||||||
<div class="columns">
|
|
||||||
{{travis-switch action="toggle" target=hook toggleAutomatically="false"}}
|
|
||||||
{{!-- <button class="switch is-on"></button> --}}
|
|
||||||
{{#if hook.isSaving}}
|
|
||||||
<span class="sync-spinner sync-spinner--grey"><i></i><i></i><i></i></span>
|
|
||||||
{{else}}
|
|
||||||
{{#link-to "settings" hook.ownerName hook.name class="profile-settings" title="Repository settings"}}<span class="icon icon--cog"></span>{{/link-to}}
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
|
||||||
<a {{bind-attr href="hook.urlGithub"}} rel="nofollow" class="profile-repo columns">
|
|
||||||
{{hook.slug}}
|
|
||||||
<span>{{hook.description}}</span></a>
|
|
||||||
</li>
|
|
||||||
{{else}}
|
{{else}}
|
||||||
<li>
|
<li>
|
||||||
{{#if hooksWithoutAdmin.length}}
|
{{#if hooksWithoutAdmin.length}}
|
||||||
|
|
6
app/templates/components/hook-switch.hbs
Normal file
6
app/templates/components/hook-switch.hbs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<span class="on">
|
||||||
|
ON
|
||||||
|
</span>
|
||||||
|
<span class="off">
|
||||||
|
OFF
|
||||||
|
</span>
|
18
app/templates/components/hooks-list-item.hbs
Normal file
18
app/templates/components/hooks-list-item.hbs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<div class="columns">
|
||||||
|
{{hook-switch hook=hook onToggleError="handleToggleError"}}
|
||||||
|
{{!-- <button class="switch is-on"></button> --}}
|
||||||
|
{{#if hook.isSaving}}
|
||||||
|
<span class="sync-spinner sync-spinner--grey"><i></i><i></i><i></i></span>
|
||||||
|
{{else}}
|
||||||
|
{{#link-to "settings" hook.ownerName hook.name class="profile-settings" title="Repository settings"}}<span class="icon icon--cog"></span>{{/link-to}}
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
<a {{bind-attr href="hook.urlGithub"}} rel="nofollow" class="profile-repo columns">
|
||||||
|
{{hook.slug}}
|
||||||
|
<span>{{hook.description}}</span></a>
|
||||||
|
|
||||||
|
{{#if errorMessage}}
|
||||||
|
<div class="error">
|
||||||
|
{{errorMessage}}
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
17
tests/unit/components/hook-switch-test.coffee
Normal file
17
tests/unit/components/hook-switch-test.coffee
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
`import { test, moduleForComponent } from 'ember-qunit'`
|
||||||
|
|
||||||
|
moduleForComponent 'hook-switch', 'HookSwitchComponent', {
|
||||||
|
# specify the other units that are required for this test
|
||||||
|
# needs: ['component:foo', 'helper:bar']
|
||||||
|
}
|
||||||
|
|
||||||
|
test 'it renders', ->
|
||||||
|
expect 2
|
||||||
|
|
||||||
|
# creates the component instance
|
||||||
|
component = @subject()
|
||||||
|
equal component._state, 'preRender'
|
||||||
|
|
||||||
|
# appends the component to the page
|
||||||
|
@append()
|
||||||
|
equal component._state, 'inDOM'
|
17
tests/unit/components/hooks-list-item-test.coffee
Normal file
17
tests/unit/components/hooks-list-item-test.coffee
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
`import { test, moduleForComponent } from 'ember-qunit'`
|
||||||
|
|
||||||
|
moduleForComponent 'hooks-list-item', 'HooksListItemComponent', {
|
||||||
|
# specify the other units that are required for this test
|
||||||
|
# needs: ['component:foo', 'helper:bar']
|
||||||
|
}
|
||||||
|
|
||||||
|
test 'it renders', ->
|
||||||
|
expect 2
|
||||||
|
|
||||||
|
# creates the component instance
|
||||||
|
component = @subject()
|
||||||
|
equal component._state, 'preRender'
|
||||||
|
|
||||||
|
# appends the component to the page
|
||||||
|
@append()
|
||||||
|
equal component._state, 'inDOM'
|
Loading…
Reference in New Issue
Block a user