mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 00:32:52 +08:00
Can edit settings on the embedding page
This commit is contained in:
@ -1,9 +1,46 @@
|
||||
import computed from 'ember-addons/ember-computed-decorators';
|
||||
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
saved: false,
|
||||
embedding: null,
|
||||
|
||||
// show settings if we have at least one created host
|
||||
@computed('embedding.embeddable_hosts.@each.isCreated')
|
||||
showSecondary() {
|
||||
const hosts = this.get('embedding.embeddable_hosts');
|
||||
return hosts.length && hosts.findProperty('isCreated');
|
||||
},
|
||||
|
||||
@computed('embedding.base_url')
|
||||
embeddingCode(baseUrl) {
|
||||
|
||||
const html =
|
||||
`<div id='discourse-comments'></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
DiscourseEmbed = { discourseUrl: '${baseUrl}/',
|
||||
discourseEmbedUrl: 'REPLACE_ME' };
|
||||
|
||||
(function() {
|
||||
var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
|
||||
d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
|
||||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
|
||||
})();
|
||||
</script>`;
|
||||
|
||||
return html;
|
||||
},
|
||||
|
||||
actions: {
|
||||
saveChanges() {
|
||||
this.get('embedding').update({});
|
||||
const embedding = this.get('embedding');
|
||||
const updates = embedding.getProperties(embedding.get('fields'));
|
||||
|
||||
this.set('saved', false);
|
||||
this.get('embedding').update(updates).then(() => {
|
||||
this.set('saved', true);
|
||||
}).catch(popupAjaxError);
|
||||
},
|
||||
|
||||
addHost() {
|
||||
|
Reference in New Issue
Block a user