(window.webpackJsonp=window.webpackJsonp||[]).push([[77],{29783:function(e,t,o){"use strict";o.r(t),function(e){o.d(t,"default",(function(){return E}));var s,r=o(2),a=o.n(r),n=o(2353),i=o(1656),l=o(7326),h=o(2825),c=o.n(h),g=o(29769),d=o(7121),p=o(5929),u=o(9),f=o(7124),m=o(29772),C=o(29771),S=o(24818);let E=Object(n.observer)(s=class extends r.Component{constructor(t){super(t),this.state={releaseGroup:{},isLoading:!0,loadingErr:!1},this.fetchChangelogs=this.fetchChangelogs.bind(this),this.handleScroll=this.handleScroll.bind(this),this.handleScrollDebounced=e.debounce(this.handleScroll,100),this.loadMoreChanges=this.loadMoreChanges.bind(this)}componentDidMount(){this.isReleaseChanging=Object(i.reaction)((()=>e.get(this.props,"contextData.model.activeRelease")),(()=>{this.fetchChangelogs()}),{fireImmediately:!0})}componentWillUnmount(){this.isReleaseChanging&&this.isReleaseChanging()}getRefreshTextClass(){return c()({"release-changelog-context-view-wrapper__refresh-button":!0,"release-changelog-context-view-wrapper__refresh-button__loading":this.state.isLoading})}getRefreshIconText(){return!Object(p.getStore)("SyncStatusStore").isSocketConnected?"Get online to perform this action":this.state.isLoading?"Please wait...":"Refresh changelog"}fetchChangelogs(){this.setState({releaseGroup:{},isLoading:!0,loadingErr:!1}),this.props.controller.fetchChangelog(e.get(this.props,"contextData.model",{})).then((e=>{this.setState({releaseGroup:e,isLoading:!1})})).catch((e=>{this.setState({isLoading:!1,loadingErr:!0})}))}handleScroll(){let t=this.refs.changelog_feed;if(t.scrollHeight-(t.scrollTop+t.offsetHeight)<=5){if(!e.isEmpty(e.get(this.props,"controller.loadMoreError"))||e.get(this.props,"controller.isLoaded")||!e.get(this.props,"controller.loadMore"))return;this.loadMoreChanges()}}loadMoreChanges(){return this.props.controller.loadMore().then((t=>{e.isEmpty(t)||this.setState({releaseGroup:t,isLoading:!1})}))}renderChangelog(){const t=!Object(p.getStore)("SyncStatusStore").isSocketConnected;if(t&&this.state.isLoading)return a.a.createElement(C.default,null);if(this.state.isLoading)return a.a.createElement(d.default,null);if(this.state.loadingErr)return a.a.createElement(m.default,{onRetry:this.fetchChangelogs});const o=e.get(this.props,"contextData.model",{}),s=e.get(this.props,"controller.isLoadingMore"),r=e.get(this.props,"controller.loadMoreError",{});return a.a.createElement(a.a.Fragment,null,a.a.createElement("div",{className:"release-changelog",ref:"changelog_feed",onScroll:this.handleScrollDebounced},a.a.createElement(g.default,{model:o,release:this.state.releaseGroup,promoteTab:e.get(this.props,"contextData.promoteTab"),isLastRelease:!0})),(s||!e.isEmpty(r))&&a.a.createElement(S.LoadFeed,{error:r,key:"loading-more",isLoading:s,isOffline:t,onRetry:this.loadMoreChanges}))}render(){return a.a.createElement("div",{className:"release-changelog-context-view-wrapper"},a.a.createElement(l.ContextBarViewHeader,{title:this.props.title,onClose:this.props.onClose},a.a.createElement(f.Button,{className:this.getRefreshTextClass(),tooltip:this.getRefreshIconText(),tooltipImmediate:!0,type:"tertiary",onClick:this.fetchChangelogs,disabled:this.state.isLoading||!Object(p.getStore)("SyncStatusStore").isSocketConnected},a.a.createElement(u.Icon,{name:"icon-action-refresh-stroke"}))),this.renderChangelog())}})||s}.call(this,o(2753))}}]);