Skip to content

Commit

Permalink
Merge branch 'max-user-in-pm' into 'master'
Browse files Browse the repository at this point in the history
Feat: modal for max user in pm

See merge request kchat/webapp!848
  • Loading branch information
antonbuks committed Aug 7, 2024
2 parents b5b83bf + 58bb3e6 commit 59366d3
Show file tree
Hide file tree
Showing 26 changed files with 368 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ exports[`components/AddGroupsToChannelModal should match snapshot 1`] = `
ariaLabelRenderer={[Function]}
buttonSubmitLoadingText="Adding..."
buttonSubmitText="Add"
changeMessageColor=""
disableMultiSelectList={false}
focusOnLoad={true}
handleAdd={[Function]}
handleDelete={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import type {ActionResult} from 'mattermost-redux/types/actions';
import MultiSelect from 'components/multiselect/multiselect';
import type {Value} from 'components/multiselect/multiselect';

import groupsAvatar from 'images/groups-avatar.png';
import Constants from 'utils/constants';
import {localizeMessage} from 'utils/utils';

import groupsAvatar from 'images/groups-avatar.png';

const GROUPS_PER_PAGE = 50;
const MAX_SELECTABLE_VALUES = 10;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ exports[`components/AddGroupsToTeamModal should match snapshot 1`] = `
ariaLabelRenderer={[Function]}
buttonSubmitLoadingText="Adding..."
buttonSubmitText="Add"
changeMessageColor=""
disableMultiSelectList={false}
focusOnLoad={true}
handleAdd={[Function]}
handleDelete={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ exports[`component/add_user_to_group_multiselect should match snapshot with diff
ariaLabelRenderer={[Function]}
buttonSubmitLoadingText="Updating..."
buttonSubmitText="Update Group"
changeMessageColor=""
disableMultiSelectList={false}
focusOnLoad={false}
handleAdd={[Function]}
handleDelete={[Function]}
Expand Down Expand Up @@ -90,6 +92,8 @@ exports[`component/add_user_to_group_multiselect should match snapshot with prof
ariaLabelRenderer={[Function]}
buttonSubmitLoadingText="Creating..."
buttonSubmitText="Create Group"
changeMessageColor=""
disableMultiSelectList={false}
focusOnLoad={false}
handleAdd={[Function]}
handleDelete={[Function]}
Expand Down Expand Up @@ -175,6 +179,8 @@ exports[`component/add_user_to_group_multiselect should match snapshot without a
ariaLabelRenderer={[Function]}
buttonSubmitLoadingText="Creating..."
buttonSubmitText="Create Group"
changeMessageColor=""
disableMultiSelectList={false}
focusOnLoad={false}
handleAdd={[Function]}
handleDelete={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ exports[`components/admin_console/add_users_to_team_modal/AddUsersToTeamModal sh
ariaLabelRenderer={[Function]}
buttonSubmitLoadingText="Adding..."
buttonSubmitText="Add"
changeMessageColor=""
disableMultiSelectList={false}
focusOnLoad={true}
handleAdd={[Function]}
handleDelete={[Function]}
Expand Down Expand Up @@ -286,6 +288,8 @@ exports[`components/admin_console/add_users_to_team_modal/AddUsersToTeamModal sh
ariaLabelRenderer={[Function]}
buttonSubmitLoadingText="Adding..."
buttonSubmitText="Add"
changeMessageColor=""
disableMultiSelectList={false}
focusOnLoad={true}
handleAdd={[Function]}
handleDelete={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ exports[`admin_console/add_users_to_role_modal search should not include bot use
ariaLabelRenderer={[Function]}
buttonSubmitLoadingText="Adding..."
buttonSubmitText="Add"
changeMessageColor=""
disableMultiSelectList={false}
focusOnLoad={true}
handleAdd={[Function]}
handleDelete={[Function]}
Expand Down Expand Up @@ -240,6 +242,8 @@ exports[`admin_console/add_users_to_role_modal should exclude user 1`] = `
ariaLabelRenderer={[Function]}
buttonSubmitLoadingText="Adding..."
buttonSubmitText="Add"
changeMessageColor=""
disableMultiSelectList={false}
focusOnLoad={true}
handleAdd={[Function]}
handleDelete={[Function]}
Expand Down Expand Up @@ -377,6 +381,8 @@ exports[`admin_console/add_users_to_role_modal should have single passed value 1
ariaLabelRenderer={[Function]}
buttonSubmitLoadingText="Adding..."
buttonSubmitText="Add"
changeMessageColor=""
disableMultiSelectList={false}
focusOnLoad={true}
handleAdd={[Function]}
handleDelete={[Function]}
Expand Down Expand Up @@ -558,6 +564,8 @@ exports[`admin_console/add_users_to_role_modal should include additional user 1`
ariaLabelRenderer={[Function]}
buttonSubmitLoadingText="Adding..."
buttonSubmitText="Add"
changeMessageColor=""
disableMultiSelectList={false}
focusOnLoad={true}
handleAdd={[Function]}
handleDelete={[Function]}
Expand Down Expand Up @@ -780,6 +788,8 @@ exports[`admin_console/add_users_to_role_modal should include additional user 2`
ariaLabelRenderer={[Function]}
buttonSubmitLoadingText="Adding..."
buttonSubmitText="Add"
changeMessageColor=""
disableMultiSelectList={false}
focusOnLoad={true}
handleAdd={[Function]}
handleDelete={[Function]}
Expand Down Expand Up @@ -1002,6 +1012,8 @@ exports[`admin_console/add_users_to_role_modal should not include bot user 1`] =
ariaLabelRenderer={[Function]}
buttonSubmitLoadingText="Adding..."
buttonSubmitText="Add"
changeMessageColor=""
disableMultiSelectList={false}
focusOnLoad={true}
handleAdd={[Function]}
handleDelete={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ exports[`components/channel_invite_modal should match snapshot for channel_invit
ariaLabelRenderer={[Function]}
backButtonClass="btn-tertiary tertiary-button"
backButtonClick={[Function]}
changeMessageColor=""
customNoOptionsMessage={null}
disableMultiSelectList={false}
focusOnLoad={true}
handleAdd={[Function]}
handleCancel={[Function]}
Expand Down Expand Up @@ -205,7 +207,9 @@ exports[`components/channel_invite_modal should match snapshot for channel_invit
ariaLabelRenderer={[Function]}
backButtonClass="btn-tertiary tertiary-button"
backButtonClick={[Function]}
changeMessageColor=""
customNoOptionsMessage={null}
disableMultiSelectList={false}
focusOnLoad={true}
handleAdd={[Function]}
handleCancel={[Function]}
Expand Down Expand Up @@ -366,7 +370,9 @@ exports[`components/channel_invite_modal should match snapshot with exclude and
ariaLabelRenderer={[Function]}
backButtonClass="btn-tertiary tertiary-button"
backButtonClick={[Function]}
changeMessageColor=""
customNoOptionsMessage={null}
disableMultiSelectList={false}
focusOnLoad={true}
handleAdd={[Function]}
handleCancel={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ exports[`components/ChannelSelectorModal exclude already selected 1`] = `
<MultiSelect
ariaLabelRenderer={[Function]}
buttonSubmitText="Add"
changeMessageColor=""
disableMultiSelectList={false}
focusOnLoad={true}
handleAdd={[Function]}
handleDelete={[Function]}
Expand Down Expand Up @@ -204,6 +206,8 @@ exports[`components/ChannelSelectorModal should match snapshot 1`] = `
<MultiSelect
ariaLabelRenderer={[Function]}
buttonSubmitText="Add"
changeMessageColor=""
disableMultiSelectList={false}
focusOnLoad={true}
handleAdd={[Function]}
handleDelete={[Function]}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

import React from 'react';
import {FormattedMessage} from 'react-intl';

import type {OptionValue} from 'components/more_direct_channels/types';

import Constants from 'utils/constants';

interface Props {
values: OptionValue[];
openModal: () => void;
}

const CreateChannelTip: React.FC<Props> = ({values, openModal}) => {
const lampIcon = () => Constants.LAMP_ICON;

return (
(values.length >= (Constants.MAX_USERS_IN_GM - 1)) ? (
<div className='create-new-channel'>
<img src={lampIcon()}/>
<FormattedMessage
id='multiselect.new_channel'
defaultMessage='Create a channel to communicate with more people'
/>
<a
href='#'
onClick={(e) => {
e.preventDefault();
openModal();
}}
>
<FormattedMessage
id='multiselect.new_channel_create'
defaultMessage='Create a channel'
/>
</a>
</div>

) : null

);
};

export default CreateChannelTip;
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,12 @@ exports[`components/MoreDirectChannels should exclude deleted users if there is
]
}
values={Array []}
/>
>
<CreateChannelTip
openModal={[Function]}
values={Array []}
/>
</Connect(Component)>
</ModalBody>
<ModalFooter
bsClass="modal-footer"
Expand Down Expand Up @@ -566,7 +571,97 @@ exports[`components/MoreDirectChannels should match snapshot 1`] = `
},
]
}
/>
>
<CreateChannelTip
openModal={[Function]}
values={
Array [
Object {
"auth_service": "",
"bot_description": "",
"create_at": 0,
"delete_at": 0,
"email": "",
"first_name": "",
"id": "user_id_1",
"is_bot": false,
"label": "some-user",
"last_activity_at": 0,
"last_name": "",
"last_password_update": 0,
"last_picture_update": 0,
"locale": "",
"mfa_active": false,
"nickname": "",
"notify_props": Object {
"calls_desktop_sound": "true",
"channel": "false",
"comments": "never",
"desktop": "default",
"desktop_sound": "false",
"email": "false",
"first_name": "false",
"highlight_keys": "",
"mark_unread": "mention",
"mention_keys": "",
"push": "none",
"push_status": "offline",
},
"password": "",
"position": "",
"props": Object {},
"roles": "",
"terms_of_service_create_at": 0,
"terms_of_service_id": "",
"update_at": 0,
"username": "some-user",
"value": "user_id_1",
},
Object {
"auth_service": "",
"bot_description": "",
"create_at": 0,
"delete_at": 0,
"email": "",
"first_name": "",
"id": "user_id_2",
"is_bot": false,
"label": "some-user",
"last_activity_at": 0,
"last_name": "",
"last_password_update": 0,
"last_picture_update": 0,
"locale": "",
"mfa_active": false,
"nickname": "",
"notify_props": Object {
"calls_desktop_sound": "true",
"channel": "false",
"comments": "never",
"desktop": "default",
"desktop_sound": "false",
"email": "false",
"first_name": "false",
"highlight_keys": "",
"mark_unread": "mention",
"mention_keys": "",
"push": "none",
"push_status": "offline",
},
"password": "",
"position": "",
"props": Object {},
"roles": "",
"terms_of_service_create_at": 0,
"terms_of_service_id": "",
"update_at": 0,
"username": "some-user",
"value": "user_id_2",
},
]
}
/>
</Connect(Component)>
</ModalBody>
<ModalFooter
bsClass="modal-footer"
Expand Down
2 changes: 2 additions & 0 deletions webapp/channels/src/components/more_direct_channels/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
import {openDirectChannelToUserId, openGroupChannelToUserIds} from 'actions/channel_actions';
import {loadStatusesForProfilesList, loadProfilesMissingStatus} from 'actions/status_actions';
import {loadProfilesForGroupChannels} from 'actions/user_actions';
import {openModal} from 'actions/views/modals';
import {setModalSearchTerm} from 'actions/views/search';

import type {GlobalState} from 'types/store';
Expand Down Expand Up @@ -86,6 +87,7 @@ const makeMapStateToProps = () => {
function mapDispatchToProps(dispatch: Dispatch) {
return {
actions: bindActionCreators({
openModal,
getProfiles,
getProfilesInTeam,
loadProfilesMissingStatus,
Expand Down
Loading

0 comments on commit 59366d3

Please sign in to comment.