-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[MM-20534] migrate 'components/create team/components/team url' module and associated tests to type script #5983
Changes from 1 commit
b9890b1
37955c2
eea21c7
823f8b0
4c5e681
7d4b2fa
1f43585
6116054
eac4135
d56f572
9268f14
4f330bd
87dc416
536f7c9
253a309
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,12 +19,17 @@ import logoImage from 'images/logo.png'; | |
import FormattedMarkdownMessage from 'components/formatted_markdown_message.jsx'; | ||
import OverlayTrigger from 'components/overlay_trigger'; | ||
|
||
type State = { | ||
isLoading: boolean; | ||
nameError: string | JSX.Element; | ||
} | ||
|
||
type Props = { | ||
|
||
/* | ||
* Object containing team's display_name and name | ||
*/ | ||
state: {team: object; wizard: string}; | ||
state: {team: any; wizard: string}; | ||
|
||
/* | ||
* Function that updates parent component with state props | ||
|
@@ -46,9 +51,12 @@ type Props = { | |
*/ | ||
createTeam: (team: Team) => ActionFunc; | ||
}; | ||
history: { | ||
push(path: string): void; | ||
}; | ||
} | ||
|
||
export default class TeamUrl extends React.PureComponent<Props> { | ||
export default class TeamUrl extends React.PureComponent<Props, State> { | ||
public constructor(props: Props) { | ||
super(props); | ||
|
||
|
@@ -74,7 +82,7 @@ export default class TeamUrl extends React.PureComponent<Props> { | |
e.preventDefault(); | ||
trackEvent('signup', 'click_finish'); | ||
|
||
const name = ReactDOM.findDOMNode<>(this.refs.name).value.trim(); | ||
const name = (ReactDOM.findDOMNode(this.refs.name) as HTMLInputElement)?.value.trim(); | ||
const cleanedName = URL.cleanUpUrlable(name); | ||
const urlRegex = /^[a-z]+([a-z\-0-9]+|(__)?)[a-z0-9]+$/g; | ||
const {actions: {checkIfTeamExists, createTeam}} = this.props; | ||
|
@@ -130,7 +138,7 @@ export default class TeamUrl extends React.PureComponent<Props> { | |
teamSignup.team.type = 'O'; | ||
teamSignup.team.name = name; | ||
|
||
const {exists} = await checkIfTeamExists(name); | ||
const {exists}: any = await checkIfTeamExists(name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It causes the problem that exists is not visible in if statement on 143 line and it does not exist on type ActionFunc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you might want to change the return type of |
||
|
||
if (exists) { | ||
this.setState({nameError: ( | ||
|
@@ -143,7 +151,7 @@ export default class TeamUrl extends React.PureComponent<Props> { | |
return; | ||
} | ||
|
||
const {data, error} = await createTeam(teamSignup.team); | ||
const {data, error}: any = await createTeam(teamSignup.team); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It causes the same problems as exists change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can do the same thing here as above. |
||
|
||
if (data) { | ||
this.props.history.push('/' + data.name + '/channels/' + Constants.DEFAULT_CHANNEL); | ||
|
@@ -221,7 +229,7 @@ export default class TeamUrl extends React.PureComponent<Props> { | |
ref='name' | ||
className='form-control' | ||
placeholder='' | ||
maxLength='128' | ||
maxLength={128} | ||
defaultValue={this.props.state.team.name} | ||
autoFocus={true} | ||
onFocus={this.handleFocus} | ||
|
@@ -264,7 +272,7 @@ export default class TeamUrl extends React.PureComponent<Props> { | |
type='submit' | ||
bsStyle='primary' | ||
disabled={this.state.isLoading} | ||
onClick={this.submitNext} | ||
onClick={this.submitNext as any} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't need to be declared as |
||
> | ||
{finishMessage} | ||
</Button> | ||
|
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.
Is there a specific reason this is
public
? Usually we're not creating new instances of this component in JS/TS.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.
No, there isn't any specific reason. I'll remove it.