mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[MM-56849] Convert ./components/post_view/failed_post_options/failed_post_options.tsx
from Class Component to Function Component (#26234)
Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
parent
bff19228e1
commit
95e85db811
@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||||
// See LICENSE.txt for license information.
|
// See LICENSE.txt for license information.
|
||||||
|
|
||||||
import React from 'react';
|
import React, {memo, useCallback} from 'react';
|
||||||
import type {MouseEvent} from 'react';
|
import type {MouseEvent} from 'react';
|
||||||
import {FormattedMessage} from 'react-intl';
|
import {FormattedMessage} from 'react-intl';
|
||||||
|
|
||||||
@ -18,46 +18,49 @@ type Props = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class FailedPostOptions extends React.PureComponent<Props> {
|
const FailedPostOptions = ({
|
||||||
retryPost = (e: MouseEvent): void => {
|
post,
|
||||||
|
actions,
|
||||||
|
}: Props) => {
|
||||||
|
const retryPost = useCallback((e: MouseEvent): void => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const post = {...this.props.post};
|
const postDetails = {...post};
|
||||||
Reflect.deleteProperty(post, 'id');
|
Reflect.deleteProperty(postDetails, 'id');
|
||||||
this.props.actions.createPost(post, []);
|
actions.createPost(postDetails, []);
|
||||||
};
|
}, [actions, post]);
|
||||||
|
|
||||||
cancelPost = (e: MouseEvent): void => {
|
const cancelPost = useCallback((e: MouseEvent): void => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
this.props.actions.removePost(this.props.post);
|
actions.removePost(post);
|
||||||
};
|
}, [actions, post]);
|
||||||
|
|
||||||
render(): JSX.Element {
|
return (
|
||||||
return (
|
<span className='pending-post-actions'>
|
||||||
<span className='pending-post-actions'>
|
<a
|
||||||
<a
|
className='post-retry'
|
||||||
className='post-retry'
|
href='#'
|
||||||
href='#'
|
onClick={retryPost}
|
||||||
onClick={this.retryPost}
|
>
|
||||||
>
|
<FormattedMessage
|
||||||
<FormattedMessage
|
id='pending_post_actions.retry'
|
||||||
id='pending_post_actions.retry'
|
defaultMessage='Retry'
|
||||||
defaultMessage='Retry'
|
/>
|
||||||
/>
|
</a>
|
||||||
</a>
|
{' - '}
|
||||||
{' - '}
|
<a
|
||||||
<a
|
className='post-cancel'
|
||||||
className='post-cancel'
|
href='#'
|
||||||
href='#'
|
onClick={cancelPost}
|
||||||
onClick={this.cancelPost}
|
>
|
||||||
>
|
<FormattedMessage
|
||||||
<FormattedMessage
|
id='pending_post_actions.cancel'
|
||||||
id='pending_post_actions.cancel'
|
defaultMessage='Cancel'
|
||||||
defaultMessage='Cancel'
|
/>
|
||||||
/>
|
</a>
|
||||||
</a>
|
</span>
|
||||||
</span>
|
);
|
||||||
);
|
};
|
||||||
}
|
|
||||||
}
|
export default memo(FailedPostOptions);
|
||||||
|
Loading…
Reference in New Issue
Block a user