FEATURE: Multiple embeddable hosts
- Also refactors two site settings components into one, with tests
This commit is contained in:
@@ -2,7 +2,7 @@ import BufferedContent from 'discourse/mixins/buffered-content';
|
||||
import ScrollTop from 'discourse/mixins/scroll-top';
|
||||
import SiteSetting from 'admin/models/site-setting';
|
||||
|
||||
const CustomTypes = ['bool', 'enum', 'list', 'url_list'];
|
||||
const CustomTypes = ['bool', 'enum', 'list', 'url_list', 'host_list'];
|
||||
|
||||
export default Ember.Component.extend(BufferedContent, ScrollTop, {
|
||||
classNameBindings: [':row', ':setting', 'setting.overridden', 'typeClass'],
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
export default Ember.Component.extend({
|
||||
_setupUrls: function() {
|
||||
const value = this.get('value');
|
||||
this.set('urls', (value && value.length) ? value.split("\n") : []);
|
||||
}.on('init').observes('value'),
|
||||
|
||||
_urlsChanged: function() {
|
||||
this.set('value', this.get('urls').join("\n"));
|
||||
}.observes('urls.@each'),
|
||||
|
||||
urlInvalid: Ember.computed.empty('newUrl'),
|
||||
|
||||
keyDown(e) {
|
||||
if (e.keyCode === 13) {
|
||||
this.send('addUrl');
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
addUrl() {
|
||||
if (this.get('urlInvalid')) { return; }
|
||||
|
||||
this.get('urls').addObject(this.get('newUrl'));
|
||||
this.set('newUrl', '');
|
||||
},
|
||||
|
||||
removeUrl(url) {
|
||||
const urls = this.get('urls');
|
||||
urls.removeObject(url);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
export default Ember.Component.extend({
|
||||
classNameBindings: [':value-list'],
|
||||
|
||||
_setupCollection: function() {
|
||||
const values = this.get('values');
|
||||
this.set('collection', (values && values.length) ? values.split("\n") : []);
|
||||
}.on('init').observes('values'),
|
||||
|
||||
_collectionChanged: function() {
|
||||
this.set('values', this.get('collection').join("\n"));
|
||||
}.observes('collection.@each'),
|
||||
|
||||
inputInvalid: Ember.computed.empty('newValue'),
|
||||
|
||||
keyDown(e) {
|
||||
if (e.keyCode === 13) {
|
||||
this.send('addValue');
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
addValue() {
|
||||
if (this.get('inputInvalid')) { return; }
|
||||
|
||||
this.get('collection').addObject(this.get('newValue'));
|
||||
this.set('newValue', '');
|
||||
},
|
||||
|
||||
removeValue(value) {
|
||||
const collection = this.get('collection');
|
||||
collection.removeObject(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,18 +0,0 @@
|
||||
{{#if urls}}
|
||||
<div class='urls'>
|
||||
{{#each url in urls}}
|
||||
<div class='url'>
|
||||
{{d-button action="removeUrl"
|
||||
actionParam=url
|
||||
icon="times"
|
||||
class="btn-small no-text"}}
|
||||
<a href="{{unbound url}}" target="_blank">{{url}}</a>
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class='input'>
|
||||
{{text-field value=newUrl placeholderKey="admin.site_settings.add_url"}}
|
||||
{{d-button action="addUrl" icon="plus" class="btn-primary btn-small no-text" disabled=urlInvalid}}
|
||||
</div>
|
||||
@@ -0,0 +1,18 @@
|
||||
{{#if collection}}
|
||||
<div class='values'>
|
||||
{{#each collection as |value|}}
|
||||
<div class='value'>
|
||||
{{d-button action="removeValue"
|
||||
actionParam=value
|
||||
icon="times"
|
||||
class="btn-small no-text"}}
|
||||
{{value}}
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class='input'>
|
||||
{{text-field value=newValue placeholderKey=addKey}}
|
||||
{{d-button action="addValue" icon="plus" class="btn-primary btn-small no-text" disabled=inputInvalid}}
|
||||
</div>
|
||||
@@ -0,0 +1,3 @@
|
||||
{{value-list values=buffered.value addKey="admin.site_settings.add_host"}}
|
||||
{{setting-validation-message message=validationMessage}}
|
||||
<div class='desc'>{{{unbound setting.description}}}</div>
|
||||
@@ -1,3 +1,3 @@
|
||||
{{url-list value=buffered.value}}
|
||||
{{value-list value=buffered.value addKey="admin.site_settings.add_url"}}
|
||||
{{setting-validation-message message=validationMessage}}
|
||||
<div class='desc'>{{{unbound setting.description}}}</div>
|
||||
|
||||
Reference in New Issue
Block a user