Skip to content

Commit

Permalink
Merge branch 'rm/304118' into 'master'
Browse files Browse the repository at this point in the history
Fix: cannot invite poeple that are already in the channel group

See merge request kchat/webapp!650
  • Loading branch information
antonbuks committed Feb 22, 2024
2 parents abb6572 + d403477 commit 7b0ca69
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,6 @@ export default class ChannelInviteModal extends React.PureComponent<Props, State
rowSelected = 'more-modal__row--selected';
}

const ProfilesInGroup = this.props.profilesInCurrentChannel.map((user) => user.id);

const userMapping: Record<string, string> = {};

for (let i = 0; i < ProfilesInGroup.length; i++) {
userMapping[ProfilesInGroup[i]] = 'Already in channel';
}

const displayName = displayUsername(option, this.props.teammateNameDisplaySetting);

return (
Expand Down Expand Up @@ -286,7 +278,12 @@ export default class ChannelInviteModal extends React.PureComponent<Props, State
style={{position: 'absolute', right: 20}}
className='light'
>
{userMapping[option.id]}
{'disabled' in option && option.disabled && (
<FormattedMessage
id='channel_invite.already_in_channel'
defaultMessage={'Already in channel'}
/>
)}
</span>
</span>
</div>
Expand Down Expand Up @@ -320,6 +317,7 @@ export default class ChannelInviteModal extends React.PureComponent<Props, State

const buttonSubmitText = localizeMessage('multiselect.add', 'Add');
const buttonSubmitLoadingText = localizeMessage('multiselect.adding', 'Adding...');
const idsInGroup = this.props.profilesInCurrentChannel.map((user) => user.id);
let excludedAndNotInTeamUserIds: Set<string>;
if (this.props.excludeUsers) {
excludedAndNotInTeamUserIds = new Set(...this.props.profilesNotInCurrentTeam.map((user) => user.id), Object.values(this.props.excludeUsers).map((user) => user.id));
Expand All @@ -342,7 +340,7 @@ export default class ChannelInviteModal extends React.PureComponent<Props, State
slice(0, USERS_FROM_DMS) as UserProfileValue[],
...users,
].
slice(0, MAX_USERS);
slice(0, MAX_USERS).map(((u) => ({...u, disabled: idsInGroup.includes(u.id)})));

users = Array.from(new Set(users));

Expand Down
5 changes: 5 additions & 0 deletions webapp/channels/src/components/multiselect/multiselect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type Value = {
label: string;
scheme_id?: string;
value: string;
disabled?: boolean;
};

export type Props<T extends Value> = {
Expand Down Expand Up @@ -171,6 +172,10 @@ export default class MultiSelect<T extends Value> extends React.PureComponent<Pr
};

private onAdd = (value: T) => {
if ('disabled' in value && value.disabled) {
return;
}

if (this.props.maxValues && this.props.values.length >= this.props.maxValues) {
return;
}
Expand Down
1 change: 1 addition & 0 deletions webapp/channels/src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2905,6 +2905,7 @@
"channel_info_rhs.top_buttons.muted": "Stumm geschaltet",
"channel_invite.addNewMembers": "Füge neue Mitglieder zu {channel} hinzu",
"channel_invite.invite_guest": "Einen neuen Gast einladen",
"channel_invite.already_in_channel": "Bereits im Kanal",
"channel_invite.no_options_message": "Kein Treffer gefunden - <InvitationModalLink>Lade sie ins Team ein</InvitationModalLink>",
"channel_limitation.messages": "Nachrichten und Dateien, die älter als 3 Monate sind, werden ausgeblendet. Um mehr Beiträge anzuzeigen, {isAdmin, select, true {melden Sie sich für ein höheres Angebot an. <modifyOffer>Mein Angebot ändern</modifyOffer>} other {Kontaktieren Sie einen Administrator, um sich für ein höheres Angebot anzumelden.}}",
"channel_loader.posted": "Verschickt",
Expand Down
1 change: 1 addition & 0 deletions webapp/channels/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2899,6 +2899,7 @@
"channel_info_rhs.top_buttons.muted": "Muted",
"channel_invite.addNewMembers": "Add people to {channel}",
"channel_invite.invite_guest": "Invite a new Guest",
"channel_invite.already_in_channel": "Already in channel",
"channel_invite.no_options_message": "No matches found - <InvitationModalLink>Invite them to the team</InvitationModalLink>",
"channel_limitation.messages": "Messages and files older than 3 months are hidden. To view more posts, {isAdmin, select, true {subscribe to a higher offer. <modifyOffer>Change my offer</modifyOffer>} other {contact an administrator to subscribe to a higher offer}}",
"channel_loader.posted": "Posted",
Expand Down
1 change: 1 addition & 0 deletions webapp/channels/src/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2832,6 +2832,7 @@
"channel_invite.addNewMembers": "Añadir gente a {channel}",
"channel_limitation.messages": "Los mensajes y archivos de más de 3 meses están ocultos. Para ver más mensajes, {isAdmin, select, true {suscribirse a una oferta superior. <modifyOffer>Cambiar mi oferta</modifyOffer>} other {contacta con un administrador para suscribirte a una oferta superior}}",
"channel_invite.invite_guest": "Invitar a un nuevo huésped",
"channel_invite.already_in_channel": "Ya en el canal",
"channel_invite.no_options_message": "No se encontraron coincidencias - <InvitationModalLink>Invítalos al equipo</InvitationModalLink>",
"channel_loader.posted": "Publicó",
"channel_loader.postedImage": " publicó una imagen",
Expand Down
1 change: 1 addition & 0 deletions webapp/channels/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2765,6 +2765,7 @@
"channel_info_rhs.top_buttons.muted": "En sourdine",
"channel_invite.addNewMembers": "Ajouter des nouveaux membres à {channel}",
"channel_invite.invite_guest": "Ajouter un nouvel utilisateur externe",
"channel_invite.already_in_channel": "Déjà dans le canal",
"channel_invite.no_options_message": "Aucun résultat trouvé - <InvitationModalLink>Invitez-les dans l'équipe</InvitationModalLink>",
"channel_limitation.messages": "Les messages et fichiers datant de plus de 3 mois sont masqués. Pour afficher plus de messages, {isAdmin, select, true {souscrivez à une offre supérieure. <modifyOffer>Modifier mon offre</modifyOffer>} other {contactez un administrateur pour qu’il souscrive à une offre supérieure.}}",
"channel_loader.posted": "Publié",
Expand Down
1 change: 1 addition & 0 deletions webapp/channels/src/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -2178,6 +2178,7 @@
"channel_header.viewMembers": "Mostra membri",
"channel_invite.addNewMembers": "Aggiungi nuovi membri a {channel}",
"channel_invite.invite_guest": "Invitare un nuovo ospite",
"channel_invite.already_in_channel": "Già nel canale",
"channel_limitation.messages": "I messaggi e i file più vecchi di 3 mesi sono nascosti. Per visualizzare altri messaggi, {isAdmin, select, true {sottoscriversi a un'offerta superiore. <modifyOffer>Cambia la mia offerta</modifyOffer>} other {contatta un amministratore per iscriverti a un'offerta superiore}}.",
"channel_loader.posted": "Pubblicato",
"channel_loader.postedImage": " ha caricato un'immagine",
Expand Down

0 comments on commit 7b0ca69

Please sign in to comment.