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
Refactor Modals, ChannelHeader and Navbar component #1666
Merged
Merged
Changes from all commits
Commits
Show all changes
100 commits
Select commit
Hold shift + click to select a range
7a3d7ed
Refactor duplicated RenameChannelModal component
cometkim a53c657
Refactor duplicated EditChannelPurposeModal comp
cometkim fb641b7
Refactor duplicated ChannelMembersModal component
cometkim 7c2cf32
Refactor ChannelNotificationsModal comp
cometkim 45d3eaf
Move QuickSwitchModal to ModalController
cometkim 0d0e4be
Refactor ModalController component
cometkim 0681abe
Change Navbar component to PureComponent
cometkim 21b4eeb
Migrate NavBar code to be use mattermost-redux
cometkim faba039
Refactor actions in NavBar
cometkim 4da5158
Extract SetChannelHeaderOption component from NavBar
cometkim 6daa40f
Extract ViewChannelInfoOption component from NavBar
cometkim 2abbbf3
Extract NotificationPreferencesOption component from NavBar
cometkim 32d06e6
Extract ChannelMembersOption component from NavBar
cometkim ab03668
Extract ViewPinnedPostsOption component from NavBar
cometkim fdb3627
Extract AddMembersOption component from NavBar
cometkim a71acdc
Extract SetChannelPurposeOption component from NavBar
cometkim 5eae8c3
Extract RenameChannelOption component from NavBar
cometkim 68db33c
Extract ConvertChannelOption component from NavBar
cometkim 59f3602
Extract DeleteChannelOption component from NavBar
cometkim 07f8b6a
Extract LeaveChannelOption component from NavBar
cometkim 65891fa
Extract ToggleFavoriteChannel component from NavBar
cometkim a0793cb
Fix typo in ModalIdentifiers
cometkim 28fd15f
Extract WebrtcOption component from NavBar
cometkim 3d6aeb5
Building clean dropdown code, start from AddMembers
cometkim 32f2c62
... ViewChannelInfo
cometkim 29097b1
... ViewPinnedPosts
cometkim 4541859
... NotificationPreferences
cometkim 3f0195f
... ToggleFavoriteChannel
cometkim 099fa0a
... SetChannelHeader
cometkim 193568b
... SetChannelPurpose
cometkim ff6f507
... ViewMembers
cometkim 37e650c
... ManageMembers
cometkim 48592df
... ConvertChannel
cometkim 6e0a628
... RenameChannel
cometkim 5d47cc7
... DeleteChannel
cometkim 7109c11
... LeaveChannel
cometkim 858b868
... WebRTC
cometkim 457ee43
Add draft of ChannelHeaderDropdown component
cometkim 2ec1a44
Connect MobileChannelHeaderComponent to redux store
cometkim c306bab
Change the default rendering of dropdown
cometkim 94d673d
Clean Navbar component with the new dropdown component
cometkim b0dc1e7
Remove more
cometkim 8b43b15
Extract ShowSearchButton component from Navbar
cometkim 69ab511
Remove undefined prop
cometkim 91119f1
Remove unnecessary wrapper
cometkim 54025e9
Comment on collapseButtons
cometkim 21defc4
Refactor Navbar even more
cometkim cf0ff04
Fix character of close button
cometkim 16c3702
Make channel prop to be required
cometkim f39ea39
Remove unused codes
cometkim fb38963
Fix ToggleFavorite menu
cometkim 29e4211
[MM-11162] Add mute icon to mobile view (#1744)
saturninoabril ed484a3
Fix the composition of navbar
cometkim b0e2b06
Fix NotificationPreference modal
cometkim bb30e01
Extract ToggleMuteChannel comp from ChannelHeader
cometkim d082673
Cleanup ChannelHeader with new ChannelHeaderDropdown
cometkim d7139fd
Update snapshot of NotificationPreferences menu
cometkim 4b87632
Refactor ChannelHeader component
cometkim 7bd8110
Fix tests
cometkim a392c5a
MM-12150 - Updating x icon and plugins (#1841)
asaadmahmood a032ccb
Fix tests
cometkim f9f0f67
Rename Navbar to ChannelHeaderMobile
cometkim d76f995
MM-12503: Show Mute/Unmute menu item for GMs too. (#1847)
grundleborg c9fefde
Remove comment from view
cometkim f1c2823
Change ext of modified components to .js instead of .jsx
cometkim 7fafd9e
MM-12494 Removing some flux store usage. (#1882)
crspeller 8e6d305
Fix some filename extensions
cometkim 2c96292
Fix a updated snaphost
cometkim 96b03b3
Migrate ChannelActions joinChannel and leaveChannel to redux (#1898)
enahum 496dc0b
Update ModalController snapshot
cometkim d887c61
Drop WebRTC from ChannelHeader
cometkim f2ada0f
Remove deprecated lifecycle method from ChannelHeader
cometkim 8f8b197
Replace hardcoded isMobile to utils
cometkim 8420ef1
Fix import annotations
cometkim 5b7a299
Migrate current channel state selectors to use mattermost-redux
cometkim 95deaf0
Remove unused declarations
cometkim 48aa099
Cherry-picked MM-11577: Back to previous channel on archive (#1775)
jespino 2a5d742
Cherry-picked: MM-12497 Remove flux store usages from user settings (…
jwilander b854604
Change ToggleMuteChannel component to PureComponent class style to av…
cometkim c4292d9
Remove unnecessary arrow function in render
cometkim 114d417
Rollback mapStateToProps to plain function
cometkim 70fdf9c
Change UnmuteChannelButton component to PureComponent class style to …
cometkim 18e55b4
Change file ext for UnmuteChannelButton to .js
cometkim 859e6b9
Move back QuickSwitchModal to ChannelHeader (Desktop only), and use r…
cometkim 288f618
Change ShowSearchButton component to PureComponent class style to avo…
cometkim ce99b44
Rollback mapStateToProps for ViewPinnedPosts to plain function
cometkim f29dda7
Cherry-picked: Remove flux usages from email invite modal (#1954)
jwilander 9d9c512
Fix Channel Header
cometkim cf00c3f
Fix ShowSearchButton in ChannelHeaderMobile
cometkim a86b9e1
Fix ChannelMembersModal on PopoverListMembers
cometkim 463501b
Migrate test files to component path
cometkim 5acdc93
fix eslint style error on test mock
cometkim 32a47c4
Update per feedback
cometkim e32df59
Fix ChannelMembersModal test, IDK when it have been break exactly
cometkim 3c31e33
Fix errors on dropdown
cometkim 84a809e
Fix view_and_manage_members to show different name by permission
cometkim b3c430d
Fix to show RenameChannel on defaultChannel
cometkim 71b0f26
Refactor ChannelMembersModal to use redux action
cometkim 22d8563
Fix ChannelNotificationModal to handle hide anim correctly
cometkim 59d3874
Fix ViewAndManageMembers to be view mode only in default channel
cometkim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
737 changes: 4 additions & 733 deletions
737
components/channel_header/__snapshots__/channel_header.test.jsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
components/channel_header_dropdown/channel_header_dropdown.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// 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> | ||
hmhealey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<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> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// 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); | ||
saturninoabril marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
); | ||
|
||
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); | ||
saturninoabril marked this conversation as resolved.
Show resolved
Hide resolved
|
38 changes: 38 additions & 0 deletions
38
components/channel_header_dropdown/menu_items/__snapshots__/add_members.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// 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)> | ||
`; |
34 changes: 34 additions & 0 deletions
34
components/channel_header_dropdown/menu_items/__snapshots__/convert_channel.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// 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)> | ||
`; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: I'd prefer the current implementation of using function over constant for consistency if no better advantage of doing so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I prefer to use function style, but yes. agreed for consistency.