Thanks, Robin. Your tip was just what I needed. ![]()
This works, but I wonder if the direct ajax call is needed (when I took the connector path, I had access to the Post but not the Revision; now that I took the component path, I have access to the Revision, but not the Post
)
{{! templates/connectors/revision-user-details-after/reply-to-editor.hbs }}
{{reply-to-editor
postId=model.post_id
postVersion=model.current_version
revisionAuthor=model.username
}}
{{! templates/components/reply-to-editor.hbs }}
{{#if isVisible}}
{{d-button
action=(action 'replyToEditor')
label='test'
}}
{{/if}}
{{! javascripts/discourse/components/reply-to-editor.js.es6 }}
import { ajax } from 'discourse/lib/ajax';
export default Ember.Component.extend({
isVisible: true,
didRender() {
if (!this.get('postId')) return;
ajax(`/posts/${this.get('postId')}`).then((post) => {
// only show the button if the revision author is not the post author
this.set('isVisible', this.get('revisionAuthor') !== post.username);
});
}
});