mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
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:
parent
28cb8d0441
commit
5758f234e5
@ -182,6 +182,7 @@ export type Props = {
|
|||||||
searchAssociatedGroupsForReference: (prefix: string, teamId: string, channelId: string | undefined) => Promise<ActionResult>;
|
searchAssociatedGroupsForReference: (prefix: string, teamId: string, channelId: string | undefined) => Promise<ActionResult>;
|
||||||
postEditorActions: PluginComponent[];
|
postEditorActions: PluginComponent[];
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
|
isPlugin?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
|
@ -45,6 +45,7 @@ type OwnProps = {
|
|||||||
rootId: string;
|
rootId: string;
|
||||||
channelId: string;
|
channelId: string;
|
||||||
latestPostId: string;
|
latestPostId: string;
|
||||||
|
isPlugin?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
function makeMapStateToProps() {
|
function makeMapStateToProps() {
|
||||||
@ -134,20 +135,22 @@ function makeMapDispatchToProps() {
|
|||||||
let latestPostId: string;
|
let latestPostId: string;
|
||||||
|
|
||||||
return (dispatch: Dispatch, ownProps: OwnProps) => {
|
return (dispatch: Dispatch, ownProps: OwnProps) => {
|
||||||
if (rootId !== ownProps.rootId) {
|
if (!ownProps.isPlugin) {
|
||||||
onUpdateCommentDraft = makeOnUpdateCommentDraft(ownProps.rootId, ownProps.channelId);
|
if (rootId !== ownProps.rootId) {
|
||||||
}
|
onUpdateCommentDraft = makeOnUpdateCommentDraft(ownProps.rootId, ownProps.channelId);
|
||||||
|
}
|
||||||
|
|
||||||
if (channelId !== ownProps.channelId) {
|
if (channelId !== ownProps.channelId) {
|
||||||
updateCommentDraftWithRootId = makeUpdateCommentDraftWithRootId(ownProps.channelId);
|
updateCommentDraftWithRootId = makeUpdateCommentDraftWithRootId(ownProps.channelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rootId !== ownProps.rootId) {
|
if (rootId !== ownProps.rootId) {
|
||||||
onEditLatestPost = makeOnEditLatestPost(ownProps.rootId);
|
onEditLatestPost = makeOnEditLatestPost(ownProps.rootId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rootId !== ownProps.rootId || channelId !== ownProps.channelId || latestPostId !== ownProps.latestPostId) {
|
if (rootId !== ownProps.rootId || channelId !== ownProps.channelId || latestPostId !== ownProps.latestPostId) {
|
||||||
onSubmit = makeOnSubmit(ownProps.channelId, ownProps.rootId, ownProps.latestPostId);
|
onSubmit = makeOnSubmit(ownProps.channelId, ownProps.rootId, ownProps.latestPostId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rootId = ownProps.rootId;
|
rootId = ownProps.rootId;
|
||||||
|
@ -4,30 +4,25 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import AdvancedCreateComment from 'components/advanced_create_comment';
|
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';
|
const ExportedCreatePost = (props: Partial<Props>) => {
|
||||||
|
|
||||||
type Props = {
|
|
||||||
placeholder?: string;
|
|
||||||
onSubmit: (draft: PostDraft) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ExportedCreatePost = ({placeholder, onSubmit}: Props) => {
|
|
||||||
const Component = AdvancedCreateComment as any;
|
const Component = AdvancedCreateComment as any;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Component
|
<Component
|
||||||
placeholder={placeholder}
|
placeholder={''}
|
||||||
rootDeleted={false}
|
rootDeleted={false}
|
||||||
channelId={undefined}
|
channelId={undefined}
|
||||||
rootId={undefined}
|
rootId={undefined}
|
||||||
latestPostId={undefined}
|
latestPostId={undefined}
|
||||||
onSubmit={onSubmit}
|
|
||||||
onUpdateCommentDraft={() => null}
|
onUpdateCommentDraft={() => null}
|
||||||
updateCommentDraftWithRootId={() => null}
|
updateCommentDraftWithRootId={() => null}
|
||||||
onMoveHistoryIndexBack={() => null}
|
onMoveHistoryIndexBack={() => null}
|
||||||
onMoveHistoryIndexForward={() => null}
|
onMoveHistoryIndexForward={() => null}
|
||||||
onEditLatestPost={() => ({data: true})}
|
onEditLatestPost={() => ({data: true})}
|
||||||
|
isPlugin={true}
|
||||||
|
{...props}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user