add compontents for settings
This commit is contained in:
parent
c4bc5a5f8b
commit
1072577ce0
55
app/components/env-var.coffee
Normal file
55
app/components/env-var.coffee
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
`import Ember from 'ember'`
|
||||||
|
|
||||||
|
EnvVarComponent = Ember.Component.extend
|
||||||
|
|
||||||
|
|
||||||
|
name: DS.attr()
|
||||||
|
value: DS.attr()
|
||||||
|
public: DS.attr('boolean')
|
||||||
|
|
||||||
|
repo: DS.belongsTo('repo', async: true)
|
||||||
|
|
||||||
|
isEditing: false
|
||||||
|
isDeleting: false
|
||||||
|
|
||||||
|
validates:
|
||||||
|
name: ['presence']
|
||||||
|
|
||||||
|
actionType: 'Save'
|
||||||
|
showValueField: Ember.computed.alias('public')
|
||||||
|
|
||||||
|
value: ( (key, value) ->
|
||||||
|
if arguments.length == 2
|
||||||
|
@get('model').set('value', value)
|
||||||
|
value
|
||||||
|
else if @get('public')
|
||||||
|
@get('model.value')
|
||||||
|
else
|
||||||
|
'••••••••••••••••'
|
||||||
|
).property('model.value', 'public')
|
||||||
|
|
||||||
|
actions:
|
||||||
|
delete: ->
|
||||||
|
return if @get('isDeleting')
|
||||||
|
@set('isDeleting', true)
|
||||||
|
|
||||||
|
@get('model').destroyRecord()
|
||||||
|
|
||||||
|
edit: ->
|
||||||
|
@set('isEditing', true)
|
||||||
|
|
||||||
|
cancel: ->
|
||||||
|
@set('isEditing', false)
|
||||||
|
@get('model').revert()
|
||||||
|
|
||||||
|
save: ->
|
||||||
|
return if @get('isSaving')
|
||||||
|
|
||||||
|
if @isValid()
|
||||||
|
env_var = @get('model')
|
||||||
|
|
||||||
|
# TODO: handle errors
|
||||||
|
env_var.save().then =>
|
||||||
|
@set('isEditing', false)
|
||||||
|
|
||||||
|
`export default EnvVarComponent`
|
26
app/components/settings-switch.coffee
Normal file
26
app/components/settings-switch.coffee
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
`import Ember from 'ember'`
|
||||||
|
|
||||||
|
SettingsSwitchComponent = Ember.Component.extend
|
||||||
|
|
||||||
|
tagName: 'a'
|
||||||
|
classNames: ['settings-switch']
|
||||||
|
classNameBindings: ['_active:active']
|
||||||
|
|
||||||
|
# TODO: how to handle overriding properties to
|
||||||
|
# avoid naming it _action?
|
||||||
|
_active: (->
|
||||||
|
@get('target.active') || @get('active')
|
||||||
|
).property('target.active', 'active')
|
||||||
|
|
||||||
|
click: ->
|
||||||
|
target = @get('target')
|
||||||
|
if @get('toggleAutomatically') != 'false'
|
||||||
|
if target
|
||||||
|
@set('target.active', !@get('target.active'))
|
||||||
|
else
|
||||||
|
@set('active', !@get('active'))
|
||||||
|
# allow for bindings to propagate
|
||||||
|
Ember.run.next this, ->
|
||||||
|
@sendAction('action', target)
|
||||||
|
|
||||||
|
`export default SettingsSwitchComponent`
|
5
app/components/ssh-key.coffee
Normal file
5
app/components/ssh-key.coffee
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
`import Ember from 'ember'`
|
||||||
|
|
||||||
|
SshKeyComponent = Ember.Component.extend()
|
||||||
|
|
||||||
|
`export default SshKeyComponent`
|
1
app/templates/components/env-var.hbs
Normal file
1
app/templates/components/env-var.hbs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<p>this is an env-var</p>
|
9
app/templates/components/settings-switch.hbs
Normal file
9
app/templates/components/settings-switch.hbs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<div>
|
||||||
|
<span class="on">
|
||||||
|
ON
|
||||||
|
</span>
|
||||||
|
<span class="off">
|
||||||
|
OFF
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<span class="label">Some label text</span>
|
1
app/templates/components/ssh-key.hbs
Normal file
1
app/templates/components/ssh-key.hbs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<p>This is an ssh key</p>
|
17
tests/unit/components/env-var-test.coffee
Normal file
17
tests/unit/components/env-var-test.coffee
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
`import { test, moduleForComponent } from 'ember-qunit'`
|
||||||
|
|
||||||
|
moduleForComponent 'env-var', {
|
||||||
|
# specify the other units that are required for this test
|
||||||
|
# needs: ['component:foo', 'helper:bar']
|
||||||
|
}
|
||||||
|
|
||||||
|
test 'it renders', (assert) ->
|
||||||
|
assert.expect 2
|
||||||
|
|
||||||
|
# creates the component instance
|
||||||
|
component = @subject()
|
||||||
|
assert.equal component._state, 'preRender'
|
||||||
|
|
||||||
|
# renders the component to the page
|
||||||
|
@render()
|
||||||
|
assert.equal component._state, 'inDOM'
|
17
tests/unit/components/settings-switch-test.coffee
Normal file
17
tests/unit/components/settings-switch-test.coffee
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
`import { test, moduleForComponent } from 'ember-qunit'`
|
||||||
|
|
||||||
|
moduleForComponent 'settings-switch', {
|
||||||
|
# specify the other units that are required for this test
|
||||||
|
# needs: ['component:foo', 'helper:bar']
|
||||||
|
}
|
||||||
|
|
||||||
|
test 'it renders', (assert) ->
|
||||||
|
assert.expect 2
|
||||||
|
|
||||||
|
# creates the component instance
|
||||||
|
component = @subject()
|
||||||
|
assert.equal component._state, 'preRender'
|
||||||
|
|
||||||
|
# renders the component to the page
|
||||||
|
@render()
|
||||||
|
assert.equal component._state, 'inDOM'
|
17
tests/unit/components/ssh-key-test.coffee
Normal file
17
tests/unit/components/ssh-key-test.coffee
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
`import { test, moduleForComponent } from 'ember-qunit'`
|
||||||
|
|
||||||
|
moduleForComponent 'ssh-key', {
|
||||||
|
# specify the other units that are required for this test
|
||||||
|
# needs: ['component:foo', 'helper:bar']
|
||||||
|
}
|
||||||
|
|
||||||
|
test 'it renders', (assert) ->
|
||||||
|
assert.expect 2
|
||||||
|
|
||||||
|
# creates the component instance
|
||||||
|
component = @subject()
|
||||||
|
assert.equal component._state, 'preRender'
|
||||||
|
|
||||||
|
# renders the component to the page
|
||||||
|
@render()
|
||||||
|
assert.equal component._state, 'inDOM'
|
Loading…
Reference in New Issue
Block a user