This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
set_channel_header.jsx
59 lines (50 loc) · 1.89 KB
/
set_channel_header.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// 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 {FormattedMessage} from 'react-intl';
import {Permissions} from 'mattermost-redux/constants';
import ChannelPermissionGate from 'components/permissions_gates/channel_permission_gate';
import ToggleModalButtonRedux from 'components/toggle_modal_button_redux';
import EditChannelHeaderModal from 'components/edit_channel_header_modal';
import {Constants, ModalIdentifiers} from 'utils/constants';
const SetChannelHeader = ({channel, isReadonly}) => {
if (isReadonly) {
return null;
}
const isPrivate = channel.type === Constants.PRIVATE_CHANNEL;
const permission = isPrivate ? Permissions.MANAGE_PRIVATE_CHANNEL_PROPERTIES : Permissions.MANAGE_PUBLIC_CHANNEL_PROPERTIES;
return (
<ChannelPermissionGate
channelId={channel.id}
teamId={channel.team_id}
permissions={[permission]}
>
<li role='presentation'>
<ToggleModalButtonRedux
id='editChannelHeader'
role='menuitem'
modalId={ModalIdentifiers.EDIT_CHANNEL_HEADER}
dialogType={EditChannelHeaderModal}
dialogProps={{channel}}
>
<FormattedMessage
id='channel_header.setHeader'
defaultMessage='Edit Channel Header'
/>
</ToggleModalButtonRedux>
</li>
</ChannelPermissionGate>
);
};
SetChannelHeader.propTypes = {
/**
* Object with info about user
*/
channel: PropTypes.object.isRequired,
/**
* Boolean whether the channel is readonly
*/
isReadonly: PropTypes.bool.isRequired,
};
export default SetChannelHeader;