Migrate history modal to components

This commit is contained in:
Robin Ward 2016-11-15 16:37:31 -05:00
parent 33fd84c990
commit 6387acc649
2 changed files with 11 additions and 19 deletions

View File

@ -1,17 +1,10 @@
import ModalBodyView from "discourse/views/modal-body";
import ClickTrack from 'discourse/lib/click-track';
import { selectedText } from 'discourse/lib/utilities';
export default ModalBodyView.extend({
templateName: 'modal/history',
title: I18n.t('history'),
export default Ember.Component.extend({
didInsertElement() {
this._super();
resizeModal: function(){
const viewPortHeight = $(window).height();
this.$(".modal-body").css("max-height", Math.floor(0.8 * viewPortHeight) + "px");
}.on("didInsertElement"),
_inserted: function() {
this.$().on('mouseup.discourse-redirect', '#revisions a', function(e) {
// bypass if we are selecting stuff
const selection = window.getSelection && window.getSelection();
@ -26,11 +19,10 @@ export default ModalBodyView.extend({
return ClickTrack.trackClick(e);
});
},
}.on('didInsertElement'),
// This view is being removed. Shut down operations
_destroyed: function() {
willDestroyElement() {
this._super();
this.$().off('mouseup.discourse-redirect', '#revisions a');
}.on('willDestroyElement')
}
});

View File

@ -1,4 +1,4 @@
<div class="modal-body">
{{#d-modal-body title="history" maxHeight="80%"}}
<div>
<div id="revision-controls">
{{d-button action="loadFirstVersion" icon="fast-backward" title="post.revisions.controls.first" disabled=loadFirstDisabled}}
@ -89,9 +89,9 @@
{{plugin-outlet "post-revisions"}}
<div class="row">
{{#links-redirect class="row"}}
{{{bodyDiff}}}
</div>
{{/links-redirect}}
{{#if displayRevert}}
{{d-button action="revertToVersion" icon="undo" label="post.revisions.controls.revert" class="btn-danger" disabled=loading}}
@ -103,4 +103,4 @@
{{d-button action="showVersion" icon="eye" label="post.revisions.controls.show" disabled=loading}}
{{/if}}
</div>
</div>
{{/d-modal-body}}