Commit fa4abebb authored by Harrison Healey's avatar Harrison Healey
Browse files

Merge branch 'master' into post-metadata

parents e005b58a a0b36ae4
......@@ -706,7 +706,7 @@ function handleChannelDeletedEvent(msg) {
browserHistory.push(teamUrl + '/channels/' + Constants.DEFAULT_CHANNEL);
}
dispatch({type: ChannelTypes.RECEIVED_CHANNEL_DELETED, data: {id: msg.data.channel_id, team_id: msg.broadcast.team_id, deleteAt: msg.data.delete_at}});
dispatch({type: ChannelTypes.RECEIVED_CHANNEL_DELETED, data: {id: msg.data.channel_id, team_id: msg.broadcast.team_id, deleteAt: msg.data.delete_at, viewArchivedChannels}});
}
function handlePreferenceChangedEvent(msg) {
......
......@@ -288,7 +288,7 @@ export default class AdminSidebar extends React.Component {
title={
<FormattedMessage
id='admin.sidebar.data_retention'
defaultMessage='Data Retention Policy (Beta)'
defaultMessage='Data Retention Policy'
/>
}
/>
......
......@@ -162,7 +162,7 @@ export default class DataRetentionSettings extends AdminSettings {
return (
<FormattedMessage
id='admin.data_retention.title'
defaultMessage='Data Retention Policy (Beta)'
defaultMessage='Data Retention Policy'
/>
);
}
......
......@@ -19,10 +19,13 @@ describe('components/ChannelHeader', () => {
closeRightHandSide: jest.fn(),
updateRhsState: jest.fn(),
openModal: jest.fn(),
closeModal: jest.fn(),
getCustomEmojisInText: jest.fn(),
updateChannelNotifyProps: jest.fn(),
goToLastViewedChannel: jest.fn(),
},
teamUrl: 'team_url',
teamId: 'team_id',
channel: {},
channelMember: {},
currentUser: {},
......
......@@ -6,7 +6,7 @@ import React from 'react';
import {FormattedMessage} from 'react-intl';
import {OverlayTrigger, Tooltip} from 'react-bootstrap';
import {Constants} from 'utils/constants.jsx';
import {Constants} from 'utils/constants';
import {t} from 'utils/i18n';
export default function HeaderIconWrapper({
......
......@@ -9,7 +9,7 @@ import MentionsIcon from 'components/svg/mentions_icon';
import PinIcon from 'components/svg/pin_icon';
import SearchIcon from 'components/svg/search_icon';
import HeaderIconWrapper from 'components/channel_header/components/header_icon_wrapper.jsx';
import HeaderIconWrapper from 'components/channel_header/components/header_icon_wrapper';
describe('components/channel_header/components/HeaderIconWrapper', () => {
function emptyFunction() {} //eslint-disable-line no-empty-function
......
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {favoriteChannel, leaveChannel, unfavoriteChannel, updateChannelNotifyProps} from 'mattermost-redux/actions/channels';
import {connect} from 'react-redux';
import {withRouter} from 'react-router-dom';
import {
favoriteChannel,
unfavoriteChannel,
updateChannelNotifyProps,
} from 'mattermost-redux/actions/channels';
import {getCustomEmojisInText} from 'mattermost-redux/actions/emojis';
import {General} from 'mattermost-redux/constants';
import {getChannel, getMyChannelMember, isCurrentChannelReadOnly} from 'mattermost-redux/selectors/entities/channels';
import {getMyTeamMember} from 'mattermost-redux/selectors/entities/teams';
import {getCurrentUser, getUser} from 'mattermost-redux/selectors/entities/users';
import {getUserIdFromChannelName, isDefault, isFavoriteChannel} from 'mattermost-redux/utils/channel_utils';
import {getLicense} from 'mattermost-redux/selectors/entities/general';
import {withRouter} from 'react-router-dom';
import {
getCurrentChannel,
getMyCurrentChannelMembership,
isCurrentChannelFavorite,
isCurrentChannelMuted,
isCurrentChannelReadOnly,
} from 'mattermost-redux/selectors/entities/channels';
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {
getCurrentUser,
getUser,
} from 'mattermost-redux/selectors/entities/users';
import {getUserIdFromChannelName} from 'mattermost-redux/utils/channel_utils';
import {goToLastViewedChannel} from 'actions/views/channel';
import {getPenultimateViewedChannelName} from 'selectors/local_storage';
import {Constants} from 'utils/constants.jsx';
import {openModal, closeModal} from 'actions/views/modals';
import {
showFlaggedPosts,
showPinnedPosts,
......@@ -26,14 +34,12 @@ import {
closeRightHandSide,
updateRhsState,
} from 'actions/views/rhs';
import {openModal} from 'actions/views/modals';
import {getRhsState} from 'selectors/rhs';
import ChannelHeader from './channel_header.jsx';
import ChannelHeader from './channel_header';
function mapStateToProps(state, ownProps) {
const channel = getChannel(state, ownProps.channelId) || {};
const prefs = state.entities.preferences.myPreferences;
const mapStateToProps = (state) => {
const channel = getCurrentChannel(state) || {};
const user = getCurrentUser(state);
let dmUser;
......@@ -42,45 +48,34 @@ function mapStateToProps(state, ownProps) {
dmUser = getUser(state, dmUserId);
}
const license = getLicense(state);
let penultimateViewedChannelName = getPenultimateViewedChannelName(state);
if (!penultimateViewedChannelName) {
penultimateViewedChannelName = Constants.DEFAULT_CHANNEL;
}
return {
teamId: getCurrentTeamId(state),
channel,
channelMember: getMyChannelMember(state, ownProps.channelId),
teamMember: getMyTeamMember(state, channel.team_id),
isFavorite: isFavoriteChannel(prefs, ownProps.channelId),
isDefault: isDefault(channel),
channelMember: getMyCurrentChannelMembership(state),
currentUser: user,
dmUser,
rhsState: getRhsState(state),
isLicensed: license.IsLicensed === 'true',
isFavorite: isCurrentChannelFavorite(state),
isReadOnly: isCurrentChannelReadOnly(state),
penultimateViewedChannelName,
isMuted: isCurrentChannelMuted(state),
};
}
};
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
leaveChannel,
favoriteChannel,
unfavoriteChannel,
showFlaggedPosts,
showPinnedPosts,
showMentions,
closeRightHandSide,
updateRhsState,
openModal,
getCustomEmojisInText,
updateChannelNotifyProps,
goToLastViewedChannel,
}, dispatch),
};
}
const mapDispatchToProps = (dispatch) => ({
actions: bindActionCreators({
favoriteChannel,
unfavoriteChannel,
showFlaggedPosts,
showPinnedPosts,
showMentions,
closeRightHandSide,
updateRhsState,
getCustomEmojisInText,
updateChannelNotifyProps,
goToLastViewedChannel,
openModal,
closeModal,
}, dispatch),
});
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(ChannelHeader));
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import * as MenuItem from './menu_items';
export default class ChannelHeaderDropdown extends React.PureComponent {
static propTypes = {
user: PropTypes.object.isRequired,
channel: PropTypes.object.isRequired,
isDefault: PropTypes.bool.isRequired,
isReadonly: PropTypes.bool.isRequired,
isMuted: PropTypes.bool.isRequired,
isArchived: PropTypes.bool.isRequired,
}
render() {
const {
user,
channel,
isDefault,
isMuted,
isReadonly,
isArchived,
} = this.props;
return (
<ul
id='channelHeaderDropdownMenu'
className='dropdown-menu'
role='menu'
aria-labelledby='channel_header_dropdown'
>
<MenuItem.Group>
<MenuItem.ViewChannelInfo channel={channel}/>
<MenuItem.NotificationPreferences
user={user}
channel={channel}
isArchived={isArchived}
/>
<MenuItem.ToggleMuteChannel
user={user}
channel={channel}
isMuted={isMuted}
isArchived={isArchived}
/>
</MenuItem.Group>
<MenuItem.Group>
<MenuItem.AddMembers
channel={channel}
isDefault={isDefault}
isArchived={isArchived}
/>
<MenuItem.ViewAndManageMembers
channel={channel}
isDefault={isDefault}
/>
</MenuItem.Group>
<MenuItem.Group>
<MenuItem.SetChannelHeader
channel={channel}
isArchived={isArchived}
isReadonly={isReadonly}
/>
<MenuItem.SetChannelPurpose
channel={channel}
isArchived={isArchived}
isReadonly={isReadonly}
/>
<MenuItem.RenameChannel
channel={channel}
isArchived={isArchived}
/>
<MenuItem.ConvertChannel
channel={channel}
isDefault={isDefault}
isArchived={isArchived}
/>
<MenuItem.DeleteChannel
channel={channel}
isDefault={isDefault}
isArchived={isArchived}
/>
</MenuItem.Group>
<MenuItem.Group showDivider={false}>
<MenuItem.LeaveChannel
channel={channel}
isDefault={isDefault}
/>
<MenuItem.CloseChannel isArchived={isArchived}/>
</MenuItem.Group>
</ul>
);
}
}
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {connect} from 'react-redux';
import {createSelector} from 'reselect';
import {
getCurrentUser,
getUserStatuses,
} from 'mattermost-redux/selectors/entities/users';
import {
getCurrentChannel,
isCurrentChannelDefault,
isCurrentChannelFavorite,
isCurrentChannelMuted,
isCurrentChannelArchived,
isCurrentChannelReadOnly,
} from 'mattermost-redux/selectors/entities/channels';
import {Constants} from 'utils/constants';
import * as Utils from 'utils/utils';
import Desktop from './channel_header_dropdown';
import Mobile from './mobile_channel_header_dropdown';
const getTeammateId = createSelector(
getCurrentChannel,
(channel) => {
if (channel.type !== Constants.DM_CHANNEL) {
return null;
}
return Utils.getUserIdFromChannelName(channel);
},
);
const getTeammateStatus = createSelector(
getUserStatuses,
getTeammateId,
(userStatuses, teammateId) => {
if (!teammateId) {
return null;
}
return userStatuses[teammateId];
}
);
const mapStateToProps = (state) => ({
user: getCurrentUser(state),
channel: getCurrentChannel(state),
isDefault: isCurrentChannelDefault(state),
isFavorite: isCurrentChannelFavorite(state),
isMuted: isCurrentChannelMuted(state),
isReadonly: isCurrentChannelReadOnly(state),
isArchived: isCurrentChannelArchived(state),
teammateId: getTeammateId(state),
teammateStatus: getTeammateStatus(state),
});
export const ChannelHeaderDropdown = connect(mapStateToProps)(Desktop);
export const MobileChannelHeaderDropdown = connect(mapStateToProps)(Mobile);
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/ChannelHeaderDropdown/MenuItem.AddMembers should match snapshot 1`] = `
<Connect(ChannelPermissionGate)
channelId="channel_id"
permissions={
Array [
"manage_public_channel_members",
]
}
teamId="team_id"
>
<li
role="presentation"
>
<Connect(ModalToggleButtonRedux)
dialogProps={
Object {
"channel": Object {
"id": "channel_id",
"team_id": "team_id",
"type": "O",
},
}
}
dialogType={[Function]}
modalId="channel_invite"
role="menuitem"
>
<FormattedMessage
defaultMessage="Add Members"
id="navbar.addMembers"
values={Object {}}
/>
</Connect(ModalToggleButtonRedux)>
</li>
</Connect(ChannelPermissionGate)>
`;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/ChannelHeaderDropdown/MenuItem.ConvertChannel should match snapshot 1`] = `
<Connect(TeamPermissionGate)
permissions={
Array [
"manage_team",
]
}
teamId="team_id"
>
<li
role="presentation"
>
<Connect(ModalToggleButtonRedux)
dialogProps={
Object {
"channelDisplayName": "Test Channel",
"channelId": "channel_id",
}
}
dialogType={[Function]}
modalId="convert_channel"
role="menuitem"
>
<FormattedMessage
defaultMessage="Convert to Private Channel"
id="channel_header.convert"
values={Object {}}
/>
</Connect(ModalToggleButtonRedux)>
</li>
</Connect(TeamPermissionGate)>
`;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/ChannelHeaderDropdown/MenuItem.Group should match snapshot 1`] = `
<Fragment>
children
<li
className="divider"
/>
</Fragment>
`;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/ChannelHeaderDropdown/MenuItem.NotificationPreferences should match snapshot 1`] = `
<li
role="presentation"
>
<Connect(ModalToggleButtonRedux)
dialogProps={
Object {
"channel": Object {
"type": "O",
},
"currentUser": Object {},
}
}
dialogType={[Function]}
modalId="channel_notifications"
role="menuitem"
>
<FormattedMessage
defaultMessage="Notification Preferences"
id="navbar.preferences"
values={Object {}}
/>
</Connect(ModalToggleButtonRedux)>
</li>
`;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/ChannelHeaderDropdown/MenuItem.RenameChannel should match snapshot 1`] = `
<Connect(ChannelPermissionGate)
channelId="channel_id"
permissions={
Array [
"manage_public_channel_properties",
]
}
teamId="team_id"
>
<li
role="presentation"
>
<Connect(ModalToggleButtonRedux)
dialogProps={
Object {
"channel": Object {
"id": "channel_id",
"team_id": "team_id",
"type": "O",
},
}
}
dialogType={[Function]}
modalId="rename_channel"
role="menuitem"
>
<FormattedMessage
defaultMessage="Rename Channel"
id="channel_header.rename"
values={Object {}}
/>
</Connect(ModalToggleButtonRedux)>
</li>
</Connect(ChannelPermissionGate)>
`;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/ChannelHeaderDropdown/MenuItem.SetChannelHeader should match snapshot 1`] = `
<Connect(ChannelPermissionGate)
channelId="channel_id"
permissions={
Array [
"manage_public_channel_properties",
]
}
teamId="team_id"
>
<li
role="presentation"
>
<Connect(ModalToggleButtonRedux)
dialogProps={
Object {
"channel": Object {
"id": "channel_id",
"team_id": "team_id",
"type": "O",
},
}
}
dialogType={[Function]}
id="editChannelHeader"
modalId="edit_channel_header"
role="menuitem"
>
<FormattedMessage
defaultMessage="Edit Channel Header"
id="channel_header.setHeader"
values={Object {}}
/>
</Connect(ModalToggleButtonRedux)>
</li>
</Connect(ChannelPermissionGate)>
`;
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`components/ChannelHeaderDropdown/MenuItem.SetChannelPurpose should match snapshot 1`] = `
<Connect(ChannelPermissionGate)
channelId="channel_id"
permissions={
Array [
"manage_public_channel_properties",
]
}
teamId="team_id"
>
<li
role="presentation"
>
<Connect(ModalToggleButtonRedux)
dialogProps={
Object {
"channel": Object {
"id": "channel_id",
"team_id": "team_id",
"type": "O",
},
}
}
dialogType={[Function]}
modalId="edit_channel_purpose"
role="menuitem"
>
<FormattedMessage
defaultMessage="Edit Channel Purpose"
id="channel_header.setPurpose"
values={Object {}}
/>
</Connect(ModalToggleButtonRedux)>