mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
GH-24784 Convert ./components/common/site_name_and_description.tsx to Function Component (#24809)
* fix: convert ./components/common/site_name_and_description.tsx to function component * update: code style changes * fix: refactor code * fix: update failing snapshots --------- Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
parent
8f2ae32e82
commit
1a12faaaae
@ -6,41 +6,27 @@ import {FormattedMessage} from 'react-intl';
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
customDescriptionText?: string;
|
customDescriptionText?: string;
|
||||||
siteName: string;
|
siteName: string | undefined;
|
||||||
}
|
};
|
||||||
|
const SiteNameAndDescription = ({customDescriptionText, siteName = 'Mattermost'}: Props) => {
|
||||||
|
const description = customDescriptionText || (
|
||||||
|
<FormattedMessage
|
||||||
|
id='web.root.signup_info'
|
||||||
|
defaultMessage='All team communication in one place, searchable and accessible anywhere'
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
export default class SiteNameAndDescription extends React.PureComponent<Props> {
|
return (
|
||||||
public static defaultProps: Partial<Props> = {
|
<>
|
||||||
siteName: 'Mattermost',
|
<h1 id='site_name'>{siteName}</h1>
|
||||||
};
|
<h3
|
||||||
|
id='site_description'
|
||||||
|
className='color--light'
|
||||||
|
>
|
||||||
|
{description}
|
||||||
|
</h3>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
public render(): JSX.Element {
|
export default React.memo(SiteNameAndDescription);
|
||||||
const {
|
|
||||||
customDescriptionText,
|
|
||||||
siteName,
|
|
||||||
} = this.props;
|
|
||||||
let description = null;
|
|
||||||
if (customDescriptionText) {
|
|
||||||
description = customDescriptionText;
|
|
||||||
} else {
|
|
||||||
description = (
|
|
||||||
<FormattedMessage
|
|
||||||
id='web.root.signup_info'
|
|
||||||
defaultMessage='All team communication in one place, searchable and accessible anywhere'
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<React.Fragment>
|
|
||||||
<h1 id='site_name'>{siteName}</h1>
|
|
||||||
<h3
|
|
||||||
id='site_description'
|
|
||||||
className='color--light'
|
|
||||||
>
|
|
||||||
{description}
|
|
||||||
</h3>
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -12,7 +12,7 @@ exports[`component/create_team should match snapshot default 1`] = `
|
|||||||
<div
|
<div
|
||||||
className="signup-team__container"
|
className="signup-team__container"
|
||||||
>
|
>
|
||||||
<SiteNameAndDescription
|
<Memo(SiteNameAndDescription)
|
||||||
customDescriptionText=""
|
customDescriptionText=""
|
||||||
siteName=""
|
siteName=""
|
||||||
/>
|
/>
|
||||||
|
@ -17,7 +17,7 @@ exports[`components/select_team/SelectTeam should match snapshot 1`] = `
|
|||||||
className="signup-team-logo"
|
className="signup-team-logo"
|
||||||
src={null}
|
src={null}
|
||||||
/>
|
/>
|
||||||
<SiteNameAndDescription
|
<Memo(SiteNameAndDescription)
|
||||||
siteName="Mattermost"
|
siteName="Mattermost"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
@ -129,7 +129,7 @@ exports[`components/select_team/SelectTeam should match snapshot, on create team
|
|||||||
className="signup-team-logo"
|
className="signup-team-logo"
|
||||||
src={null}
|
src={null}
|
||||||
/>
|
/>
|
||||||
<SiteNameAndDescription
|
<Memo(SiteNameAndDescription)
|
||||||
siteName="Mattermost"
|
siteName="Mattermost"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
@ -214,7 +214,7 @@ exports[`components/select_team/SelectTeam should match snapshot, on error 1`] =
|
|||||||
className="signup-team-logo"
|
className="signup-team-logo"
|
||||||
src={null}
|
src={null}
|
||||||
/>
|
/>
|
||||||
<SiteNameAndDescription
|
<Memo(SiteNameAndDescription)
|
||||||
siteName="Mattermost"
|
siteName="Mattermost"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
@ -302,7 +302,7 @@ exports[`components/select_team/SelectTeam should match snapshot, on loading 1`]
|
|||||||
className="signup-team-logo"
|
className="signup-team-logo"
|
||||||
src={null}
|
src={null}
|
||||||
/>
|
/>
|
||||||
<SiteNameAndDescription
|
<Memo(SiteNameAndDescription)
|
||||||
siteName="Mattermost"
|
siteName="Mattermost"
|
||||||
/>
|
/>
|
||||||
<LoadingScreen />
|
<LoadingScreen />
|
||||||
@ -378,7 +378,7 @@ exports[`components/select_team/SelectTeam should match snapshot, on no joinable
|
|||||||
className="signup-team-logo"
|
className="signup-team-logo"
|
||||||
src={null}
|
src={null}
|
||||||
/>
|
/>
|
||||||
<SiteNameAndDescription
|
<Memo(SiteNameAndDescription)
|
||||||
siteName="Mattermost"
|
siteName="Mattermost"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
@ -511,7 +511,7 @@ exports[`components/select_team/SelectTeam should match snapshot, on no joinable
|
|||||||
className="signup-team-logo"
|
className="signup-team-logo"
|
||||||
src={null}
|
src={null}
|
||||||
/>
|
/>
|
||||||
<SiteNameAndDescription
|
<Memo(SiteNameAndDescription)
|
||||||
siteName="Mattermost"
|
siteName="Mattermost"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
@ -602,7 +602,7 @@ exports[`components/select_team/SelectTeam should match snapshot, on no joinable
|
|||||||
className="signup-team-logo"
|
className="signup-team-logo"
|
||||||
src={null}
|
src={null}
|
||||||
/>
|
/>
|
||||||
<SiteNameAndDescription
|
<Memo(SiteNameAndDescription)
|
||||||
siteName="Mattermost"
|
siteName="Mattermost"
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
|
Loading…
Reference in New Issue
Block a user