From 37ebeeb9f3e3a2139f5f530f9de56c7fbf3aa73e Mon Sep 17 00:00:00 2001 From: Guilherme Gomes <80290114+gomessguii@users.noreply.github.com> Date: Tue, 16 May 2023 07:08:20 -0300 Subject: [PATCH] MM-50305 : Implemented url auto generation on channel creating (#22598) --- .../src/components/new_channel_modal/new_channel_modal.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/webapp/channels/src/components/new_channel_modal/new_channel_modal.tsx b/webapp/channels/src/components/new_channel_modal/new_channel_modal.tsx index 67eaaa8a78..9052004e60 100644 --- a/webapp/channels/src/components/new_channel_modal/new_channel_modal.tsx +++ b/webapp/channels/src/components/new_channel_modal/new_channel_modal.tsx @@ -7,6 +7,7 @@ import {FormattedMessage, useIntl} from 'react-intl'; import {Tooltip} from 'react-bootstrap'; import classNames from 'classnames'; +import crypto from 'crypto'; import OverlayTrigger from 'components/overlay_trigger'; import GenericModal from 'components/generic_modal'; @@ -233,6 +234,9 @@ const NewChannelModal = () => { }; const handleOnDisplayNameBlur = () => { + if (displayName && !url) { + setURL(crypto.randomBytes(16).toString('hex')); + } if (!displayNameModified) { setDisplayNameModified(true); } @@ -270,7 +274,7 @@ const NewChannelModal = () => { e.stopPropagation(); }; - const canCreate = displayName && !displayNameError && url && !urlError && type && !purposeError && !serverError && canCreateFromPluggable; + const canCreate = displayName && !displayNameError && !urlError && type && !purposeError && !serverError && canCreateFromPluggable; const newBoardInfoIcon = (