Pass the 'mode' over via UpdatePublishForm to hide some fields when Posting a Markdown.

This commit is contained in:
infiinte-persistence 2020-10-01 15:52:52 +08:00 committed by Sean Yesmunt
parent 3df7ea71d3
commit 92b211dd94
3 changed files with 8 additions and 1 deletions

View file

@ -24,6 +24,7 @@ declare type UpdatePublishFormData = {
licenseType?: string, licenseType?: string,
uri?: string, uri?: string,
nsfw: boolean, nsfw: boolean,
isMarkdownPost: boolean,
}; };
declare type PublishParams = { declare type PublishParams = {

View file

@ -221,6 +221,10 @@ function PublishForm(props: Props) {
} }
}, [name, channel, resolveUri, updatePublishForm, checkAvailability]); }, [name, channel, resolveUri, updatePublishForm, checkAvailability]);
useEffect(() => {
updatePublishForm({ isMarkdownPost: mode === PUBLISH_MODES.POST });
}, [mode, updatePublishForm]);
function handleChannelNameChange(channel) { function handleChannelNameChange(channel) {
updatePublishForm({ channel }); updatePublishForm({ channel });
} }

View file

@ -10,6 +10,7 @@ import { COPYRIGHT, OTHER } from 'constants/licenses';
type Props = { type Props = {
filePath: string | WebFile, filePath: string | WebFile,
isMarkdownPost: boolean,
optimize: boolean, optimize: boolean,
title: ?string, title: ?string,
description: ?string, description: ?string,
@ -73,6 +74,7 @@ class ModalPublishPreview extends React.PureComponent<Props> {
render() { render() {
const { const {
filePath, filePath,
isMarkdownPost,
optimize, optimize,
title, title,
description, description,
@ -133,7 +135,7 @@ class ModalPublishPreview extends React.PureComponent<Props> {
<div className="section"> <div className="section">
<table className="table table--condensed table--publish-preview"> <table className="table table--condensed table--publish-preview">
<tbody> <tbody>
{this.createRow(__('File'), this.resolveFilePathName(filePath))} {!isMarkdownPost && this.createRow(__('File'), this.resolveFilePathName(filePath))}
{isOptimizeAvail && this.createRow(__('Transcode'), optimize ? __('Yes') : __('No'))} {isOptimizeAvail && this.createRow(__('Transcode'), optimize ? __('Yes') : __('No'))}
{this.createRow(__('Title'), title)} {this.createRow(__('Title'), title)}
{this.createRow(__('Description'), descriptionValue)} {this.createRow(__('Description'), descriptionValue)}