Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration to TypeScript: Sidebar_button migrated to Typescript #450

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Willy-Wakam
Copy link
Contributor

Summary

  • The file sidebar_header.jsx was migrated into his appropriated Typescript version

  • All properties and classes were well typed

Ticket Link

Fixes #431

Copy link

codecov bot commented Jan 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (60d1605) 33.53% compared to head (ecd3bfe) 33.53%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #450   +/-   ##
=======================================
  Coverage   33.53%   33.53%           
=======================================
  Files          22       22           
  Lines        3996     3996           
=======================================
  Hits         1340     1340           
  Misses       2523     2523           
  Partials      133      133           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@mickmister mickmister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution @Willy-Wakam 👍

The changes look good. I have just one request type the related index.ts (which is straightforward in this case), and a suggestion to convert an existing React class component into a function component. Please let me know what you think

@@ -1,6 +1,6 @@
import {connect} from 'react-redux';

import SidebarHeader from './sidebar_header.jsx';
import SidebarHeader from './sidebar_header';

function mapStateToProps(state) {
const members = state.entities.teams.myMembers || {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Willy-Wakam What are your thoughts on typing this file to index.ts as well? We can use this type for the state parameter:

import {GlobalState} from 'mattermost-redux/types/store';

function mapStateToProps(state: GlobalState) {

Comment on lines +7 to +10
interface SidebarHeaderProps{
show: boolean,
theme: Theme
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically we would have the type like this to differentiate types from real data, though it's not configured in eslint for some reason

Suggested change
interface SidebarHeaderProps{
show: boolean,
theme: Theme
}
interface SidebarHeaderProps {
show: boolean;
theme: Theme;
}

Comment on lines +12 to +15
export default class SidebarHeader extends PureComponent<SidebarHeaderProps> {
render(): ReactElement | null {
if (!this.props.show) {
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we convert this into a function component in this PR?

Suggested change
export default class SidebarHeader extends PureComponent<SidebarHeaderProps> {
render(): ReactElement | null {
if (!this.props.show) {
return null;
export default function SidebarHeader(props: SidebarHeaderProps): React.ReactNode {
if (!props.show) {
return null;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Willy-Wakam This actually isn't necessary for this PR

@mickmister mickmister requested a review from ayusht2810 February 6, 2024 14:46
@hanzei hanzei added the 2: Dev Review Requires review by a core committer label Feb 6, 2024
Copy link
Contributor

@ayusht2810 ayusht2810 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, apart from @mickmister comments.

@raghavaggarwal2308
Copy link
Contributor

@Willy-Wakam Are you planning to continue work on this PR anytime soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a core committer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Convert sidebar_header component to typescript
5 participants