mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* Updating client dependancies. Switching to using yarn. * Updating React * Moving pure components to using function syntax (performance gains with newer react version) * Updating client dependancies. * Ignore .yarninstall * Enabling pre-lockfile because it's the entire point of using yarn. * Removing old webpack config * Moving to new prop-types * Fixing ESLint Errors * Updating jest snapshots. * Cleaning up package.json
96 lines
3.0 KiB
JavaScript
96 lines
3.0 KiB
JavaScript
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
import $ from 'jquery';
|
|
import PropTypes from 'prop-types';
|
|
import React from 'react';
|
|
|
|
import ChannelHeader from 'components/channel_header.jsx';
|
|
import PostFocusViewController from 'components/post_view/post_focus_view_controller.jsx';
|
|
|
|
import ChannelStore from 'stores/channel_store.jsx';
|
|
import TeamStore from 'stores/team_store.jsx';
|
|
|
|
import {Link} from 'react-router/es6';
|
|
import {FormattedMessage} from 'react-intl';
|
|
|
|
export default class PermalinkView extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
|
|
this.getStateFromStores = this.getStateFromStores.bind(this);
|
|
this.isStateValid = this.isStateValid.bind(this);
|
|
this.updateState = this.updateState.bind(this);
|
|
|
|
this.state = this.getStateFromStores(props);
|
|
}
|
|
getStateFromStores(props) {
|
|
const postId = props.params.postid;
|
|
const channel = ChannelStore.getCurrent();
|
|
const channelId = channel ? channel.id : '';
|
|
const channelName = channel ? channel.name : '';
|
|
const team = TeamStore.getCurrent();
|
|
const teamName = team ? team.name : '';
|
|
return {
|
|
channelId,
|
|
channelName,
|
|
teamName,
|
|
postId
|
|
};
|
|
}
|
|
isStateValid() {
|
|
return this.state.channelId !== '' && this.state.teamName;
|
|
}
|
|
updateState() {
|
|
this.setState(this.getStateFromStores(this.props));
|
|
}
|
|
componentDidMount() {
|
|
ChannelStore.addChangeListener(this.updateState);
|
|
TeamStore.addChangeListener(this.updateState);
|
|
|
|
$('body').addClass('app__body');
|
|
}
|
|
componentWillUnmount() {
|
|
ChannelStore.removeChangeListener(this.updateState);
|
|
TeamStore.removeChangeListener(this.updateState);
|
|
|
|
$('body').removeClass('app__body');
|
|
}
|
|
componentWillReceiveProps(nextProps) {
|
|
this.setState(this.getStateFromStores(nextProps));
|
|
}
|
|
render() {
|
|
if (!this.isStateValid()) {
|
|
return null;
|
|
}
|
|
return (
|
|
<div
|
|
id='app-content'
|
|
className='app__content'
|
|
>
|
|
<ChannelHeader
|
|
channelId={this.state.channelId}
|
|
/>
|
|
<PostFocusViewController/>
|
|
<div
|
|
id='archive-link-home'
|
|
>
|
|
<Link
|
|
to={'/' + this.state.teamName + '/channels/' + this.state.channelName}
|
|
>
|
|
<FormattedMessage
|
|
id='center_panel.recent'
|
|
defaultMessage='Click here to jump to recent messages. '
|
|
/>
|
|
<i className='fa fa-arrow-down'/>
|
|
</Link>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
PermalinkView.propTypes = {
|
|
params: PropTypes.object.isRequired
|
|
};
|