Allow plugins to specify all props for create comment. (#26152)

* Allow plugins to specificy all props for create comment.

* Types
This commit is contained in:
Christopher Speller 2024-02-14 07:46:12 -08:00 committed by GitHub
parent 28cb8d0441
commit 5758f234e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 21 deletions

View File

@ -182,6 +182,7 @@ export type Props = {
searchAssociatedGroupsForReference: (prefix: string, teamId: string, channelId: string | undefined) => Promise<ActionResult>;
postEditorActions: PluginComponent[];
placeholder?: string;
isPlugin?: boolean;
}
type State = {

View File

@ -45,6 +45,7 @@ type OwnProps = {
rootId: string;
channelId: string;
latestPostId: string;
isPlugin?: boolean;
};
function makeMapStateToProps() {
@ -134,20 +135,22 @@ function makeMapDispatchToProps() {
let latestPostId: string;
return (dispatch: Dispatch, ownProps: OwnProps) => {
if (rootId !== ownProps.rootId) {
onUpdateCommentDraft = makeOnUpdateCommentDraft(ownProps.rootId, ownProps.channelId);
}
if (!ownProps.isPlugin) {
if (rootId !== ownProps.rootId) {
onUpdateCommentDraft = makeOnUpdateCommentDraft(ownProps.rootId, ownProps.channelId);
}
if (channelId !== ownProps.channelId) {
updateCommentDraftWithRootId = makeUpdateCommentDraftWithRootId(ownProps.channelId);
}
if (channelId !== ownProps.channelId) {
updateCommentDraftWithRootId = makeUpdateCommentDraftWithRootId(ownProps.channelId);
}
if (rootId !== ownProps.rootId) {
onEditLatestPost = makeOnEditLatestPost(ownProps.rootId);
}
if (rootId !== ownProps.rootId) {
onEditLatestPost = makeOnEditLatestPost(ownProps.rootId);
}
if (rootId !== ownProps.rootId || channelId !== ownProps.channelId || latestPostId !== ownProps.latestPostId) {
onSubmit = makeOnSubmit(ownProps.channelId, ownProps.rootId, ownProps.latestPostId);
if (rootId !== ownProps.rootId || channelId !== ownProps.channelId || latestPostId !== ownProps.latestPostId) {
onSubmit = makeOnSubmit(ownProps.channelId, ownProps.rootId, ownProps.latestPostId);
}
}
rootId = ownProps.rootId;

View File

@ -4,30 +4,25 @@
import React from 'react';
import AdvancedCreateComment from 'components/advanced_create_comment';
import type {Props} from 'components/advanced_create_comment/advanced_create_comment';
import type {PostDraft} from 'types/store/draft';
type Props = {
placeholder?: string;
onSubmit: (draft: PostDraft) => void;
}
const ExportedCreatePost = ({placeholder, onSubmit}: Props) => {
const ExportedCreatePost = (props: Partial<Props>) => {
const Component = AdvancedCreateComment as any;
return (
<Component
placeholder={placeholder}
placeholder={''}
rootDeleted={false}
channelId={undefined}
rootId={undefined}
latestPostId={undefined}
onSubmit={onSubmit}
onUpdateCommentDraft={() => null}
updateCommentDraftWithRootId={() => null}
onMoveHistoryIndexBack={() => null}
onMoveHistoryIndexForward={() => null}
onEditLatestPost={() => ({data: true})}
isPlugin={true}
{...props}
/>
);
};