mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Fixed a bug where channel URL preview used incorrect team (#24705)
This commit is contained in:
parent
ff929e4a15
commit
510136a192
@ -5,6 +5,8 @@ import React, {useCallback, useEffect, useRef, useState} from 'react';
|
||||
import {useIntl} from 'react-intl';
|
||||
import {useSelector} from 'react-redux';
|
||||
|
||||
import type {Team} from '@mattermost/types/teams';
|
||||
|
||||
import {getCurrentTeam} from 'mattermost-redux/selectors/entities/teams';
|
||||
|
||||
import type {CustomMessageInputType} from 'components/widgets/inputs/input/input';
|
||||
@ -23,6 +25,7 @@ export type Props = {
|
||||
onURLChange: (url: string) => void;
|
||||
autoFocus?: boolean;
|
||||
onErrorStateChange?: (isError: boolean) => void;
|
||||
team?: Team;
|
||||
}
|
||||
|
||||
import './channel_name_form_field.scss';
|
||||
@ -58,6 +61,7 @@ const ChannelNameFormField = (props: Props): JSX.Element => {
|
||||
const [inputCustomMessage, setInputCustomMessage] = useState<CustomMessageInputType | null>(null);
|
||||
|
||||
const {name: currentTeamName} = useSelector(getCurrentTeam);
|
||||
const teamName = props.team ? props.team.name : currentTeamName;
|
||||
|
||||
const handleOnDisplayNameChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
e.preventDefault();
|
||||
@ -131,7 +135,7 @@ const ChannelNameFormField = (props: Props): JSX.Element => {
|
||||
<URLInput
|
||||
className='new-channel-modal__url'
|
||||
base={getSiteURL()}
|
||||
path={`${currentTeamName}/channels`}
|
||||
path={`${teamName}/channels`}
|
||||
pathInfo={url}
|
||||
limit={Constants.MAX_CHANNELNAME_LENGTH}
|
||||
shortenLength={Constants.DEFAULT_CHANNELURL_SHORTEN_LENGTH}
|
||||
|
@ -44,8 +44,8 @@ describe('component/ConvertGmToChannelModal', () => {
|
||||
entities: {
|
||||
teams: {
|
||||
teams: {
|
||||
team_id_1: {id: 'team_id_1', display_name: 'Team 1'} as Team,
|
||||
team_id_2: {id: 'team_id_2', display_name: 'Team 2'} as Team,
|
||||
team_id_1: {id: 'team_id_1', display_name: 'Team 1', name: 'team_1'} as Team,
|
||||
team_id_2: {id: 'team_id_2', display_name: 'Team 2', name: 'team_2'} as Team,
|
||||
},
|
||||
currentTeamId: 'team_id_1',
|
||||
},
|
||||
@ -57,8 +57,8 @@ describe('component/ConvertGmToChannelModal', () => {
|
||||
nock(Client4.getBaseRoute()).
|
||||
get('/channels/channel_id_1/common_teams').
|
||||
reply(200, [
|
||||
{id: 'team_id_1', display_name: 'Team 1'},
|
||||
{id: 'team_id_2', display_name: 'Team 2'},
|
||||
{id: 'team_id_1', display_name: 'Team 1', name: 'team_1'},
|
||||
{id: 'team_id_2', display_name: 'Team 2', name: 'team_2'},
|
||||
]);
|
||||
|
||||
renderWithFullContext(
|
||||
@ -76,6 +76,7 @@ describe('component/ConvertGmToChannelModal', () => {
|
||||
expect(screen.queryByText('Select Team')).toBeInTheDocument();
|
||||
expect(screen.queryByPlaceholderText('Channel name')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Edit')).toBeInTheDocument();
|
||||
expect(screen.queryByText('URL: http://localhost:8065/team_1/channels/')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('members part of single common teams', async () => {
|
||||
@ -83,7 +84,7 @@ describe('component/ConvertGmToChannelModal', () => {
|
||||
nock(Client4.getBaseRoute()).
|
||||
get('/channels/channel_id_1/common_teams').
|
||||
reply(200, [
|
||||
{id: 'team_id_1', display_name: 'Team 1'},
|
||||
{id: 'team_id_1', display_name: 'Team 1', name: 'team_1'},
|
||||
]);
|
||||
|
||||
renderWithFullContext(
|
||||
@ -131,8 +132,8 @@ describe('component/ConvertGmToChannelModal', () => {
|
||||
nock(Client4.getBaseRoute()).
|
||||
get('/channels/channel_id_1/common_teams').
|
||||
reply(200, [
|
||||
{id: 'team_id_1', display_name: 'Team 1'},
|
||||
{id: 'team_id_2', display_name: 'Team 2'},
|
||||
{id: 'team_id_1', display_name: 'Team 1', name: 'team_1'},
|
||||
{id: 'team_id_2', display_name: 'Team 2', name: 'team_2'},
|
||||
]);
|
||||
|
||||
baseProps.actions.convertGroupMessageToPrivateChannel.mockResolvedValueOnce({});
|
||||
|
@ -170,6 +170,7 @@ const ConvertGmToChannelModal = (props: Props) => {
|
||||
onDisplayNameChange={setChannelName}
|
||||
onURLChange={handleChannelURLChange}
|
||||
onErrorStateChange={setNameError}
|
||||
team={selectedTeamId ? commonTeamsById[selectedTeamId] : undefined}
|
||||
/>
|
||||
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user